ccxt 4.2.57 → 4.2.59

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 (110) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/README.md +4 -5
  3. package/build.sh +1 -1
  4. package/cleanup.sh +3 -0
  5. package/dist/ccxt.browser.js +772 -497
  6. package/dist/ccxt.browser.min.js +7 -7
  7. package/dist/cjs/ccxt.js +1 -1
  8. package/dist/cjs/src/alpaca.js +90 -88
  9. package/dist/cjs/src/base/Exchange.js +24 -1
  10. package/dist/cjs/src/binance.js +43 -30
  11. package/dist/cjs/src/bingx.js +15 -4
  12. package/dist/cjs/src/bitget.js +72 -57
  13. package/dist/cjs/src/bitmex.js +13 -29
  14. package/dist/cjs/src/bitrue.js +24 -15
  15. package/dist/cjs/src/blofin.js +25 -2
  16. package/dist/cjs/src/bybit.js +11 -3
  17. package/dist/cjs/src/coinbase.js +24 -14
  18. package/dist/cjs/src/currencycom.js +15 -5
  19. package/dist/cjs/src/delta.js +14 -1
  20. package/dist/cjs/src/gate.js +1 -1
  21. package/dist/cjs/src/hitbtc.js +12 -1
  22. package/dist/cjs/src/krakenfutures.js +22 -7
  23. package/dist/cjs/src/kuna.js +14 -11
  24. package/dist/cjs/src/lbank.js +1 -1
  25. package/dist/cjs/src/mexc.js +20 -20
  26. package/dist/cjs/src/okx.js +32 -2
  27. package/dist/cjs/src/phemex.js +1 -1
  28. package/dist/cjs/src/pro/alpaca.js +1 -1
  29. package/dist/cjs/src/pro/binance.js +1 -1
  30. package/dist/cjs/src/pro/bitfinex2.js +1 -1
  31. package/dist/cjs/src/pro/bitget.js +1 -1
  32. package/dist/cjs/src/pro/bitmart.js +51 -89
  33. package/dist/cjs/src/pro/bitvavo.js +1 -1
  34. package/dist/cjs/src/pro/bybit.js +1 -1
  35. package/dist/cjs/src/pro/coinex.js +1 -1
  36. package/dist/cjs/src/pro/cryptocom.js +1 -1
  37. package/dist/cjs/src/pro/deribit.js +201 -84
  38. package/dist/cjs/src/pro/gate.js +1 -1
  39. package/dist/cjs/src/pro/independentreserve.js +1 -1
  40. package/dist/cjs/src/pro/kraken.js +1 -1
  41. package/dist/cjs/src/pro/kucoinfutures.js +1 -1
  42. package/dist/cjs/src/pro/mexc.js +5 -3
  43. package/dist/cjs/src/pro/okx.js +1 -1
  44. package/dist/cjs/src/pro/whitebit.js +4 -6
  45. package/dist/cjs/src/pro/woo.js +1 -1
  46. package/dist/cjs/src/probit.js +1 -1
  47. package/dist/cjs/src/wavesexchange.js +1 -1
  48. package/dist/cjs/src/woo.js +22 -6
  49. package/js/ccxt.d.ts +3 -3
  50. package/js/ccxt.js +1 -1
  51. package/js/src/alpaca.js +90 -88
  52. package/js/src/base/Exchange.d.ts +6 -4
  53. package/js/src/base/Exchange.js +24 -1
  54. package/js/src/base/types.d.ts +9 -0
  55. package/js/src/binance.d.ts +3 -2
  56. package/js/src/binance.js +43 -30
  57. package/js/src/bingx.d.ts +3 -2
  58. package/js/src/bingx.js +15 -4
  59. package/js/src/bitget.d.ts +3 -2
  60. package/js/src/bitget.js +72 -57
  61. package/js/src/bitmex.d.ts +3 -3
  62. package/js/src/bitmex.js +13 -29
  63. package/js/src/bitrue.js +24 -15
  64. package/js/src/blofin.d.ts +3 -2
  65. package/js/src/blofin.js +25 -2
  66. package/js/src/bybit.d.ts +3 -6
  67. package/js/src/bybit.js +11 -3
  68. package/js/src/coinbase.js +24 -14
  69. package/js/src/currencycom.d.ts +3 -2
  70. package/js/src/currencycom.js +15 -5
  71. package/js/src/delta.d.ts +3 -2
  72. package/js/src/delta.js +14 -1
  73. package/js/src/gate.js +1 -1
  74. package/js/src/hitbtc.d.ts +3 -2
  75. package/js/src/hitbtc.js +12 -1
  76. package/js/src/krakenfutures.d.ts +3 -2
  77. package/js/src/krakenfutures.js +22 -7
  78. package/js/src/kuna.js +14 -11
  79. package/js/src/lbank.js +1 -1
  80. package/js/src/mexc.d.ts +3 -13
  81. package/js/src/mexc.js +20 -20
  82. package/js/src/okx.d.ts +3 -2
  83. package/js/src/okx.js +32 -2
  84. package/js/src/phemex.js +1 -1
  85. package/js/src/pro/alpaca.js +1 -1
  86. package/js/src/pro/binance.js +1 -1
  87. package/js/src/pro/bitfinex2.js +1 -1
  88. package/js/src/pro/bitget.js +1 -1
  89. package/js/src/pro/bitmart.d.ts +2 -2
  90. package/js/src/pro/bitmart.js +51 -89
  91. package/js/src/pro/bitvavo.js +1 -1
  92. package/js/src/pro/bybit.js +1 -1
  93. package/js/src/pro/coinex.js +1 -1
  94. package/js/src/pro/cryptocom.js +1 -1
  95. package/js/src/pro/deribit.d.ts +5 -0
  96. package/js/src/pro/deribit.js +202 -85
  97. package/js/src/pro/gate.js +1 -1
  98. package/js/src/pro/independentreserve.js +1 -1
  99. package/js/src/pro/kraken.js +1 -1
  100. package/js/src/pro/kucoinfutures.js +1 -1
  101. package/js/src/pro/mexc.js +6 -4
  102. package/js/src/pro/okx.js +1 -1
  103. package/js/src/pro/whitebit.js +4 -6
  104. package/js/src/pro/woo.js +1 -1
  105. package/js/src/probit.js +1 -1
  106. package/js/src/wavesexchange.js +1 -1
  107. package/js/src/woo.d.ts +3 -5
  108. package/js/src/woo.js +22 -6
  109. package/package.json +1 -1
  110. package/skip-tests.json +8 -3
