ccxt 4.2.56 → 4.2.58

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 (75) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.js +818 -335
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/alpaca.js +90 -88
  6. package/dist/cjs/src/base/Exchange.js +53 -3
  7. package/dist/cjs/src/binance.js +196 -28
  8. package/dist/cjs/src/bingx.js +12 -1
  9. package/dist/cjs/src/bitget.js +71 -56
  10. package/dist/cjs/src/bitmex.js +26 -1
  11. package/dist/cjs/src/bitrue.js +24 -15
  12. package/dist/cjs/src/blofin.js +24 -1
  13. package/dist/cjs/src/bybit.js +11 -3
  14. package/dist/cjs/src/currencycom.js +15 -5
  15. package/dist/cjs/src/delta.js +14 -1
  16. package/dist/cjs/src/gate.js +1 -1
  17. package/dist/cjs/src/hitbtc.js +63 -55
  18. package/dist/cjs/src/krakenfutures.js +22 -7
  19. package/dist/cjs/src/kuna.js +14 -11
  20. package/dist/cjs/src/mexc.js +75 -0
  21. package/dist/cjs/src/okx.js +31 -1
  22. package/dist/cjs/src/pro/alpaca.js +1 -1
  23. package/dist/cjs/src/pro/bitmex.js +23 -32
  24. package/dist/cjs/src/pro/cex.js +6 -2
  25. package/dist/cjs/src/pro/coinex.js +6 -3
  26. package/dist/cjs/src/pro/mexc.js +2 -2
  27. package/dist/cjs/src/pro/whitebit.js +15 -13
  28. package/dist/cjs/src/probit.js +1 -1
  29. package/dist/cjs/src/wavesexchange.js +1 -1
  30. package/dist/cjs/src/woo.js +20 -4
  31. package/js/ccxt.d.ts +3 -3
  32. package/js/ccxt.js +1 -1
  33. package/js/src/alpaca.js +90 -88
  34. package/js/src/base/Exchange.d.ts +14 -6
  35. package/js/src/base/Exchange.js +53 -3
  36. package/js/src/base/types.d.ts +12 -1
  37. package/js/src/binance.d.ts +5 -2
  38. package/js/src/binance.js +196 -28
  39. package/js/src/bingx.d.ts +3 -2
  40. package/js/src/bingx.js +12 -1
  41. package/js/src/bitget.d.ts +3 -2
  42. package/js/src/bitget.js +71 -56
  43. package/js/src/bitmex.d.ts +3 -1
  44. package/js/src/bitmex.js +26 -1
  45. package/js/src/bitrue.js +24 -15
  46. package/js/src/blofin.d.ts +3 -2
  47. package/js/src/blofin.js +24 -1
  48. package/js/src/bybit.d.ts +3 -6
  49. package/js/src/bybit.js +11 -3
  50. package/js/src/currencycom.d.ts +3 -2
  51. package/js/src/currencycom.js +15 -5
  52. package/js/src/delta.d.ts +3 -2
  53. package/js/src/delta.js +14 -1
  54. package/js/src/gate.js +1 -1
  55. package/js/src/hitbtc.d.ts +5 -3
  56. package/js/src/hitbtc.js +63 -55
  57. package/js/src/krakenfutures.d.ts +3 -2
  58. package/js/src/krakenfutures.js +22 -7
  59. package/js/src/kuna.js +14 -11
  60. package/js/src/mexc.d.ts +3 -1
  61. package/js/src/mexc.js +75 -0
  62. package/js/src/okx.d.ts +3 -2
  63. package/js/src/okx.js +31 -1
  64. package/js/src/pro/alpaca.js +1 -1
  65. package/js/src/pro/bitmex.js +24 -31
  66. package/js/src/pro/cex.js +6 -2
  67. package/js/src/pro/coinex.js +6 -3
  68. package/js/src/pro/mexc.js +2 -2
  69. package/js/src/pro/whitebit.js +15 -13
  70. package/js/src/probit.js +1 -1
  71. package/js/src/wavesexchange.js +1 -1
  72. package/js/src/woo.d.ts +3 -5
  73. package/js/src/woo.js +20 -4
  74. package/package.json +1 -1
  75. package/skip-tests.json +26 -8
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.56';
179
+ const version = '4.2.58';
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) {
@@ -436,9 +436,11 @@ class Exchange {
436
436
  'fetchLedger': undefined,
437
437
  'fetchLedgerEntry': undefined,
438
438
  'fetchLeverage': undefined,
439
+ 'fetchLeverages': undefined,
439
440
  'fetchLeverageTiers': undefined,
440
441
  'fetchLiquidations': undefined,
441
442
  'fetchMarginMode': undefined,
443
+ 'fetchMarginModes': undefined,
442
444
  'fetchMarketLeverageTiers': undefined,
443
445
  'fetchMarkets': true,
444
446
  'fetchMarketsWs': undefined,
@@ -1867,8 +1869,17 @@ class Exchange {
1867
1869
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
1868
1870
  throw new errors.NotSupported(this.id + ' fetchOrderBook() is not supported yet');
1869
1871
  }
1870
- async fetchMarginMode(symbol = undefined, params = {}) {
1871
- throw new errors.NotSupported(this.id + ' fetchMarginMode() is not supported yet');
1872
+ async fetchMarginMode(symbol, params = {}) {
1873
+ if (this.has['fetchMarginModes']) {
1874
+ const marginModes = await this.fetchMarginModes([symbol], params);
1875
+ return this.safeDict(marginModes, symbol);
1876
+ }
1877
+ else {
1878
+ throw new errors.NotSupported(this.id + ' fetchMarginMode() is not supported yet');
1879
+ }
1880
+ }
1881
+ async fetchMarginModes(symbols = undefined, params = {}) {
1882
+ throw new errors.NotSupported(this.id + ' fetchMarginModes () is not supported yet');
1872
1883
  }
1873
1884
  async fetchRestOrderBookSafe(symbol, limit = undefined, params = {}) {
1874
1885
  const fetchSnapshotMaxRetries = this.handleOption('watchOrderBook', 'maxRetries', 3);
@@ -1977,7 +1988,16 @@ class Exchange {
1977
1988
  throw new errors.NotSupported(this.id + ' setLeverage() is not supported yet');
1978
1989
  }
1979
1990
  async fetchLeverage(symbol, params = {}) {
1980
- 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
+ }
1998
+ }
1999
+ async fetchLeverages(symbols = undefined, params = {}) {
2000
+ throw new errors.NotSupported(this.id + ' fetchLeverages() is not supported yet');
1981
2001
  }
1982
2002
  async setPositionMode(hedged, symbol = undefined, params = {}) {
1983
2003
  throw new errors.NotSupported(this.id + ' setPositionMode() is not supported yet');
@@ -5558,6 +5578,36 @@ class Exchange {
5558
5578
  parseGreeks(greeks, market = undefined) {
5559
5579
  throw new errors.NotSupported(this.id + ' parseGreeks () is not supported yet');
5560
5580
  }
5581
+ parseMarginModes(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
5582
+ const marginModeStructures = {};
5583
+ for (let i = 0; i < response.length; i++) {
5584
+ const info = response[i];
5585
+ const marketId = this.safeString(info, symbolKey);
5586
+ const market = this.safeMarket(marketId, undefined, undefined, marketType);
5587
+ if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
5588
+ marginModeStructures[market['symbol']] = this.parseMarginMode(info, market);
5589
+ }
5590
+ }
5591
+ return marginModeStructures;
5592
+ }
5593
+ parseMarginMode(marginMode, market = undefined) {
5594
+ throw new errors.NotSupported(this.id + ' parseMarginMode () is not supported yet');
5595
+ }
5596
+ parseLeverages(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
5597
+ const leverageStructures = {};
5598
+ for (let i = 0; i < response.length; i++) {
5599
+ const info = response[i];
5600
+ const marketId = this.safeString(info, symbolKey);
5601
+ const market = this.safeMarket(marketId, undefined, undefined, marketType);
5602
+ if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
5603
+ leverageStructures[market['symbol']] = this.parseLeverage(info, market);
5604
+ }
5605
+ }
5606
+ return leverageStructures;
5607
+ }
5608
+ parseLeverage(leverage, market = undefined) {
5609
+ throw new errors.NotSupported(this.id + ' parseLeverage() is not supported yet');
5610
+ }
5561
5611
  }
5562
5612
 
5563
5613
  exports.Exchange = Exchange;
@@ -94,9 +94,12 @@ 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,
101
+ 'fetchMarginMode': 'emulated',
102
+ 'fetchMarginModes': true,
100
103
  'fetchMarketLeverageTiers': 'emulated',
101
104
  'fetchMarkets': true,
102
105
  'fetchMarkOHLCV': true,
@@ -10386,31 +10389,27 @@ class binance extends binance$1 {
10386
10389
  //
10387
10390
  return response;
10388
10391
  }
10389
- async fetchLeverage(symbol, params = {}) {
10392
+ async fetchLeverages(symbols = undefined, params = {}) {
10390
10393
  /**
10391
10394
  * @method
10392
- * @name binance#fetchLeverage
10393
- * @description fetch the set leverage for a market
10395
+ * @name binance#fetchLeverages
10396
+ * @description fetch the set leverage for all markets
10394
10397
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
10395
10398
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
10396
10399
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
10397
10400
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
10398
- * @param {string} symbol unified market symbol
10401
+ * @param {string[]} [symbols] a list of unified market symbols
10399
10402
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10400
- * @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}
10401
10404
  */
10402
10405
  await this.loadMarkets();
10403
10406
  await this.loadLeverageBrackets(false, params);
10404
- const market = this.market(symbol);
10405
- if (!market['contract']) {
10406
- throw new errors.NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
10407
- }
10408
10407
  let type = undefined;
10409
- [type, params] = this.handleMarketTypeAndParams('fetchLeverage', market, params);
10408
+ [type, params] = this.handleMarketTypeAndParams('fetchLeverages', undefined, params);
10410
10409
  let subType = undefined;
10411
- [subType, params] = this.handleSubTypeAndParams('fetchLeverage', market, params, 'linear');
10410
+ [subType, params] = this.handleSubTypeAndParams('fetchLeverages', undefined, params, 'linear');
10412
10411
  let isPortfolioMargin = undefined;
10413
- [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverage', 'papi', 'portfolioMargin', false);
10412
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverages', 'papi', 'portfolioMargin', false);
10414
10413
  let response = undefined;
10415
10414
  if (this.isLinear(type, subType)) {
10416
10415
  if (isPortfolioMargin) {
@@ -10429,23 +10428,39 @@ class binance extends binance$1 {
10429
10428
  }
10430
10429
  }
10431
10430
  else {
10432
- 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');
10433
10432
  }
10434
- const positions = this.safeList(response, 'positions', []);
10435
- for (let i = 0; i < positions.length; i++) {
10436
- const position = positions[i];
10437
- const innerSymbol = this.safeString(position, 'symbol');
10438
- if (innerSymbol === market['id']) {
10439
- const isolated = this.safeBool(position, 'isolated');
10440
- const marginMode = isolated ? 'isolated' : 'cross';
10441
- return {
10442
- 'info': position,
10443
- 'marginMode': marginMode,
10444
- 'leverage': this.safeInteger(position, 'leverage'),
10445
- };
10446
- }
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';
10447
10442
  }
10448
- 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
+ };
10449
10464
  }
10450
10465
  async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
10451
10466
  /**
@@ -12158,6 +12173,159 @@ class binance extends binance$1 {
12158
12173
  'hedged': dualSidePosition,
12159
12174
  };
12160
12175
  }
12176
+ async fetchMarginModes(symbols = undefined, params = {}) {
12177
+ /**
12178
+ * @method
12179
+ * @name binance#fetchMarginMode
12180
+ * @description fetches margin modes ("isolated" or "cross") that the market for the symbol in in, with symbol=undefined all markets for a subType (linear/inverse) are returned
12181
+ * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
12182
+ * @param {string} symbol unified symbol of the market the order was made in
12183
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
12184
+ * @returns {object} struct of marginMode
12185
+ */
12186
+ await this.loadMarkets();
12187
+ let market = undefined;
12188
+ if (symbols !== undefined) {
12189
+ symbols = this.marketSymbols(symbols);
12190
+ market = this.market(symbols[0]);
12191
+ }
12192
+ let subType = undefined;
12193
+ [subType, params] = this.handleSubTypeAndParams('fetchMarginMode', market, params);
12194
+ let response = undefined;
12195
+ if (subType === 'linear') {
12196
+ response = await this.fapiPrivateV2GetAccount(params);
12197
+ //
12198
+ // {
12199
+ // feeTier: '0',
12200
+ // canTrade: true,
12201
+ // canDeposit: true,
12202
+ // canWithdraw: true,
12203
+ // tradeGroupId: '-1',
12204
+ // updateTime: '0',
12205
+ // multiAssetsMargin: true,
12206
+ // totalInitialMargin: '438.31134352',
12207
+ // totalMaintMargin: '5.90847101',
12208
+ // totalWalletBalance: '4345.15626338',
12209
+ // totalUnrealizedProfit: '376.45220224',
12210
+ // totalMarginBalance: '4721.60846562',
12211
+ // totalPositionInitialMargin: '425.45252687',
12212
+ // totalOpenOrderInitialMargin: '12.85881664',
12213
+ // totalCrossWalletBalance: '4345.15626338',
12214
+ // totalCrossUnPnl: '376.45220224',
12215
+ // availableBalance: '4281.84764041',
12216
+ // maxWithdrawAmount: '4281.84764041',
12217
+ // assets: [
12218
+ // {
12219
+ // asset: 'ETH',
12220
+ // walletBalance: '0.00000000',
12221
+ // unrealizedProfit: '0.00000000',
12222
+ // marginBalance: '0.00000000',
12223
+ // maintMargin: '0.00000000',
12224
+ // initialMargin: '0.00000000',
12225
+ // positionInitialMargin: '0.00000000',
12226
+ // openOrderInitialMargin: '0.00000000',
12227
+ // maxWithdrawAmount: '0.00000000',
12228
+ // crossWalletBalance: '0.00000000',
12229
+ // crossUnPnl: '0.00000000',
12230
+ // availableBalance: '1.26075574',
12231
+ // marginAvailable: true,
12232
+ // updateTime: '0'
12233
+ // },
12234
+ // ...
12235
+ // ],
12236
+ // positions: [
12237
+ // {
12238
+ // symbol: 'SNTUSDT',
12239
+ // initialMargin: '0',
12240
+ // maintMargin: '0',
12241
+ // unrealizedProfit: '0.00000000',
12242
+ // positionInitialMargin: '0',
12243
+ // openOrderInitialMargin: '0',
12244
+ // leverage: '20',
12245
+ // isolated: false,
12246
+ // entryPrice: '0.0',
12247
+ // breakEvenPrice: '0.0',
12248
+ // maxNotional: '25000',
12249
+ // positionSide: 'BOTH',
12250
+ // positionAmt: '0',
12251
+ // notional: '0',
12252
+ // isolatedWallet: '0',
12253
+ // updateTime: '0',
12254
+ // bidNotional: '0',
12255
+ // askNotional: '0'
12256
+ // },
12257
+ // ...
12258
+ // ]
12259
+ // }
12260
+ //
12261
+ }
12262
+ else if (subType === 'inverse') {
12263
+ response = await this.dapiPrivateGetAccount(params);
12264
+ //
12265
+ // {
12266
+ // feeTier: '0',
12267
+ // canTrade: true,
12268
+ // canDeposit: true,
12269
+ // canWithdraw: true,
12270
+ // updateTime: '0',
12271
+ // assets: [
12272
+ // {
12273
+ // asset: 'APT',
12274
+ // walletBalance: '0.00000000',
12275
+ // unrealizedProfit: '0.00000000',
12276
+ // marginBalance: '0.00000000',
12277
+ // maintMargin: '0.00000000',
12278
+ // initialMargin: '0.00000000',
12279
+ // positionInitialMargin: '0.00000000',
12280
+ // openOrderInitialMargin: '0.00000000',
12281
+ // maxWithdrawAmount: '0.00000000',
12282
+ // crossWalletBalance: '0.00000000',
12283
+ // crossUnPnl: '0.00000000',
12284
+ // availableBalance: '0.00000000',
12285
+ // updateTime: '0'
12286
+ // },
12287
+ // ...
12288
+ // ],
12289
+ // positions: [
12290
+ // {
12291
+ // symbol: 'BCHUSD_240329',
12292
+ // initialMargin: '0',
12293
+ // maintMargin: '0',
12294
+ // unrealizedProfit: '0.00000000',
12295
+ // positionInitialMargin: '0',
12296
+ // openOrderInitialMargin: '0',
12297
+ // leverage: '20',
12298
+ // isolated: false,
12299
+ // positionSide: 'BOTH',
12300
+ // entryPrice: '0.00000000',
12301
+ // maxQty: '1000',
12302
+ // notionalValue: '0',
12303
+ // isolatedWallet: '0',
12304
+ // updateTime: '0',
12305
+ // positionAmt: '0',
12306
+ // breakEvenPrice: '0.00000000'
12307
+ // },
12308
+ // ...
12309
+ // ]
12310
+ // }
12311
+ //
12312
+ }
12313
+ else {
12314
+ throw new errors.BadRequest(this.id + ' fetchMarginModes () supports linear and inverse subTypes only');
12315
+ }
12316
+ const assets = this.safeValue(response, 'positions', []);
12317
+ return this.parseMarginModes(assets, symbols, 'symbol', 'swap');
12318
+ }
12319
+ parseMarginMode(marginMode, market = undefined) {
12320
+ const marketId = this.safeString(marginMode, 'symbol');
12321
+ market = this.safeMarket(marketId, market);
12322
+ const isIsolated = this.safeBool(marginMode, 'isolated');
12323
+ return {
12324
+ 'info': marginMode,
12325
+ 'symbol': market['symbol'],
12326
+ 'marginMode': isIsolated ? 'isolated' : 'cross',
12327
+ };
12328
+ }
12161
12329
  }
12162
12330
 
12163
12331
  module.exports = binance;
@@ -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
  /**