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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 mStock by Mirae Asset Capital Markets (India) Private Limited
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,351 @@
1
+ # TradingAPI TypeB TypeScript/JavaScript SDK
2
+
3
+ [![npm version](https://badge.fury.io/js/@mstock-mirae-asset%2Fnodetradingapi-typeb.svg)](https://www.npmjs.com/package/@mstock-mirae-asset/nodetradingapi-typeb)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js Version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen)](https://nodejs.org/)
6
+
7
+
8
+ The official TypeScript/JavaScript client for communicating with the TypeB Trading API.
9
+
10
+ mStock TypeB is a comprehensive trading API that provides capabilities required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (WebSockets), and more.
11
+
12
+ ## Documentation
13
+
14
+ - [TradingAPI documentation](https://tradingapi.mstock.com/)
15
+ - [Examples](./examples/)
16
+ - [Testing Guide](./test/RUNTEST.md)
17
+
18
+ ## Requirements
19
+
20
+ - Node.js v18.0.0+
21
+
22
+ ## Installation
23
+
24
+ npm install
25
+
26
+ Install via [npm](https://www.npmjs.com/package/@mstock-mirae-asset/nodetradingapi-typeb)
27
+
28
+ ```bash
29
+ npm install @mstock-mirae-asset/nodetradingapi-typeb
30
+ ```
31
+ ## Features
32
+
33
+ - **Comprehensive API Coverage** - Full support for all TypeB trading API endpoints
34
+ - **TypeScript Support** - Fully typed with TypeScript for better development experience
35
+ - **Authentication** - Built-in support for JWT token authentication
36
+ - **Order Management** - Place, modify, cancel orders with ease
37
+ - **Portfolio Management** - View positions, holdings, and trade history
38
+ - **Market Data** - Real-time quotes, historical data, and chart data
39
+ - **WebSocket Support** - Real-time market data streaming with MTicker
40
+ - **Basket Orders** - Create and manage basket orders
41
+ - **Options Trading** - Complete options chain support
42
+ - **Error Handling** - Comprehensive error handling and retry mechanisms
43
+
44
+ ## Getting started with API
45
+
46
+ ### Basic Setup
47
+
48
+ ```typescript
49
+ import { MConnect } from '@mstock-mirae-asset/nodetradingapi-typeb';
50
+
51
+ // Initialize the client
52
+ const client = new MConnect('https://api.mstock.trade', 'your-api-key');
53
+
54
+ // Login
55
+ const loginResponse = await client.login({
56
+ clientcode: 'your-client-code',
57
+ password: 'your-password',
58
+ totp: 'your-totp',
59
+ state: 'your-state'
60
+ });
61
+
62
+ // Set access token
63
+ client.setAccessToken(loginResponse.data.jwtToken);
64
+ ```
65
+
66
+ ### Place an Order
67
+
68
+ ```typescript
69
+ const order = await client.placeOrder({
70
+ variety: 'NORMAL',
71
+ tradingsymbol: 'INFY',
72
+ symboltoken: '1594',
73
+ exchange: 'NSE',
74
+ transactiontype: 'BUY',
75
+ ordertype: 'LIMIT',
76
+ quantity: '100',
77
+ producttype: 'DELIVERY',
78
+ price: '1500'
79
+ });
80
+ ```
81
+
82
+ ## Authentication
83
+
84
+ The SDK supports JWT token authentication. After successful login, use the `setAccessToken` method to set the authentication token.
85
+
86
+ ```typescript
87
+ const loginResponse = await client.login({
88
+ clientcode: 'your-client-code',
89
+ password: 'your-password',
90
+ totp: 'your-totp',
91
+ state: 'your-state'
92
+ });
93
+
94
+ client.setAccessToken(loginResponse.data.jwtToken);
95
+ ```
96
+
97
+ ## Usage Examples
98
+
99
+ ### Order Management
100
+
101
+ ```typescript
102
+ // Place an order
103
+ const order = await client.placeOrder({
104
+ variety: 'NORMAL',
105
+ tradingsymbol: 'INFY',
106
+ symboltoken: '1594',
107
+ exchange: 'NSE',
108
+ transactiontype: 'BUY',
109
+ ordertype: 'LIMIT',
110
+ quantity: '100',
111
+ producttype: 'DELIVERY',
112
+ price: '1500'
113
+ });
114
+
115
+ // Modify an order
116
+ const modifiedOrder = await client.modifyOrder({
117
+ variety: 'NORMAL',
118
+ orderid: '123456',
119
+ tradingsymbol: 'INFY',
120
+ symboltoken: '1594',
121
+ exchange: 'NSE',
122
+ ordertype: 'MARKET',
123
+ quantity: '50',
124
+ producttype: 'DELIVERY'
125
+ });
126
+
127
+ // Cancel an order
128
+ await client.cancelOrder({
129
+ variety: 'NORMAL',
130
+ orderid: '123456'
131
+ });
132
+ ```
133
+
134
+ ### Portfolio Management
135
+
136
+ ```typescript
137
+ // Get positions
138
+ const positions = await client.getPositions();
139
+
140
+ // Get holdings
141
+ const holdings = await client.getHoldings();
142
+
143
+ // Get fund summary
144
+ const fundSummary = await client.getFundSummary();
145
+ ```
146
+
147
+ ### Market Data
148
+
149
+ ```typescript
150
+ // Get historical data
151
+ const historicalData = await client.getHistoricalData({
152
+ exchange: 'NSE',
153
+ symboltoken: '1594',
154
+ interval: 'ONE_MINUTE',
155
+ fromdate: '2024-01-01',
156
+ todate: '2024-01-31'
157
+ });
158
+
159
+ // Get real-time quotes
160
+ const quotes = await client.getQuote({
161
+ mode: 'FULL',
162
+ exchangeTokens: {
163
+ NSE: ['1594', '2885'],
164
+ BSE: ['500325', '500209']
165
+ }
166
+ });
167
+ ```
168
+
169
+ ### Basket Orders
170
+
171
+ ```typescript
172
+ // Create basket
173
+ const basket = await client.createBasket({
174
+ BaskName: 'MyStrategy',
175
+ BaskDesc: 'My trading strategy basket'
176
+ });
177
+
178
+ // Calculate basket
179
+ const calculation = await client.calculateBasket({
180
+ basket_name: 'MyStrategy',
181
+ basket_id: '123',
182
+ operation: 'CALCULATE',
183
+ include_exist_pos: 'Y'
184
+ });
185
+ ```
186
+
187
+ ### WebSocket Market Data
188
+
189
+ ```typescript
190
+ import { MTicker } from '@mstock-mirae-asset/nodetradingapi-typeb';
191
+
192
+ // Initialize MTicker
193
+ const ticker = new MTicker(apiKey, accessToken, 'wss://ws.mstock.trade', true);
194
+
195
+ // Event handlers
196
+ ticker.on('ticks', (ticks) => {
197
+ console.log('Market data:', ticks);
198
+ });
199
+
200
+ ticker.on('connect', () => {
201
+ ticker.sendLoginAfterConnect();
202
+ // Subscribe to instruments with different modes
203
+ ticker.subscribe('NSE', ['1594'], MTicker.MODE_LTP); // LTP only
204
+ ticker.subscribe('NSE', ['2885'], MTicker.MODE_QUOTE); // OHLC + Volume
205
+ ticker.subscribe('NSE', ['1333'], MTicker.MODE_SNAP); // Full market depth
206
+ });
207
+
208
+ ticker.on('order_update', (data) => {
209
+ console.log('Order update:', data);
210
+ });
211
+
212
+ ticker.on('trade_update', (data) => {
213
+ console.log('Trade update:', data);
214
+ });
215
+
216
+ // Connect to WebSocket
217
+ ticker.connect();
218
+ ```
219
+
220
+ ## API Reference
221
+
222
+ ### Authentication
223
+
224
+ | Method | Description |
225
+ |--------|-------------|
226
+ | `login()` | User authentication |
227
+ | `verifyOTP()` | Verify OTP for session token |
228
+ | `verifyTOTP()` | Verify TOTP for 2FA |
229
+ | `logout()` | User logout |
230
+
231
+ ### Order Management
232
+
233
+ | Method | Description |
234
+ |--------|-------------|
235
+ | `placeOrder()` | Place new orders |
236
+ | `modifyOrder()` | Modify existing orders |
237
+ | `cancelOrder()` | Cancel orders |
238
+ | `cancelAllOrders()` | Cancel all open orders |
239
+ | `getOrderBook()` | Get order book |
240
+ | `getOrderDetails()` | Get specific order details |
241
+
242
+ ### Portfolio Operations
243
+
244
+ | Method | Description |
245
+ |--------|-------------|
246
+ | `getPositions()` | Get open positions |
247
+ | `getHoldings()` | Get portfolio holdings |
248
+ | `getFundSummary()` | Get fund summary |
249
+ | `convertPosition()` | Convert position between product types |
250
+ | `getTradeBook()` | Get trade book |
251
+ | `getTradeHistory()` | Get trade history |
252
+
253
+ ### Market Data
254
+
255
+ | Method | Description |
256
+ |--------|-------------|
257
+ | `getHistoricalData()` | Get historical candlestick data |
258
+ | `getIntradayChartData()` | Get intraday chart data |
259
+ | `getQuote()` | Get real-time quotes |
260
+ | `getInstrumentMaster()` | Get instrument master data |
261
+ | `loserGainer()` | Get top gainers and losers |
262
+
263
+ ### Options Trading
264
+
265
+ | Method | Description |
266
+ |--------|-------------|
267
+ | `getOptionChainMaster()` | Get option chain master data |
268
+ | `getOptionChain()` | Get detailed option chain data |
269
+
270
+ ### Basket Operations
271
+
272
+ | Method | Description |
273
+ |--------|-------------|
274
+ | `createBasket()` | Create new basket |
275
+ | `fetchBasket()` | Fetch existing baskets |
276
+ | `renameBasket()` | Rename basket |
277
+ | `deleteBasket()` | Delete basket |
278
+ | `calculateBasket()` | Calculate basket margin and charges |
279
+
280
+ ### WebSocket (MTicker)
281
+
282
+ | Method | Description |
283
+ |--------|-------------|
284
+ | `connect()` | Connect to WebSocket |
285
+ | `subscribe()` | Subscribe to instruments |
286
+ | `unsubscribe()` | Unsubscribe from instruments |
287
+ | `sendLoginAfterConnect()` | Send login after connection |
288
+ | `close()` | Close WebSocket connection |
289
+
290
+ ### Other Operations
291
+
292
+ | Method | Description |
293
+ |--------|-------------|
294
+ | `orderMargin()` | Calculate order margin requirements |
295
+
296
+
297
+ ## Testing
298
+
299
+ The SDK includes comprehensive testing utilities:
300
+
301
+ ### Interactive API Testing
302
+
303
+ ```bash
304
+ # Run interactive test menu
305
+ npx ts-node test/test-api.ts
306
+ ```
307
+
308
+ ### WebSocket Testing
309
+
310
+ ```bash
311
+ # Test real-time market data
312
+ npx ts-node test/test-ticker.ts
313
+ ```
314
+
315
+ ### Available Test Categories
316
+
317
+ - **Authentication**: Login, OTP verification, TOTP verification
318
+ - **Order Management**: Place, modify, cancel orders
319
+ - **Portfolio & Funds**: Positions, holdings, fund summary
320
+ - **Market Data**: Historical data, quotes, instrument master
321
+ - **WebSocket**: Real-time market data streaming
322
+ - **Basket Operations**: Create, manage, calculate baskets
323
+ - **Options Trading**: Option chain data
324
+
325
+ See [test/RUNTEST.md](./test/RUNTEST.md) for detailed testing instructions.
326
+
327
+ ### Building
328
+
329
+ ```bash
330
+ npm run build
331
+ ```
332
+
333
+
334
+ ## License
335
+
336
+ MIT License - see [LICENSE](LICENSE) file for details.
337
+
338
+ mStock By Mirae Asset Capital Markets (India) Pvt. Ltd. (c) 2025. Licensed under the MIT License.
339
+
340
+
341
+ ## Support
342
+ For issues, please open an issue on GitHub.
343
+
344
+ ## Contributing
345
+
346
+ We welcome contributions! Please follow these steps:
347
+
348
+ 1. Fork the repository
349
+ 2. Create a new branch (feature-xyz)
350
+ 3. Commit your changes
351
+ 4. Push the branch and create a pull request
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Trading constants and enumerations for TypeB SDK
3
+ *
4
+ * This module contains all the constant values and enumerations used throughout the TypeB SDK.
5
+ * These constants define standard values for product types, order types, exchanges, intervals,
6
+ * and other trading-related configurations.
7
+ *
8
+ * @module constants
9
+ */
10
+ /**
11
+ * Product types available for trading
12
+ * Defines the different types of trading products supported by the SDK
13
+ *
14
+ * @constant
15
+ * @type {Object}
16
+ * @property {string} DELIVERY - Delivery-based trading (hold positions overnight)
17
+ * @property {string} MARGIN - Margin trading with leverage
18
+ * @property {string} INTRADAY - Intraday trading (square off same day)
19
+ * @property {string} BO - Bracket Order trading with predefined stop loss and target
20
+ * @property {string} CARRYFORWARD - Carry forward positions to next day
21
+ */
22
+ export declare const PRODUCT_TYPES: {
23
+ readonly DELIVERY: "DELIVERY";
24
+ readonly MARGIN: "MARGIN";
25
+ readonly INTRADAY: "INTRADAY";
26
+ readonly BO: "BO";
27
+ readonly CARRYFORWARD: "CARRYFORWARD";
28
+ };
29
+ /**
30
+ * Order types for placing trades
31
+ * Defines the various order types supported for trade execution
32
+ *
33
+ * @constant
34
+ * @type {Object}
35
+ * @property {string} MARKET - Market order (executes at current market price)
36
+ * @property {string} LIMIT - Limit order (executes at specified price or better)
37
+ * @property {string} STOPLOSS_LIMIT - Stop loss limit order (triggers at stop price, executes at limit price)
38
+ * @property {string} STOPLOSS_MARKET - Stop loss market order (triggers at stop price, executes at market price)
39
+ */
40
+ export declare const ORDER_TYPES: {
41
+ readonly MARKET: "MARKET";
42
+ readonly LIMIT: "LIMIT";
43
+ readonly STOPLOSS_LIMIT: "STOPLOSS_LIMIT";
44
+ readonly STOPLOSS_MARKET: "STOPLOSS_MARKET";
45
+ };
46
+ /**
47
+ * Order varieties for different trading scenarios
48
+ * Defines special order types for specific trading requirements
49
+ *
50
+ * @constant
51
+ * @type {Object}
52
+ * @property {string} NORMAL - Regular order type
53
+ * @property {string} STOPLOSS - Stop loss order variety
54
+ * @property {string} ROBO - Robo order with automated features
55
+ * @property {string} AMO - After Market Order (placed outside market hours)
56
+ */
57
+ export declare const VARIETIES: {
58
+ readonly NORMAL: "NORMAL";
59
+ readonly STOPLOSS: "STOPLOSS";
60
+ readonly ROBO: "ROBO";
61
+ readonly AMO: "AMO";
62
+ };
63
+ /**
64
+ * Transaction types for buy/sell operations
65
+ * Defines the basic transaction directions
66
+ *
67
+ * @constant
68
+ * @type {Object}
69
+ * @property {string} BUY - Buy transaction
70
+ * @property {string} SELL - Sell transaction
71
+ */
72
+ export declare const TRANSACTION_TYPES: {
73
+ readonly BUY: "BUY";
74
+ readonly SELL: "SELL";
75
+ };
76
+ /**
77
+ * Order validity types
78
+ * Defines how long an order remains active in the system
79
+ *
80
+ * @constant
81
+ * @type {Object}
82
+ * @property {string} DAY - Valid for the entire trading day
83
+ * @property {string} IOC - Immediate or Cancel (executes immediately or cancels)
84
+ */
85
+ export declare const VALIDITY_TYPES: {
86
+ readonly DAY: "DAY";
87
+ readonly IOC: "IOC";
88
+ };
89
+ /**
90
+ * Exchange identifiers
91
+ * Defines all supported exchanges for trading
92
+ *
93
+ * @constant
94
+ * @type {Object}
95
+ * @property {string} NSE - National Stock Exchange of India
96
+ * @property {string} BSE - Bombay Stock Exchange
97
+ * @property {string} NFO - NSE Futures and Options
98
+ * @property {string} BFO - BSE Futures and Options
99
+ * @property {string} CDS - Currency Derivatives Segment
100
+ * @property {string} MCX - Multi Commodity Exchange
101
+ * @property {string} NCDEX - National Commodity & Derivatives Exchange
102
+ */
103
+ export declare const EXCHANGES: {
104
+ readonly NSE: "NSE";
105
+ readonly BSE: "BSE";
106
+ readonly NFO: "NFO";
107
+ readonly BFO: "BFO";
108
+ readonly CDS: "CDS";
109
+ readonly MCX: "MCX";
110
+ readonly NCDEX: "NCDEX";
111
+ };
112
+ /**
113
+ * Candlestick intervals for historical data
114
+ * Defines the time intervals for fetching historical price data
115
+ *
116
+ * @constant
117
+ * @type {Object}
118
+ * @property {string} ONE_MINUTE - 1 minute interval
119
+ * @property {string} THREE_MINUTE - 3 minute interval
120
+ * @property {string} FIVE_MINUTE - 5 minute interval
121
+ * @property {string} TEN_MINUTE - 10 minute interval
122
+ * @property {string} FIFTEEN_MINUTE - 15 minute interval
123
+ * @property {string} THIRTY_MINUTE - 30 minute interval
124
+ * @property {string} ONE_HOUR - 1 hour interval
125
+ * @property {string} ONE_DAY - 1 day interval
126
+ */
127
+ export declare const INTERVALS: {
128
+ readonly ONE_MINUTE: "ONE_MINUTE";
129
+ readonly THREE_MINUTE: "THREE_MINUTE";
130
+ readonly FIVE_MINUTE: "FIVE_MINUTE";
131
+ readonly TEN_MINUTE: "TEN_MINUTE";
132
+ readonly FIFTEEN_MINUTE: "FIFTEEN_MINUTE";
133
+ readonly THIRTY_MINUTE: "THIRTY_MINUTE";
134
+ readonly ONE_HOUR: "ONE_HOUR";
135
+ readonly ONE_DAY: "ONE_DAY";
136
+ };
137
+ /**
138
+ * Default configuration values
139
+ * Defines the default settings and URLs for the SDK
140
+ *
141
+ * @constant
142
+ * @type {Object}
143
+ * @property {string} API_BASE_URL - Base URL for API endpoints
144
+ * @property {string} SOCKET_BASE_URL - Base URL for WebSocket connections
145
+ * @property {string} wsURL - WebSocket URL for real-time data
146
+ * @property {number} MAX_RECONNECTION_ATTEMPTS - Maximum attempts for reconnection
147
+ * @property {number} RECONNECT_DELAY - Delay between reconnection attempts (milliseconds)
148
+ * @property {number} TIMEOUT - Request timeout duration (milliseconds)
149
+ */
150
+ export declare const DEFAULTS: {
151
+ readonly API_BASE_URL: "https://api.mstock.trade";
152
+ readonly SOCKET_BASE_URL: "wss://ws.mstock.trade";
153
+ readonly wsURL: "wss://ws.mstock.trade";
154
+ readonly MAX_RECONNECTION_ATTEMPTS: 5;
155
+ readonly RECONNECT_DELAY: 5000;
156
+ readonly TIMEOUT: 30000;
157
+ };
158
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../constants/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa;;;;;;CAMhB,CAAC;AAEX;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW;;;;;CAKd,CAAC;AAEX;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS;;;;;CAKZ,CAAC;AAEX;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB;;;CAGpB,CAAC;AAEX;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAEX;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,SAAS;;;;;;;;CAQZ,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS;;;;;;;;;CASZ,CAAC;AAEX;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ;;;;;;;CAOX,CAAC"}
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ /**
3
+ * Trading constants and enumerations for TypeB SDK
4
+ *
5
+ * This module contains all the constant values and enumerations used throughout the TypeB SDK.
6
+ * These constants define standard values for product types, order types, exchanges, intervals,
7
+ * and other trading-related configurations.
8
+ *
9
+ * @module constants
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DEFAULTS = exports.INTERVALS = exports.EXCHANGES = exports.VALIDITY_TYPES = exports.TRANSACTION_TYPES = exports.VARIETIES = exports.ORDER_TYPES = exports.PRODUCT_TYPES = void 0;
13
+ /**
14
+ * Product types available for trading
15
+ * Defines the different types of trading products supported by the SDK
16
+ *
17
+ * @constant
18
+ * @type {Object}
19
+ * @property {string} DELIVERY - Delivery-based trading (hold positions overnight)
20
+ * @property {string} MARGIN - Margin trading with leverage
21
+ * @property {string} INTRADAY - Intraday trading (square off same day)
22
+ * @property {string} BO - Bracket Order trading with predefined stop loss and target
23
+ * @property {string} CARRYFORWARD - Carry forward positions to next day
24
+ */
25
+ exports.PRODUCT_TYPES = {
26
+ DELIVERY: 'DELIVERY',
27
+ MARGIN: 'MARGIN',
28
+ INTRADAY: 'INTRADAY',
29
+ BO: 'BO',
30
+ CARRYFORWARD: 'CARRYFORWARD',
31
+ };
32
+ /**
33
+ * Order types for placing trades
34
+ * Defines the various order types supported for trade execution
35
+ *
36
+ * @constant
37
+ * @type {Object}
38
+ * @property {string} MARKET - Market order (executes at current market price)
39
+ * @property {string} LIMIT - Limit order (executes at specified price or better)
40
+ * @property {string} STOPLOSS_LIMIT - Stop loss limit order (triggers at stop price, executes at limit price)
41
+ * @property {string} STOPLOSS_MARKET - Stop loss market order (triggers at stop price, executes at market price)
42
+ */
43
+ exports.ORDER_TYPES = {
44
+ MARKET: 'MARKET',
45
+ LIMIT: 'LIMIT',
46
+ STOPLOSS_LIMIT: 'STOPLOSS_LIMIT',
47
+ STOPLOSS_MARKET: 'STOPLOSS_MARKET',
48
+ };
49
+ /**
50
+ * Order varieties for different trading scenarios
51
+ * Defines special order types for specific trading requirements
52
+ *
53
+ * @constant
54
+ * @type {Object}
55
+ * @property {string} NORMAL - Regular order type
56
+ * @property {string} STOPLOSS - Stop loss order variety
57
+ * @property {string} ROBO - Robo order with automated features
58
+ * @property {string} AMO - After Market Order (placed outside market hours)
59
+ */
60
+ exports.VARIETIES = {
61
+ NORMAL: 'NORMAL',
62
+ STOPLOSS: 'STOPLOSS',
63
+ ROBO: 'ROBO',
64
+ AMO: 'AMO',
65
+ };
66
+ /**
67
+ * Transaction types for buy/sell operations
68
+ * Defines the basic transaction directions
69
+ *
70
+ * @constant
71
+ * @type {Object}
72
+ * @property {string} BUY - Buy transaction
73
+ * @property {string} SELL - Sell transaction
74
+ */
75
+ exports.TRANSACTION_TYPES = {
76
+ BUY: 'BUY',
77
+ SELL: 'SELL',
78
+ };
79
+ /**
80
+ * Order validity types
81
+ * Defines how long an order remains active in the system
82
+ *
83
+ * @constant
84
+ * @type {Object}
85
+ * @property {string} DAY - Valid for the entire trading day
86
+ * @property {string} IOC - Immediate or Cancel (executes immediately or cancels)
87
+ */
88
+ exports.VALIDITY_TYPES = {
89
+ DAY: 'DAY',
90
+ IOC: 'IOC',
91
+ };
92
+ /**
93
+ * Exchange identifiers
94
+ * Defines all supported exchanges for trading
95
+ *
96
+ * @constant
97
+ * @type {Object}
98
+ * @property {string} NSE - National Stock Exchange of India
99
+ * @property {string} BSE - Bombay Stock Exchange
100
+ * @property {string} NFO - NSE Futures and Options
101
+ * @property {string} BFO - BSE Futures and Options
102
+ * @property {string} CDS - Currency Derivatives Segment
103
+ * @property {string} MCX - Multi Commodity Exchange
104
+ * @property {string} NCDEX - National Commodity & Derivatives Exchange
105
+ */
106
+ exports.EXCHANGES = {
107
+ NSE: 'NSE',
108
+ BSE: 'BSE',
109
+ NFO: 'NFO',
110
+ BFO: 'BFO',
111
+ CDS: 'CDS',
112
+ MCX: 'MCX',
113
+ NCDEX: 'NCDEX',
114
+ };
115
+ /**
116
+ * Candlestick intervals for historical data
117
+ * Defines the time intervals for fetching historical price data
118
+ *
119
+ * @constant
120
+ * @type {Object}
121
+ * @property {string} ONE_MINUTE - 1 minute interval
122
+ * @property {string} THREE_MINUTE - 3 minute interval
123
+ * @property {string} FIVE_MINUTE - 5 minute interval
124
+ * @property {string} TEN_MINUTE - 10 minute interval
125
+ * @property {string} FIFTEEN_MINUTE - 15 minute interval
126
+ * @property {string} THIRTY_MINUTE - 30 minute interval
127
+ * @property {string} ONE_HOUR - 1 hour interval
128
+ * @property {string} ONE_DAY - 1 day interval
129
+ */
130
+ exports.INTERVALS = {
131
+ ONE_MINUTE: 'ONE_MINUTE',
132
+ THREE_MINUTE: 'THREE_MINUTE',
133
+ FIVE_MINUTE: 'FIVE_MINUTE',
134
+ TEN_MINUTE: 'TEN_MINUTE',
135
+ FIFTEEN_MINUTE: 'FIFTEEN_MINUTE',
136
+ THIRTY_MINUTE: 'THIRTY_MINUTE',
137
+ ONE_HOUR: 'ONE_HOUR',
138
+ ONE_DAY: 'ONE_DAY',
139
+ };
140
+ /**
141
+ * Default configuration values
142
+ * Defines the default settings and URLs for the SDK
143
+ *
144
+ * @constant
145
+ * @type {Object}
146
+ * @property {string} API_BASE_URL - Base URL for API endpoints
147
+ * @property {string} SOCKET_BASE_URL - Base URL for WebSocket connections
148
+ * @property {string} wsURL - WebSocket URL for real-time data
149
+ * @property {number} MAX_RECONNECTION_ATTEMPTS - Maximum attempts for reconnection
150
+ * @property {number} RECONNECT_DELAY - Delay between reconnection attempts (milliseconds)
151
+ * @property {number} TIMEOUT - Request timeout duration (milliseconds)
152
+ */
153
+ exports.DEFAULTS = {
154
+ API_BASE_URL: 'https://api.mstock.trade',
155
+ SOCKET_BASE_URL: 'wss://ws.mstock.trade',
156
+ wsURL: 'wss://ws.mstock.trade',
157
+ MAX_RECONNECTION_ATTEMPTS: 5,
158
+ RECONNECT_DELAY: 5000,
159
+ TIMEOUT: 30000,
160
+ };
161
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../constants/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH;;;;;;;;;;;GAWG;AACU,QAAA,aAAa,GAAG;IACzB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,EAAE,EAAE,IAAI;IACR,YAAY,EAAE,cAAc;CACtB,CAAC;AAEX;;;;;;;;;;GAUG;AACU,QAAA,WAAW,GAAG;IACvB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;CAC5B,CAAC;AAEX;;;;;;;;;;GAUG;AACU,QAAA,SAAS,GAAG;IACrB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX;;;;;;;;GAQG;AACU,QAAA,iBAAiB,GAAG;IAC7B,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;CACN,CAAC;AAEX;;;;;;;;GAQG;AACU,QAAA,cAAc,GAAG;IAC1B,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;CACJ,CAAC;AAEX;;;;;;;;;;;;;GAaG;AACU,QAAA,SAAS,GAAG;IACrB,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;CACR,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACU,QAAA,SAAS,GAAG;IACrB,UAAU,EAAE,YAAY;IACxB,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa;IAC1B,UAAU,EAAE,YAAY;IACxB,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,eAAe;IAC9B,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;CACZ,CAAC;AAEX;;;;;;;;;;;;GAYG;AACU,QAAA,QAAQ,GAAG;IACpB,YAAY,EAAE,0BAA0B;IACxC,eAAe,EAAE,uBAAuB;IACxC,KAAK,EAAE,uBAAuB;IAC9B,yBAAyB,EAAE,CAAC;IAC5B,eAAe,EAAE,IAAI;IACrB,OAAO,EAAE,KAAK;CACR,CAAC"}