mconnectb 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +351 -0
  3. package/dist/constants/index.d.ts +158 -0
  4. package/dist/constants/index.d.ts.map +1 -0
  5. package/dist/constants/index.js +161 -0
  6. package/dist/constants/index.js.map +1 -0
  7. package/dist/constants/routes.d.ts +109 -0
  8. package/dist/constants/routes.d.ts.map +1 -0
  9. package/dist/constants/routes.js +120 -0
  10. package/dist/constants/routes.js.map +1 -0
  11. package/dist/example/example.d.ts +44 -0
  12. package/dist/example/example.d.ts.map +1 -0
  13. package/dist/example/example.js +727 -0
  14. package/dist/example/example.js.map +1 -0
  15. package/dist/example/websocket-stream.d.ts +2 -0
  16. package/dist/example/websocket-stream.d.ts.map +1 -0
  17. package/dist/example/websocket-stream.js +116 -0
  18. package/dist/example/websocket-stream.js.map +1 -0
  19. package/dist/lib/connect.d.ts +306 -0
  20. package/dist/lib/connect.d.ts.map +1 -0
  21. package/dist/lib/connect.js +514 -0
  22. package/dist/lib/connect.js.map +1 -0
  23. package/dist/lib/index.d.ts +5 -0
  24. package/dist/lib/index.d.ts.map +1 -0
  25. package/dist/lib/index.js +27 -0
  26. package/dist/lib/index.js.map +1 -0
  27. package/dist/lib/response-logger.d.ts +15 -0
  28. package/dist/lib/response-logger.d.ts.map +1 -0
  29. package/dist/lib/response-logger.js +73 -0
  30. package/dist/lib/response-logger.js.map +1 -0
  31. package/dist/lib/ticker.d.ts +43 -0
  32. package/dist/lib/ticker.d.ts.map +1 -0
  33. package/dist/lib/ticker.js +362 -0
  34. package/dist/lib/ticker.js.map +1 -0
  35. package/dist/lib/utils.d.ts +36 -0
  36. package/dist/lib/utils.d.ts.map +1 -0
  37. package/dist/lib/utils.js +75 -0
  38. package/dist/lib/utils.js.map +1 -0
  39. package/dist/test/test-websocket.d.ts +2 -0
  40. package/dist/test/test-websocket.d.ts.map +1 -0
  41. package/dist/test/test-websocket.js +116 -0
  42. package/dist/test/test-websocket.js.map +1 -0
  43. package/dist/test/test.d.ts +2 -0
  44. package/dist/test/test.d.ts.map +1 -0
  45. package/dist/test/test.js +892 -0
  46. package/dist/test/test.js.map +1 -0
  47. package/dist/types/config.d.ts +138 -0
  48. package/dist/types/config.d.ts.map +1 -0
  49. package/dist/types/config.js +12 -0
  50. package/dist/types/config.js.map +1 -0
  51. package/dist/types/index.d.ts +631 -0
  52. package/dist/types/index.d.ts.map +1 -0
  53. package/dist/types/index.js +12 -0
  54. package/dist/types/index.js.map +1 -0
  55. package/package.json +91 -0