package/dist/cjs/ccxt.js CHANGED
@@ -176,7 +176,7 @@ var woo$1 = require('./src/pro/woo.js');
176
176
 
177
177
  //-----------------------------------------------------------------------------
178
178
  // this is updated by vss.js when building
179
- const version = '4.2.57';
179
+ const version = '4.2.59';
180
180
  Exchange["default"].ccxtVersion = version;
181
181
  const exchanges = {
182
182
  'ace': ace,
@@ -440,7 +440,7 @@ class alpaca extends alpaca$1 {
440
440
  'loc': loc,
441
441
  };
442
442
  params = this.omit(params, ['loc', 'method']);
443
- let response = undefined;
443
+ let symbolTrades = undefined;
444
444
  if (method === 'marketPublicGetV1beta3CryptoLocTrades') {
445
445
  if (since !== undefined) {
446
446
  request['start'] = this.iso8601(since);
@@ -448,47 +448,48 @@ class alpaca extends alpaca$1 {
448
448
  if (limit !== undefined) {
449
449
  request['limit'] = limit;
450
450
  }
451
- response = await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(request, params));
451
+ const response = await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(request, params));
452
+ //
453
+ // {
454
+ // "next_page_token": null,
455
+ // "trades": {
456
+ // "BTC/USD": [
457
+ // {
458
+ // "i": 36440704,
459
+ // "p": 22625,
460
+ // "s": 0.0001,
461
+ // "t": "2022-07-21T11:47:31.073391Z",
462
+ // "tks": "B"
463
+ // }
464
+ // ]
465
+ // }
466
+ // }
467
+ //
468
+ const trades = this.safeDict(response, 'trades', {});
469
+ symbolTrades = this.safeList(trades, marketId, []);
452
470
  }
453
471
  else if (method === 'marketPublicGetV1beta3CryptoLocLatestTrades') {
454
- response = await this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(request, params));
472
+ const response = await this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(request, params));
473
+ //
474
+ // {
475
+ // "trades": {
476
+ // "BTC/USD": {
477
+ // "i": 36440704,
478
+ // "p": 22625,
479
+ // "s": 0.0001,
480
+ // "t": "2022-07-21T11:47:31.073391Z",
481
+ // "tks": "B"
482
+ // }
483
+ // }
484
+ // }
485
+ //
486
+ const trades = this.safeDict(response, 'trades', {});
487
+ symbolTrades = this.safeDict(trades, marketId, {});
488
+ symbolTrades = [symbolTrades];
455
489
  }
