binance 3.0.0-beta.0 → 3.0.0-beta.10

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