@@ -0,0 +1,109 @@
1
+ /**
2
+ * API routes and endpoints for TypeB SDK
3
+ *
4
+ * This module contains all the API endpoint URLs used by the TypeB SDK to communicate with the backend services.
5
+ * These routes cover authentication, order management, portfolio operations, market data, and other trading functionalities.
6
+ *
7
+ * @module routes
8
+ */
9
+ /**
10
+ * API route definitions for all available endpoints
11
+ * Defines the complete set of REST API endpoints supported by the TypeB SDK
12
+ *
13
+ * @constant
14
+ * @type {Object}
15
+ *
16
+ * Authentication Endpoints:
17
+ * @property {string} login - User authentication endpoint for login
18
+ * @property {string} sessionToken - Generate session token for authenticated access
19
+ * @property {string} verifyTOTP - Verify Two-Factor Authentication (2FA) TOTP code
20
+ *
21
+ * Order Management Endpoints:
22
+ * @property {string} placeOrder - Place new orders (regular orders)
23
+ * @property {string} modifyOrder - Modify existing orders by order ID
24
+ * @property {string} cancelOrder - Cancel specific order by order ID
25
+ * @property {string} cancelAll - Cancel all open orders at once
26
+ * @property {string} getOrders - Get list of all orders
27
+ * @property {string} getorderdetails - Get detailed information for a specific order
28
+ * @property {string} ordermargin - Calculate margin required for placing orders
29
+ *
30
+ * Portfolio Endpoints:
31
+ * @property {string} getPositions - Get current open positions
32
+ * @property {string} getHoldings - Get portfolio holdings
33
+ * @property {string} convertPosition - Convert position from intraday to delivery or vice versa
34
+ *
35
+ * Market Data Endpoints:
36
+ * @property {string} historicalData - Get historical candlestick data
37
+ * @property {string} intradayChartData - Get intraday chart data
38
+ * @property {string} scriptMaster - Get complete scrip master data
39
+ * @property {string} quote - Get real-time quotes for instruments
40
+ * @property {string} losergainer - Get top losers and gainers data
41
+ *
42
+ * Trading Endpoints:
43
+ * @property {string} tradeBook - Get trade book data
44
+ * @property {string} trades - Get individual trades information
45
+ *
46
+ * User Account Endpoints:
47
+ * @property {string} fundSummary - Get user fund summary and balance
48
+ * @property {string} logout - User logout endpoint
49
+ *
50
+ * Basket Order Endpoints:
51
+ * @property {string} createbasket - Create new basket order
52
+ * @property {string} fetchbasket - Fetch existing basket orders
53
+ * @property {string} renamebasket - Rename existing basket order
54
+ * @property {string} deletebasket - Delete basket order
55
+ * @property {string} calculatebasket - Calculate basket order details
56
+ *
57
+ * Options Trading Endpoints:
58
+ * @property {string} optionchainmaster - Get option chain master data for an exchange
59
+ * @property {string} optionchain - Get option chain data for specific expiry and token
60
+ */
61
+ export declare const ROUTES: {
62
+ readonly login: "/openapi/typeb/connect/login";
63
+ readonly sessionToken: "/openapi/typeb/session/token";
64
+ readonly verifyTOTP: "/openapi/typeb/session/verifytotp";
65
+ readonly placeOrder: "/openapi/typeb/orders/regular";
66
+ readonly modifyOrder: "/openapi/typeb/orders/regular/{orderid}";
67
+ readonly cancelOrder: "/openapi/typeb/orders/regular/{orderid}";
68
+ readonly cancelAll: "/openapi/typeb/orders/cancelall";
69
+ readonly getOrders: "/openapi/typeb/orders";
70
+ readonly getorderdetails: "/openapi/typeb/order/details";
71
+ readonly ordermargin: "/openapi/typeb/margins/orders";
72
+ readonly losergainer: "/openapi/typeb/losergainer";
73
+ readonly getPositions: "/openapi/typeb/portfolio/positions";
74
+ readonly getHoldings: "/openapi/typeb/portfolio/holdings";
75
+ readonly historicalData: "/openapi/typeb/instruments/historical";
76
+ readonly intradayChartData: "/openapi/typeb/instruments/intraday";
77
+ readonly scriptMaster: "openapi/typeb/instruments/OpenAPIScripMaster";
78
+ readonly quote: "/openapi/typeb/instruments/quote";
79
+ readonly convertPosition: "/openapi/typeb/portfolio/convertposition";
80
+ readonly tradeBook: "/openapi/typeb/tradebook";
81
+ readonly trades: "/openapi/typeb/trades";
82
+ readonly fundSummary: "/openapi/typeb/user/fundsummary";
83
+ readonly logout: "/openapi/typeb/logout";
84
+ readonly createbasket: "/openapi/typeb/CreateBasket";
85
+ readonly fetchbasket: "/openapi/typeb/FetchBasket";
86
+ readonly renamebasket: "/openapi/typeb/RenameBasket";
87
+ readonly deletebasket: "/openapi/typeb/DeleteBasket";
88
+ readonly calculatebasket: "/openapi/typeb/CalculateBasket";
89
+ readonly optionchainmaster: "/openapi/typeb/getoptionchainmaster/{exchange}";
90
+ readonly optionchain: "/openapi/typeb/GetOptionChain/{exchange}/{expiry}/{token}";
91
+ };
92
+ /**
93
+ * Default configuration values for API connections
94
+ * Defines the default settings for connecting to the TypeB API services
95
+ *
96
+ * @constant
97
+ * @type {Object}
98
+ * @property {string} baseURL - Base URL for the API server
99
+ * @property {string} wsURL - WebSocket URL for real-time data streaming
100
+ * @property {number} timeout - Request timeout in milliseconds
101
+ * @property {boolean} debug - Debug mode flag for verbose logging
102
+ */
103
+ export declare const DEFAULTS: {
104
+ baseURL: string;
105
+ wsURL: string;
106
+ timeout: number;
107
+ debug: boolean;
108
+ };
109
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../constants/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CT,CAAC;AAEX;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAC"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /**
3
+ * API routes and endpoints for TypeB SDK
4
+ *
5
+ * This module contains all the API endpoint URLs used by the TypeB SDK to communicate with the backend services.
6
+ * These routes cover authentication, order management, portfolio operations, market data, and other trading functionalities.
7
+ *
8
+ * @module routes
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.DEFAULTS = exports.ROUTES = void 0;
12
+ /**
13
+ * API route definitions for all available endpoints
14
+ * Defines the complete set of REST API endpoints supported by the TypeB SDK
15
+ *
16
+ * @constant
17
+ * @type {Object}
18
+ *
19
+ * Authentication Endpoints:
20
+ * @property {string} login - User authentication endpoint for login
21
+ * @property {string} sessionToken - Generate session token for authenticated access
22
+ * @property {string} verifyTOTP - Verify Two-Factor Authentication (2FA) TOTP code
23
+ *
24
+ * Order Management Endpoints:
25
+ * @property {string} placeOrder - Place new orders (regular orders)
26
+ * @property {string} modifyOrder - Modify existing orders by order ID
27
+ * @property {string} cancelOrder - Cancel specific order by order ID
28
+ * @property {string} cancelAll - Cancel all open orders at once
29
+ * @property {string} getOrders - Get list of all orders
30
+ * @property {string} getorderdetails - Get detailed information for a specific order
31
+ * @property {string} ordermargin - Calculate margin required for placing orders
32
+ *
33
+ * Portfolio Endpoints:
34
+ * @property {string} getPositions - Get current open positions
35
+ * @property {string} getHoldings - Get portfolio holdings
36
+ * @property {string} convertPosition - Convert position from intraday to delivery or vice versa
37
+ *
38
+ * Market Data Endpoints:
39
+ * @property {string} historicalData - Get historical candlestick data
40
+ * @property {string} intradayChartData - Get intraday chart data
41
+ * @property {string} scriptMaster - Get complete scrip master data
42
+ * @property {string} quote - Get real-time quotes for instruments
43
+ * @property {string} losergainer - Get top losers and gainers data
44
+ *
45
+ * Trading Endpoints:
46
+ * @property {string} tradeBook - Get trade book data
47
+ * @property {string} trades - Get individual trades information
48
+ *
49
+ * User Account Endpoints:
50
+ * @property {string} fundSummary - Get user fund summary and balance
51
+ * @property {string} logout - User logout endpoint
52
+ *
53
+ * Basket Order Endpoints:
54
+ * @property {string} createbasket - Create new basket order
55
+ * @property {string} fetchbasket - Fetch existing basket orders
56
+ * @property {string} renamebasket - Rename existing basket order
57
+ * @property {string} deletebasket - Delete basket order
58
+ * @property {string} calculatebasket - Calculate basket order details
59
+ *
60
+ * Options Trading Endpoints:
61
+ * @property {string} optionchainmaster - Get option chain master data for an exchange
62
+ * @property {string} optionchain - Get option chain data for specific expiry and token
63
+ */
64
+ exports.ROUTES = {
65
+ // Authentication
66
+ login: "/openapi/typeb/connect/login",
67
+ sessionToken: "/openapi/typeb/session/token",
68
+ verifyTOTP: "/openapi/typeb/session/verifytotp",
69
+ // Order Management
70
+ placeOrder: "/openapi/typeb/orders/regular",
71
+ modifyOrder: "/openapi/typeb/orders/regular/{orderid}",
72
+ cancelOrder: "/openapi/typeb/orders/regular/{orderid}",
73
+ cancelAll: "/openapi/typeb/orders/cancelall",
74
+ getOrders: "/openapi/typeb/orders",
75
+ getorderdetails: "/openapi/typeb/order/details",
76
+ ordermargin: "/openapi/typeb/margins/orders",
77
+ // Market Data
78
+ losergainer: "/openapi/typeb/losergainer",
79
+ // Portfolio
80
+ getPositions: "/openapi/typeb/portfolio/positions",
81
+ getHoldings: "/openapi/typeb/portfolio/holdings",
82
+ historicalData: "/openapi/typeb/instruments/historical",
83
+ intradayChartData: "/openapi/typeb/instruments/intraday",
84
+ scriptMaster: "openapi/typeb/instruments/OpenAPIScripMaster",
85
+ quote: "/openapi/typeb/instruments/quote",
86
+ convertPosition: "/openapi/typeb/portfolio/convertposition",
87
+ // Trading
88
+ tradeBook: "/openapi/typeb/tradebook",
89
+ trades: "/openapi/typeb/trades",
90
+ // User Account
91
+ fundSummary: "/openapi/typeb/user/fundsummary",
92
+ logout: "/openapi/typeb/logout",
93
+ // Basket Orders
94
+ createbasket: "/openapi/typeb/CreateBasket",
95
+ fetchbasket: "/openapi/typeb/FetchBasket",
96
+ renamebasket: "/openapi/typeb/RenameBasket",
97
+ deletebasket: "/openapi/typeb/DeleteBasket",
98
+ calculatebasket: "/openapi/typeb/CalculateBasket",
99
+ // Options
100
+ optionchainmaster: "/openapi/typeb/getoptionchainmaster/{exchange}",
101
+ optionchain: "/openapi/typeb/GetOptionChain/{exchange}/{expiry}/{token}"
102
+ };
103
+ /**
104
+ * Default configuration values for API connections
105
+ * Defines the default settings for connecting to the TypeB API services
106
+ *
107
+ * @constant
108
+ * @type {Object}
109
+ * @property {string} baseURL - Base URL for the API server
110
+ * @property {string} wsURL - WebSocket URL for real-time data streaming
111
+ * @property {number} timeout - Request timeout in milliseconds
112
+ * @property {boolean} debug - Debug mode flag for verbose logging
113
+ */
114
+ exports.DEFAULTS = {
115
+ baseURL: 'https://api.mstock.trade',
116
+ wsURL: 'wss://ws.mstock.trade',
117
+ timeout: 7000,
118
+ debug: false
119
+ };
120
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../../constants/routes.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACU,QAAA,MAAM,GAAG;IAClB,iBAAiB;IACjB,KAAK,EAAE,8BAA8B;IACrC,YAAY,EAAE,8BAA8B;IAC5C,UAAU,EAAE,mCAAmC;IAE/C,mBAAmB;IACnB,UAAU,EAAE,+BAA+B;IAC3C,WAAW,EAAE,yCAAyC;IACtD,WAAW,EAAE,yCAAyC;IACtD,SAAS,EAAE,iCAAiC;IAC5C,SAAS,EAAE,uBAAuB;IAClC,eAAe,EAAE,8BAA8B;IAC/C,WAAW,EAAE,+BAA+B;IAE5C,cAAc;IACd,WAAW,EAAE,4BAA4B;IAEzC,YAAY;IACZ,YAAY,EAAE,oCAAoC;IAClD,WAAW,EAAE,mCAAmC;IAChD,cAAc,EAAE,uCAAuC;IACvD,iBAAiB,EAAE,qCAAqC;IACxD,YAAY,EAAE,8CAA8C;IAC5D,KAAK,EAAE,kCAAkC;IACzC,eAAe,EAAE,0CAA0C;IAE3D,UAAU;IACV,SAAS,EAAE,0BAA0B;IACrC,MAAM,EAAE,uBAAuB;IAE/B,eAAe;IACf,WAAW,EAAE,iCAAiC;IAC9C,MAAM,EAAE,uBAAuB;IAE/B,gBAAgB;IAChB,YAAY,EAAE,6BAA6B;IAC3C,WAAW,EAAE,4BAA4B;IACzC,YAAY,EAAE,6BAA6B;IAC3C,YAAY,EAAE,6BAA6B;IAC3C,eAAe,EAAE,gCAAgC;IAEjD,UAAU;IACV,iBAAiB,EAAE,gDAAgD;IACnE,WAAW,EAAE,2DAA2D;CAClE,CAAC;AAEX;;;;;;;;;;GAUG;AACU,QAAA,QAAQ,GAAG;IACpB,OAAO,EAAE,0BAA0B;IACnC,KAAK,EAAE,uBAAuB;IAC9B,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,KAAK;CACf,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * TypeB SDK Usage Examples
3
+ * This file demonstrates how to use the TypeB SDK for TypeB Trading API
4
+ * Package name: mconnectb
5
+ */
6
+ import { MConnect } from '../lib/connect';
7
+ declare const client: MConnect;
8
+ declare function authenticate(): Promise<import("../types").TypeBToken | null>;
9
+ declare function verifyOTP(refreshToken: string, otp: string): Promise<import("../types").TypeBToken | null>;
10
+ declare function verifyTOTP(refreshToken: string, totp: string): Promise<import("../types").TypeBToken | null>;
11
+ declare function placeMarketOrder(): Promise<{
12
+ orderid: string;
13
+ } | null>;
14
+ declare function placeLimitOrder(): Promise<{
15
+ orderid: string;
16
+ } | null>;
17
+ declare function modifyOrder(orderId: string): Promise<{
18
+ orderid: string;
19
+ } | null>;
20
+ declare function cancelOrder(orderId: string): Promise<{
21
+ orderid: string;
22
+ } | null>;
23
+ declare function getOrderBook(): Promise<import("../types").OrderBookData[] | null>;
24
+ declare function getPositions(): Promise<import("../types").PositionData[] | null>;
25
+ declare function getHoldings(): Promise<import("../types").TypeBHolding[] | null>;
26
+ declare function getFundSummary(): Promise<any>;
27
+ declare function getHistoricalData(): Promise<[string, number, number, number, number, number][] | null>;
28
+ declare function getQuoteData(): Promise<import("../types").QuoteData<import("../types").FetchedLtp | import("../types").FetchedOhlc> | null>;
29
+ declare function cancelAllOrders(): Promise<any>;
30
+ declare function getOrderDetails(orderNo: string, segment: string): Promise<import("../types").OrderDetails[] | null>;
31
+ declare function convertPosition(): Promise<any>;
32
+ declare function getIntradayChartData(): Promise<[string, number, number, number, number, number][] | null>;
33
+ declare function getInstrumentMaster(): Promise<string | null>;
34
+ declare function getTradeBook(): Promise<any>;
35
+ declare function getTradeHistory(): Promise<any[] | null>;
36
+ declare function orderMargin(): Promise<any[] | null>;
37
+ declare function loserGainer(): Promise<any[] | null>;
38
+ declare function deleteBasket(basketId: string): Promise<any[] | null>;
39
+ declare function calculateBasket(): Promise<any[] | null>;
40
+ declare function basketOperations(): Promise<import("../types").FetchBasket[] | null>;
41
+ declare function completeWorkflow(): Promise<void>;
42
+ declare function errorHandlingExample(): Promise<void>;
43
+ export { authenticate, verifyOTP, verifyTOTP, placeMarketOrder, placeLimitOrder, modifyOrder, cancelOrder, cancelAllOrders, getOrderDetails, getOrderBook, getPositions, getHoldings, convertPosition, getFundSummary, getHistoricalData, getIntradayChartData, getInstrumentMaster, getTradeBook, getTradeHistory, getQuoteData, orderMargin, loserGainer, deleteBasket, calculateBasket, basketOperations, completeWorkflow, errorHandlingExample, client };
44
+ //# sourceMappingURL=example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../example/example.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAO,gBAAgB,CAAC;AA6B3C,QAAA,MAAM,MAAM,UAIX,CAAC;AAGF,iBAAe,YAAY,kDA4B1B;AAGD,iBAAe,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iDAkBzD;AAGD,iBAAe,UAAU,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iDAkB3D;AAGD,iBAAe,gBAAgB;;UA8B9B;AAGD,iBAAe,eAAe;;UA+B7B;AAGD,iBAAe,WAAW,CAAC,OAAO,EAAE,MAAM;;UA8BzC;AAGD,iBAAe,WAAW,CAAC,OAAO,EAAE,MAAM;;UAuBzC;AAGD,iBAAe,YAAY,uDAkB1B;AAGD,iBAAe,YAAY,sDAkB1B;AAGD,iBAAe,WAAW,sDAkBzB;AAGD,iBAAe,cAAc,iBAmB5B;AAGD,iBAAe,iBAAiB,uEA0B/B;AAGD,iBAAe,YAAY,iHAyB1B;AAGD,iBAAe,eAAe,iBAiB7B;AAGD,iBAAe,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,qDAuB9D;AAGD,iBAAe,eAAe,iBA6B7B;AAGD,iBAAe,oBAAoB,uEAwBlC;AAGD,iBAAe,mBAAmB,2BAkBjC;AAGD,iBAAe,YAAY,iBAkB1B;AAGD,iBAAe,eAAe,0BAuB7B;AAGD,iBAAe,WAAW,0BA8BzB;AAGD,iBAAe,WAAW,0BAwBzB;AAGD,iBAAe,YAAY,CAAC,QAAQ,EAAE,MAAM,yBAqB3C;AAGD,iBAAe,eAAe,0BAqC7B;AAGD,iBAAe,gBAAgB,qDAqC9B;AAGD,iBAAe,gBAAgB,kBAiC9B;AAGD,iBAAe,oBAAoB,kBAclC;AAGD,OAAO,EACH,YAAY,EACZ,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,WAAW,EACX,eAAe,EACf,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,EACT,CAAC"}