456
490
  else {
457
491
  throw new errors.NotSupported(this.id + ' fetchTrades() does not support ' + method + ', marketPublicGetV1beta3CryptoLocTrades and marketPublicGetV1beta3CryptoLocLatestTrades are supported');
458
492
  }
459
- //
460
- // {
461
- // "next_page_token":null,
462
- // "trades":{
463
- // "BTC/USD":[
464
- // {
465
- // "i":36440704,
466
- // "p":22625,
467
- // "s":0.0001,
468
- // "t":"2022-07-21T11:47:31.073391Z",
469
- // "tks":"B"
470
- // }
471
- // ]
472
- // }
473
- // }
474
- //
475
- // {
476
- // "trades":{
477
- // "BTC/USD":{
478
- // "i":36440704,
479
- // "p":22625,
480
- // "s":0.0001,
481
- // "t":"2022-07-21T11:47:31.073391Z",
482
- // "tks":"B"
483
- // }
484
- // }
485
- // }
486
- //
487
- const trades = this.safeValue(response, 'trades', {});
488
- let symbolTrades = this.safeValue(trades, marketId, {});
489
- if (!Array.isArray(symbolTrades)) {
490
- symbolTrades = [symbolTrades];
491
- }
492
493
  return this.parseTrades(symbolTrades, market, since, limit);
493
494
  }
494
495
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
@@ -580,7 +581,7 @@ class alpaca extends alpaca$1 {
580
581
  'loc': loc,
581
582
  };
582
583
  params = this.omit(params, ['loc', 'method']);
583
- let response = undefined;
584
+ let ohlcvs = undefined;
584
585
  if (method === 'marketPublicGetV1beta3CryptoLocBars') {
585
586
  if (limit !== undefined) {
586
587
  request['limit'] = limit;
@@ -589,63 +590,64 @@ class alpaca extends alpaca$1 {
589
590
  request['start'] = this.yyyymmdd(since);
590
591
  }
591
592
  request['timeframe'] = this.safeString(this.timeframes, timeframe, timeframe);
592
- response = await this.marketPublicGetV1beta3CryptoLocBars(this.extend(request, params));
593
+ const response = await this.marketPublicGetV1beta3CryptoLocBars(this.extend(request, params));
594
+ //
595
+ // {
596
+ // "bars": {
597
+ // "BTC/USD": [
598
+ // {
599
+ // "c": 22887,
600
+ // "h": 22888,
601
+ // "l": 22873,
602
+ // "n": 11,
603
+ // "o": 22883,
604
+ // "t": "2022-07-21T05:00:00Z",
605
+ // "v": 1.1138,
606
+ // "vw": 22883.0155324116
607
+ // },
608
+ // {
609
+ // "c": 22895,
610
+ // "h": 22895,
611
+ // "l": 22884,
612
+ // "n": 6,
613
+ // "o": 22884,
614
+ // "t": "2022-07-21T05:01:00Z",
615
+ // "v": 0.001,
616
+ // "vw": 22889.5
617
+ // }
618
+ // ]
619
+ // },
620
+ // "next_page_token": "QlRDL1VTRHxNfDIwMjItMDctMjFUMDU6MDE6MDAuMDAwMDAwMDAwWg=="
621
+ // }
622
+ //
623
+ const bars = this.safeDict(response, 'bars', {});
624
+ ohlcvs = this.safeList(bars, marketId, []);
593
625
  }
594
626
  else if (method === 'marketPublicGetV1beta3CryptoLocLatestBars') {
595
- response = await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(request, params));
627
+ const response = await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(request, params));
628
+ //
629
+ // {
630
+ // "bars": {
631
+ // "BTC/USD": {
632
+ // "c": 22887,
633
+ // "h": 22888,
634
+ // "l": 22873,
635
+ // "n": 11,
636
+ // "o": 22883,
637
+ // "t": "2022-07-21T05:00:00Z",
638
+ // "v": 1.1138,
639
+ // "vw": 22883.0155324116
640
+ // }
641
+ // }
642
+ // }
643
+ //
644
+ const bars = this.safeDict(response, 'bars', {});
645
+ ohlcvs = this.safeDict(bars, marketId, {});
646
+ ohlcvs = [ohlcvs];
596
647
  }
