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
@@ -99,7 +99,7 @@ class binance extends binance$1 {
99
99
  'fetchOHLCV': true,
100
100
  'fetchOpenInterest': true,
101
101
  'fetchOpenInterestHistory': true,
102
- 'fetchOpenOrder': false,
102
+ 'fetchOpenOrder': true,
103
103
  'fetchOpenOrders': true,
104
104
  'fetchOrder': true,
105
105
  'fetchOrderBook': true,
@@ -3158,25 +3158,38 @@ class binance extends binance$1 {
3158
3158
  account['debt'] = Precise["default"].stringAdd(debt, interest);
3159
3159
  return account;
3160
3160
  }
3161
- parseBalanceCustom(response, type = undefined, marginMode = undefined) {
3161
+ parseBalanceCustom(response, type = undefined, marginMode = undefined, isPortfolioMargin = false) {
3162
3162
  const result = {
3163
3163
  'info': response,
3164
3164
  };
3165
3165
  let timestamp = undefined;
3166
3166
  const isolated = marginMode === 'isolated';
3167
3167
  const cross = (type === 'margin') || (marginMode === 'cross');
3168
- if (type === 'papi') {
3168
+ if (isPortfolioMargin) {
3169
3169
  for (let i = 0; i < response.length; i++) {
3170
3170
  const entry = response[i];
3171
3171
  const account = this.account();
3172
3172
  const currencyId = this.safeString(entry, 'asset');
3173
3173
  const code = this.safeCurrencyCode(currencyId);
3174
- const borrowed = this.safeString(entry, 'crossMarginBorrowed');
3175
- const interest = this.safeString(entry, 'crossMarginInterest');
3176
- account['free'] = this.safeString(entry, 'crossMarginFree');
3177
- account['used'] = this.safeString(entry, 'crossMarginLocked');
3178
- account['total'] = this.safeString(entry, 'crossMarginAsset');
3179
- account['debt'] = Precise["default"].stringAdd(borrowed, interest);
3174
+ if (type === 'linear') {
3175
+ account['free'] = this.safeString(entry, 'umWalletBalance');
3176
+ account['used'] = this.safeString(entry, 'umUnrealizedPNL');
3177
+ }
3178
+ else if (type === 'inverse') {
3179
+ account['free'] = this.safeString(entry, 'cmWalletBalance');
3180
+ account['used'] = this.safeString(entry, 'cmUnrealizedPNL');
3181
+ }
3182
+ else if (cross) {
3183
+ const borrowed = this.safeString(entry, 'crossMarginBorrowed');
3184
+ const interest = this.safeString(entry, 'crossMarginInterest');
3185
+ account['debt'] = Precise["default"].stringAdd(borrowed, interest);
3186
+ account['free'] = this.safeString(entry, 'crossMarginFree');
3187
+ account['used'] = this.safeString(entry, 'crossMarginLocked');
3188
+ account['total'] = this.safeString(entry, 'crossMarginAsset');
3189
+ }
3190
+ else {
3191
+ account['total'] = this.safeString(entry, 'totalWalletBalance');
3192
+ }
3180
3193
  result[code] = account;
3181
3194
  }
3182
3195
  }
@@ -3296,7 +3309,13 @@ class binance extends binance$1 {
3296
3309
  let response = undefined;
3297
3310
  const request = {};
3298
3311
  if (isPortfolioMargin || (type === 'papi')) {
3299
- type = 'papi';
3312
+ if (this.isLinear(type, subType)) {
3313
+ type = 'linear';
3314
+ }
3315
+ else if (this.isInverse(type, subType)) {
3316
+ type = 'inverse';
3317
+ }
3318
+ isPortfolioMargin = true;
3300
3319
  response = await this.papiGetBalance(this.extend(request, query));
3301
3320
  }
3302
3321
  else if (this.isLinear(type, subType)) {
@@ -3544,7 +3563,7 @@ class binance extends binance$1 {
3544
3563
  // },
3545
3564
  // ]
3546
3565
  //
3547
- return this.parseBalanceCustom(response, type, marginMode);
3566
+ return this.parseBalanceCustom(response, type, marginMode, isPortfolioMargin);
3548
3567
  }
3549
3568
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
3550
3569
  /**
@@ -5168,7 +5187,7 @@ class binance extends binance$1 {
5168
5187
  // "status": "NEW"
5169
5188
  // }
5170
5189
  //
5171
- // createOrder, fetchOpenOrders: portfolio margin linear swap and future conditional
5190
+ // createOrder, fetchOpenOrders, fetchOpenOrder: portfolio margin linear swap and future conditional
5172
5191
  //
5173
5192
  // {
5174
5193
  // "newClientStrategyId": "x-xcKtGhcu27f109953d6e4dc0974006",
@@ -5307,6 +5326,130 @@ class binance extends binance$1 {
5307
5326
  // "selfTradePreventionMode": "NONE"
5308
5327
  // }
5309
5328
  //
5329
+ // fetchOpenOrder: linear swap
5330
+ //
5331
+ // {
5332
+ // "orderId": 3697213934,
5333
+ // "symbol": "BTCUSDT",
5334
+ // "status": "NEW",
5335
+ // "clientOrderId": "x-xcKtGhcufb20c5a7761a4aa09aa156",
5336
+ // "price": "33000.00",
5337
+ // "avgPrice": "0.00000",
5338
+ // "origQty": "0.010",
5339
+ // "executedQty": "0.000",
5340
+ // "cumQuote": "0.00000",
5341
+ // "timeInForce": "GTC",
5342
+ // "type": "LIMIT",
5343
+ // "reduceOnly": false,
5344
+ // "closePosition": false,
5345
+ // "side": "BUY",
5346
+ // "positionSide": "BOTH",
5347
+ // "stopPrice": "0.00",
5348
+ // "workingType": "CONTRACT_PRICE",
5349
+ // "priceProtect": false,
5350
+ // "origType": "LIMIT",
5351
+ // "priceMatch": "NONE",
5352
+ // "selfTradePreventionMode": "NONE",
5353
+ // "goodTillDate": 0,
5354
+ // "time": 1707892893502,
5355
+ // "updateTime": 1707892893515
5356
+ // }
5357
+ //
5358
+ // fetchOpenOrder: inverse swap
5359
+ //
5360
+ // {
5361
+ // "orderId": 597368542,
5362
+ // "symbol": "BTCUSD_PERP",
5363
+ // "pair": "BTCUSD",
5364
+ // "status": "NEW",
5365
+ // "clientOrderId": "x-xcKtGhcubbde7ba93b1a4ab881eff3",
5366
+ // "price": "35000",
5367
+ // "avgPrice": "0",
5368
+ // "origQty": "1",
5369
+ // "executedQty": "0",
5370
+ // "cumBase": "0",
5371
+ // "timeInForce": "GTC",
5372
+ // "type": "LIMIT",
5373
+ // "reduceOnly": false,
5374
+ // "closePosition": false,
5375
+ // "side": "BUY",
5376
+ // "positionSide": "BOTH",
5377
+ // "stopPrice": "0",
5378
+ // "workingType": "CONTRACT_PRICE",
5379
+ // "priceProtect": false,
5380
+ // "origType": "LIMIT",
5381
+ // "time": 1707893453199,
5382
+ // "updateTime": 1707893453199
5383
+ // }
5384
+ //
5385
+ // fetchOpenOrder: linear portfolio margin
5386
+ //
5387
+ // {
5388
+ // "orderId": 264895013409,
5389
+ // "symbol": "BTCUSDT",
5390
+ // "status": "NEW",
5391
+ // "clientOrderId": "x-xcKtGhcu6278f1adbdf14f74ab432e",
5392
+ // "price": "35000",
5393
+ // "avgPrice": "0",
5394
+ // "origQty": "0.010",
5395
+ // "executedQty": "0",
5396
+ // "cumQuote": "0",
5397
+ // "timeInForce": "GTC",
5398
+ // "type": "LIMIT",
5399
+ // "reduceOnly": false,
5400
+ // "side": "BUY",
5401
+ // "positionSide": "LONG",
5402
+ // "origType": "LIMIT",
5403
+ // "time": 1707893839364,
5404
+ // "updateTime": 1707893839364,
5405
+ // "goodTillDate": 0,
5406
+ // "selfTradePreventionMode": "NONE"
5407
+ // }
5408
+ //
5409
+ // fetchOpenOrder: inverse portfolio margin
5410
+ //
5411
+ // {
5412
+ // "orderId": 71790316950,
5413
+ // "symbol": "ETHUSD_PERP",
5414
+ // "pair": "ETHUSD",
5415
+ // "status": "NEW",
5416
+ // "clientOrderId": "x-xcKtGhcuec11030474204ab08ba2c2",
5417
+ // "price": "2500",
5418
+ // "avgPrice": "0",
5419
+ // "origQty": "1",
5420
+ // "executedQty": "0",
5421
+ // "cumBase": "0",
5422
+ // "timeInForce": "GTC",
5423
+ // "type": "LIMIT",
5424
+ // "reduceOnly": false,
5425
+ // "side": "BUY",
5426
+ // "positionSide": "LONG",
5427
+ // "origType": "LIMIT",
5428
+ // "time": 1707894181694,
5429
+ // "updateTime": 1707894181694
5430
+ // }
5431
+ //
5432
+ // fetchOpenOrder: inverse portfolio margin conditional
5433
+ //
5434
+ // {
5435
+ // "newClientStrategyId": "x-xcKtGhcu2da9c765294b433994ffce",
5436
+ // "strategyId": 1423501,
5437
+ // "strategyStatus": "NEW",
5438
+ // "strategyType": "STOP",
5439
+ // "origQty": "1",
5440
+ // "price": "2500",
5441
+ // "reduceOnly": false,
5442
+ // "side": "BUY",
5443
+ // "positionSide": "LONG",
5444
+ // "stopPrice": "4000",
5445
+ // "symbol": "ETHUSD_PERP",
5446
+ // "bookTime": 1707894782679,
5447
+ // "updateTime": 1707894782679,
5448
+ // "timeInForce": "GTC",
5449
+ // "workingType": "CONTRACT_PRICE",
5450
+ // "priceProtect": false
5451
+ // }
5452
+ //
5310
5453
  const code = this.safeString(order, 'code');
5311
5454
  if (code !== undefined) {
5312
5455
  // cancelOrders/createOrders might have a partial success
@@ -6306,7 +6449,7 @@ class binance extends binance$1 {
6306
6449
  [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
6307
6450
  let isPortfolioMargin = undefined;
6308
6451
  [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOpenOrders', 'papi', 'portfolioMargin', false);
6309
- const isConditional = this.safeBool2(params, 'stop', 'conditional');
6452
+ const isConditional = this.safeBoolN(params, ['stop', 'conditional', 'trigger']);
6310
6453
  if (symbol !== undefined) {
6311
6454
  market = this.market(symbol);
6312
6455
  request['symbol'] = market['id'];
@@ -6326,7 +6469,7 @@ class binance extends binance$1 {
6326
6469
  }
6327
6470
  let subType = undefined;
6328
6471
  [subType, params] = this.handleSubTypeAndParams('fetchOpenOrders', market, params);
6329
- params = this.omit(params, ['type', 'stop', 'conditional']);
6472
+ params = this.omit(params, ['type', 'stop', 'conditional', 'trigger']);
6330
6473
  let response = undefined;
6331
6474
  if (type === 'option') {
6332
6475
  if (since !== undefined) {
@@ -6382,6 +6525,223 @@ class binance extends binance$1 {
6382
6525
  }
6383
6526
  return this.parseOrders(response, market, since, limit);
6384
6527
  }
6528
+ async fetchOpenOrder(id, symbol = undefined, params = {}) {
6529
+ /**
6530
+ * @method
6531
+ * @name binance#fetchOpenOrder
6532
+ * @description fetch an open order by the id
6533
+ * @see https://binance-docs.github.io/apidocs/futures/en/#query-current-open-order-user_data
6534
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#query-current-open-order-user_data
6535
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-um-open-order-user_data
6536
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-cm-open-order-user_data
6537
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-um-open-conditional-order-user_data
6538
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-current-cm-open-conditional-order-user_data
6539
+ * @param {string} id order id
6540
+ * @param {string} symbol unified market symbol
6541
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
6542
+ * @param {string} [params.trigger] set to true if you would like to fetch portfolio margin account stop or conditional orders
6543
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
6544
+ */
6545
+ if (symbol === undefined) {
6546
+ throw new errors.ArgumentsRequired(this.id + ' fetchOpenOrder() requires a symbol argument');
6547
+ }
6548
+ await this.loadMarkets();
6549
+ const market = this.market(symbol);
6550
+ const request = {
6551
+ 'symbol': market['id'],
6552
+ };
6553
+ let isPortfolioMargin = undefined;
6554
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchOpenOrder', 'papi', 'portfolioMargin', false);
6555
+ const isConditional = this.safeBoolN(params, ['stop', 'conditional', 'trigger']);
6556
+ params = this.omit(params, ['stop', 'conditional', 'trigger']);
6557
+ const isPortfolioMarginConditional = (isPortfolioMargin && isConditional);
6558
+ const orderIdRequest = isPortfolioMarginConditional ? 'strategyId' : 'orderId';
6559
+ request[orderIdRequest] = id;
6560
+ let response = undefined;
6561
+ if (market['linear']) {
6562
+ if (isPortfolioMargin) {
6563
+ if (isConditional) {
6564
+ response = await this.papiGetUmConditionalOpenOrder(this.extend(request, params));
6565
+ }
6566
+ else {
6567
+ response = await this.papiGetUmOpenOrder(this.extend(request, params));
6568
+ }
6569
+ }
6570
+ else {
6571
+ response = await this.fapiPrivateGetOpenOrder(this.extend(request, params));
6572
+ }
6573
+ }
6574
+ else if (market['inverse']) {
6575
+ if (isPortfolioMargin) {
6576
+ if (isConditional) {
6577
+ response = await this.papiGetCmConditionalOpenOrder(this.extend(request, params));
6578
+ }
6579
+ else {
6580
+ response = await this.papiGetCmOpenOrder(this.extend(request, params));
6581
+ }
6582
+ }
6583
+ else {
6584
+ response = await this.dapiPrivateGetOpenOrder(this.extend(request, params));
6585
+ }
6586
+ }
6587
+ else {
6588
+ if (market['option']) {
6589
+ throw new errors.NotSupported(this.id + ' fetchOpenOrder() does not support option markets');
6590
+ }
6591
+ else if (market['spot']) {
6592
+ throw new errors.NotSupported(this.id + ' fetchOpenOrder() does not support spot markets');
6593
+ }
6594
+ }
6595
+ //
6596
+ // linear swap
6597
+ //
6598
+ // {
6599
+ // "orderId": 3697213934,
6600
+ // "symbol": "BTCUSDT",
6601
+ // "status": "NEW",
6602
+ // "clientOrderId": "x-xcKtGhcufb20c5a7761a4aa09aa156",
6603
+ // "price": "33000.00",
6604
+ // "avgPrice": "0.00000",
6605
+ // "origQty": "0.010",
6606
+ // "executedQty": "0.000",
6607
+ // "cumQuote": "0.00000",
6608
+ // "timeInForce": "GTC",
6609
+ // "type": "LIMIT",
6610
+ // "reduceOnly": false,
6611
+ // "closePosition": false,
6612
+ // "side": "BUY",
6613
+ // "positionSide": "BOTH",
6614
+ // "stopPrice": "0.00",
6615
+ // "workingType": "CONTRACT_PRICE",
6616
+ // "priceProtect": false,
6617
+ // "origType": "LIMIT",
6618
+ // "priceMatch": "NONE",
6619
+ // "selfTradePreventionMode": "NONE",
6620
+ // "goodTillDate": 0,
6621
+ // "time": 1707892893502,
6622
+ // "updateTime": 1707892893515
6623
+ // }
6624
+ //
6625
+ // inverse swap
6626
+ //
6627
+ // {
6628
+ // "orderId": 597368542,
6629
+ // "symbol": "BTCUSD_PERP",
6630
+ // "pair": "BTCUSD",
6631
+ // "status": "NEW",
6632
+ // "clientOrderId": "x-xcKtGhcubbde7ba93b1a4ab881eff3",
6633
+ // "price": "35000",
6634
+ // "avgPrice": "0",
6635
+ // "origQty": "1",
6636
+ // "executedQty": "0",
6637
+ // "cumBase": "0",
6638
+ // "timeInForce": "GTC",
6639
+ // "type": "LIMIT",
6640
+ // "reduceOnly": false,
6641
+ // "closePosition": false,
6642
+ // "side": "BUY",
6643
+ // "positionSide": "BOTH",
6644
+ // "stopPrice": "0",
6645
+ // "workingType": "CONTRACT_PRICE",
6646
+ // "priceProtect": false,
6647
+ // "origType": "LIMIT",
6648
+ // "time": 1707893453199,
6649
+ // "updateTime": 1707893453199
6650
+ // }
6651
+ //
6652
+ // linear portfolio margin
6653
+ //
6654
+ // {
6655
+ // "orderId": 264895013409,
6656
+ // "symbol": "BTCUSDT",
6657
+ // "status": "NEW",
6658
+ // "clientOrderId": "x-xcKtGhcu6278f1adbdf14f74ab432e",
6659
+ // "price": "35000",
6660
+ // "avgPrice": "0",
6661
+ // "origQty": "0.010",
6662
+ // "executedQty": "0",
6663
+ // "cumQuote": "0",
6664
+ // "timeInForce": "GTC",
6665
+ // "type": "LIMIT",
6666
+ // "reduceOnly": false,
6667
+ // "side": "BUY",
6668
+ // "positionSide": "LONG",
6669
+ // "origType": "LIMIT",
6670
+ // "time": 1707893839364,
6671
+ // "updateTime": 1707893839364,
6672
+ // "goodTillDate": 0,
6673
+ // "selfTradePreventionMode": "NONE"
6674
+ // }
6675
+ //
6676
+ // inverse portfolio margin
6677
+ //
6678
+ // {
6679
+ // "orderId": 71790316950,
6680
+ // "symbol": "ETHUSD_PERP",
6681
+ // "pair": "ETHUSD",
6682
+ // "status": "NEW",
6683
+ // "clientOrderId": "x-xcKtGhcuec11030474204ab08ba2c2",
6684
+ // "price": "2500",
6685
+ // "avgPrice": "0",
6686
+ // "origQty": "1",
6687
+ // "executedQty": "0",
6688
+ // "cumBase": "0",
6689
+ // "timeInForce": "GTC",
6690
+ // "type": "LIMIT",
6691
+ // "reduceOnly": false,
6692
+ // "side": "BUY",
6693
+ // "positionSide": "LONG",
6694
+ // "origType": "LIMIT",
6695
+ // "time": 1707894181694,
6696
+ // "updateTime": 1707894181694
6697
+ // }
6698
+ //
6699
+ // linear portfolio margin conditional
6700
+ //
6701
+ // {
6702
+ // "newClientStrategyId": "x-xcKtGhcu2205fde44418483ca21874",
6703
+ // "strategyId": 4084339,
6704
+ // "strategyStatus": "NEW",
6705
+ // "strategyType": "STOP",
6706
+ // "origQty": "0.010",
6707
+ // "price": "35000",
6708
+ // "reduceOnly": false,
6709
+ // "side": "BUY",
6710
+ // "positionSide": "LONG",
6711
+ // "stopPrice": "60000",
6712
+ // "symbol": "BTCUSDT",
6713
+ // "bookTime": 1707894490094,
6714
+ // "updateTime": 1707894490094,
6715
+ // "timeInForce": "GTC",
6716
+ // "workingType": "CONTRACT_PRICE",
6717
+ // "priceProtect": false,
6718
+ // "goodTillDate": 0,
6719
+ // "selfTradePreventionMode": "NONE"
6720
+ // }
6721
+ //
6722
+ // inverse portfolio margin conditional
6723
+ //
6724
+ // {
6725
+ // "newClientStrategyId": "x-xcKtGhcu2da9c765294b433994ffce",
6726
+ // "strategyId": 1423501,
6727
+ // "strategyStatus": "NEW",
6728
+ // "strategyType": "STOP",
6729
+ // "origQty": "1",
6730
+ // "price": "2500",
6731
+ // "reduceOnly": false,
6732
+ // "side": "BUY",
6733
+ // "positionSide": "LONG",
6734
+ // "stopPrice": "4000",
6735
+ // "symbol": "ETHUSD_PERP",
6736
+ // "bookTime": 1707894782679,
6737
+ // "updateTime": 1707894782679,
6738
+ // "timeInForce": "GTC",
6739
+ // "workingType": "CONTRACT_PRICE",
6740
+ // "priceProtect": false
6741
+ // }
6742
+ //
6743
+ return this.parseOrder(response, market);
6744
+ }
6385
6745
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
6386
6746
  /**
6387
6747
  * @method
@@ -9486,12 +9846,12 @@ class binance extends binance$1 {
9486
9846
  /**
9487
9847
  * @method
9488
9848
  * @name binance#fetchPositions
9849
+ * @description fetch all open positions
9489
9850
  * @see https://binance-docs.github.io/apidocs/futures/en/#position-information-v2-user_data
9490
9851
  * @see https://binance-docs.github.io/apidocs/delivery/en/#position-information-user_data
9491
9852
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
9492
9853
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
9493
9854
  * @see https://binance-docs.github.io/apidocs/voptions/en/#option-position-information-user_data
9494
- * @description fetch all open positions
9495
9855
  * @param {string[]} [symbols] list of unified market symbols
9496
9856
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9497
9857
  * @param {string} [method] method name to call, "positionRisk", "account" or "option", default is "positionRisk"
@@ -9715,7 +10075,10 @@ class binance extends binance$1 {
9715
10075
  const result = [];
9716
10076
  for (let i = 0; i < response.length; i++) {
9717
10077
  const parsed = this.parsePositionRisk(response[i]);
9718
- result.push(parsed);
10078
+ const entryPrice = this.safeString(parsed, 'entryPrice');
10079
+ if ((entryPrice !== '0') && (entryPrice !== '0.0') && (entryPrice !== '0.00000000')) {
10080
+ result.push(parsed);
10081
+ }
9719
10082
  }
9720
10083
  symbols = this.marketSymbols(symbols);
9721
10084
  return this.filterByArrayPositions(result, 'symbol', symbols, false);
@@ -11295,12 +11658,16 @@ class binance extends binance$1 {
11295
11658
  * @see https://binance-docs.github.io/apidocs/spot/en/#get-force-liquidation-record-user_data
11296
11659
  * @see https://binance-docs.github.io/apidocs/futures/en/#user-39-s-force-orders-user_data
11297
11660
  * @see https://binance-docs.github.io/apidocs/delivery/en/#user-39-s-force-orders-user_data
11661
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-margin-force-orders-user_data
11662
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-um-force-orders-user_data
11663
+ * @see https://binance-docs.github.io/apidocs/pm/en/#query-user-39-s-cm-force-orders-user_data
11298
11664
  * @param {string} [symbol] unified CCXT market symbol
11299
11665
  * @param {int} [since] the earliest time in ms to fetch liquidations for
11300
11666
  * @param {int} [limit] the maximum number of liquidation structures to retrieve
11301
11667
  * @param {object} [params] exchange specific parameters for the binance api endpoint
11302
11668
  * @param {int} [params.until] timestamp in ms of the latest liquidation
11303
11669
  * @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)
11670
+ * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch liquidations in a portfolio margin account
11304
11671
  * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
11305
11672
  */
11306
11673
  await this.loadMarkets();
@@ -11317,13 +11684,17 @@ class binance extends binance$1 {
11317
11684
  [type, params] = this.handleMarketTypeAndParams('fetchMyLiquidations', market, params);
11318
11685
  let subType = undefined;
11319
11686
  [subType, params] = this.handleSubTypeAndParams('fetchMyLiquidations', market, params, 'linear');
11687
+ let isPortfolioMargin = undefined;
11688
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchMyLiquidations', 'papi', 'portfolioMargin', false);
11320
11689
  let request = {};
11321
11690
  if (type !== 'spot') {
11322
11691
  request['autoCloseType'] = 'LIQUIDATION';
11323
11692
  }
11324
11693
  if (market !== undefined) {
11325
11694
  const symbolKey = market['spot'] ? 'isolatedSymbol' : 'symbol';
11326
- request[symbolKey] = market['id'];
11695
+ if (!isPortfolioMargin) {
11696
+ request[symbolKey] = market['id'];
11697
+ }
11327
11698
  }
11328
11699
  if (since !== undefined) {
11329
11700
  request['startTime'] = since;
@@ -11339,13 +11710,28 @@ class binance extends binance$1 {
11339
11710
  [request, params] = this.handleUntilOption('endTime', request, params);
11340
11711
  let response = undefined;
11341
11712
  if (type === 'spot') {
11342
- response = await this.sapiGetMarginForceLiquidationRec(this.extend(request, params));
11713
+ if (isPortfolioMargin) {
11714
+ response = await this.papiGetMarginForceOrders(this.extend(request, params));
11715
+ }
11716
+ else {
11717
+ response = await this.sapiGetMarginForceLiquidationRec(this.extend(request, params));
11718
+ }
11343
11719
  }
11344
11720
  else if (subType === 'linear') {
11345
- response = await this.fapiPrivateGetForceOrders(this.extend(request, params));
11721
+ if (isPortfolioMargin) {
11722
+ response = await this.papiGetUmForceOrders(this.extend(request, params));
11723
+ }
11724
+ else {
11725
+ response = await this.fapiPrivateGetForceOrders(this.extend(request, params));
11726
+ }
11346
11727
  }
11347
11728
  else if (subType === 'inverse') {
11348
- response = await this.dapiPrivateGetForceOrders(this.extend(request, params));
11729
+ if (isPortfolioMargin) {
11730
+ response = await this.papiGetCmForceOrders(this.extend(request, params));
11731
+ }
11732
+ else {
11733
+ response = await this.dapiPrivateGetForceOrders(this.extend(request, params));
11734
+ }
11349
11735
  }
11350
11736
  else {
11351
11737
  throw new errors.NotSupported(this.id + ' fetchMyLiquidations() does not support ' + market['type'] + ' markets');
@@ -11427,7 +11813,7 @@ class binance extends binance$1 {
11427
11813
  // },
11428
11814
  // ]
11429
11815
  //
11430
- const liquidations = this.safeValue(response, 'rows', response);
11816
+ const liquidations = this.safeList(response, 'rows', response);
11431
11817
  return this.parseLiquidations(liquidations, market, since, limit);
11432
11818
  }
11433
11819
  parseLiquidation(liquidation, market = undefined) {
@@ -50,6 +50,7 @@ class bingx extends bingx$1 {
50
50
  'fetchClosedOrders': true,
51
51
  'fetchCurrencies': true,
52
52
  'fetchDepositAddress': true,
53
+ 'fetchDepositAddressesByNetwork': true,
53
54
  'fetchDeposits': true,
54
55
  'fetchDepositWithdrawFee': 'emulated',
55
56
  'fetchDepositWithdrawFees': true,
@@ -402,6 +403,13 @@ class bingx extends bingx$1 {
402
403
  },
403
404
  'recvWindow': 5 * 1000,
404
405
  'broker': 'CCXT',
406
+ 'defaultNetworks': {
407
+ 'ETH': 'ETH',
408
+ 'USDT': 'ERC20',
409
+ 'USDC': 'ERC20',
410
+ 'BTC': 'BTC',
411
+ 'LTC': 'LTC',
412
+ },
405
413
  },
406
414
  });
407
415
  }
@@ -3085,15 +3093,15 @@ class bingx extends bingx$1 {
3085
3093
  'status': status,
3086
3094
  };
3087
3095
  }
3088
- async fetchDepositAddress(code, params = {}) {
3096
+ async fetchDepositAddressesByNetwork(code, params = {}) {
3089
3097
  /**
3090
3098
  * @method
3091
- * @name bingx#fetchDepositAddress
3092
- * @description fetch the deposit address for a currency associated with this account
3093
- * @see https://bingx-api.github.io/docs/#/common/sub-account#Query%20Main%20Account%20Deposit%20Address
3099
+ * @name bingx#fetchDepositAddressesByNetwork
3100
+ * @description fetch the deposit addresses for a currency associated with this account
3101
+ * @see https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Query%20Main%20Account%20Deposit%20Address
3094
3102
  * @param {string} code unified currency code
3095
3103
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3096
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
3104
+ * @returns {object} a dictionary [address structures]{@link https://docs.ccxt.com/#/?id=address-structure}, indexed by the network
3097
3105
  */
3098
3106
  await this.loadMarkets();
3099
3107
  const currency = this.currency(code);
@@ -3128,6 +3136,36 @@ class bingx extends bingx$1 {
3128
3136
  const parsed = this.parseDepositAddresses(data, [currency['code']], false);
3129
3137
  return this.indexBy(parsed, 'network');
3130
3138
  }
3139
+ async fetchDepositAddress(code, params = {}) {
3140
+ /**
3141
+ * @method
3142
+ * @name bingx#fetchDepositAddress
3143
+ * @description fetch the deposit address for a currency associated with this account
3144
+ * @see https://bingx-api.github.io/docs/#/en-us/common/wallet-api.html#Query%20Main%20Account%20Deposit%20Address
3145
+ * @param {string} code unified currency code
3146
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3147
+ * @param {string} [params.network] The chain of currency. This only apply for multi-chain currency, and there is no need for single chain currency
3148
+ * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
3149
+ */
3150
+ const network = this.safeString(params, 'network');
3151
+ params = this.omit(params, ['network']);
3152
+ const addressStructures = await this.fetchDepositAddressesByNetwork(code, params);
3153
+ if (network !== undefined) {
3154
+ return this.safeDict(addressStructures, network);
3155
+ }
3156
+ else {
3157
+ const options = this.safeDict(this.options, 'defaultNetworks');
3158
+ const defaultNetworkForCurrency = this.safeString(options, code);
3159
+ if (defaultNetworkForCurrency !== undefined) {
3160
+ return this.safeDict(addressStructures, defaultNetworkForCurrency);
3161
+ }
3162
+ else {
3163
+ const keys = Object.keys(addressStructures);
3164
+ const key = this.safeString(keys, 0);
3165
+ return this.safeDict(addressStructures, key);
3166
+ }
3167
+ }
3168
+ }
3131
3169
  parseDepositAddress(depositAddress, currency = undefined) {
3132
3170
  //
3133
3171
  // {
@@ -406,6 +406,7 @@ class bitfinex2 extends bitfinex2$1 {
406
406
  'EDO': 'PNT',
407
407
  'EUS': 'EURS',
408
408
  'EUT': 'EURT',
409
+ 'HTX': 'HT',
409
410
  'IDX': 'ID',
410
411
  'IOT': 'IOTA',
411
412
  'IQX': 'IQ',