binance 3.0.0-beta.3 → 3.0.0-beta.5

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 (78) hide show
  1. package/README.md +5 -5
  2. package/index.js +1 -1
  3. package/lib/coinm-client.d.ts +46 -16
  4. package/lib/coinm-client.js +4 -4
  5. package/lib/coinm-client.js.map +1 -1
  6. package/lib/index.d.ts +2 -0
  7. package/lib/index.js +2 -0
  8. package/lib/index.js.map +1 -1
  9. package/lib/main-client.d.ts +64 -15
  10. package/lib/main-client.js +41 -13
  11. package/lib/main-client.js.map +1 -1
  12. package/lib/portfolio-client.js.map +1 -1
  13. package/lib/types/coin.d.ts +1 -0
  14. package/lib/types/futures.d.ts +5 -4
  15. package/lib/types/futures.js.map +1 -1
  16. package/lib/types/shared.d.ts +7 -13
  17. package/lib/types/spot.d.ts +126 -8
  18. package/lib/types/spot.js.map +1 -1
  19. package/lib/types/websockets/ws-api-requests.d.ts +429 -2
  20. package/lib/types/websockets/ws-api-responses.d.ts +564 -0
  21. package/lib/types/websockets/ws-api.d.ts +149 -55
  22. package/lib/types/websockets/ws-api.js +46 -3
  23. package/lib/types/websockets/ws-api.js.map +1 -1
  24. package/lib/types/websockets/ws-events-formatted.d.ts +2 -2
  25. package/lib/types/websockets/ws-events-raw.d.ts +2 -2
  26. package/lib/types/websockets/ws-general.d.ts +4 -19
  27. package/lib/usdm-client.d.ts +41 -18
  28. package/lib/usdm-client.js +5 -8
  29. package/lib/usdm-client.js.map +1 -1
  30. package/lib/util/BaseRestClient.js +4 -1
  31. package/lib/util/BaseRestClient.js.map +1 -1
  32. package/lib/util/BaseWSClient.d.ts +14 -3
  33. package/lib/util/BaseWSClient.js +61 -26
  34. package/lib/util/BaseWSClient.js.map +1 -1
  35. package/lib/util/beautifier-maps.d.ts +19 -0
  36. package/lib/util/beautifier-maps.js +28 -0
  37. package/lib/util/beautifier-maps.js.map +1 -1
  38. package/lib/util/beautifier.js +1 -1
  39. package/lib/util/beautifier.js.map +1 -1
  40. package/lib/util/browser-support.d.ts +1 -1
  41. package/lib/util/browser-support.js +1 -41
  42. package/lib/util/browser-support.js.map +1 -1
  43. package/lib/util/node-support.js +7 -5
  44. package/lib/util/node-support.js.map +1 -1
  45. package/lib/util/requestUtils.d.ts +3 -2
  46. package/lib/util/requestUtils.js +46 -23
  47. package/lib/util/requestUtils.js.map +1 -1
  48. package/lib/util/rounding.d.ts +8 -0
  49. package/lib/util/rounding.js +41 -0
  50. package/lib/util/rounding.js.map +1 -0
  51. package/lib/util/typeGuards.d.ts +4 -2
  52. package/lib/util/typeGuards.js +33 -0
  53. package/lib/util/typeGuards.js.map +1 -1
  54. package/lib/util/webCryptoAPI.js +20 -45
  55. package/lib/util/webCryptoAPI.js.map +1 -1
  56. package/lib/util/websockets/WsStore.js +7 -2
  57. package/lib/util/websockets/WsStore.js.map +1 -1
  58. package/lib/util/websockets/enum.d.ts +11 -0
  59. package/lib/util/websockets/enum.js +24 -0
  60. package/lib/util/websockets/enum.js.map +1 -0
  61. package/lib/util/websockets/rest-client-cache.d.ts +3 -3
  62. package/lib/util/websockets/rest-client-cache.js +9 -9
  63. package/lib/util/websockets/rest-client-cache.js.map +1 -1
  64. package/lib/util/websockets/user-data-stream-manager.js +7 -8
  65. package/lib/util/websockets/user-data-stream-manager.js.map +1 -1
  66. package/lib/util/websockets/websocket-util.d.ts +10 -5
  67. package/lib/util/websockets/websocket-util.js +66 -42
  68. package/lib/util/websockets/websocket-util.js.map +1 -1
  69. package/lib/websocket-api-client.d.ts +396 -0
  70. package/lib/websocket-api-client.js +636 -0
  71. package/lib/websocket-api-client.js.map +1 -0
  72. package/lib/websocket-client-legacy.d.ts +2 -2
  73. package/lib/websocket-client-legacy.js +7 -7
  74. package/lib/websocket-client-legacy.js.map +1 -1
  75. package/lib/websocket-client.d.ts +23 -11
  76. package/lib/websocket-client.js +101 -120
  77. package/lib/websocket-client.js.map +1 -1
  78. package/package.json +2 -2