597
648
  else {
598
649
  throw new errors.NotSupported(this.id + ' fetchOHLCV() does not support ' + method + ', marketPublicGetV1beta3CryptoLocBars and marketPublicGetV1beta3CryptoLocLatestBars are supported');
599
650
  }
600
- //
601
- // {
602
- // "bars":{
603
- // "BTC/USD":[
604
- // {
605
- // "c":22887,
606
- // "h":22888,
607
- // "l":22873,
608
- // "n":11,
609
- // "o":22883,
610
- // "t":"2022-07-21T05:00:00Z",
611
- // "v":1.1138,
612
- // "vw":22883.0155324116
613
- // },
614
- // {
615
- // "c":22895,
616
- // "h":22895,
617
- // "l":22884,
618
- // "n":6,
619
- // "o":22884,
620
- // "t":"2022-07-21T05:01:00Z",
621
- // "v":0.001,
622
- // "vw":22889.5
623
- // }
624
- // ]
625
- // },
626
- // "next_page_token":"QlRDL1VTRHxNfDIwMjItMDctMjFUMDU6MDE6MDAuMDAwMDAwMDAwWg=="
627
- // }
628
- //
629
- // {
630
- // "bars":{
631
- // "BTC/USD":{
632
- // "c":22887,
633
- // "h":22888,
634
- // "l":22873,
635
- // "n":11,
636
- // "o":22883,
637
- // "t":"2022-07-21T05:00:00Z",
638
- // "v":1.1138,
639
- // "vw":22883.0155324116
640
- // }
641
- // }
642
- // }
643
- //
644
- const bars = this.safeValue(response, 'bars', {});
645
- let ohlcvs = this.safeValue(bars, marketId, {});
646
- if (!Array.isArray(ohlcvs)) {
647
- ohlcvs = [ohlcvs];
648
- }
649
651
  return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
650
652
  }
