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
@@ -1,4 +1,13 @@
1
- export interface WsAPISessionStatus {
1
+ import { numberInString } from '../shared';
2
+ import { OrderResponse } from '../spot';
3
+ /**
4
+ * Error response type
5
+ */
6
+ export interface ErrorResponse {
7
+ code: number;
8
+ msg: string;
9
+ }
10
+ export interface WSAPISessionStatus {
2
11
  apiKey: string;
3
12
  authorizedSince: number;
4
13
  connectedSince: number;
@@ -6,3 +15,558 @@ export interface WsAPISessionStatus {
6
15
  serverTime: number;
7
16
  userDataStream: boolean;
8
17
  }
18
+ /**
19
+ * General response types
20
+ */
21
+ export interface WSAPIServerTime {
22
+ serverTime: number;
23
+ }
24
+ /**
25
+ * Market data response types
26
+ */
27
+ export interface WSAPIOrderBook {
28
+ lastUpdateId: number;
29
+ bids: [numberInString, numberInString][];
30
+ asks: [numberInString, numberInString][];
31
+ }
32
+ export interface WSAPITrade {
33
+ id: number;
34
+ price: numberInString;
35
+ qty: numberInString;
36
+ quoteQty: numberInString;
37
+ time: number;
38
+ isBuyerMaker: boolean;
39
+ isBestMatch: boolean;
40
+ }
41
+ export interface WSAPIAggregateTrade {
42
+ a: number;
43
+ p: numberInString;
44
+ q: numberInString;
45
+ f: number;
46
+ l: number;
47
+ T: number;
48
+ m: boolean;
49
+ M: boolean;
50
+ }
51
+ export type WSAPIKline = [
52
+ number,
53
+ numberInString,
54
+ numberInString,
55
+ numberInString,
56
+ numberInString,
57
+ numberInString,
58
+ number,
59
+ numberInString,
60
+ number,
61
+ numberInString,
62
+ numberInString,
63
+ numberInString
64
+ ];
65
+ export interface WSAPIAvgPrice {
66
+ mins: number;
67
+ price: numberInString;
68
+ closeTime: number;
69
+ }
70
+ export interface WSAPIFullTicker {
71
+ symbol: string;
72
+ priceChange: numberInString;
73
+ priceChangePercent: numberInString;
74
+ weightedAvgPrice: numberInString;
75
+ prevClosePrice: numberInString;
76
+ lastPrice: numberInString;
77
+ lastQty: numberInString;
78
+ bidPrice: numberInString;
79
+ bidQty: numberInString;
80
+ askPrice: numberInString;
81
+ askQty: numberInString;
82
+ openPrice: numberInString;
83
+ highPrice: numberInString;
84
+ lowPrice: numberInString;
85
+ volume: numberInString;
86
+ quoteVolume: numberInString;
87
+ openTime: number;
88
+ closeTime: number;
89
+ firstId: number;
90
+ lastId: number;
91
+ count: number;
92
+ }
93
+ export interface WSAPIMiniTicker {
94
+ symbol: string;
95
+ openPrice: numberInString;
96
+ highPrice: numberInString;
97
+ lowPrice: numberInString;
98
+ lastPrice: numberInString;
99
+ volume: numberInString;
100
+ quoteVolume: numberInString;
101
+ openTime: number;
102
+ closeTime: number;
103
+ firstId: number;
104
+ lastId: number;
105
+ count: number;
106
+ }
107
+ export interface WSAPIPriceTicker {
108
+ symbol: string;
109
+ price: numberInString;
110
+ }
111
+ export interface WSAPIBookTicker {
112
+ symbol: string;
113
+ bidPrice: numberInString;
114
+ bidQty: numberInString;
115
+ askPrice: numberInString;
116
+ askQty: numberInString;
117
+ }
118
+ /**
119
+ * Futures market data response types
120
+ */
121
+ export interface WSAPIFuturesOrderBook {
122
+ lastUpdateId: number;
123
+ E: number;
124
+ T: number;
125
+ bids: [numberInString, numberInString][];
126
+ asks: [numberInString, numberInString][];
127
+ }
128
+ export interface WSAPIFuturesPriceTicker {
129
+ symbol: string;
130
+ price: numberInString;
131
+ time: number;
132
+ }
133
+ export interface WSAPIFuturesBookTicker {
134
+ lastUpdateId: number;
135
+ symbol: string;
136
+ bidPrice: numberInString;
137
+ bidQty: numberInString;
138
+ askPrice: numberInString;
139
+ askQty: numberInString;
140
+ time: number;
141
+ }
142
+ /**
143
+ * Account response types
144
+ */
145
+ export interface WSAPIAccountInformation {
146
+ makerCommission: number;
147
+ takerCommission: number;
148
+ buyerCommission: number;
149
+ sellerCommission: number;
150
+ canTrade: boolean;
151
+ canWithdraw: boolean;
152
+ canDeposit: boolean;
153
+ commissionRates: {
154
+ maker: numberInString;
155
+ taker: numberInString;
156
+ buyer: numberInString;
157
+ seller: numberInString;
158
+ };
159
+ brokered: boolean;
160
+ requireSelfTradePrevention: boolean;
161
+ preventSor: boolean;
162
+ updateTime: number;
163
+ accountType: string;
164
+ balances: {
165
+ asset: string;
166
+ free: numberInString;
167
+ locked: numberInString;
168
+ }[];
169
+ permissions: string[];
170
+ uid: number;
171
+ }
172
+ export interface WSAPIAccountCommission {
173
+ symbol: string;
174
+ standardCommission: {
175
+ maker: numberInString;
176
+ taker: numberInString;
177
+ buyer: numberInString;
178
+ seller: numberInString;
179
+ };
180
+ taxCommission: {
181
+ maker: numberInString;
182
+ taker: numberInString;
183
+ buyer: numberInString;
184
+ seller: numberInString;
185
+ };
186
+ discount: {
187
+ enabledForAccount: boolean;
188
+ enabledForSymbol: boolean;
189
+ discountAsset: string;
190
+ discount: numberInString;
191
+ };
192
+ }
193
+ export interface WSAPIRateLimit {
194
+ rateLimitType: string;
195
+ interval: string;
196
+ intervalNum: number;
197
+ limit: number;
198
+ count: number;
199
+ }
200
+ export interface WSAPIOrder {
201
+ symbol: string;
202
+ orderId: number;
203
+ orderListId: number;
204
+ clientOrderId: string;
205
+ price: numberInString;
206
+ origQty: numberInString;
207
+ executedQty: numberInString;
208
+ cummulativeQuoteQty: numberInString;
209
+ status: string;
210
+ timeInForce: string;
211
+ type: string;
212
+ side: string;
213
+ stopPrice: numberInString;
214
+ icebergQty: numberInString;
215
+ time: number;
216
+ updateTime: number;
217
+ isWorking: boolean;
218
+ workingTime: number;
219
+ origQuoteOrderQty: numberInString;
220
+ selfTradePreventionMode: string;
221
+ preventedMatchId?: number;
222
+ preventedQuantity?: numberInString;
223
+ }
224
+ export interface WSAPIOrderList {
225
+ orderListId: number;
226
+ contingencyType: string;
227
+ listStatusType: string;
228
+ listOrderStatus: string;
229
+ listClientOrderId: string;
230
+ transactionTime: number;
231
+ symbol: string;
232
+ orders: {
233
+ symbol: string;
234
+ orderId: number;
235
+ clientOrderId: string;
236
+ }[];
237
+ }
238
+ export interface WSAPITrade {
239
+ symbol: string;
240
+ id: number;
241
+ orderId: number;
242
+ orderListId: number;
243
+ price: numberInString;
244
+ qty: numberInString;
245
+ quoteQty: numberInString;
246
+ commission: numberInString;
247
+ commissionAsset: string;
248
+ time: number;
249
+ isBuyer: boolean;
250
+ isMaker: boolean;
251
+ isBestMatch: boolean;
252
+ }
253
+ export interface WSAPIPreventedMatch {
254
+ symbol: string;
255
+ preventedMatchId: number;
256
+ takerOrderId: number;
257
+ makerSymbol: string;
258
+ makerOrderId: number;
259
+ tradeGroupId: number;
260
+ selfTradePreventionMode: string;
261
+ price: numberInString;
262
+ makerPreventedQuantity: numberInString;
263
+ transactTime: number;
264
+ }
265
+ export interface WSAPIAllocation {
266
+ symbol: string;
267
+ allocationId: number;
268
+ allocationType: string;
269
+ orderId: number;
270
+ orderListId: number;
271
+ price: numberInString;
272
+ qty: numberInString;
273
+ quoteQty: numberInString;
274
+ commission: numberInString;
275
+ commissionAsset: string;
276
+ time: number;
277
+ isBuyer: boolean;
278
+ isMaker: boolean;
279
+ isAllocator: boolean;
280
+ }
281
+ /**
282
+ * Trading response types
283
+ */
284
+ export interface WSAPIOrderTestResponse {
285
+ [key: string]: never;
286
+ }
287
+ export interface WSAPIOrderTestWithCommission {
288
+ standardCommissionForOrder: {
289
+ maker: numberInString;
290
+ taker: numberInString;
291
+ };
292
+ taxCommissionForOrder: {
293
+ maker: numberInString;
294
+ taker: numberInString;
295
+ };
296
+ discount: {
297
+ enabledForAccount: boolean;
298
+ enabledForSymbol: boolean;
299
+ discountAsset: string;
300
+ discount: numberInString;
301
+ };
302
+ }
303
+ export interface WSAPIOrderCancel {
304
+ symbol: string;
305
+ origClientOrderId: string;
306
+ orderId: number;
307
+ orderListId: number;
308
+ clientOrderId: string;
309
+ transactTime: number;
310
+ price: numberInString;
311
+ origQty: numberInString;
312
+ executedQty: numberInString;
313
+ origQuoteOrderQty: numberInString;
314
+ cummulativeQuoteQty: numberInString;
315
+ status: string;
316
+ timeInForce: string;
317
+ type: string;
318
+ side: string;
319
+ stopPrice?: numberInString;
320
+ trailingDelta?: number;
321
+ trailingTime?: number;
322
+ icebergQty?: numberInString;
323
+ strategyId?: number;
324
+ strategyType?: number;
325
+ selfTradePreventionMode: string;
326
+ }
327
+ export interface WSAPIOrderCancelReplaceResponse {
328
+ cancelResult: 'SUCCESS' | 'FAILURE' | 'NOT_ATTEMPTED';
329
+ newOrderResult: 'SUCCESS' | 'FAILURE' | 'NOT_ATTEMPTED';
330
+ cancelResponse: WSAPIOrderCancel | ErrorResponse;
331
+ newOrderResponse: OrderResponse | ErrorResponse | null;
332
+ }
333
+ export interface WSAPIOrderListCancelResponse {
334
+ orderListId: number;
335
+ contingencyType: string;
336
+ listStatusType: string;
337
+ listOrderStatus: string;
338
+ listClientOrderId: string;
339
+ transactionTime: number;
340
+ symbol: string;
341
+ orders: {
342
+ symbol: string;
343
+ orderId: number;
344
+ clientOrderId: string;
345
+ }[];
346
+ orderReports: WSAPIOrderCancel[];
347
+ }
348
+ /**
349
+ * Order list response types
350
+ */
351
+ export interface WSAPIOrderListPlaceResponse {
352
+ orderListId: number;
353
+ contingencyType: string;
354
+ listStatusType: string;
355
+ listOrderStatus: string;
356
+ listClientOrderId: string;
357
+ transactionTime: number;
358
+ symbol: string;
359
+ orders: {
360
+ symbol: string;
361
+ orderId: number;
362
+ clientOrderId: string;
363
+ }[];
364
+ orderReports: OrderResponse[];
365
+ }
366
+ export interface WSAPIOrderListStatusResponse {
367
+ orderListId: number;
368
+ contingencyType: string;
369
+ listStatusType: string;
370
+ listOrderStatus: string;
371
+ listClientOrderId: string;
372
+ transactionTime: number;
373
+ symbol: string;
374
+ orders: {
375
+ symbol: string;
376
+ orderId: number;
377
+ clientOrderId: string;
378
+ }[];
379
+ }
380
+ /**
381
+ * SOR response types
382
+ */
383
+ export interface WSAPISOROrderPlaceResponse {
384
+ symbol: string;
385
+ orderId: number;
386
+ orderListId: number;
387
+ clientOrderId: string;
388
+ transactTime: number;
389
+ price: string;
390
+ origQty: string;
391
+ executedQty: string;
392
+ origQuoteOrderQty: string;
393
+ cummulativeQuoteQty: string;
394
+ status: string;
395
+ timeInForce: string;
396
+ type: string;
397
+ side: string;
398
+ workingTime: number;
399
+ fills: {
400
+ matchType: string;
401
+ price: string;
402
+ qty: string;
403
+ commission: string;
404
+ commissionAsset: string;
405
+ tradeId: number;
406
+ allocId: number;
407
+ }[];
408
+ workingFloor: string;
409
+ selfTradePreventionMode: string;
410
+ usedSor: boolean;
411
+ }
412
+ export interface WSAPISOROrderTestResponse {
413
+ [key: string]: never;
414
+ }
415
+ export interface WSAPISOROrderTestResponseWithCommission {
416
+ standardCommissionForOrder: {
417
+ maker: numberInString;
418
+ taker: numberInString;
419
+ };
420
+ taxCommissionForOrder: {
421
+ maker: numberInString;
422
+ taker: numberInString;
423
+ };
424
+ discount: {
425
+ enabledForAccount: boolean;
426
+ enabledForSymbol: boolean;
427
+ discountAsset: string;
428
+ discount: numberInString;
429
+ };
430
+ }
431
+ /**
432
+ * Futures trading response types
433
+ */
434
+ export interface WSAPIFuturesOrder {
435
+ orderId: number;
436
+ symbol: string;
437
+ status: string;
438
+ clientOrderId: string;
439
+ price: string;
440
+ avgPrice: string;
441
+ origQty: string;
442
+ executedQty: string;
443
+ cumQty: string;
444
+ cumQuote: string;
445
+ timeInForce: string;
446
+ type: string;
447
+ reduceOnly: boolean;
448
+ closePosition: boolean;
449
+ side: string;
450
+ positionSide: string;
451
+ stopPrice: string;
452
+ workingType: string;
453
+ priceProtect: boolean;
454
+ origType: string;
455
+ priceMatch: string;
456
+ selfTradePreventionMode: string;
457
+ goodTillDate: number;
458
+ updateTime: number;
459
+ time?: number;
460
+ activatePrice?: string;
461
+ priceRate?: string;
462
+ }
463
+ export interface WSAPIFuturesPosition {
464
+ entryPrice: string;
465
+ breakEvenPrice: string;
466
+ marginType: string;
467
+ isAutoAddMargin: string;
468
+ isolatedMargin: string;
469
+ leverage: string;
470
+ liquidationPrice: string;
471
+ markPrice: string;
472
+ maxNotionalValue: string;
473
+ positionAmt: string;
474
+ notional: string;
475
+ isolatedWallet: string;
476
+ symbol: string;
477
+ unRealizedProfit: string;
478
+ positionSide: string;
479
+ updateTime: number;
480
+ }
481
+ export interface WSAPIFuturesPositionV2 {
482
+ symbol: string;
483
+ positionSide: string;
484
+ positionAmt: string;
485
+ entryPrice: string;
486
+ breakEvenPrice: string;
487
+ markPrice: string;
488
+ unrealizedProfit: string;
489
+ liquidationPrice: string;
490
+ isolatedMargin: string;
491
+ notional: string;
492
+ marginAsset: string;
493
+ isolatedWallet: string;
494
+ initialMargin: string;
495
+ maintMargin: string;
496
+ positionInitialMargin: string;
497
+ openOrderInitialMargin: string;
498
+ adl: number;
499
+ bidNotional: string;
500
+ askNotional: string;
501
+ updateTime: number;
502
+ }
503
+ /**
504
+ * Futures account response types
505
+ */
506
+ export interface WSAPIFuturesAccountBalanceItem {
507
+ accountAlias: string;
508
+ asset: string;
509
+ balance: string;
510
+ crossWalletBalance: string;
511
+ crossUnPnl: string;
512
+ availableBalance: string;
513
+ maxWithdrawAmount: string;
514
+ marginAvailable: boolean;
515
+ updateTime: number;
516
+ }
517
+ export interface WSAPIFuturesAccountAsset {
518
+ asset: string;
519
+ walletBalance: string;
520
+ unrealizedProfit: string;
521
+ marginBalance: string;
522
+ maintMargin: string;
523
+ initialMargin: string;
524
+ positionInitialMargin: string;
525
+ openOrderInitialMargin: string;
526
+ crossWalletBalance: string;
527
+ crossUnPnl: string;
528
+ availableBalance: string;
529
+ maxWithdrawAmount: string;
530
+ marginAvailable?: boolean;
531
+ updateTime: number;
532
+ }
533
+ export interface WSAPIFuturesAccountPosition {
534
+ symbol: string;
535
+ initialMargin?: string;
536
+ maintMargin?: string;
537
+ unrealizedProfit: string;
538
+ positionInitialMargin?: string;
539
+ openOrderInitialMargin?: string;
540
+ leverage?: string;
541
+ isolated?: boolean;
542
+ entryPrice?: string;
543
+ breakEvenPrice?: string;
544
+ maxNotional?: string;
545
+ bidNotional?: string;
546
+ askNotional?: string;
547
+ positionSide: string;
548
+ positionAmt: string;
549
+ updateTime: number;
550
+ }
551
+ export interface WSAPIFuturesAccountStatus {
552
+ feeTier?: number;
553
+ canTrade?: boolean;
554
+ canDeposit?: boolean;
555
+ canWithdraw?: boolean;
556
+ updateTime: number;
557
+ multiAssetsMargin: boolean;
558
+ tradeGroupId?: number;
559
+ totalInitialMargin: string;
560
+ totalMaintMargin: string;
561
+ totalWalletBalance: string;
562
+ totalUnrealizedProfit: string;
563
+ totalMarginBalance: string;
564
+ totalPositionInitialMargin: string;
565
+ totalOpenOrderInitialMargin: string;
566
+ totalCrossWalletBalance: string;
567
+ totalCrossUnPnl: string;
568
+ availableBalance: string;
569
+ maxWithdrawAmount: string;
570
+ assets: WSAPIFuturesAccountAsset[];
571
+ positions: WSAPIFuturesAccountPosition[];
572
+ }