@@ -0,0 +1,636 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.WebsocketAPIClient = void 0;
13
+ const typeGuards_1 = require("./util/typeGuards");
14
+ const websocket_util_1 = require("./util/websockets/websocket-util");
15
+ const websocket_client_1 = require("./websocket-client");
16
+ function getFuturesMarketWsKey(market) {
17
+ if (market === 'usdm') {
18
+ return websocket_util_1.WS_KEY_MAP.usdmWSAPI;
19
+ }
20
+ return websocket_util_1.WS_KEY_MAP.coinmWSAPI;
21
+ }
22
+ /**
23
+ * This is a minimal Websocket API wrapper around the WebsocketClient.
24
+ *
25
+ * Some methods support passing in a custom "wsKey". This is a reference to which WS connection should
26
+ * be used to transmit that message. This is only useful if you wish to use an alternative wss
27
+ * domain that is supported by the SDK.
28
+ *
29
+ * Note: To use testnet, don't set the wsKey - use `testnet: true` in
30
+ * the constructor instead.
31
+ *
32
+ * Note: You can also directly use the sendWSAPIRequest() method to make WS API calls, but some
33
+ * may find the below methods slightly more intuitive.
34
+ *
35
+ * Refer to the WS API promises example for a more detailed example on using sendWSAPIRequest() directly:
36
+ * https://github.com/tiagosiebler/binance/blob/wsapi/examples/ws-api-promises.ts#L52-L61
37
+ */
38
+ class WebsocketAPIClient {
39
+ constructor(options, logger) {
40
+ /**
41
+ * Minimal state store around automating sticky "userDataStream.subscribe" sessions
42
+ */
43
+ this.subscribedUserDataStreamState = {};
44
+ this.wsClient = new websocket_client_1.WebsocketClient(options, logger);
45
+ this.options = Object.assign({ resubscribeUserDataStreamAfterReconnect: true, resubscribeUserDataStreamDelaySeconds: 2, attachEventListeners: true }, options);
46
+ this.logger = this.wsClient.logger;
47
+ this.setupDefaultEventListeners();
48
+ this.wsClient.on('reconnected', ({ wsKey }) => {
49
+ this.handleWSReconnectedEvent({ wsKey });
50
+ });
51
+ }
52
+ getWSClient() {
53
+ return this.wsClient;
54
+ }
55
+ setTimeOffsetMs(newOffset) {
56
+ return this.getWSClient().setTimeOffsetMs(newOffset);
57
+ }
58
+ /*
59
+ *
60
+ * SPOT - General requests
61
+ *
62
+ */
63
+ /**
64
+ * Test connectivity to the WebSocket API
65
+ */
66
+ testSpotConnectivity(wsKey) {
67
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'ping');
68
+ }
69
+ /**
70
+ * Test connectivity to the WebSocket API and get the current server time
71
+ */
72
+ getSpotServerTime(wsKey) {
73
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'time');
74
+ }
75
+ /**
76
+ * Query current exchange trading rules, rate limits, and symbol information
77
+ */
78
+ getSpotExchangeInfo(params, wsKey) {
79
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'exchangeInfo', params);
80
+ }
81
+ getSpotSessionStatus(wsKey) {
82
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'session.status');
83
+ }
84
+ /*
85
+ *
86
+ * SPOT - Market data requests
87
+ *
88
+ */
89
+ /**
90
+ * Get current order book
91
+ * Note: If you need to continuously monitor order book updates, consider using WebSocket Streams
92
+ */
93
+ getSpotOrderBook(params, wsKey) {
94
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'depth', params);
95
+ }
96
+ /**
97
+ * Get recent trades
98
+ * Note: If you need access to real-time trading activity, consider using WebSocket Streams
99
+ */
100
+ getSpotRecentTrades(params, wsKey) {
101
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'trades.recent', params);
102
+ }
103
+ /**
104
+ * Get historical trades
105
+ * Note: If fromId is not specified, the most recent trades are returned
106
+ */
107
+ getSpotHistoricalTrades(params, wsKey) {
108
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'trades.historical', params);
109
+ }
110
+ /**
111
+ * Get aggregate trades
112
+ * Note: An aggregate trade represents one or more individual trades that fill at the same time
113
+ */
114
+ getSpotAggregateTrades(params, wsKey) {
115
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'trades.aggregate', params);
116
+ }
117
+ /**
118
+ * Get klines (candlestick bars)
119
+ * Note: If you need access to real-time kline updates, consider using WebSocket Streams
120
+ */
121
+ getSpotKlines(params, wsKey) {
122
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'klines', params);
123
+ }
124
+ /**
125
+ * Get klines (candlestick bars) optimized for presentation
126
+ * Note: This request is similar to klines, having the same parameters and response
127
+ */
128
+ getSpotUIKlines(params, wsKey) {
129
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'uiKlines', params);
130
+ }
131
+ /**
132
+ * Get current average price for a symbol
133
+ */
134
+ getSpotAveragePrice(params, wsKey) {
135
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'avgPrice', params);
136
+ }
137
+ /**
138
+ * Get 24-hour rolling window price change statistics
139
+ * Note: If you need to continuously monitor trading statistics, consider using WebSocket Streams
140
+ */
141
+ getSpot24hrTicker(params, wsKey) {
142
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'ticker.24hr', params);
143
+ }
144
+ /**
145
+ * Get price change statistics for a trading day
146
+ */
147
+ getSpotTradingDayTicker(params, wsKey) {
148
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'ticker.tradingDay', params);
149
+ }
150
+ /**
151
+ * Get rolling window price change statistics with a custom window
152
+ * Note: Window size precision is limited to 1 minute
153
+ */
154
+ getSpotTicker(params, wsKey) {
155
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'ticker', params);
156
+ }
157
+ /**
158
+ * Get the latest market price for a symbol
159
+ * Note: If you need access to real-time price updates, consider using WebSocket Streams
160
+ */
161
+ getSpotSymbolPriceTicker(params, wsKey) {
162
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'ticker.price', params);
163
+ }
164
+ /**
165
+ * Get the current best price and quantity on the order book
166
+ * Note: If you need access to real-time order book ticker updates, consider using WebSocket Streams
167
+ */
168
+ getSpotSymbolOrderBookTicker(params, wsKey) {
169
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'ticker.book', params);
170
+ }
171
+ /*
172
+ *
173
+ * SPOT - Trading requests
174
+ *
175
+ */
176
+ /**
177
+ * Submit a spot order
178
+ */
179
+ submitNewSpotOrder(params, wsKey) {
180
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'order.place', params);
181
+ }
182
+ /**
183
+ * Test order placement
184
+ * Note: Validates new order parameters and verifies your signature but does not send the order into the matching engine
185
+ */
186
+ testSpotOrder(params, wsKey) {
187
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'order.test', params);
188
+ }
189
+ /**
190
+ * Check execution status of an order
191
+ * Note: If both orderId and origClientOrderId parameters are specified, only orderId is used
192
+ */
193
+ getSpotOrderStatus(params, wsKey) {
194
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'order.status', params);
195
+ }
196
+ /**
197
+ * Cancel an active order
198
+ * Note: If both orderId and origClientOrderId parameters are specified, only orderId is used
199
+ */
200
+ cancelSpotOrder(params, wsKey) {
201
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'order.cancel', params);
202
+ }
203
+ /**
204
+ * Cancel an existing order and immediately place a new order
205
+ * Note: If both cancelOrderId and cancelOrigClientOrderId parameters are specified, only cancelOrderId is used
206
+ */
207
+ cancelReplaceSpotOrder(params, wsKey) {
208
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'order.cancelReplace', params);
209
+ }
210
+ /**
211
+ * Query execution status of all open orders
212
+ * Note: If you need to continuously monitor order status updates, consider using WebSocket Streams
213
+ */
214
+ getSpotOpenOrders(params, wsKey) {
215
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'openOrders.status', params);
216
+ }
217
+ /**
218
+ * Cancel all open orders on a symbol
219
+ * Note: This includes orders that are part of an order list
220
+ */
221
+ cancelAllSpotOpenOrders(params, wsKey) {
222
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'openOrders.cancelAll', params);
223
+ }
224
+ /**
225
+ * Place a new order list
226
+ * Note: This is a deprecated endpoint, consider using placeOCOOrderList instead
227
+ */
228
+ placeSpotOrderList(params, wsKey) {
229
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'orderList.place', params);
230
+ }
231
+ /**
232
+ * Place a new OCO (One-Cancels-the-Other) order list
233
+ * Note: Activation of one order immediately cancels the other
234
+ */
235
+ placeSpotOCOOrderList(params, wsKey) {
236
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'orderList.place.oco', params);
237
+ }
238
+ /**
239
+ * Place a new OTO (One-Triggers-the-Other) order list
240
+ * Note: The pending order is placed only when the working order is fully filled
241
+ */
242
+ placeSpotOTOOrderList(params, wsKey) {
243
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'orderList.place.oto', params);
244
+ }
245
+ /**
246
+ * Place a new OTOCO (One-Triggers-One-Cancels-the-Other) order list
247
+ * Note: The pending orders are placed only when the working order is fully filled
248
+ */
249
+ placeSpotOTOCOOrderList(params, wsKey) {
250
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'orderList.place.otoco', params);
251
+ }
252
+ /**
253
+ * Check execution status of an order list
254
+ * Note: If both origClientOrderId and orderListId parameters are specified, only origClientOrderId is used
255
+ */
256
+ getSpotOrderListStatus(params, wsKey) {
257
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'orderList.status', params);
258
+ }
259
+ /**
260
+ * Cancel an active order list
261
+ * Note: If both orderListId and listClientOrderId parameters are specified, only orderListId is used
262
+ */
263
+ cancelSpotOrderList(params, wsKey) {
264
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'orderList.cancel', params);
265
+ }
266
+ /**
267
+ * Query execution status of all open order lists
268
+ * Note: If you need to continuously monitor order status updates, consider using WebSocket Streams
269
+ */
270
+ getSpotOpenOrderLists(params, wsKey) {
271
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'openOrderLists.status', params);
272
+ }
273
+ /**
274
+ * Place a new order using Smart Order Routing (SOR)
275
+ * Note: Only supports LIMIT and MARKET orders. quoteOrderQty is not supported
276
+ */
277
+ placeSpotSOROrder(params, wsKey) {
278
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'sor.order.place', params);
279
+ }
280
+ /**
281
+ * Test new order creation and signature/recvWindow using Smart Order Routing (SOR)
282
+ * Note: Creates and validates a new order but does not send it into the matching engine
283
+ */
284
+ testSpotSOROrder(params, wsKey) {
285
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'sor.order.test', params);
286
+ }
287
+ /*
288
+ *
289
+ * SPOT - Account requests
290
+ *
291
+ */
292
+ /**
293
+ * Query information about your account
294
+ * Note: Weight: 20
295
+ */
296
+ getSpotAccountStatus(params, wsKey) {
297
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'account.status', params);
298
+ }
299
+ /**
300
+ * Query your current unfilled order count for all intervals
301
+ * Note: Weight: 40
302
+ */
303
+ getSpotOrderRateLimits(params, wsKey) {
304
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'account.rateLimits.orders', params);
305
+ }
306
+ /**
307
+ * Query information about all your orders – active, canceled, filled – filtered by time range
308
+ * Note: Weight: 20
309
+ */
310
+ getSpotAllOrders(params, wsKey) {
311
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'allOrders', params);
312
+ }
313
+ /**
314
+ * Query information about all your order lists, filtered by time range
315
+ * Note: Weight: 20
316
+ */
317
+ getSpotAllOrderLists(params, wsKey) {
318
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'allOrderLists', params);
319
+ }
320
+ /**
321
+ * Query information about all your trades, filtered by time range
322
+ * Note: Weight: 20
323
+ */
324
+ getSpotMyTrades(params, wsKey) {
325
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'myTrades', params);
326
+ }
327
+ /**
328
+ * Displays the list of orders that were expired due to STP
329
+ * Note: Weight varies based on query type (2-20)
330
+ */
331
+ getSpotPreventedMatches(params, wsKey) {
332
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'myPreventedMatches', params);
333
+ }
334
+ /**
335
+ * Retrieves allocations resulting from SOR order placement
336
+ * Note: Weight: 20
337
+ */
338
+ getSpotAllocations(params, wsKey) {
339
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'myAllocations', params);
340
+ }
341
+ /**
342
+ * Get current account commission rates
343
+ * Note: Weight: 20
344
+ */
345
+ getSpotAccountCommission(params, wsKey) {
346
+ return this.wsClient.sendWSAPIRequest(wsKey || websocket_util_1.WS_KEY_MAP.mainWSAPI, 'account.commission', params);
347
+ }
348
+ /*
349
+ *
350
+ * FUTURES - Market data requests
351
+ *
352
+ */
353
+ /**
354
+ * Get current order book for futures
355
+ * Note: If you need to continuously monitor order book updates, consider using WebSocket Streams
356
+ */
357
+ getFuturesOrderBook(params) {
358
+ return this.wsClient.sendWSAPIRequest(websocket_util_1.WS_KEY_MAP.usdmWSAPI, 'depth', params);
359
+ }
360
+ /**
361
+ * Get latest price for a futures symbol or symbols
362
+ * Note: If symbol is not provided, prices for all symbols will be returned
363
+ */
364
+ getFuturesSymbolPriceTicker(params) {
365
+ return this.wsClient.sendWSAPIRequest(websocket_util_1.WS_KEY_MAP.usdmWSAPI, 'ticker.price', params);
366
+ }
367
+ /**
368
+ * Get best price/qty on the order book for a futures symbol or symbols
369
+ * Note: If symbol is not provided, bookTickers for all symbols will be returned
370
+ */
371
+ getFuturesSymbolOrderBookTicker(params) {
372
+ return this.wsClient.sendWSAPIRequest(websocket_util_1.WS_KEY_MAP.usdmWSAPI, 'ticker.book', params);
373
+ }
374
+ /*
375
+ *
376
+ * FUTURES - Trading requests
377
+ *
378
+ */
379
+ /**
380
+ * Submit a futures order
381
+ *
382
+ * This endpoint is used for both USDM and COINM futures.
383
+ */
384
+ submitNewFuturesOrder(market, params) {
385
+ return this.wsClient.sendWSAPIRequest(getFuturesMarketWsKey(market), 'order.place', params);
386
+ }
387
+ /**
388
+ * Modify an existing futures order
389
+ *
390
+ * This endpoint is used for both USDM and COINM futures.
391
+ */
392
+ modifyFuturesOrder(market, params) {
393
+ return this.wsClient.sendWSAPIRequest(getFuturesMarketWsKey(market), 'order.modify', params);
394
+ }
395
+ /**
396
+ * Cancel a futures order
397
+ *
398
+ * This endpoint is used for both USDM and COINM futures.
399
+ */
400
+ cancelFuturesOrder(market, params) {
401
+ return this.wsClient.sendWSAPIRequest(getFuturesMarketWsKey(market), 'order.cancel', params);
402
+ }
403
+ /**
404
+ * Query futures order status
405
+ *
406
+ * This endpoint is used for both USDM and COINM futures.
407
+ */
408
+ getFuturesOrderStatus(market, params) {
409
+ return this.wsClient.sendWSAPIRequest(getFuturesMarketWsKey(market), 'order.status', params);
410
+ }
411
+ /**
412
+ * Get current position information (V2)
413
+ * Note: Only symbols that have positions or open orders will be returned
414
+ */
415
+ getFuturesPositionV2(params) {
416
+ return this.wsClient.sendWSAPIRequest(websocket_util_1.WS_KEY_MAP.usdmWSAPI, 'v2/account.position', params);
417
+ }
418
+ /**
419
+ * Get current position information
420
+ * Note: Only symbols that have positions or open orders will be returned
421
+ *
422
+ * This endpoint is used for both USDM and COINM futures.
423
+ */
424
+ getFuturesPosition(market, params) {
425
+ return this.wsClient.sendWSAPIRequest(getFuturesMarketWsKey(market), 'account.position', params);
426
+ }
427
+ /*
428
+ *
429
+ * FUTURES - Account requests
430
+ *
431
+ */
432
+ /**
433
+ * Get account balance information (V2)
434
+ * Note: Returns balance information for all assets
435
+ */
436
+ getFuturesAccountBalanceV2(params) {
437
+ return this.wsClient.sendWSAPIRequest(websocket_util_1.WS_KEY_MAP.usdmWSAPI, 'v2/account.balance', params);
438
+ }
439
+ /**
440
+ * Get account balance information
441
+ * Note: Returns balance information for all assets
442
+ *
443
+ * This endpoint is used for both USDM and COINM futures.
444
+ */
445
+ getFuturesAccountBalance(market, params) {
446
+ return this.wsClient.sendWSAPIRequest(getFuturesMarketWsKey(market), 'account.balance', params);
447
+ }
448
+ /**
449
+ * Get account information (V2)
450
+ * Note: Returns detailed account information including positions and assets
451
+ */
452
+ getFuturesAccountStatusV2(params) {
453
+ return this.wsClient.sendWSAPIRequest(websocket_util_1.WS_KEY_MAP.usdmWSAPI, 'v2/account.status', params);
454
+ }
455
+ /**
456
+ * Get account information
457
+ * Note: Returns detailed account information including positions and assets
458
+ *
459
+ * This endpoint is used for both USDM and COINM futures.
460
+ */
461
+ getFuturesAccountStatus(market, params) {
462
+ return this.wsClient.sendWSAPIRequest(getFuturesMarketWsKey(market), 'account.status', params);
463
+ }
464
+ /*
465
+ *
466
+ * User data stream requests
467
+ *
468
+ */
469
+ /**
470
+ * Start the user data stream for an apiKey (passed as param).
471
+ *
472
+ * Note: for "Spot" markets, the listenKey workflow is deprecated, use `subscribeUserDataStream()` instead.
473
+ *
474
+ * @param params
475
+ * @param wsKey
476
+ * @returns listenKey
477
+ */
478
+ startUserDataStreamForKey(params, wsKey = websocket_util_1.WS_KEY_MAP.mainWSAPI) {
479
+ return this.wsClient.sendWSAPIRequest(wsKey, 'userDataStream.start', params);
480
+ }
481
+ /**
482
+ * Attempt to "ping" a listen key.
483
+ *
484
+ * Note: for "Spot" markets, the listenKey workflow is deprecated, use `subscribeUserDataStream()` instead.
485
+ *
486
+ * @param params
487
+ * @param wsKey
488
+ * @returns
489
+ */
490
+ pingUserDataStreamForKey(params, wsKey = websocket_util_1.WS_KEY_MAP.mainWSAPI) {
491
+ return this.wsClient.sendWSAPIRequest(wsKey, 'userDataStream.ping', params);
492
+ }
493
+ /**
494
+ * Stop the user data stream listen key.
495
+ *
496
+ * @param params
497
+ * @param wsKey
498
+ * @returns
499
+ */
500
+ stopUserDataStreamForKey(params, wsKey = websocket_util_1.WS_KEY_MAP.mainWSAPI) {
501
+ return this.wsClient.sendWSAPIRequest(wsKey, 'userDataStream.stop', params);
502
+ }
503
+ /**
504
+ * Request user data stream subscription on the currently authenticated connection.
505
+ *
506
+ * If reconnected, this will automatically resubscribe unless you unsubscribe manually.
507
+ */
508
+ subscribeUserDataStream(wsKey) {
509
+ return __awaiter(this, void 0, void 0, function* () {
510
+ const resolvedWsKey = this.options.useTestnet
511
+ ? (0, websocket_util_1.getTestnetWsKey)(wsKey)
512
+ : wsKey;
513
+ const res = yield this.wsClient.sendWSAPIRequest(resolvedWsKey, 'userDataStream.subscribe');
514
+ // Used to track whether this connection had the general "userDataStream.subscribe" called.
515
+ // Used as part of `resubscribeUserDataStreamAfterReconnect` to know which connections to resub.
516
+ this.subscribedUserDataStreamState[resolvedWsKey] = {
517
+ subscribedAt: new Date(),
518
+ subscribeAttempt: 0,
519
+ };
520
+ return res;
521
+ });
522
+ }
523
+ /**
524
+ * Unsubscribe from the user data stream subscription on the currently authenticated connection.
525
+ *
526
+ * If reconnected, this will also stop it from automatically resubscribing after reconnect.
527
+ */
528
+ unsubscribeUserDataStream(wsKey) {
529
+ const resolvedWsKey = this.options.useTestnet
530
+ ? (0, websocket_util_1.getTestnetWsKey)(wsKey)
531
+ : wsKey;
532
+ delete this.subscribedUserDataStreamState[resolvedWsKey];
533
+ return this.wsClient.sendWSAPIRequest(resolvedWsKey, 'userDataStream.unsubscribe');
534
+ }
535
+ /**
536
+ *
537
+ *
538
+ *
539
+ *
540
+ *
541
+ *
542
+ *
543
+ * Private methods for handling some of the convenience/automation provided by the WS API Client
544
+ *
545
+ *
546
+ *
547
+ *
548
+ *
549
+ *
550
+ *
551
+ */
552
+ setupDefaultEventListeners() {
553
+ if (this.options.attachEventListeners) {
554
+ /**
555
+ * General event handlers for monitoring the WebsocketClient
556
+ */
557
+ this.wsClient
558
+ .on('open', (data) => {
559
+ console.log(new Date(), 'ws connected', data.wsKey);
560
+ })
561
+ .on('reconnecting', ({ wsKey }) => {
562
+ console.log(new Date(), 'ws automatically reconnecting.... ', wsKey);
563
+ })
564
+ .on('reconnected', (data) => {
565
+ console.log(new Date(), 'ws has reconnected ', data === null || data === void 0 ? void 0 : data.wsKey);
566
+ })
567
+ .on('authenticated', (data) => {
568
+ console.info(new Date(), 'ws has authenticated ', data === null || data === void 0 ? void 0 : data.wsKey);
569
+ })
570
+ .on('exception', (data) => {
571
+ console.error(new Date(), 'ws exception: ', JSON.stringify(data));
572
+ });
573
+ }
574
+ }
575
+ tryResubscribeUserDataStream(wsKey) {
576
+ return __awaiter(this, void 0, void 0, function* () {
577
+ var _a;
578
+ const subscribeState = this.getSubscribedUserDataStreamState(wsKey);
579
+ const respawnDelayInSeconds = this.options.resubscribeUserDataStreamDelaySeconds;
580
+ this.logger.error('tryResubscribeUserDataStream(): resubscribing to user data stream....', Object.assign(Object.assign({}, websocket_util_1.WS_LOGGER_CATEGORY), { wsKey }));
581
+ try {
582
+ if ((_a = this.subscribedUserDataStreamState[wsKey]) === null || _a === void 0 ? void 0 : _a.respawnTimeout) {
583
+ clearTimeout(this.subscribedUserDataStreamState[wsKey].respawnTimeout);
584
+ delete this.subscribedUserDataStreamState[wsKey].respawnTimeout;
585
+ }
586
+ subscribeState.subscribeAttempt++;
587
+ yield this.subscribeUserDataStream(wsKey);
588
+ this.subscribedUserDataStreamState[wsKey] = Object.assign(Object.assign({}, subscribeState), { subscribedAt: new Date(), subscribeAttempt: 0 });
589
+ this.logger.info('tryResubscribeUserDataStream()->ok', Object.assign(Object.assign(Object.assign({}, websocket_util_1.WS_LOGGER_CATEGORY), subscribeState), { wsKey }));
590
+ }
591
+ catch (e) {
592
+ this.logger.error('tryResubscribeUserDataStream() exception - retry after timeout', Object.assign(Object.assign({}, websocket_util_1.WS_LOGGER_CATEGORY), { wsKey, exception: e, subscribeState }));
593
+ subscribeState.respawnTimeout = setTimeout(() => {
594
+ this.tryResubscribeUserDataStream(wsKey);
595
+ }, 1000 * respawnDelayInSeconds);
596
+ this.subscribedUserDataStreamState[wsKey] = Object.assign({}, subscribeState);
597
+ }
598
+ });
599
+ }
600
+ getSubscribedUserDataStreamState(wsKey) {
601
+ const subscribedState = this.subscribedUserDataStreamState[wsKey] || {
602
+ subscribedAt: new Date(),
603
+ subscribeAttempt: 0,
604
+ };
605
+ return subscribedState;
606
+ }
607
+ handleWSReconnectedEvent(params) {
608
+ var _a;
609
+ const wsKey = params.wsKey;
610
+ // Not a WS API connection
611
+ if (!(0, typeGuards_1.isWSAPIWsKey)(wsKey)) {
612
+ return;
613
+ }
614
+ const fnName = 'handleWSReconnectedEvent()';
615
+ // For the workflow without the listen key
616
+ if (
617
+ // Feature enabled
618
+ this.options.resubscribeUserDataStreamAfterReconnect &&
619
+ // Was subscribed to user data stream (without listen key)
620
+ this.subscribedUserDataStreamState[wsKey]) {
621
+ // Delay existing timer, if exists
622
+ if ((_a = this.subscribedUserDataStreamState[wsKey]) === null || _a === void 0 ? void 0 : _a.respawnTimeout) {
623
+ clearTimeout(this.subscribedUserDataStreamState[wsKey].respawnTimeout);
624
+ delete this.subscribedUserDataStreamState[wsKey].respawnTimeout;
625
+ this.logger.error(`${fnName} -> resubUserData(): Respawn timer already active while trying to queue respawn...delaying existing timer further...`, Object.assign(Object.assign({}, websocket_util_1.WS_LOGGER_CATEGORY), { wsKey }));
626
+ }
627
+ this.logger.trace(`${fnName} -> resubUserData():: queued resubscribe for wsKey user data stream`, Object.assign(Object.assign({}, websocket_util_1.WS_LOGGER_CATEGORY), { wsKey }));
628
+ // Queue resubscribe workflow
629
+ this.subscribedUserDataStreamState[wsKey].respawnTimeout = setTimeout(() => {
630
+ this.tryResubscribeUserDataStream(wsKey);
631
+ }, 1000 * this.options.resubscribeUserDataStreamDelaySeconds);
632
+ }
633
+ }
634
+ }
635
+ exports.WebsocketAPIClient = WebsocketAPIClient;
636
+ //# sourceMappingURL=websocket-api-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket-api-client.js","sourceRoot":"","sources":["../src/websocket-api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAyFA,kDAAiD;AACjD,qEAQ0C;AAC1C,yDAAqD;AAErD,SAAS,qBAAqB,CAAC,M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M,MAAM,GAAG,4BAA4B,CAAC;QAE5C,0CAA0C;QAC1C;QACE,kBAAkB;QAClB,IAAI,CAAC,OAAO,CAAC,uCAAuC;YACpD,0DAA0D;YAC1D,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,EACzC,CAAC;YACD,kCAAkC;YAClC,IAAI,MAAA,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,0CAAE,cAAc,EAAE,CAAC;gBAC9D,YAAY,CAAC,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,CAAC;gBACvE,OAAO,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC;gBAEhE,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,GAAG,MAAM,sHAAsH,kCAE1H,mCAAkB,KACrB,KAAK,IAER,CAAC;YACJ,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,GAAG,MAAM,qEAAqE,kCAEzE,mCAAkB,KACrB,KAAK,IAER,CAAC;YAEF,6BAA6B;YAC7B,IAAI,CAAC,6BAA6B,CAAC,KAAK,CAAC,CAAC,cAAc,GAAG,UAAU,CACnE,GAAG,EAAE;gBACH,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;YAC3C,CAAC,EACD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,qCAAqC,CAC1D,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA7oCD,gDA6oCC"}
@@ -1,11 +1,11 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import WebSocket from 'isomorphic-ws';
3
3
  import { KlineInterval } from './types/shared';
4
+ import { WsFormattedMessage, WsUserDataEvents } from './types/websockets/ws-events-formatted';
5
+ import { WsRawMessage } from './types/websockets/ws-events-raw';
4
6
  import { WSClientConfigurableOptions, WsResponse } from './types/websockets/ws-general';
5
7
  import { DefaultLogger } from './util/logger';
6
8
  import { WsKey } from './util/websockets/websocket-util';
7
- import { WsFormattedMessage, WsUserDataEvents } from './types/websockets/ws-events-formatted';
8
- import { WsRawMessage } from './types/websockets/ws-events-raw';
9
9
  export declare interface WebsocketClientV1 {
10
10
  on(event: 'reply', listener: (event: WsResponse) => void): this;
11
11
  on(event: 'message', listener: (event: WsRawMessage) => void): this;