651
653
  parseOHLCV(ohlcv, market = undefined) {
@@ -1988,7 +1988,13 @@ class Exchange {
1988
1988
  throw new errors.NotSupported(this.id + ' setLeverage() is not supported yet');
1989
1989
  }
1990
1990
  async fetchLeverage(symbol, params = {}) {
1991
- throw new errors.NotSupported(this.id + ' fetchLeverage() is not supported yet');
1991
+ if (this.has['fetchLeverages']) {
1992
+ const leverages = await this.fetchLeverages([symbol], params);
1993
+ return this.safeDict(leverages, symbol);
1994
+ }
1995
+ else {
1996
+ throw new errors.NotSupported(this.id + ' fetchLeverage() is not supported yet');
1997
+ }
1992
1998
  }
1993
1999
  async fetchLeverages(symbols = undefined, params = {}) {
1994
2000
  throw new errors.NotSupported(this.id + ' fetchLeverages() is not supported yet');
@@ -3889,6 +3895,8 @@ class Exchange {
3889
3895
  params = this.omit(params, [optionName, defaultOptionName]);
3890
3896
  }
3891
3897
  else {
3898
+ // handle routed methods like "watchTrades > watchTradesForSymbols" (or "watchTicker > watchTickers")
3899
+ [methodName, params] = this.handleParamString(params, 'callerMethodName', methodName);
3892
3900
  // check if exchange has properties for this method
3893
3901
  const exchangeWideMethodOptions = this.safeValue(this.options, methodName);
3894
3902
  if (exchangeWideMethodOptions !== undefined) {
@@ -5587,6 +5595,21 @@ class Exchange {
5587
5595
  parseMarginMode(marginMode, market = undefined) {
5588
5596
  throw new errors.NotSupported(this.id + ' parseMarginMode () is not supported yet');
5589
5597
  }
5598
+ parseLeverages(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
5599
+ const leverageStructures = {};
5600
+ for (let i = 0; i < response.length; i++) {
5601
+ const info = response[i];
5602
+ const marketId = this.safeString(info, symbolKey);
5603
+ const market = this.safeMarket(marketId, undefined, undefined, marketType);
5604
+ if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
5605
+ leverageStructures[market['symbol']] = this.parseLeverage(info, market);
5606
+ }
5607
+ }
5608
+ return leverageStructures;
5609
+ }
5610
+ parseLeverage(leverage, market = undefined) {
5611
+ throw new errors.NotSupported(this.id + ' parseLeverage() is not supported yet');
5612
+ }
5590
5613
  }
5591
5614
 
5592
5615
  exports.Exchange = Exchange;
@@ -94,7 +94,8 @@ class binance extends binance$1 {
94
94
  'fetchLastPrices': true,
95
95
  'fetchLedger': true,
96
96
  'fetchLedgerEntry': true,
97
- 'fetchLeverage': true,
97
+ 'fetchLeverage': 'emulated',
98
+ 'fetchLeverages': true,
98
99
  'fetchLeverageTiers': true,
99
100
  'fetchLiquidations': false,
100
101
  'fetchMarginMode': 'emulated',
@@ -4809,7 +4810,7 @@ class binance extends binance$1 {
4809
4810
  let stopPriceIsRequired = false;
4810
4811
  let quantityIsRequired = false;
4811
4812
  if (uppercaseType === 'MARKET') {
4812
- const quoteOrderQty = this.safeValue(this.options, 'quoteOrderQty', true);
4813
+ const quoteOrderQty = this.safeBool(this.options, 'quoteOrderQty', true);
4813
4814
  if (quoteOrderQty) {
4814
4815
  const quoteOrderQtyNew = this.safeValue2(params, 'quoteOrderQty', 'cost');
4815
4816
  const precision = market['precision']['price'];
@@ -10317,7 +10318,7 @@ class binance extends binance$1 {
10317
10318
  // POST https://fapi.binance.com/fapi/v1/marginType 400 Bad Request
10318
10319
  // binanceusdm
10319
10320
  if (e instanceof errors.MarginModeAlreadySet) {
10320
- const throwMarginModeAlreadySet = this.safeValue(this.options, 'throwMarginModeAlreadySet', false);
10321
+ const throwMarginModeAlreadySet = this.safeBool(this.options, 'throwMarginModeAlreadySet', false);
10321
10322
  if (throwMarginModeAlreadySet) {
10322
10323
  throw e;
10323
10324
  }
@@ -10388,31 +10389,27 @@ class binance extends binance$1 {
10388
10389
  //
10389
10390
  return response;
10390
10391
  }
10391
- async fetchLeverage(symbol, params = {}) {
10392
+ async fetchLeverages(symbols = undefined, params = {}) {
10392
10393
  /**
10393
10394
  * @method
10394
- * @name binance#fetchLeverage
10395
- * @description fetch the set leverage for a market
10395
+ * @name binance#fetchLeverages
10396
+ * @description fetch the set leverage for all markets
10396
10397
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
10397
10398
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
10398
10399
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
10399
10400
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
10400
- * @param {string} symbol unified market symbol
10401
+ * @param {string[]} [symbols] a list of unified market symbols
10401
10402
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10402
- * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
10403
+ * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
10403
10404
  */
10404
10405
  await this.loadMarkets();
10405
10406
  await this.loadLeverageBrackets(false, params);
10406
- const market = this.market(symbol);
10407
- if (!market['contract']) {
10408
- throw new errors.NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
10409
- }
10410
10407
  let type = undefined;
10411
- [type, params] = this.handleMarketTypeAndParams('fetchLeverage', market, params);
10408
+ [type, params] = this.handleMarketTypeAndParams('fetchLeverages', undefined, params);
10412
10409
  let subType = undefined;
10413
- [subType, params] = this.handleSubTypeAndParams('fetchLeverage', market, params, 'linear');
10410
+ [subType, params] = this.handleSubTypeAndParams('fetchLeverages', undefined, params, 'linear');
10414
10411
  let isPortfolioMargin = undefined;
10415
- [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverage', 'papi', 'portfolioMargin', false);
10412
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverages', 'papi', 'portfolioMargin', false);
10416
10413
  let response = undefined;
10417
10414
  if (this.isLinear(type, subType)) {
10418
10415
  if (isPortfolioMargin) {
@@ -10431,23 +10428,39 @@ class binance extends binance$1 {
10431
10428
  }
10432
10429
  }
10433
10430
  else {
10434
- throw new errors.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
10431
+ throw new errors.NotSupported(this.id + ' fetchLeverages() supports linear and inverse contracts only');
10435
10432
  }
10436
- const positions = this.safeList(response, 'positions', []);
10437
- for (let i = 0; i < positions.length; i++) {
10438
- const position = positions[i];
10439
- const innerSymbol = this.safeString(position, 'symbol');
10440
- if (innerSymbol === market['id']) {
10441
- const isolated = this.safeBool(position, 'isolated');
10442
- const marginMode = isolated ? 'isolated' : 'cross';
10443
- return {
10444
- 'info': position,
10445
- 'marginMode': marginMode,
10446
- 'leverage': this.safeInteger(position, 'leverage'),
10447
- };
10448
- }
10433
+ const leverages = this.safeList(response, 'positions', []);
10434
+ return this.parseLeverages(leverages, symbols, 'symbol');
10435
+ }
10436
+ parseLeverage(leverage, market = undefined) {
10437
+ const marketId = this.safeString(leverage, 'symbol');
10438
+ const marginModeRaw = this.safeBool(leverage, 'isolated');
10439
+ let marginMode = undefined;
10440
+ if (marginModeRaw !== undefined) {
10441
+ marginMode = marginModeRaw ? 'isolated' : 'cross';
10449
10442
  }
10450
- return response;
10443
+ const side = this.safeStringLower(leverage, 'positionSide');
10444
+ let longLeverage = undefined;
10445
+ let shortLeverage = undefined;
10446
+ const leverageValue = this.safeInteger(leverage, 'leverage');
10447
+ if (side === 'both') {
10448
+ longLeverage = leverageValue;
10449
+ shortLeverage = leverageValue;
10450
+ }
10451
+ else if (side === 'long') {
10452
+ longLeverage = leverageValue;
10453
+ }
10454
+ else if (side === 'short') {
10455
+ shortLeverage = leverageValue;
10456
+ }
10457
+ return {
10458
+ 'info': leverage,
10459
+ 'symbol': this.safeSymbol(marketId, market),
10460
+ 'marginMode': marginMode,
10461
+ 'longLeverage': longLeverage,
10462
+ 'shortLeverage': shortLeverage,
10463
+ };
10451
10464
  }
10452
10465
  async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
10453
10466
  /**
@@ -449,7 +449,7 @@ class bingx extends bingx$1 {
449
449
  if (!this.checkRequiredCredentials(false)) {
450
450
  return undefined;
451
451
  }
452
- const isSandbox = this.safeValue(this.options, 'sandboxMode', false);
452
+ const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
453
453
  if (isSandbox) {
454
454
  return undefined;
455
455
  }
@@ -693,7 +693,7 @@ class bingx extends bingx$1 {
693
693
  * @returns {object[]} an array of objects representing market data
694
694
  */
695
695
  const requests = [this.fetchSwapMarkets(params)];
696
- const isSandbox = this.safeValue(this.options, 'sandboxMode', false);
696
+ const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
697
697
  if (!isSandbox) {
698
698
  requests.push(this.fetchSpotMarkets(params)); // sandbox is swap only
699
699
  }
@@ -3496,7 +3496,18 @@ class bingx extends bingx$1 {
3496
3496
  // }
3497
3497
  // }
3498
3498
  //
3499
- return response;
3499
+ const data = this.safeDict(response, 'data', {});
3500
+ return this.parseLeverage(data, market);
3501
+ }
3502
+ parseLeverage(leverage, market = undefined) {
3503
+ const marketId = this.safeString(leverage, 'symbol');
3504
+ return {
3505
+ 'info': leverage,
3506
+ 'symbol': this.safeSymbol(marketId, market),
3507
+ 'marginMode': undefined,
3508
+ 'longLeverage': this.safeInteger(leverage, 'longLeverage'),
3509
+ 'shortLeverage': this.safeInteger(leverage, 'shortLeverage'),
3510
+ };
3500
3511
  }
3501
3512
  async setLeverage(leverage, symbol = undefined, params = {}) {
3502
3513
  /**
@@ -4159,7 +4170,7 @@ class bingx extends bingx$1 {
4159
4170
  const type = section[0];
4160
4171
  const version = section[1];
4161
4172
  const access = section[2];
4162
- const isSandbox = this.safeValue(this.options, 'sandboxMode', false);
4173
+ const isSandbox = this.safeBool(this.options, 'sandboxMode', false);
4163
4174
  if (isSandbox && (type !== 'swap')) {
4164
4175
  throw new errors.NotSupported(this.id + ' does not have a testnet/sandbox URL for ' + type + ' endpoints');
4165
4176
  }