ccxt 4.2.44 → 4.2.46

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 (92) hide show
  1. package/CHANGELOG.md +3099 -8415
  2. package/README.md +4 -4
  3. package/change.sh +4 -2
  4. package/dist/ccxt.browser.js +1242 -195
  5. package/dist/ccxt.browser.min.js +7 -7
  6. package/dist/cjs/ccxt.js +1 -1
  7. package/dist/cjs/src/base/Exchange.js +48 -0
  8. package/dist/cjs/src/base/ws/Cache.js +13 -5
  9. package/dist/cjs/src/base/ws/OrderBook.js +2 -2
  10. package/dist/cjs/src/binance.js +407 -21
  11. package/dist/cjs/src/bingx.js +43 -5
  12. package/dist/cjs/src/bitfinex2.js +1 -0
  13. package/dist/cjs/src/bithumb.js +5 -0
  14. package/dist/cjs/src/bitstamp.js +1 -1
  15. package/dist/cjs/src/btcturk.js +11 -0
  16. package/dist/cjs/src/bybit.js +96 -43
  17. package/dist/cjs/src/coinbase.js +228 -38
  18. package/dist/cjs/src/coincheck.js +11 -0
  19. package/dist/cjs/src/coinmate.js +114 -1
  20. package/dist/cjs/src/coinspot.js +7 -0
  21. package/dist/cjs/src/cryptocom.js +2 -2
  22. package/dist/cjs/src/deribit.js +1 -1
  23. package/dist/cjs/src/hitbtc.js +2 -0
  24. package/dist/cjs/src/idex.js +60 -1
  25. package/dist/cjs/src/latoken.js +3 -0
  26. package/dist/cjs/src/mercado.js +3 -0
  27. package/dist/cjs/src/oceanex.js +3 -0
  28. package/dist/cjs/src/okx.js +1 -0
  29. package/dist/cjs/src/pro/bitget.js +12 -8
  30. package/dist/cjs/src/pro/bitmart.js +11 -11
  31. package/dist/cjs/src/pro/bitmex.js +4 -4
  32. package/dist/cjs/src/pro/cex.js +2 -2
  33. package/dist/cjs/src/pro/gate.js +76 -42
  34. package/dist/cjs/src/pro/gemini.js +4 -3
  35. package/dist/cjs/src/pro/hitbtc.js +1 -0
  36. package/dist/cjs/src/probit.js +3 -3
  37. package/dist/cjs/src/timex.js +65 -0
  38. package/js/ccxt.d.ts +1 -1
  39. package/js/ccxt.js +1 -1
  40. package/js/src/abstract/bequant.d.ts +2 -0
  41. package/js/src/abstract/bitcoincom.d.ts +2 -0
  42. package/js/src/abstract/bithumb.d.ts +5 -0
  43. package/js/src/abstract/coinbase.d.ts +1 -0
  44. package/js/src/abstract/coinmate.d.ts +12 -0
  45. package/js/src/abstract/fmfwio.d.ts +2 -0
  46. package/js/src/abstract/hitbtc.d.ts +2 -0
  47. package/js/src/abstract/hitbtc3.d.ts +2 -0
  48. package/js/src/abstract/okx.d.ts +1 -0
  49. package/js/src/base/Exchange.d.ts +12 -6
  50. package/js/src/base/Exchange.js +48 -0
  51. package/js/src/base/ws/Cache.d.ts +5 -1
  52. package/js/src/base/ws/Cache.js +13 -5
  53. package/js/src/base/ws/OrderBook.d.ts +5 -1
  54. package/js/src/base/ws/OrderBook.js +3 -3
  55. package/js/src/binance.d.ts +2 -1
  56. package/js/src/binance.js +407 -21
  57. package/js/src/bingx.d.ts +2 -1
  58. package/js/src/bingx.js +43 -5
  59. package/js/src/bitfinex2.js +1 -0
  60. package/js/src/bithumb.js +5 -0
  61. package/js/src/bitstamp.js +1 -1
  62. package/js/src/btcturk.js +11 -0
  63. package/js/src/bybit.d.ts +4 -1
  64. package/js/src/bybit.js +96 -43
  65. package/js/src/coinbase.d.ts +10 -4
  66. package/js/src/coinbase.js +228 -38
  67. package/js/src/coincheck.js +11 -0
  68. package/js/src/coinmate.d.ts +3 -1
  69. package/js/src/coinmate.js +114 -1
  70. package/js/src/coinspot.js +7 -0
  71. package/js/src/cryptocom.js +2 -2
  72. package/js/src/deribit.js +1 -1
  73. package/js/src/hitbtc.js +2 -0
  74. package/js/src/idex.d.ts +14 -0
  75. package/js/src/idex.js +60 -1
  76. package/js/src/latoken.js +3 -0
  77. package/js/src/mercado.js +3 -0
  78. package/js/src/oceanex.js +3 -0
  79. package/js/src/okx.js +1 -0
  80. package/js/src/pro/bitget.js +12 -8
  81. package/js/src/pro/bitmart.js +11 -11
  82. package/js/src/pro/bitmex.js +4 -4
  83. package/js/src/pro/cex.js +2 -2
  84. package/js/src/pro/gate.d.ts +4 -0
  85. package/js/src/pro/gate.js +76 -42
  86. package/js/src/pro/gemini.js +4 -3
  87. package/js/src/pro/hitbtc.js +1 -0
  88. package/js/src/probit.js +3 -3
  89. package/js/src/timex.d.ts +14 -0
  90. package/js/src/timex.js +65 -0
  91. package/package.json +1 -1
  92. package/skip-tests.json +4 -0
@@ -21,7 +21,7 @@ export default class binance extends Exchange {
21
21
  fetchMarkets(params?: {}): Promise<any[]>;
22
22
  parseMarket(market: any): Market;
23
23
  parseBalanceHelper(entry: any): import("./base/types.js").Account;
24
- parseBalanceCustom(response: any, type?: any, marginMode?: any): Balances;
24
+ parseBalanceCustom(response: any, type?: any, marginMode?: any, isPortfolioMargin?: boolean): Balances;
25
25
  fetchBalance(params?: {}): Promise<Balances>;
26
26
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
27
27
  parseTicker(ticker: any, market?: Market): Ticker;
@@ -63,6 +63,7 @@ export default class binance extends Exchange {
63
63
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
64
64
  fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
65
65
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
66
+ fetchOpenOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
66
67
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
67
68
  fetchCanceledOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
68
69
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
package/js/src/binance.js CHANGED
@@ -102,7 +102,7 @@ export default class binance extends Exchange {
102
102
  'fetchOHLCV': true,
103
103
  'fetchOpenInterest': true,
104
104
  'fetchOpenInterestHistory': true,
105
- 'fetchOpenOrder': false,
105
+ 'fetchOpenOrder': true,
106
106
  'fetchOpenOrders': true,
107
107
  'fetchOrder': true,
108
108
  'fetchOrderBook': true,
@@ -3161,25 +3161,38 @@ export default class binance extends Exchange {
3161
3161
  account['debt'] = Precise.stringAdd(debt, interest);
3162
3162
  return account;
3163
3163
  }
3164
- parseBalanceCustom(response, type = undefined, marginMode = undefined) {
3164
+ parseBalanceCustom(response, type = undefined, marginMode = undefined, isPortfolioMargin = false) {
3165
3165
  const result = {
3166
3166
  'info': response,
3167
3167
  };
3168
3168
  let timestamp = undefined;
3169
3169
  const isolated = marginMode === 'isolated';
3170
3170
  const cross = (type === 'margin') || (marginMode === 'cross');
3171
- if (type === 'papi') {
3171
+ if (isPortfolioMargin) {
3172
3172
  for (let i = 0; i < response.length; i++) {
3173
3173
  const entry = response[i];
3174
3174
  const account = this.account();
3175
3175
  const currencyId = this.safeString(entry, 'asset');
3176
3176
  const code = this.safeCurrencyCode(currencyId);
3177
- const borrowed = this.safeString(entry, 'crossMarginBorrowed');
3178
- const interest = this.safeString(entry, 'crossMarginInterest');
3179
- account['free'] = this.safeString(entry, 'crossMarginFree');
3180
- account['used'] = this.safeString(entry, 'crossMarginLocked');
3181
- account['total'] = this.safeString(entry, 'crossMarginAsset');
3182
- account['debt'] = Precise.stringAdd(borrowed, interest);
3177
+ if (type === 'linear') {
3178
+ account['free'] = this.safeString(entry, 'umWalletBalance');
3179
+ account['used'] = this.safeString(entry, 'umUnrealizedPNL');
3180
+ }
3181
+ else if (type === 'inverse') {
3182
+ account['free'] = this.safeString(entry, 'cmWalletBalance');
3183
+ account['used'] = this.safeString(entry, 'cmUnrealizedPNL');
3184
+ }
3185
+ else if (cross) {
3186
+ const borrowed = this.safeString(entry, 'crossMarginBorrowed');
3187
+ const interest = this.safeString(entry, 'crossMarginInterest');
3188
+ account['debt'] = Precise.stringAdd(borrowed, interest);
3189
+ account['free'] = this.safeString(entry, 'crossMarginFree');
3190
+ account['used'] = this.safeString(entry, 'crossMarginLocked');
3191
+ account['total'] = this.safeString(entry, 'crossMarginAsset');
3192
+ }
3193
+ else {
3194
+ account['total'] = this.safeString(entry, 'totalWalletBalance');
3195
+ }
3183
3196
  result[code] = account;
3184
3197
  }
3185
3198
  }
@@ -3299,7 +3312,13 @@ export default class binance extends Exchange {
3299
3312
  let response = undefined;
3300
3313
  const request = {};
3301
3314
  if (isPortfolioMargin || (type === 'papi')) {
3302
- type = 'papi';
3315
+ if (this.isLinear(type, subType)) {
3316
+ type = 'linear';
3317
+ }
3318
+ else if (this.isInverse(type, subType)) {
3319
+ type = 'inverse';
3320
+ }
3321
+ isPortfolioMargin = true;
3303
3322
  response = await this.papiGetBalance(this.extend(request, query));
3304
3323
  }
3305
3324
  else if (this.isLinear(type, subType)) {
@@ -3547,7 +3566,7 @@ export default class binance extends Exchange {
3547
3566
  // },
3548
3567
  // ]
3549
3568
  //
3550
- return this.parseBalanceCustom(response, type, marginMode);
3569
+ return this.parseBalanceCustom(response, type, marginMode, isPortfolioMargin);
3551
3570
  }
3552
3571
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
3553
3572
  /**
@@ -5171,7 +5190,7 @@ export default class binance extends Exchange {
5171
5190
  // "status": "NEW"
5172
5191
  // }
5173
5192
  //
5174
- // createOrder, fetchOpenOrders: portfolio margin linear swap and future conditional
5193
+ // createOrder, fetchOpenOrders, fetchOpenOrder: portfolio margin linear swap and future conditional
5175
5194
  //
5176
5195
  // {
5177
5196
  // "newClientStrategyId": "x-xcKtGhcu27f109953d6e4dc0974006",
@@ -5310,6 +5329,130 @@ export default class binance extends Exchange {
5310
5329
  // "selfTradePreventionMode": "NONE"
5311
5330
  // }
5312
5331
  //
5332
+ // fetchOpenOrder: linear swap
5333
+ //
5334
+ // {
5335
+ // "orderId": 3697213934,
5336
+ // "symbol": "BTCUSDT",
5337
+ // "status": "NEW",
5338
+ // "clientOrderId": "x-xcKtGhcufb20c5a7761a4aa09aa156",
5339
+ // "price": "33000.00",
5340
+ // "avgPrice": "0.00000",
5341
+ // "origQty": "0.010",
5342
+ // "executedQty": "0.000",
5343
+ // "cumQuote": "0.00000",
5344
+ // "timeInForce": "GTC",
5345
+ // "type": "LIMIT",
5346
+ // "reduceOnly": false,
5347
+ // "closePosition": false,
5348
+ // "side": "BUY",
5349
+ // "positionSide": "BOTH",
5350
+ // "stopPrice": "0.00",
5351
+ // "workingType": "CONTRACT_PRICE",
5352
+ // "priceProtect": false,
5353
+ // "origType": "LIMIT",
5354
+ // "priceMatch": "NONE",
5355
+ // "selfTradePreventionMode": "NONE",
5356
+ // "goodTillDate": 0,
5357
+ // "time": 1707892893502,
5358
+ // "updateTime": 1707892893515
5359
+ // }
5360
+ //
5361
+ // fetchOpenOrder: inverse swap
5362
+ //
5363
+ // {
5364
+ // "orderId": 597368542,
5365
+ // "symbol": "BTCUSD_PERP",
5366
+ // "pair": "BTCUSD",
5367
+ // "status": "NEW",
5368
+ // "clientOrderId": "x-xcKtGhcubbde7ba93b1a4ab881eff3",
5369
+ // "price": "35000",
5370
+ // "avgPrice": "0",
5371
+ // "origQty": "1",
5372
+ // "executedQty": "0",
5373
+ // "cumBase": "0",
5374
+ // "timeInForce": "GTC",
5375
+ // "type": "LIMIT",
5376
+ // "reduceOnly": false,
5377
+ // "closePosition": false,
5378
+ // "side": "BUY",
5379
+ // "positionSide": "BOTH",
5380
+ // "stopPrice": "0",
5381
+ // "workingType": "CONTRACT_PRICE",
5382
+ // "priceProtect": false,
5383
+ // "origType": "LIMIT",
5384
+ // "time": 1707893453199,
5385
+ // "updateTime": 1707893453199
5386
+ // }
5387
+ //
5388
+ // fetchOpenOrder: linear portfolio margin
5389
+ //
5390
+ // {
5391
+ // "orderId": 264895013409,
5392
+ // "symbol": "BTCUSDT",
5393
+ // "status": "NEW",
5394
+ // "clientOrderId": "x-xcKtGhcu6278f1adbdf14f74ab432e",
5395
+ // "price": "35000",
5396
+ // "avgPrice": "0",
5397
+ // "origQty": "0.010",
5398
+ // "executedQty": "0",
5399
+ // "cumQuote": "0",
5400
+ // "timeInForce": "GTC",
5401
+ // "type": "LIMIT",
5402
+ // "reduceOnly": false,
5403
+ // "side": "BUY",
5404
+ // "positionSide": "LONG",
5405
+ // "origType": "LIMIT",
5406
+ // "time": 1707893839364,
5407
+ // "updateTime": 1707893839364,
5408
+ // "goodTillDate": 0,
5409
+ // "selfTradePreventionMode": "NONE"
5410
+ // }
5411
+ //
5412
+ // fetchOpenOrder: inverse portfolio margin
5413
+ //
5414
+ // {
5415
+ // "orderId": 71790316950,
5416
+ // "symbol": "ETHUSD_PERP",
5417
+ // "pair": "ETHUSD",
5418
+ // "status": "NEW",
5419
+ // "clientOrderId": "x-xcKtGhcuec11030474204ab08ba2c2",
5420
+ // "price": "2500",
5421
+ // "avgPrice": "0",
5422
+ // "origQty": "1",
5423
+ // "executedQty": "0",
5424
+ // "cumBase": "0",
5425
+ // "timeInForce": "GTC",
5426
+ // "type": "LIMIT",
5427
+ // "reduceOnly": false,
5428
+ // "side": "BUY",
5429
+ // "positionSide": "LONG",
5430
+ // "origType": "LIMIT",
5431
+ // "time": 1707894181694,
5432
+ // "updateTime": 1707894181694
5433
+ // }
5434
+ //
5435
+ // fetchOpenOrder: inverse portfolio margin conditional
5436
+ //
5437
+ // {
5438
+ // "newClientStrategyId": "x-xcKtGhcu2da9c765294b433994ffce",
5439
+ // "strategyId": 1423501,
5440
+ // "strategyStatus": "NEW",
5441
+ // "strategyType": "STOP",
5442
+ // "origQty": "1",
5443
+ // "price": "2500",
5444
+ // "reduceOnly": false,
5445
+ // "side": "BUY",
5446
+ // "positionSide": "LONG",
5447
+ // "stopPrice": "4000",
5448
+ // "symbol": "ETHUSD_PERP",
5449
+ // "bookTime": 1707894782679,
5450
+ // "updateTime": 1707894782679,
5451
+ // "timeInForce": "GTC",
5452
+ // "workingType": "CONTRACT_PRICE",
5453
+ // "priceProtect": false
5454
+ // }
5455
+ //
5313
5456
  const code = this.safeString(order, 'code');
5314
5457
  if (code !== undefined) {
5315
5458
  // cancelOrders/createOrders might have a partial success
@@ -6309,7 +6452,7 @@ export default class binance extends Exchange {
6309
6452
  [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
6310
6453
  let isPortfolioMargin = undefined;
6311
6454
  [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOpenOrders', 'papi', 'portfolioMargin', false);
6312
- const isConditional = this.safeBool2(params, 'stop', 'conditional');
6455
+ const isConditional = this.safeBoolN(params, ['stop', 'conditional', 'trigger']);
6313
6456
  if (symbol !== undefined) {
6314
6457
  market = this.market(symbol);
6315
6458
  request['symbol'] = market['id'];
@@ -6329,7 +6472,7 @@ export default class binance extends Exchange {
6329
6472
  }
6330
6473
  let subType = undefined;
6331
6474
  [subType, params] = this.handleSubTypeAndParams('fetchOpenOrders', market, params);
6332
- params = this.omit(params, ['type', 'stop', 'conditional']);
6475
+ params = this.omit(params, ['type', 'stop', 'conditional', 'trigger']);
6333
6476
  let response = undefined;
6334
6477
  if (type === 'option') {
6335
6478
  if (since !== undefined) {
@@ -6385,6 +6528,223 @@ export default class binance extends Exchange {
6385
6528
  }
6386
6529
  return this.parseOrders(response, market, since, limit);
6387
6530
  }
6531
+ async fetchOpenOrder(id, symbol = undefined, params = {}) {
6532
+ /**
6533
+ * @method
6534
+ * @name binance#fetchOpenOrder
6535
+ * @description fetch an open order by the id
6536
+ * @see https://binance-docs.github.io/apidocs/futures/en/#query-current-open-order-user_data
6537
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#query-current-open-order-user_data
6538
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-um-open-order-user_data
6539
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-cm-open-order-user_data
6540
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-um-open-conditional-order-user_data
6541
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-cm-open-conditional-order-user_data
6542
+ * @param {string} id order id
6543
+ * @param {string} symbol unified market symbol
6544
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
6545
+ * @param {string} [params.trigger] set to true if you would like to fetch portfolio margin account stop or conditional orders
6546
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
6547
+ */
6548
+ if (symbol === undefined) {
6549
+ throw new ArgumentsRequired(this.id + ' fetchOpenOrder() requires a symbol argument');
6550
+ }
6551
+ await this.loadMarkets();
6552
+ const market = this.market(symbol);
6553
+ const request = {
6554
+ 'symbol': market['id'],
6555
+ };
6556
+ let isPortfolioMargin = undefined;
6557
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOpenOrder', 'papi', 'portfolioMargin', false);
6558
+ const isConditional = this.safeBoolN(params, ['stop', 'conditional', 'trigger']);
6559
+ params = this.omit(params, ['stop', 'conditional', 'trigger']);
6560
+ const isPortfolioMarginConditional = (isPortfolioMargin && isConditional);
6561
+ const orderIdRequest = isPortfolioMarginConditional ? 'strategyId' : 'orderId';
6562
+ request[orderIdRequest] = id;
6563
+ let response = undefined;
6564
+ if (market['linear']) {
6565
+ if (isPortfolioMargin) {
6566
+ if (isConditional) {
6567
+ response = await this.papiGetUmConditionalOpenOrder(this.extend(request, params));
6568
+ }
6569
+ else {
6570
+ response = await this.papiGetUmOpenOrder(this.extend(request, params));
6571
+ }
6572
+ }
6573
+ else {
6574
+ response = await this.fapiPrivateGetOpenOrder(this.extend(request, params));
6575
+ }
6576
+ }
6577
+ else if (market['inverse']) {
6578
+ if (isPortfolioMargin) {
6579
+ if (isConditional) {
6580
+ response = await this.papiGetCmConditionalOpenOrder(this.extend(request, params));
6581
+ }
6582
+ else {
6583
+ response = await this.papiGetCmOpenOrder(this.extend(request, params));
6584
+ }
6585
+ }
6586
+ else {
6587
+ response = await this.dapiPrivateGetOpenOrder(this.extend(request, params));
6588
+ }
6589
+ }
6590
+ else {
6591
+ if (market['option']) {
6592
+ throw new NotSupported(this.id + ' fetchOpenOrder() does not support option markets');
6593
+ }
6594
+ else if (market['spot']) {
6595
+ throw new NotSupported(this.id + ' fetchOpenOrder() does not support spot markets');
6596
+ }
6597
+ }
6598
+ //
6599
+ // linear swap
6600
+ //
6601
+ // {
6602
+ // "orderId": 3697213934,
6603
+ // "symbol": "BTCUSDT",
6604
+ // "status": "NEW",
6605
+ // "clientOrderId": "x-xcKtGhcufb20c5a7761a4aa09aa156",
6606
+ // "price": "33000.00",
6607
+ // "avgPrice": "0.00000",
6608
+ // "origQty": "0.010",
6609
+ // "executedQty": "0.000",
6610
+ // "cumQuote": "0.00000",
6611
+ // "timeInForce": "GTC",
6612
+ // "type": "LIMIT",
6613
+ // "reduceOnly": false,
6614
+ // "closePosition": false,
6615
+ // "side": "BUY",
6616
+ // "positionSide": "BOTH",
6617
+ // "stopPrice": "0.00",
6618
+ // "workingType": "CONTRACT_PRICE",
6619
+ // "priceProtect": false,
6620
+ // "origType": "LIMIT",
6621
+ // "priceMatch": "NONE",
6622
+ // "selfTradePreventionMode": "NONE",
6623
+ // "goodTillDate": 0,
6624
+ // "time": 1707892893502,
6625
+ // "updateTime": 1707892893515
6626
+ // }
6627
+ //
6628
+ // inverse swap
6629
+ //
6630
+ // {
6631
+ // "orderId": 597368542,
6632
+ // "symbol": "BTCUSD_PERP",
6633
+ // "pair": "BTCUSD",
6634
+ // "status": "NEW",
6635
+ // "clientOrderId": "x-xcKtGhcubbde7ba93b1a4ab881eff3",
6636
+ // "price": "35000",
6637
+ // "avgPrice": "0",
6638
+ // "origQty": "1",
6639
+ // "executedQty": "0",
6640
+ // "cumBase": "0",
6641
+ // "timeInForce": "GTC",
6642
+ // "type": "LIMIT",
6643
+ // "reduceOnly": false,
6644
+ // "closePosition": false,
6645
+ // "side": "BUY",
6646
+ // "positionSide": "BOTH",
6647
+ // "stopPrice": "0",
6648
+ // "workingType": "CONTRACT_PRICE",
6649
+ // "priceProtect": false,
6650
+ // "origType": "LIMIT",
6651
+ // "time": 1707893453199,
6652
+ // "updateTime": 1707893453199
6653
+ // }
6654
+ //
6655
+ // linear portfolio margin
6656
+ //
6657
+ // {
6658
+ // "orderId": 264895013409,
6659
+ // "symbol": "BTCUSDT",
6660
+ // "status": "NEW",
6661
+ // "clientOrderId": "x-xcKtGhcu6278f1adbdf14f74ab432e",
6662
+ // "price": "35000",
6663
+ // "avgPrice": "0",
6664
+ // "origQty": "0.010",
6665
+ // "executedQty": "0",
6666
+ // "cumQuote": "0",
6667
+ // "timeInForce": "GTC",
6668
+ // "type": "LIMIT",
6669
+ // "reduceOnly": false,
6670
+ // "side": "BUY",
6671
+ // "positionSide": "LONG",
6672
+ // "origType": "LIMIT",
6673
+ // "time": 1707893839364,
6674
+ // "updateTime": 1707893839364,
6675
+ // "goodTillDate": 0,
6676
+ // "selfTradePreventionMode": "NONE"
6677
+ // }
6678
+ //
6679
+ // inverse portfolio margin
6680
+ //
6681
+ // {
6682
+ // "orderId": 71790316950,
6683
+ // "symbol": "ETHUSD_PERP",
6684
+ // "pair": "ETHUSD",
6685
+ // "status": "NEW",
6686
+ // "clientOrderId": "x-xcKtGhcuec11030474204ab08ba2c2",
6687
+ // "price": "2500",
6688
+ // "avgPrice": "0",
6689
+ // "origQty": "1",
6690
+ // "executedQty": "0",
6691
+ // "cumBase": "0",
6692
+ // "timeInForce": "GTC",
6693
+ // "type": "LIMIT",
6694
+ // "reduceOnly": false,
6695
+ // "side": "BUY",
6696
+ // "positionSide": "LONG",
6697
+ // "origType": "LIMIT",
6698
+ // "time": 1707894181694,
6699
+ // "updateTime": 1707894181694
6700
+ // }
6701
+ //
6702
+ // linear portfolio margin conditional
6703
+ //
6704
+ // {
6705
+ // "newClientStrategyId": "x-xcKtGhcu2205fde44418483ca21874",
6706
+ // "strategyId": 4084339,
6707
+ // "strategyStatus": "NEW",
6708
+ // "strategyType": "STOP",
6709
+ // "origQty": "0.010",
6710
+ // "price": "35000",
6711
+ // "reduceOnly": false,
6712
+ // "side": "BUY",
6713
+ // "positionSide": "LONG",
6714
+ // "stopPrice": "60000",
6715
+ // "symbol": "BTCUSDT",
6716
+ // "bookTime": 1707894490094,
6717
+ // "updateTime": 1707894490094,
6718
+ // "timeInForce": "GTC",
6719
+ // "workingType": "CONTRACT_PRICE",
6720
+ // "priceProtect": false,
6721
+ // "goodTillDate": 0,
6722
+ // "selfTradePreventionMode": "NONE"
6723
+ // }
6724
+ //
6725
+ // inverse portfolio margin conditional
6726
+ //
6727
+ // {
6728
+ // "newClientStrategyId": "x-xcKtGhcu2da9c765294b433994ffce",
6729
+ // "strategyId": 1423501,
6730
+ // "strategyStatus": "NEW",
6731
+ // "strategyType": "STOP",
6732
+ // "origQty": "1",
6733
+ // "price": "2500",
6734
+ // "reduceOnly": false,
6735
+ // "side": "BUY",
6736
+ // "positionSide": "LONG",
6737
+ // "stopPrice": "4000",
6738
+ // "symbol": "ETHUSD_PERP",
6739
+ // "bookTime": 1707894782679,
6740
+ // "updateTime": 1707894782679,
6741
+ // "timeInForce": "GTC",
6742
+ // "workingType": "CONTRACT_PRICE",
6743
+ // "priceProtect": false
6744
+ // }
6745
+ //
6746
+ return this.parseOrder(response, market);
6747
+ }
6388
6748
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
6389
6749
  /**
6390
6750
  * @method
@@ -9489,12 +9849,12 @@ export default class binance extends Exchange {
9489
9849
  /**
9490
9850
  * @method
9491
9851
  * @name binance#fetchPositions
9852
+ * @description fetch all open positions
9492
9853
  * @see https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data
9493
9854
  * @see https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data
9494
9855
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
9495
9856
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
9496
9857
  * @see https://binance-docs.github.io/apidocs/voptions/en/#option-position-information-user_data
9497
- * @description fetch all open positions
9498
9858
  * @param {string[]} [symbols] list of unified market symbols
9499
9859
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9500
9860
  * @param {string} [method] method name to call, "positionRisk", "account" or "option", default is "positionRisk"
@@ -9718,7 +10078,10 @@ export default class binance extends Exchange {
9718
10078
  const result = [];
9719
10079
  for (let i = 0; i < response.length; i++) {
9720
10080
  const parsed = this.parsePositionRisk(response[i]);
9721
- result.push(parsed);
10081
+ const entryPrice = this.safeString(parsed, 'entryPrice');
10082
+ if ((entryPrice !== '0') && (entryPrice !== '0.0') && (entryPrice !== '0.00000000')) {
10083
+ result.push(parsed);
10084
+ }
9722
10085
  }
9723
10086
  symbols = this.marketSymbols(symbols);
9724
10087
  return this.filterByArrayPositions(result, 'symbol', symbols, false);
@@ -11298,12 +11661,16 @@ export default class binance extends Exchange {
11298
11661
  * @see https://binance-docs.github.io/apidocs/spot/en/#get-force-liquidation-record-user_data
11299
11662
  * @see https://binance-docs.github.io/apidocs/futures/en/#user-39-s-force-orders-user_data
11300
11663
  * @see https://binance-docs.github.io/apidocs/delivery/en/#user-39-s-force-orders-user_data
11664
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-margin-force-orders-user_data
11665
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-um-force-orders-user_data
11666
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-cm-force-orders-user_data
11301
11667
  * @param {string} [symbol] unified CCXT market symbol
11302
11668
  * @param {int} [since] the earliest time in ms to fetch liquidations for
11303
11669
  * @param {int} [limit] the maximum number of liquidation structures to retrieve
11304
11670
  * @param {object} [params] exchange specific parameters for the binance api endpoint
11305
11671
  * @param {int} [params.until] timestamp in ms of the latest liquidation
11306
11672
  * @param {boolean} [params.paginate] *spot only* default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
11673
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch liquidations in a portfolio margin account
11307
11674
  * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
11308
11675
  */
11309
11676
  await this.loadMarkets();
@@ -11320,13 +11687,17 @@ export default class binance extends Exchange {
11320
11687
  [type, params] = this.handleMarketTypeAndParams('fetchMyLiquidations', market, params);
11321
11688
  let subType = undefined;
11322
11689
  [subType, params] = this.handleSubTypeAndParams('fetchMyLiquidations', market, params, 'linear');
11690
+ let isPortfolioMargin = undefined;
11691
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchMyLiquidations', 'papi', 'portfolioMargin', false);
11323
11692
  let request = {};
11324
11693
  if (type !== 'spot') {
11325
11694
  request['autoCloseType'] = 'LIQUIDATION';
11326
11695
  }
11327
11696
  if (market !== undefined) {
11328
11697
  const symbolKey = market['spot'] ? 'isolatedSymbol' : 'symbol';
11329
- request[symbolKey] = market['id'];
11698
+ if (!isPortfolioMargin) {
11699
+ request[symbolKey] = market['id'];
11700
+ }
11330
11701
  }
11331
11702
  if (since !== undefined) {
11332
11703
  request['startTime'] = since;
@@ -11342,13 +11713,28 @@ export default class binance extends Exchange {
11342
11713
  [request, params] = this.handleUntilOption('endTime', request, params);
11343
11714
  let response = undefined;
11344
11715
  if (type === 'spot') {
11345
- response = await this.sapiGetMarginForceLiquidationRec(this.extend(request, params));
11716
+ if (isPortfolioMargin) {
11717
+ response = await this.papiGetMarginForceOrders(this.extend(request, params));
11718
+ }
11719
+ else {
11720
+ response = await this.sapiGetMarginForceLiquidationRec(this.extend(request, params));
11721
+ }
11346
11722
  }
11347
11723
  else if (subType === 'linear') {
11348
- response = await this.fapiPrivateGetForceOrders(this.extend(request, params));
11724
+ if (isPortfolioMargin) {
11725
+ response = await this.papiGetUmForceOrders(this.extend(request, params));
11726
+ }
11727
+ else {
11728
+ response = await this.fapiPrivateGetForceOrders(this.extend(request, params));
11729
+ }
11349
11730
  }
11350
11731
  else if (subType === 'inverse') {
11351
- response = await this.dapiPrivateGetForceOrders(this.extend(request, params));
11732
+ if (isPortfolioMargin) {
11733
+ response = await this.papiGetCmForceOrders(this.extend(request, params));
11734
+ }
11735
+ else {
11736
+ response = await this.dapiPrivateGetForceOrders(this.extend(request, params));
11737
+ }
11352
11738
  }
11353
11739
  else {
11354
11740
  throw new NotSupported(this.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' markets');
@@ -11430,7 +11816,7 @@ export default class binance extends Exchange {
11430
11816
  // },
11431
11817
  // ]
11432
11818
  //
11433
- const liquidations = this.safeValue(response, 'rows', response);
11819
+ const liquidations = this.safeList(response, 'rows', response);
11434
11820
  return this.parseLiquidations(liquidations, market, since, limit);
11435
11821
  }
11436
11822
  parseLiquidation(liquidation, market = undefined) {
package/js/src/bingx.d.ts CHANGED
@@ -95,7 +95,8 @@ export default class bingx extends Exchange {
95
95
  toAccount: string;
96
96
  status: string;
97
97
  };
98
- fetchDepositAddress(code: string, params?: {}): Promise<{}>;
98
+ fetchDepositAddressesByNetwork(code: string, params?: {}): Promise<{}>;
99
+ fetchDepositAddress(code: string, params?: {}): Promise<import("./base/types.js").Dictionary<any>>;
99
100
  parseDepositAddress(depositAddress: any, currency?: Currency): {
100
101
  currency: string;
101
102
  address: string;