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
@@ -2943,7 +2943,7 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
2943
2943
  'loc': loc,
2944
2944
  };
2945
2945
  params = this.omit(params, ['loc', 'method']);
2946
- let response = undefined;
2946
+ let symbolTrades = undefined;
2947
2947
  if (method === 'marketPublicGetV1beta3CryptoLocTrades') {
2948
2948
  if (since !== undefined) {
2949
2949
  request['start'] = this.iso8601(since);
@@ -2951,47 +2951,48 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
2951
2951
  if (limit !== undefined) {
2952
2952
  request['limit'] = limit;
2953
2953
  }
2954
- response = await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(request, params));
2954
+ const response = await this.marketPublicGetV1beta3CryptoLocTrades(this.extend(request, params));
2955
+ //
2956
+ // {
2957
+ // "next_page_token": null,
2958
+ // "trades": {
2959
+ // "BTC/USD": [
2960
+ // {
2961
+ // "i": 36440704,
2962
+ // "p": 22625,
2963
+ // "s": 0.0001,
2964
+ // "t": "2022-07-21T11:47:31.073391Z",
2965
+ // "tks": "B"
2966
+ // }
2967
+ // ]
2968
+ // }
2969
+ // }
2970
+ //
2971
+ const trades = this.safeDict(response, 'trades', {});
2972
+ symbolTrades = this.safeList(trades, marketId, []);
2955
2973
  }
2956
2974
  else if (method === 'marketPublicGetV1beta3CryptoLocLatestTrades') {
2957
- response = await this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(request, params));
2975
+ const response = await this.marketPublicGetV1beta3CryptoLocLatestTrades(this.extend(request, params));
2976
+ //
2977
+ // {
2978
+ // "trades": {
2979
+ // "BTC/USD": {
2980
+ // "i": 36440704,
2981
+ // "p": 22625,
2982
+ // "s": 0.0001,
2983
+ // "t": "2022-07-21T11:47:31.073391Z",
2984
+ // "tks": "B"
2985
+ // }
2986
+ // }
2987
+ // }
2988
+ //
2989
+ const trades = this.safeDict(response, 'trades', {});
2990
+ symbolTrades = this.safeDict(trades, marketId, {});
2991
+ symbolTrades = [symbolTrades];
2958
2992
  }
2959
2993
  else {
2960
2994
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTrades() does not support ' + method + ', marketPublicGetV1beta3CryptoLocTrades and marketPublicGetV1beta3CryptoLocLatestTrades are supported');
2961
2995
  }
2962
- //
2963
- // {
2964
- // "next_page_token":null,
2965
- // "trades":{
2966
- // "BTC/USD":[
2967
- // {
2968
- // "i":36440704,
2969
- // "p":22625,
2970
- // "s":0.0001,
2971
- // "t":"2022-07-21T11:47:31.073391Z",
2972
- // "tks":"B"
2973
- // }
2974
- // ]
2975
- // }
2976
- // }
2977
- //
2978
- // {
2979
- // "trades":{
2980
- // "BTC/USD":{
2981
- // "i":36440704,
2982
- // "p":22625,
2983
- // "s":0.0001,
2984
- // "t":"2022-07-21T11:47:31.073391Z",
2985
- // "tks":"B"
2986
- // }
2987
- // }
2988
- // }
2989
- //
2990
- const trades = this.safeValue(response, 'trades', {});
2991
- let symbolTrades = this.safeValue(trades, marketId, {});
2992
- if (!Array.isArray(symbolTrades)) {
2993
- symbolTrades = [symbolTrades];
2994
- }
2995
2996
  return this.parseTrades(symbolTrades, market, since, limit);
2996
2997
  }
2997
2998
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
@@ -3083,7 +3084,7 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
3083
3084
  'loc': loc,
3084
3085
  };
3085
3086
  params = this.omit(params, ['loc', 'method']);
3086
- let response = undefined;
3087
+ let ohlcvs = undefined;
3087
3088
  if (method === 'marketPublicGetV1beta3CryptoLocBars') {
3088
3089
  if (limit !== undefined) {
3089
3090
  request['limit'] = limit;
@@ -3092,63 +3093,64 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
3092
3093
  request['start'] = this.yyyymmdd(since);
3093
3094
  }
3094
3095
  request['timeframe'] = this.safeString(this.timeframes, timeframe, timeframe);
3095
- response = await this.marketPublicGetV1beta3CryptoLocBars(this.extend(request, params));
3096
+ const response = await this.marketPublicGetV1beta3CryptoLocBars(this.extend(request, params));
3097
+ //
3098
+ // {
3099
+ // "bars": {
3100
+ // "BTC/USD": [
3101
+ // {
3102
+ // "c": 22887,
3103
+ // "h": 22888,
3104
+ // "l": 22873,
3105
+ // "n": 11,
3106
+ // "o": 22883,
3107
+ // "t": "2022-07-21T05:00:00Z",
3108
+ // "v": 1.1138,
3109
+ // "vw": 22883.0155324116
3110
+ // },
3111
+ // {
3112
+ // "c": 22895,
3113
+ // "h": 22895,
3114
+ // "l": 22884,
3115
+ // "n": 6,
3116
+ // "o": 22884,
3117
+ // "t": "2022-07-21T05:01:00Z",
3118
+ // "v": 0.001,
3119
+ // "vw": 22889.5
3120
+ // }
3121
+ // ]
3122
+ // },
3123
+ // "next_page_token": "QlRDL1VTRHxNfDIwMjItMDctMjFUMDU6MDE6MDAuMDAwMDAwMDAwWg=="
3124
+ // }
3125
+ //
3126
+ const bars = this.safeDict(response, 'bars', {});
3127
+ ohlcvs = this.safeList(bars, marketId, []);
3096
3128
  }
3097
3129
  else if (method === 'marketPublicGetV1beta3CryptoLocLatestBars') {
3098
- response = await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(request, params));
3130
+ const response = await this.marketPublicGetV1beta3CryptoLocLatestBars(this.extend(request, params));
3131
+ //
3132
+ // {
3133
+ // "bars": {
3134
+ // "BTC/USD": {
3135
+ // "c": 22887,
3136
+ // "h": 22888,
3137
+ // "l": 22873,
3138
+ // "n": 11,
3139
+ // "o": 22883,
3140
+ // "t": "2022-07-21T05:00:00Z",
3141
+ // "v": 1.1138,
3142
+ // "vw": 22883.0155324116
3143
+ // }
3144
+ // }
3145
+ // }
3146
+ //
3147
+ const bars = this.safeDict(response, 'bars', {});
3148
+ ohlcvs = this.safeDict(bars, marketId, {});
3149
+ ohlcvs = [ohlcvs];
3099
3150
  }
3100
3151
  else {
3101
3152
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOHLCV() does not support ' + method + ', marketPublicGetV1beta3CryptoLocBars and marketPublicGetV1beta3CryptoLocLatestBars are supported');
3102
3153
  }
3103
- //
3104
- // {
3105
- // "bars":{
3106
- // "BTC/USD":[
3107
- // {
3108
- // "c":22887,
3109
- // "h":22888,
3110
- // "l":22873,
3111
- // "n":11,
3112
- // "o":22883,
3113
- // "t":"2022-07-21T05:00:00Z",
3114
- // "v":1.1138,
3115
- // "vw":22883.0155324116
3116
- // },
3117
- // {
3118
- // "c":22895,
3119
- // "h":22895,
3120
- // "l":22884,
3121
- // "n":6,
3122
- // "o":22884,
3123
- // "t":"2022-07-21T05:01:00Z",
3124
- // "v":0.001,
3125
- // "vw":22889.5
3126
- // }
3127
- // ]
3128
- // },
3129
- // "next_page_token":"QlRDL1VTRHxNfDIwMjItMDctMjFUMDU6MDE6MDAuMDAwMDAwMDAwWg=="
3130
- // }
3131
- //
3132
- // {
3133
- // "bars":{
3134
- // "BTC/USD":{
3135
- // "c":22887,
3136
- // "h":22888,
3137
- // "l":22873,
3138
- // "n":11,
3139
- // "o":22883,
3140
- // "t":"2022-07-21T05:00:00Z",
3141
- // "v":1.1138,
3142
- // "vw":22883.0155324116
3143
- // }
3144
- // }
3145
- // }
3146
- //
3147
- const bars = this.safeValue(response, 'bars', {});
3148
- let ohlcvs = this.safeValue(bars, marketId, {});
3149
- if (!Array.isArray(ohlcvs)) {
3150
- ohlcvs = [ohlcvs];
3151
- }
3152
3154
  return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
3153
3155
  }
3154
3156
  parseOHLCV(ohlcv, market = undefined) {
@@ -7451,9 +7453,11 @@ class Exchange {
7451
7453
  'fetchLedger': undefined,
7452
7454
  'fetchLedgerEntry': undefined,
7453
7455
  'fetchLeverage': undefined,
7456
+ 'fetchLeverages': undefined,
7454
7457
  'fetchLeverageTiers': undefined,
7455
7458
  'fetchLiquidations': undefined,
7456
7459
  'fetchMarginMode': undefined,
7460
+ 'fetchMarginModes': undefined,
7457
7461
  'fetchMarketLeverageTiers': undefined,
7458
7462
  'fetchMarkets': true,
7459
7463
  'fetchMarketsWs': undefined,
@@ -8884,8 +8888,17 @@ class Exchange {
8884
8888
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
8885
8889
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchOrderBook() is not supported yet');
8886
8890
  }
8887
- async fetchMarginMode(symbol = undefined, params = {}) {
8888
- throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchMarginMode() is not supported yet');
8891
+ async fetchMarginMode(symbol, params = {}) {
8892
+ if (this.has['fetchMarginModes']) {
8893
+ const marginModes = await this.fetchMarginModes([symbol], params);
8894
+ return this.safeDict(marginModes, symbol);
8895
+ }
8896
+ else {
8897
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchMarginMode() is not supported yet');
8898
+ }
8899
+ }
8900
+ async fetchMarginModes(symbols = undefined, params = {}) {
8901
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchMarginModes () is not supported yet');
8889
8902
  }
8890
8903
  async fetchRestOrderBookSafe(symbol, limit = undefined, params = {}) {
8891
8904
  const fetchSnapshotMaxRetries = this.handleOption('watchOrderBook', 'maxRetries', 3);
@@ -8994,7 +9007,16 @@ class Exchange {
8994
9007
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' setLeverage() is not supported yet');
8995
9008
  }
8996
9009
  async fetchLeverage(symbol, params = {}) {
8997
- throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchLeverage() is not supported yet');
9010
+ if (this.has['fetchLeverages']) {
9011
+ const leverages = await this.fetchLeverages([symbol], params);
9012
+ return this.safeDict(leverages, symbol);
9013
+ }
9014
+ else {
9015
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchLeverage() is not supported yet');
9016
+ }
9017
+ }
9018
+ async fetchLeverages(symbols = undefined, params = {}) {
9019
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchLeverages() is not supported yet');
8998
9020
  }
8999
9021
  async setPositionMode(hedged, symbol = undefined, params = {}) {
9000
9022
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' setPositionMode() is not supported yet');
@@ -12575,6 +12597,36 @@ class Exchange {
12575
12597
  parseGreeks(greeks, market = undefined) {
12576
12598
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseGreeks () is not supported yet');
12577
12599
  }
12600
+ parseMarginModes(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
12601
+ const marginModeStructures = {};
12602
+ for (let i = 0; i < response.length; i++) {
12603
+ const info = response[i];
12604
+ const marketId = this.safeString(info, symbolKey);
12605
+ const market = this.safeMarket(marketId, undefined, undefined, marketType);
12606
+ if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
12607
+ marginModeStructures[market['symbol']] = this.parseMarginMode(info, market);
12608
+ }
12609
+ }
12610
+ return marginModeStructures;
12611
+ }
12612
+ parseMarginMode(marginMode, market = undefined) {
12613
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseMarginMode () is not supported yet');
12614
+ }
12615
+ parseLeverages(response, symbols = undefined, symbolKey = undefined, marketType = undefined) {
12616
+ const leverageStructures = {};
12617
+ for (let i = 0; i < response.length; i++) {
12618
+ const info = response[i];
12619
+ const marketId = this.safeString(info, symbolKey);
12620
+ const market = this.safeMarket(marketId, undefined, undefined, marketType);
12621
+ if ((symbols === undefined) || this.inArray(market['symbol'], symbols)) {
12622
+ leverageStructures[market['symbol']] = this.parseLeverage(info, market);
12623
+ }
12624
+ }
12625
+ return leverageStructures;
12626
+ }
12627
+ parseLeverage(leverage, market = undefined) {
12628
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseLeverage() is not supported yet');
12629
+ }
12578
12630
  }
12579
12631
 
12580
12632
 
@@ -18180,9 +18232,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18180
18232
  'fetchLastPrices': true,
18181
18233
  'fetchLedger': true,
18182
18234
  'fetchLedgerEntry': true,
18183
- 'fetchLeverage': true,
18235
+ 'fetchLeverage': 'emulated',
18236
+ 'fetchLeverages': true,
18184
18237
  'fetchLeverageTiers': true,
18185
18238
  'fetchLiquidations': false,
18239
+ 'fetchMarginMode': 'emulated',
18240
+ 'fetchMarginModes': true,
18186
18241
  'fetchMarketLeverageTiers': 'emulated',
18187
18242
  'fetchMarkets': true,
18188
18243
  'fetchMarkOHLCV': true,
@@ -28472,31 +28527,27 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28472
28527
  //
28473
28528
  return response;
28474
28529
  }
28475
- async fetchLeverage(symbol, params = {}) {
28530
+ async fetchLeverages(symbols = undefined, params = {}) {
28476
28531
  /**
28477
28532
  * @method
28478
- * @name binance#fetchLeverage
28479
- * @description fetch the set leverage for a market
28533
+ * @name binance#fetchLeverages
28534
+ * @description fetch the set leverage for all markets
28480
28535
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
28481
28536
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
28482
28537
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
28483
28538
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
28484
- * @param {string} symbol unified market symbol
28539
+ * @param {string[]} [symbols] a list of unified market symbols
28485
28540
  * @param {object} [params] extra parameters specific to the exchange API endpoint
28486
- * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
28541
+ * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
28487
28542
  */
28488
28543
  await this.loadMarkets();
28489
28544
  await this.loadLeverageBrackets(false, params);
28490
- const market = this.market(symbol);
28491
- if (!market['contract']) {
28492
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
28493
- }
28494
28545
  let type = undefined;
28495
- [type, params] = this.handleMarketTypeAndParams('fetchLeverage', market, params);
28546
+ [type, params] = this.handleMarketTypeAndParams('fetchLeverages', undefined, params);
28496
28547
  let subType = undefined;
28497
- [subType, params] = this.handleSubTypeAndParams('fetchLeverage', market, params, 'linear');
28548
+ [subType, params] = this.handleSubTypeAndParams('fetchLeverages', undefined, params, 'linear');
28498
28549
  let isPortfolioMargin = undefined;
28499
- [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverage', 'papi', 'portfolioMargin', false);
28550
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverages', 'papi', 'portfolioMargin', false);
28500
28551
  let response = undefined;
28501
28552
  if (this.isLinear(type, subType)) {
28502
28553
  if (isPortfolioMargin) {
@@ -28515,23 +28566,39 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28515
28566
  }
28516
28567
  }
28517
28568
  else {
28518
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPositions() supports linear and inverse contracts only');
28569
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverages() supports linear and inverse contracts only');
28519
28570
  }
28520
- const positions = this.safeList(response, 'positions', []);
28521
- for (let i = 0; i < positions.length; i++) {
28522
- const position = positions[i];
28523
- const innerSymbol = this.safeString(position, 'symbol');
28524
- if (innerSymbol === market['id']) {
28525
- const isolated = this.safeBool(position, 'isolated');
28526
- const marginMode = isolated ? 'isolated' : 'cross';
28527
- return {
28528
- 'info': position,
28529
- 'marginMode': marginMode,
28530
- 'leverage': this.safeInteger(position, 'leverage'),
28531
- };
28532
- }
28571
+ const leverages = this.safeList(response, 'positions', []);
28572
+ return this.parseLeverages(leverages, symbols, 'symbol');
28573
+ }
28574
+ parseLeverage(leverage, market = undefined) {
28575
+ const marketId = this.safeString(leverage, 'symbol');
28576
+ const marginModeRaw = this.safeBool(leverage, 'isolated');
28577
+ let marginMode = undefined;
28578
+ if (marginModeRaw !== undefined) {
28579
+ marginMode = marginModeRaw ? 'isolated' : 'cross';
28533
28580
  }
28534
- return response;
28581
+ const side = this.safeStringLower(leverage, 'positionSide');
28582
+ let longLeverage = undefined;
28583
+ let shortLeverage = undefined;
28584
+ const leverageValue = this.safeInteger(leverage, 'leverage');
28585
+ if (side === 'both') {
28586
+ longLeverage = leverageValue;
28587
+ shortLeverage = leverageValue;
28588
+ }
28589
+ else if (side === 'long') {
28590
+ longLeverage = leverageValue;
28591
+ }
28592
+ else if (side === 'short') {
28593
+ shortLeverage = leverageValue;
28594
+ }
28595
+ return {
28596
+ 'info': leverage,
28597
+ 'symbol': this.safeSymbol(marketId, market),
28598
+ 'marginMode': marginMode,
28599
+ 'longLeverage': longLeverage,
28600
+ 'shortLeverage': shortLeverage,
28601
+ };
28535
28602
  }
28536
28603
  async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
28537
28604
  /**
@@ -30244,6 +30311,159 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
30244
30311
  'hedged': dualSidePosition,
30245
30312
  };
30246
30313
  }
30314
+ async fetchMarginModes(symbols = undefined, params = {}) {
30315
+ /**
30316
+ * @method
30317
+ * @name binance#fetchMarginMode
30318
+ * @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
30319
+ * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
30320
+ * @param {string} symbol unified symbol of the market the order was made in
30321
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
30322
+ * @returns {object} struct of marginMode
30323
+ */
30324
+ await this.loadMarkets();
30325
+ let market = undefined;
30326
+ if (symbols !== undefined) {
30327
+ symbols = this.marketSymbols(symbols);
30328
+ market = this.market(symbols[0]);
30329
+ }
30330
+ let subType = undefined;
30331
+ [subType, params] = this.handleSubTypeAndParams('fetchMarginMode', market, params);
30332
+ let response = undefined;
30333
+ if (subType === 'linear') {
30334
+ response = await this.fapiPrivateV2GetAccount(params);
30335
+ //
30336
+ // {
30337
+ // feeTier: '0',
30338
+ // canTrade: true,
30339
+ // canDeposit: true,
30340
+ // canWithdraw: true,
30341
+ // tradeGroupId: '-1',
30342
+ // updateTime: '0',
30343
+ // multiAssetsMargin: true,
30344
+ // totalInitialMargin: '438.31134352',
30345
+ // totalMaintMargin: '5.90847101',
30346
+ // totalWalletBalance: '4345.15626338',
30347
+ // totalUnrealizedProfit: '376.45220224',
30348
+ // totalMarginBalance: '4721.60846562',
30349
+ // totalPositionInitialMargin: '425.45252687',
30350
+ // totalOpenOrderInitialMargin: '12.85881664',
30351
+ // totalCrossWalletBalance: '4345.15626338',
30352
+ // totalCrossUnPnl: '376.45220224',
30353
+ // availableBalance: '4281.84764041',
30354
+ // maxWithdrawAmount: '4281.84764041',
30355
+ // assets: [
30356
+ // {
30357
+ // asset: 'ETH',
30358
+ // walletBalance: '0.00000000',
30359
+ // unrealizedProfit: '0.00000000',
30360
+ // marginBalance: '0.00000000',
30361
+ // maintMargin: '0.00000000',
30362
+ // initialMargin: '0.00000000',
30363
+ // positionInitialMargin: '0.00000000',
30364
+ // openOrderInitialMargin: '0.00000000',
30365
+ // maxWithdrawAmount: '0.00000000',
30366
+ // crossWalletBalance: '0.00000000',
30367
+ // crossUnPnl: '0.00000000',
30368
+ // availableBalance: '1.26075574',
30369
+ // marginAvailable: true,
30370
+ // updateTime: '0'
30371
+ // },
30372
+ // ...
30373
+ // ],
30374
+ // positions: [
30375
+ // {
30376
+ // symbol: 'SNTUSDT',
30377
+ // initialMargin: '0',
30378
+ // maintMargin: '0',
30379
+ // unrealizedProfit: '0.00000000',
30380
+ // positionInitialMargin: '0',
30381
+ // openOrderInitialMargin: '0',
30382
+ // leverage: '20',
30383
+ // isolated: false,
30384
+ // entryPrice: '0.0',
30385
+ // breakEvenPrice: '0.0',
30386
+ // maxNotional: '25000',
30387
+ // positionSide: 'BOTH',
30388
+ // positionAmt: '0',
30389
+ // notional: '0',
30390
+ // isolatedWallet: '0',
30391
+ // updateTime: '0',
30392
+ // bidNotional: '0',
30393
+ // askNotional: '0'
30394
+ // },
30395
+ // ...
30396
+ // ]
30397
+ // }
30398
+ //
30399
+ }
30400
+ else if (subType === 'inverse') {
30401
+ response = await this.dapiPrivateGetAccount(params);
30402
+ //
30403
+ // {
30404
+ // feeTier: '0',
30405
+ // canTrade: true,
30406
+ // canDeposit: true,
30407
+ // canWithdraw: true,
30408
+ // updateTime: '0',
30409
+ // assets: [
30410
+ // {
30411
+ // asset: 'APT',
30412
+ // walletBalance: '0.00000000',
30413
+ // unrealizedProfit: '0.00000000',
30414
+ // marginBalance: '0.00000000',
30415
+ // maintMargin: '0.00000000',
30416
+ // initialMargin: '0.00000000',
30417
+ // positionInitialMargin: '0.00000000',
30418
+ // openOrderInitialMargin: '0.00000000',
30419
+ // maxWithdrawAmount: '0.00000000',
30420
+ // crossWalletBalance: '0.00000000',
30421
+ // crossUnPnl: '0.00000000',
30422
+ // availableBalance: '0.00000000',
30423
+ // updateTime: '0'
30424
+ // },
30425
+ // ...
30426
+ // ],
30427
+ // positions: [
30428
+ // {
30429
+ // symbol: 'BCHUSD_240329',
30430
+ // initialMargin: '0',
30431
+ // maintMargin: '0',
30432
+ // unrealizedProfit: '0.00000000',
30433
+ // positionInitialMargin: '0',
30434
+ // openOrderInitialMargin: '0',
30435
+ // leverage: '20',
30436
+ // isolated: false,
30437
+ // positionSide: 'BOTH',
30438
+ // entryPrice: '0.00000000',
30439
+ // maxQty: '1000',
30440
+ // notionalValue: '0',
30441
+ // isolatedWallet: '0',
30442
+ // updateTime: '0',
30443
+ // positionAmt: '0',
30444
+ // breakEvenPrice: '0.00000000'
30445
+ // },
30446
+ // ...
30447
+ // ]
30448
+ // }
30449
+ //
30450
+ }
30451
+ else {
30452
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchMarginModes () supports linear and inverse subTypes only');
30453
+ }
30454
+ const assets = this.safeValue(response, 'positions', []);
30455
+ return this.parseMarginModes(assets, symbols, 'symbol', 'swap');
30456
+ }
30457
+ parseMarginMode(marginMode, market = undefined) {
30458
+ const marketId = this.safeString(marginMode, 'symbol');
30459
+ market = this.safeMarket(marketId, market);
30460
+ const isIsolated = this.safeBool(marginMode, 'isolated');
30461
+ return {
30462
+ 'info': marginMode,
30463
+ 'symbol': market['symbol'],
30464
+ 'marginMode': isIsolated ? 'isolated' : 'cross',
30465
+ };
30466
+ }
30247
30467
  }
30248
30468
 
30249
30469
 
@@ -34088,7 +34308,18 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34088
34308
  // }
34089
34309
  // }
34090
34310
  //
34091
- return response;
34311
+ const data = this.safeDict(response, 'data', {});
34312
+ return this.parseLeverage(data, market);
34313
+ }
34314
+ parseLeverage(leverage, market = undefined) {
34315
+ const marketId = this.safeString(leverage, 'symbol');
34316
+ return {
34317
+ 'info': leverage,
34318
+ 'symbol': this.safeSymbol(marketId, market),
34319
+ 'marginMode': undefined,
34320
+ 'longLeverage': this.safeInteger(leverage, 'longLeverage'),
34321
+ 'shortLeverage': this.safeInteger(leverage, 'shortLeverage'),
34322
+ };
34092
34323
  }
34093
34324
  async setLeverage(leverage, symbol = undefined, params = {}) {
34094
34325
  /**
@@ -45948,7 +46179,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45948
46179
  let defaultProductType = undefined;
45949
46180
  if ((subType !== undefined) && (market === undefined)) {
45950
46181
  // set default only if subType is defined and market is not defined, since there is also USDC productTypes which are also linear
45951
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
46182
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
45952
46183
  if (sandboxMode) {
45953
46184
  defaultProductType = (subType === 'linear') ? 'SUSDT-FUTURES' : 'SCOIN-FUTURES';
45954
46185
  }
@@ -46017,7 +46248,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
46017
46248
  * @param {object} [params] extra parameters specific to the exchange API endpoint
46018
46249
  * @returns {object[]} an array of objects representing market data
46019
46250
  */
46020
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
46251
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
46021
46252
  let types = this.safeValue(this.options, 'fetchMarkets', ['spot', 'swap']);
46022
46253
  if (sandboxMode) {
46023
46254
  types = ['swap'];
@@ -46472,7 +46703,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
46472
46703
  * @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}
46473
46704
  */
46474
46705
  await this.loadMarkets();
46475
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
46706
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
46476
46707
  let market = undefined;
46477
46708
  if (sandboxMode) {
46478
46709
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -47008,7 +47239,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47008
47239
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
47009
47240
  */
47010
47241
  await this.loadMarkets();
47011
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
47242
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
47012
47243
  let market = undefined;
47013
47244
  if (sandboxMode) {
47014
47245
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -47171,7 +47402,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47171
47402
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
47172
47403
  */
47173
47404
  await this.loadMarkets();
47174
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
47405
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
47175
47406
  let market = undefined;
47176
47407
  if (sandboxMode) {
47177
47408
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -47275,7 +47506,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47275
47506
  let market = undefined;
47276
47507
  if (symbols !== undefined) {
47277
47508
  const symbol = this.safeValue(symbols, 0);
47278
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
47509
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
47279
47510
  if (sandboxMode) {
47280
47511
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
47281
47512
  market = this.market(sandboxSymbol);
@@ -47493,7 +47724,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47493
47724
  if (paginate) {
47494
47725
  return await this.fetchPaginatedCallCursor('fetchTrades', symbol, since, limit, params, 'idLessThan', 'idLessThan');
47495
47726
  }
47496
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
47727
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
47497
47728
  let market = undefined;
47498
47729
  if (sandboxMode) {
47499
47730
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -47812,7 +48043,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47812
48043
  if (paginate) {
47813
48044
  return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
47814
48045
  }
47815
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
48046
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
47816
48047
  let market = undefined;
47817
48048
  if (sandboxMode) {
47818
48049
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -48632,7 +48863,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
48632
48863
  return this.parseOrder(data, market);
48633
48864
  }
48634
48865
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
48635
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
48866
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
48636
48867
  let market = undefined;
48637
48868
  if (sandboxMode) {
48638
48869
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -48903,7 +49134,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
48903
49134
  const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
48904
49135
  ordersRequests.push(orderRequest);
48905
49136
  }
48906
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49137
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
48907
49138
  let market = undefined;
48908
49139
  if (sandboxMode) {
48909
49140
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49000,7 +49231,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49000
49231
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
49001
49232
  */
49002
49233
  await this.loadMarkets();
49003
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49234
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49004
49235
  let market = undefined;
49005
49236
  if (sandboxMode) {
49006
49237
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49166,7 +49397,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49166
49397
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
49167
49398
  }
49168
49399
  await this.loadMarkets();
49169
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49400
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49170
49401
  let market = undefined;
49171
49402
  if (sandboxMode) {
49172
49403
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49306,7 +49537,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49306
49537
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
49307
49538
  }
49308
49539
  await this.loadMarkets();
49309
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49540
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49310
49541
  let market = undefined;
49311
49542
  if (sandboxMode) {
49312
49543
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49400,7 +49631,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49400
49631
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
49401
49632
  }
49402
49633
  await this.loadMarkets();
49403
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49634
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49404
49635
  let market = undefined;
49405
49636
  if (sandboxMode) {
49406
49637
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49504,7 +49735,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49504
49735
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
49505
49736
  }
49506
49737
  await this.loadMarkets();
49507
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49738
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49508
49739
  let market = undefined;
49509
49740
  if (sandboxMode) {
49510
49741
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49620,7 +49851,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49620
49851
  * @param {int} [limit] the maximum number of open order structures to retrieve
49621
49852
  * @param {object} [params] extra parameters specific to the exchange API endpoint
49622
49853
  * @param {int} [params.until] the latest time in ms to fetch orders for
49623
- * @param {string} [params.planType] *contract stop only* 'normal_plan': average trigger order, 'track_plan': trailing stop order, default is 'normal_plan'
49854
+ * @param {string} [params.planType] *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
49624
49855
  * @param {boolean} [params.stop] set to true for fetching trigger orders
49625
49856
  * @param {boolean} [params.paginate] 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)
49626
49857
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
@@ -49628,7 +49859,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49628
49859
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
49629
49860
  */
49630
49861
  await this.loadMarkets();
49631
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49862
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49632
49863
  let market = undefined;
49633
49864
  let type = undefined;
49634
49865
  let request = {};
@@ -49666,8 +49897,10 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49666
49897
  return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
49667
49898
  }
49668
49899
  let response = undefined;
49669
- const trailing = this.safeValue(params, 'trailing');
49670
- const stop = this.safeValue2(params, 'stop', 'trigger');
49900
+ const trailing = this.safeBool(params, 'trailing');
49901
+ const stop = this.safeBool2(params, 'stop', 'trigger');
49902
+ const planTypeDefined = this.safeString(params, 'planType') !== undefined;
49903
+ const isStop = (stop || planTypeDefined);
49671
49904
  params = this.omit(params, ['stop', 'trigger', 'trailing']);
49672
49905
  [request, params] = this.handleUntilOption('endTime', request, params);
49673
49906
  if (since !== undefined) {
@@ -49716,7 +49949,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49716
49949
  request['planType'] = planType;
49717
49950
  response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
49718
49951
  }
49719
- else if (stop) {
49952
+ else if (isStop) {
49720
49953
  const planType = this.safeString(query, 'planType', 'normal_plan');
49721
49954
  request['planType'] = planType;
49722
49955
  response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
@@ -49983,7 +50216,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49983
50216
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
49984
50217
  */
49985
50218
  await this.loadMarkets();
49986
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
50219
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49987
50220
  let market = undefined;
49988
50221
  if (sandboxMode) {
49989
50222
  if (symbol !== undefined) {
@@ -50016,7 +50249,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
50016
50249
  }
50017
50250
  let response = undefined;
50018
50251
  const trailing = this.safeValue(params, 'trailing');
50019
- const stop = this.safeValue2(params, 'stop', 'trigger');
50252
+ const stop = this.safeBool2(params, 'stop', 'trigger');
50020
50253
  params = this.omit(params, ['stop', 'trigger', 'trailing']);
50021
50254
  [request, params] = this.handleUntilOption('endTime', request, params);
50022
50255
  if (since !== undefined) {
@@ -50300,7 +50533,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
50300
50533
  params = this.omit(params, 'symbol');
50301
50534
  let market = undefined;
50302
50535
  if (symbol !== undefined) {
50303
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
50536
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
50304
50537
  if (sandboxMode) {
50305
50538
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
50306
50539
  market = this.market(sandboxSymbol);
@@ -50520,7 +50753,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
50520
50753
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
50521
50754
  }
50522
50755
  await this.loadMarkets();
50523
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
50756
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
50524
50757
  let market = undefined;
50525
50758
  if (sandboxMode) {
50526
50759
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -50699,7 +50932,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
50699
50932
  * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
50700
50933
  */
50701
50934
  await this.loadMarkets();
50702
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
50935
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
50703
50936
  let market = undefined;
50704
50937
  if (sandboxMode) {
50705
50938
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -50775,7 +51008,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
50775
51008
  let market = undefined;
50776
51009
  if (symbols !== undefined) {
50777
51010
  const first = this.safeString(symbols, 0);
50778
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51011
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
50779
51012
  if (sandboxMode) {
50780
51013
  const sandboxSymbol = this.convertSymbolForSandbox(first);
50781
51014
  market = this.market(sandboxSymbol);
@@ -51095,7 +51328,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51095
51328
  if (paginate) {
51096
51329
  return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'pageNo', 100);
51097
51330
  }
51098
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51331
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51099
51332
  let market = undefined;
51100
51333
  if (sandboxMode) {
51101
51334
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51159,7 +51392,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51159
51392
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
51160
51393
  */
51161
51394
  await this.loadMarkets();
51162
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51395
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51163
51396
  let market = undefined;
51164
51397
  if (sandboxMode) {
51165
51398
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51246,7 +51479,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51246
51479
  if (paginate) {
51247
51480
  return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'endId', 'idLessThan');
51248
51481
  }
51249
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51482
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51250
51483
  let market = undefined;
51251
51484
  if (sandboxMode) {
51252
51485
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51342,7 +51575,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51342
51575
  async modifyMarginHelper(symbol, amount, type, params = {}) {
51343
51576
  await this.loadMarkets();
51344
51577
  const holdSide = this.safeString(params, 'holdSide');
51345
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51578
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51346
51579
  let market = undefined;
51347
51580
  if (sandboxMode) {
51348
51581
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51435,7 +51668,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51435
51668
  * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
51436
51669
  */
51437
51670
  await this.loadMarkets();
51438
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51671
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51439
51672
  let market = undefined;
51440
51673
  if (sandboxMode) {
51441
51674
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51456,28 +51689,41 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51456
51689
  // {
51457
51690
  // "code": "00000",
51458
51691
  // "msg": "success",
51459
- // "requestTime": 1700625127294,
51460
- // "data": [
51461
- // {
51462
- // "marginCoin": "USDT",
51463
- // "locked": "0",
51464
- // "available": "0",
51465
- // "crossedMaxAvailable": "0",
51466
- // "isolatedMaxAvailable": "0",
51467
- // "maxTransferOut": "0",
51468
- // "accountEquity": "0",
51469
- // "usdtEquity": "0.000000005166",
51470
- // "btcEquity": "0",
51471
- // "crossedRiskRate": "0",
51472
- // "unrealizedPL": "0",
51473
- // "coupon": "0",
51474
- // "crossedUnrealizedPL": null,
51475
- // "isolatedUnrealizedPL": null
51476
- // }
51477
- // ]
51692
+ // "requestTime": 1709366911964,
51693
+ // "data": {
51694
+ // "marginCoin": "USDT",
51695
+ // "locked": "0",
51696
+ // "available": "0",
51697
+ // "crossedMaxAvailable": "0",
51698
+ // "isolatedMaxAvailable": "0",
51699
+ // "maxTransferOut": "0",
51700
+ // "accountEquity": "0",
51701
+ // "usdtEquity": "0.000000009166",
51702
+ // "btcEquity": "0",
51703
+ // "crossedRiskRate": "0",
51704
+ // "crossedMarginLeverage": 20,
51705
+ // "isolatedLongLever": 20,
51706
+ // "isolatedShortLever": 20,
51707
+ // "marginMode": "crossed",
51708
+ // "posMode": "hedge_mode",
51709
+ // "unrealizedPL": "0",
51710
+ // "coupon": "0",
51711
+ // "crossedUnrealizedPL": "0",
51712
+ // "isolatedUnrealizedPL": ""
51713
+ // }
51478
51714
  // }
51479
51715
  //
51480
- return response;
51716
+ const data = this.safeDict(response, 'data', {});
51717
+ return this.parseLeverage(data, market);
51718
+ }
51719
+ parseLeverage(leverage, market = undefined) {
51720
+ return {
51721
+ 'info': leverage,
51722
+ 'symbol': market['symbol'],
51723
+ 'marginMode': 'isolated',
51724
+ 'longLeverage': this.safeInteger(leverage, 'isolatedLongLever'),
51725
+ 'shortLeverage': this.safeInteger(leverage, 'isolatedShortLever'),
51726
+ };
51481
51727
  }
51482
51728
  async setLeverage(leverage, symbol = undefined, params = {}) {
51483
51729
  /**
@@ -51495,7 +51741,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51495
51741
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
51496
51742
  }
51497
51743
  await this.loadMarkets();
51498
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51744
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51499
51745
  let market = undefined;
51500
51746
  if (sandboxMode) {
51501
51747
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51553,7 +51799,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51553
51799
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' setMarginMode() marginMode must be either isolated or crossed (cross)');
51554
51800
  }
51555
51801
  await this.loadMarkets();
51556
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51802
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51557
51803
  let market = undefined;
51558
51804
  if (sandboxMode) {
51559
51805
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51603,7 +51849,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51603
51849
  const posMode = hedged ? 'hedge_mode' : 'one_way_mode';
51604
51850
  let market = undefined;
51605
51851
  if (symbol !== undefined) {
51606
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51852
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51607
51853
  if (sandboxMode) {
51608
51854
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
51609
51855
  market = this.market(sandboxSymbol);
@@ -51642,7 +51888,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51642
51888
  * @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
51643
51889
  */
51644
51890
  await this.loadMarkets();
51645
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51891
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51646
51892
  let market = undefined;
51647
51893
  if (sandboxMode) {
51648
51894
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -52676,7 +52922,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
52676
52922
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
52677
52923
  */
52678
52924
  await this.loadMarkets();
52679
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
52925
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
52680
52926
  let market = undefined;
52681
52927
  if (sandboxMode) {
52682
52928
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -58531,7 +58777,8 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
58531
58777
  'fetchFundingRates': true,
58532
58778
  'fetchIndexOHLCV': false,
58533
58779
  'fetchLedger': true,
58534
- 'fetchLeverage': false,
58780
+ 'fetchLeverage': 'emulated',
58781
+ 'fetchLeverages': true,
58535
58782
  'fetchLeverageTiers': false,
58536
58783
  'fetchLiquidations': true,
58537
58784
  'fetchMarketLeverageTiers': false,
@@ -60586,6 +60833,30 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
60586
60833
  //
60587
60834
  return this.parseOrders(response, market);
60588
60835
  }
60836
+ async fetchLeverages(symbols = undefined, params = {}) {
60837
+ /**
60838
+ * @method
60839
+ * @name bitmex#fetchLeverages
60840
+ * @description fetch the set leverage for all contract markets
60841
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
60842
+ * @param {string[]} [symbols] a list of unified market symbols
60843
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
60844
+ * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
60845
+ */
60846
+ await this.loadMarkets();
60847
+ const leverages = await this.fetchPositions(symbols, params);
60848
+ return this.parseLeverages(leverages, symbols, 'symbol');
60849
+ }
60850
+ parseLeverage(leverage, market = undefined) {
60851
+ const marketId = this.safeString(leverage, 'symbol');
60852
+ return {
60853
+ 'info': leverage,
60854
+ 'symbol': this.safeSymbol(marketId, market),
60855
+ 'marginMode': this.safeStringLower(leverage, 'marginMode'),
60856
+ 'longLeverage': this.safeInteger(leverage, 'leverage'),
60857
+ 'shortLeverage': this.safeInteger(leverage, 'leverage'),
60858
+ };
60859
+ }
60589
60860
  async fetchPositions(symbols = undefined, params = {}) {
60590
60861
  /**
60591
60862
  * @method
@@ -65744,20 +66015,29 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
65744
66015
  }
65745
66016
  const response = await this.spotV1PrivateGetWithdrawHistory(this.extend(request, params));
65746
66017
  //
65747
- // {
65748
- // "code": 200,
65749
- // "msg": "succ",
65750
- // "data": {
65751
- // "msg": null,
65752
- // "amount": 1000,
65753
- // "fee": 1,
65754
- // "ctime": null,
65755
- // "coin": "usdt_erc20",
65756
- // "addressTo": "0x2edfae3878d7b6db70ce4abed177ab2636f60c83"
65757
- // }
65758
- // }
66018
+ // {
66019
+ // "code": 200,
66020
+ // "msg": "succ",
66021
+ // "data": [
66022
+ // {
66023
+ // "id": 183745,
66024
+ // "symbol": "usdt_erc20",
66025
+ // "amount": "8.4000000000000000",
66026
+ // "fee": "1.6000000000000000",
66027
+ // "payAmount": "0.0000000000000000",
66028
+ // "createdAt": 1595336441000,
66029
+ // "updatedAt": 1595336576000,
66030
+ // "addressFrom": "",
66031
+ // "addressTo": "0x2edfae3878d7b6db70ce4abed177ab2636f60c83",
66032
+ // "txid": "",
66033
+ // "confirmations": 0,
66034
+ // "status": 6,
66035
+ // "tagType": null
66036
+ // }
66037
+ // ]
66038
+ // }
65759
66039
  //
65760
- const data = this.safeValue(response, 'data', {});
66040
+ const data = this.safeList(response, 'data', []);
65761
66041
  return this.parseTransactions(data, currency);
65762
66042
  }
65763
66043
  parseTransactionStatusByType(status, type = undefined) {
@@ -66100,7 +66380,7 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
66100
66380
  // }]
66101
66381
  // }
66102
66382
  //
66103
- const data = this.safeValue(response, 'data', {});
66383
+ const data = this.safeList(response, 'data', []);
66104
66384
  return this.parseTransfers(data, currency, since, limit);
66105
66385
  }
66106
66386
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
@@ -78415,7 +78695,30 @@ class blofin extends _abstract_blofin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
78415
78695
  'marginMode': marginMode,
78416
78696
  };
78417
78697
  const response = await this.privateGetAccountLeverageInfo(this.extend(request, params));
78418
- return response;
78698
+ //
78699
+ // {
78700
+ // "code": "0",
78701
+ // "msg": "success",
78702
+ // "data": {
78703
+ // "leverage": "3",
78704
+ // "marginMode": "cross",
78705
+ // "instId": "BTC-USDT"
78706
+ // }
78707
+ // }
78708
+ //
78709
+ const data = this.safeDict(response, 'data', {});
78710
+ return this.parseLeverage(data, market);
78711
+ }
78712
+ parseLeverage(leverage, market = undefined) {
78713
+ const marketId = this.safeString(leverage, 'instId');
78714
+ const leverageValue = this.safeInteger(leverage, 'leverage');
78715
+ return {
78716
+ 'info': leverage,
78717
+ 'symbol': this.safeSymbol(marketId, market),
78718
+ 'marginMode': this.safeStringLower(leverage, 'marginMode'),
78719
+ 'longLeverage': leverageValue,
78720
+ 'shortLeverage': leverageValue,
78721
+ };
78419
78722
  }
78420
78723
  async setLeverage(leverage, symbol = undefined, params = {}) {
78421
78724
  /**
@@ -88739,11 +89042,19 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
88739
89042
  * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
88740
89043
  */
88741
89044
  await this.loadMarkets();
89045
+ const market = this.market(symbol);
88742
89046
  const position = await this.fetchPosition(symbol, params);
89047
+ return this.parseLeverage(position, market);
89048
+ }
89049
+ parseLeverage(leverage, market = undefined) {
89050
+ const marketId = this.safeString(leverage, 'symbol');
89051
+ const leverageValue = this.safeInteger(leverage, 'leverage');
88743
89052
  return {
88744
- 'info': position,
88745
- 'leverage': this.safeInteger(position, 'leverage'),
88746
- 'marginMode': this.safeNumber(position, 'marginMode'),
89053
+ 'info': leverage,
89054
+ 'symbol': this.safeSymbol(marketId, market),
89055
+ 'marginMode': this.safeStringLower(leverage, 'marginMode'),
89056
+ 'longLeverage': leverageValue,
89057
+ 'shortLeverage': leverageValue,
88747
89058
  };
88748
89059
  }
88749
89060
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
@@ -118144,12 +118455,22 @@ class currencycom extends _abstract_currencycom_js__WEBPACK_IMPORTED_MODULE_0__/
118144
118455
  };
118145
118456
  const response = await this.privateGetV2LeverageSettings(this.extend(request, params));
118146
118457
  //
118147
- // {
118148
- // "values": [ 1, 2, 5, 10, ],
118149
- // "value": "10",
118150
- // }
118458
+ // {
118459
+ // "values": [ 1, 2, 5, 10, ],
118460
+ // "value": "10",
118461
+ // }
118151
118462
  //
118152
- return this.safeNumber(response, 'value');
118463
+ return this.parseLeverage(response, market);
118464
+ }
118465
+ parseLeverage(leverage, market = undefined) {
118466
+ const leverageValue = this.safeInteger(leverage, 'value');
118467
+ return {
118468
+ 'info': leverage,
118469
+ 'symbol': market['symbol'],
118470
+ 'marginMode': undefined,
118471
+ 'longLeverage': leverageValue,
118472
+ 'shortLeverage': leverageValue,
118473
+ };
118153
118474
  }
118154
118475
  async fetchDepositAddress(code, params = {}) {
118155
118476
  /**
@@ -121196,6 +121517,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
121196
121517
  const request = {
121197
121518
  'product_id': market['numericId'],
121198
121519
  };
121520
+ const response = await this.privateGetProductsProductIdOrdersLeverage(this.extend(request, params));
121199
121521
  //
121200
121522
  // {
121201
121523
  // "result": {
@@ -121209,7 +121531,19 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
121209
121531
  // "success": true
121210
121532
  // }
121211
121533
  //
121212
- return await this.privateGetProductsProductIdOrdersLeverage(this.extend(request, params));
121534
+ const result = this.safeDict(response, 'result', {});
121535
+ return this.parseLeverage(result, market);
121536
+ }
121537
+ parseLeverage(leverage, market = undefined) {
121538
+ const marketId = this.safeString(leverage, 'index_symbol');
121539
+ const leverageValue = this.safeInteger(leverage, 'leverage');
121540
+ return {
121541
+ 'info': leverage,
121542
+ 'symbol': this.safeSymbol(marketId, market),
121543
+ 'marginMode': this.safeStringLower(leverage, 'margin_mode'),
121544
+ 'longLeverage': leverageValue,
121545
+ 'shortLeverage': leverageValue,
121546
+ };
121213
121547
  }
121214
121548
  async setLeverage(leverage, symbol = undefined, params = {}) {
121215
121549
  /**
@@ -133191,7 +133525,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
133191
133525
  * @param {object} [params] extra parameters specific to the exchange API endpoint
133192
133526
  * @returns {object[]} an array of objects representing market data
133193
133527
  */
133194
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
133528
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
133195
133529
  let rawPromises = [
133196
133530
  this.fetchContractMarkets(params),
133197
133531
  this.fetchOptionMarkets(params),
@@ -141191,7 +141525,8 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
141191
141525
  'fetchLeverage': true,
141192
141526
  'fetchLeverageTiers': undefined,
141193
141527
  'fetchLiquidations': false,
141194
- 'fetchMarginMode': true,
141528
+ 'fetchMarginMode': 'emulated',
141529
+ 'fetchMarginModes': true,
141195
141530
  'fetchMarketLeverageTiers': false,
141196
141531
  'fetchMarkets': true,
141197
141532
  'fetchMarkOHLCV': true,
@@ -143635,7 +143970,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
143635
143970
  'stopLossPrice': undefined,
143636
143971
  }, market);
143637
143972
  }
143638
- async fetchMarginMode(symbol = undefined, params = {}) {
143973
+ async fetchMarginModes(symbols = undefined, params = {}) {
143639
143974
  /**
143640
143975
  * @method
143641
143976
  * @name hitbtc#fetchMarginMode
@@ -143648,70 +143983,66 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
143648
143983
  */
143649
143984
  await this.loadMarkets();
143650
143985
  let market = undefined;
143651
- if (symbol !== undefined) {
143652
- market = this.market(symbol);
143986
+ if (symbols !== undefined) {
143987
+ symbols = this.marketSymbols(symbols);
143988
+ market = this.market(symbols[0]);
143653
143989
  }
143654
143990
  let marketType = undefined;
143655
143991
  [marketType, params] = this.handleMarketTypeAndParams('fetchMarginMode', market, params);
143656
143992
  let response = undefined;
143657
143993
  if (marketType === 'margin') {
143658
143994
  response = await this.privateGetMarginConfig(params);
143995
+ //
143996
+ // {
143997
+ // "config": [{
143998
+ // "symbol": "BTCUSD",
143999
+ // "margin_call_leverage_mul": "1.50",
144000
+ // "liquidation_leverage_mul": "2.00",
144001
+ // "max_initial_leverage": "10.00",
144002
+ // "margin_mode": "Isolated",
144003
+ // "force_close_fee": "0.05",
144004
+ // "enabled": true,
144005
+ // "active": true,
144006
+ // "limit_base": "50000.00",
144007
+ // "limit_power": "2.2",
144008
+ // "unlimited_threshold": "10.0"
144009
+ // }]
144010
+ // }
144011
+ //
143659
144012
  }
143660
144013
  else if (marketType === 'swap') {
143661
144014
  response = await this.privateGetFuturesConfig(params);
144015
+ //
144016
+ // {
144017
+ // "config": [{
144018
+ // "symbol": "BTCUSD_PERP",
144019
+ // "margin_call_leverage_mul": "1.20",
144020
+ // "liquidation_leverage_mul": "2.00",
144021
+ // "max_initial_leverage": "100.00",
144022
+ // "margin_mode": "Isolated",
144023
+ // "force_close_fee": "0.001",
144024
+ // "enabled": true,
144025
+ // "active": false,
144026
+ // "limit_base": "5000000.000000000000",
144027
+ // "limit_power": "1.25",
144028
+ // "unlimited_threshold": "2.00"
144029
+ // }]
144030
+ // }
144031
+ //
143662
144032
  }
143663
144033
  else {
143664
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' fetchMarginMode() supports swap contracts and margin only');
143665
- }
143666
- //
143667
- // margin
143668
- // {
143669
- // "config": [{
143670
- // "symbol": "BTCUSD",
143671
- // "margin_call_leverage_mul": "1.50",
143672
- // "liquidation_leverage_mul": "2.00",
143673
- // "max_initial_leverage": "10.00",
143674
- // "margin_mode": "Isolated",
143675
- // "force_close_fee": "0.05",
143676
- // "enabled": true,
143677
- // "active": true,
143678
- // "limit_base": "50000.00",
143679
- // "limit_power": "2.2",
143680
- // "unlimited_threshold": "10.0"
143681
- // }]
143682
- // }
143683
- //
143684
- // swap
143685
- // {
143686
- // "config": [{
143687
- // "symbol": "BTCUSD_PERP",
143688
- // "margin_call_leverage_mul": "1.20",
143689
- // "liquidation_leverage_mul": "2.00",
143690
- // "max_initial_leverage": "100.00",
143691
- // "margin_mode": "Isolated",
143692
- // "force_close_fee": "0.001",
143693
- // "enabled": true,
143694
- // "active": false,
143695
- // "limit_base": "5000000.000000000000",
143696
- // "limit_power": "1.25",
143697
- // "unlimited_threshold": "2.00"
143698
- // }]
143699
- // }
143700
- //
143701
- const config = this.safeValue(response, 'config', []);
143702
- const marginModes = [];
143703
- for (let i = 0; i < config.length; i++) {
143704
- const data = this.safeValue(config, i);
143705
- const marketId = this.safeString(data, 'symbol');
143706
- const marketInner = this.safeMarket(marketId);
143707
- marginModes.push({
143708
- 'info': data,
143709
- 'symbol': this.safeString(marketInner, 'symbol'),
143710
- 'marginMode': this.safeStringLower(data, 'margin_mode'),
143711
- });
144034
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol(this.id + ' fetchMarginModes () supports swap contracts and margin only');
143712
144035
  }
143713
- const filteredMargin = this.filterBySymbol(marginModes, symbol);
143714
- return this.safeValue(filteredMargin, 0);
144036
+ const config = this.safeList(response, 'config', []);
144037
+ return this.parseMarginModes(config, symbols, 'symbol');
144038
+ }
144039
+ parseMarginMode(marginMode, market = undefined) {
144040
+ const marketId = this.safeString(marginMode, 'symbol');
144041
+ return {
144042
+ 'info': marginMode,
144043
+ 'symbol': this.safeSymbol(marketId, market),
144044
+ 'marginMode': this.safeStringLower(marginMode, 'margin_mode'),
144045
+ };
143715
144046
  }
143716
144047
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
143717
144048
  /**
@@ -144530,7 +144861,18 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
144530
144861
  // ]
144531
144862
  // }
144532
144863
  //
144533
- return this.safeNumber(response, 'leverage');
144864
+ return this.parseLeverage(response, market);
144865
+ }
144866
+ parseLeverage(leverage, market = undefined) {
144867
+ const marketId = this.safeString(leverage, 'symbol');
144868
+ const leverageValue = this.safeInteger(leverage, 'leverage');
144869
+ return {
144870
+ 'info': leverage,
144871
+ 'symbol': this.safeSymbol(marketId, market),
144872
+ 'marginMode': this.safeStringLower(leverage, 'type'),
144873
+ 'longLeverage': leverageValue,
144874
+ 'shortLeverage': leverageValue,
144875
+ };
144534
144876
  }
144535
144877
  async setLeverage(leverage, symbol = undefined, params = {}) {
144536
144878
  /**
@@ -167276,7 +167618,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
167276
167618
  //
167277
167619
  return await this.privatePutLeveragepreferences(this.extend(request, params));
167278
167620
  }
167279
- async fetchLeverage(symbol = undefined, params = {}) {
167621
+ async fetchLeverage(symbol, params = {}) {
167280
167622
  /**
167281
167623
  * @method
167282
167624
  * @name krakenfutures#fetchLeverage
@@ -167290,17 +167632,32 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
167290
167632
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchLeverage() requires a symbol argument');
167291
167633
  }
167292
167634
  await this.loadMarkets();
167635
+ const market = this.market(symbol);
167293
167636
  const request = {
167294
167637
  'symbol': this.marketId(symbol).toUpperCase(),
167295
167638
  };
167639
+ const response = await this.privateGetLeveragepreferences(this.extend(request, params));
167296
167640
  //
167297
- // {
167298
- // "result": "success",
167299
- // "serverTime": "2023-08-01T09:54:08.900Z",
167300
- // "leveragePreferences": [ { symbol: "PF_LTCUSD", maxLeverage: "5.00" } ]
167301
- // }
167641
+ // {
167642
+ // "result": "success",
167643
+ // "serverTime": "2023-08-01T09:54:08.900Z",
167644
+ // "leveragePreferences": [ { symbol: "PF_LTCUSD", maxLeverage: "5.00" } ]
167645
+ // }
167302
167646
  //
167303
- return await this.privateGetLeveragepreferences(this.extend(request, params));
167647
+ const leveragePreferences = this.safeList(response, 'leveragePreferences', []);
167648
+ const data = this.safeDict(leveragePreferences, 0, {});
167649
+ return this.parseLeverage(data, market);
167650
+ }
167651
+ parseLeverage(leverage, market = undefined) {
167652
+ const marketId = this.safeString(leverage, 'symbol');
167653
+ const leverageValue = this.safeInteger(leverage, 'maxLeverage');
167654
+ return {
167655
+ 'info': leverage,
167656
+ 'symbol': this.safeSymbol(marketId, market),
167657
+ 'marginMode': undefined,
167658
+ 'longLeverage': leverageValue,
167659
+ 'shortLeverage': leverageValue,
167660
+ };
167304
167661
  }
167305
167662
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
167306
167663
  if (response === undefined) {
@@ -175237,7 +175594,7 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175237
175594
  await this.loadMarkets();
175238
175595
  const market = this.market(symbol);
175239
175596
  const request = {
175240
- 'pair': market['id'],
175597
+ 'pairs': market['id'],
175241
175598
  };
175242
175599
  if (limit !== undefined) {
175243
175600
  request['limit'] = limit;
@@ -175245,18 +175602,21 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175245
175602
  const response = await this.v4PublicGetTradePublicBookPairs(this.extend(request, params));
175246
175603
  //
175247
175604
  // {
175248
- // "data": {
175249
- // "id": "3e5591ba-2778-4d85-8851-54284045ea44", // Unique identifier of a trade
175250
- // "pair": "BTC_USDT", // Market pair that is being traded
175251
- // "quoteQuantity": "11528.8118", // Qty of the quote asset, USDT in this example
175252
- // "matchPrice": "18649", // Exchange price at the moment of execution
175253
- // "matchQuantity": "0.6182", // Qty of the base asset, BTC in this example
175254
- // "createdAt": "2022-09-23T14:30:41.486Z", // Date-time of trade execution, UTC
175255
- // "side": "Ask" // Trade type: `Ask` or `Bid`. Bid for buying base asset, Ask for selling base asset (e.g. for BTC_USDT trading pair, BTC is the base asset).
175256
- // }
175605
+ // 'data': [
175606
+ // {
175607
+ // 'createdAt': '2024-03-02T00:10:49.385Z',
175608
+ // 'id': '3b42878a-3688-4bc1-891e-5cc2fc902142',
175609
+ // 'matchPrice': '62181.31',
175610
+ // 'matchQuantity': '0.00568',
175611
+ // 'pair': 'BTC_USDT',
175612
+ // 'quoteQuantity': '353.1898408',
175613
+ // 'side': 'Bid'
175614
+ // },
175615
+ // ...
175616
+ // ]
175257
175617
  // }
175258
175618
  //
175259
- const data = this.safeValue(response, 'data', {});
175619
+ const data = this.safeList(response, 'data', []);
175260
175620
  return this.parseTrades(data, market, since, limit);
175261
175621
  }
175262
175622
  parseTrade(trade, market = undefined) {
@@ -184476,6 +184836,8 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
184476
184836
  'fetchL2OrderBook': true,
184477
184837
  'fetchLedger': undefined,
184478
184838
  'fetchLedgerEntry': undefined,
184839
+ 'fetchLeverage': true,
184840
+ 'fetchLeverages': false,
184479
184841
  'fetchLeverageTiers': true,
184480
184842
  'fetchMarginMode': false,
184481
184843
  'fetchMarketLeverageTiers': undefined,
@@ -189779,6 +190141,79 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
189779
190141
  }
189780
190142
  return this.assignDefaultDepositWithdrawFees(result);
189781
190143
  }
190144
+ async fetchLeverage(symbol, params = {}) {
190145
+ /**
190146
+ * @method
190147
+ * @name mexc#fetchLeverage
190148
+ * @description fetch the set leverage for a market
190149
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-leverage
190150
+ * @param {string} symbol unified market symbol
190151
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
190152
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
190153
+ */
190154
+ await this.loadMarkets();
190155
+ const market = this.market(symbol);
190156
+ const request = {
190157
+ 'symbol': market['id'],
190158
+ };
190159
+ const response = await this.contractPrivateGetPositionLeverage(this.extend(request, params));
190160
+ //
190161
+ // {
190162
+ // "success": true,
190163
+ // "code": 0,
190164
+ // "data": [
190165
+ // {
190166
+ // "level": 1,
190167
+ // "maxVol": 463300,
190168
+ // "mmr": 0.004,
190169
+ // "imr": 0.005,
190170
+ // "positionType": 1,
190171
+ // "openType": 1,
190172
+ // "leverage": 20,
190173
+ // "limitBySys": false,
190174
+ // "currentMmr": 0.004
190175
+ // },
190176
+ // {
190177
+ // "level": 1,
190178
+ // "maxVol": 463300,
190179
+ // "mmr": 0.004,
190180
+ // "imr": 0.005,
190181
+ // "positionType": 2,
190182
+ // "openType": 1,
190183
+ // "leverage": 20,
190184
+ // "limitBySys": false,
190185
+ // "currentMmr": 0.004
190186
+ // }
190187
+ // ]
190188
+ // }
190189
+ //
190190
+ const data = this.safeList(response, 'data', []);
190191
+ return this.parseLeverage(data, market);
190192
+ }
190193
+ parseLeverage(leverage, market = undefined) {
190194
+ let marginMode = undefined;
190195
+ let longLeverage = undefined;
190196
+ let shortLeverage = undefined;
190197
+ for (let i = 0; i < leverage.length; i++) {
190198
+ const entry = leverage[i];
190199
+ const openType = this.safeInteger(entry, 'openType');
190200
+ const positionType = this.safeInteger(entry, 'positionType');
190201
+ if (positionType === 1) {
190202
+ longLeverage = this.safeInteger(entry, 'leverage');
190203
+ }
190204
+ else if (positionType === 2) {
190205
+ shortLeverage = this.safeInteger(entry, 'leverage');
190206
+ }
190207
+ marginMode = (openType === 1) ? 'isolated' : 'cross';
190208
+ }
190209
+ return {
190210
+ 'info': leverage,
190211
+ 'symbol': market['symbol'],
190212
+ 'marginMode': marginMode,
190213
+ 'longLeverage': longLeverage,
190214
+ 'shortLeverage': shortLeverage,
190215
+ };
190216
+ }
189782
190217
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
189783
190218
  /**
189784
190219
  * @ignore
@@ -203225,7 +203660,37 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
203225
203660
  // "msg": ""
203226
203661
  // }
203227
203662
  //
203228
- return response;
203663
+ const data = this.safeList(response, 'data', []);
203664
+ return this.parseLeverage(data, market);
203665
+ }
203666
+ parseLeverage(leverage, market = undefined) {
203667
+ let marketId = undefined;
203668
+ let marginMode = undefined;
203669
+ let longLeverage = undefined;
203670
+ let shortLeverage = undefined;
203671
+ for (let i = 0; i < leverage.length; i++) {
203672
+ const entry = leverage[i];
203673
+ marginMode = this.safeStringLower(entry, 'mgnMode');
203674
+ marketId = this.safeString(entry, 'instId');
203675
+ const positionSide = this.safeStringLower(entry, 'posSide');
203676
+ if (positionSide === 'long') {
203677
+ longLeverage = this.safeInteger(entry, 'lever');
203678
+ }
203679
+ else if (positionSide === 'short') {
203680
+ shortLeverage = this.safeInteger(entry, 'lever');
203681
+ }
203682
+ else {
203683
+ longLeverage = this.safeInteger(entry, 'lever');
203684
+ shortLeverage = this.safeInteger(entry, 'lever');
203685
+ }
203686
+ }
203687
+ return {
203688
+ 'info': leverage,
203689
+ 'symbol': this.safeSymbol(marketId, market),
203690
+ 'marginMode': marginMode,
203691
+ 'longLeverage': longLeverage,
203692
+ 'shortLeverage': shortLeverage,
203693
+ };
203229
203694
  }
203230
203695
  async fetchPosition(symbol, params = {}) {
203231
203696
  /**
@@ -218919,7 +219384,7 @@ class alpaca extends _alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
218919
219384
  for (let i = 0; i < message.length; i++) {
218920
219385
  const data = message[i];
218921
219386
  const T = this.safeString(data, 'T');
218922
- const msg = this.safeValue(data, 'msg', {});
219387
+ const msg = this.safeString(data, 'msg');
218923
219388
  if (T === 'subscription') {
218924
219389
  this.handleSubscription(client, data);
218925
219390
  return;
@@ -229659,17 +230124,9 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
229659
230124
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
229660
230125
  */
229661
230126
  await this.loadMarkets();
229662
- const market = this.market(symbol);
229663
- const name = 'instrument';
229664
- const messageHash = name + ':' + market['id'];
229665
- const url = this.urls['api']['ws'];
229666
- const request = {
229667
- 'op': 'subscribe',
229668
- 'args': [
229669
- messageHash,
229670
- ],
229671
- };
229672
- return await this.watch(url, messageHash, this.extend(request, params), messageHash);
230127
+ symbol = this.symbol(symbol);
230128
+ const tickers = await this.watchTickers([symbol], params);
230129
+ return tickers[symbol];
229673
230130
  }
229674
230131
  async watchTickers(symbols = undefined, params = {}) {
229675
230132
  /**
@@ -229685,26 +230142,27 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
229685
230142
  const name = 'instrument';
229686
230143
  const url = this.urls['api']['ws'];
229687
230144
  const messageHashes = [];
230145
+ const rawSubscriptions = [];
229688
230146
  if (symbols !== undefined) {
229689
230147
  for (let i = 0; i < symbols.length; i++) {
229690
230148
  const symbol = symbols[i];
229691
230149
  const market = this.market(symbol);
229692
- const hash = name + ':' + market['id'];
229693
- messageHashes.push(hash);
230150
+ const subscription = name + ':' + market['id'];
230151
+ rawSubscriptions.push(subscription);
230152
+ const messageHash = 'ticker:' + symbol;
230153
+ messageHashes.push(messageHash);
229694
230154
  }
229695
230155
  }
229696
230156
  else {
229697
- messageHashes.push(name);
230157
+ rawSubscriptions.push(name);
230158
+ messageHashes.push('alltickers');
229698
230159
  }
229699
230160
  const request = {
229700
230161
  'op': 'subscribe',
229701
- 'args': messageHashes,
230162
+ 'args': rawSubscriptions,
229702
230163
  };
229703
- const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
230164
+ const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), rawSubscriptions);
229704
230165
  if (this.newUpdates) {
229705
- if (symbols === undefined) {
229706
- return ticker;
229707
- }
229708
230166
  const result = {};
229709
230167
  result[ticker['symbol']] = ticker;
229710
230168
  return result;
@@ -229938,23 +230396,23 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
229938
230396
  // ]
229939
230397
  // }
229940
230398
  //
229941
- const table = this.safeString(message, 'table');
229942
230399
  const data = this.safeList(message, 'data', []);
229943
230400
  const tickers = {};
229944
230401
  for (let i = 0; i < data.length; i++) {
229945
230402
  const update = data[i];
229946
230403
  const marketId = this.safeString(update, 'symbol');
229947
- const market = this.safeMarket(marketId);
229948
- const symbol = market['symbol'];
229949
- const messageHash = table + ':' + marketId;
229950
- const ticker = this.safeDict(this.tickers, symbol, {});
229951
- const info = this.safeDict(ticker, 'info', {});
229952
- const parsedTicker = this.parseTicker(this.extend(info, update), market);
229953
- tickers[symbol] = parsedTicker;
229954
- this.tickers[symbol] = parsedTicker;
229955
- client.resolve(ticker, messageHash);
230404
+ const symbol = this.safeSymbol(marketId);
230405
+ if (!(symbol in this.tickers)) {
230406
+ this.tickers[symbol] = this.parseTicker({});
230407
+ }
230408
+ const updatedTicker = this.parseTicker(update);
230409
+ const fullParsedTicker = this.deepExtend(this.tickers[symbol], updatedTicker);
230410
+ tickers[symbol] = fullParsedTicker;
230411
+ this.tickers[symbol] = fullParsedTicker;
230412
+ const messageHash = 'ticker:' + symbol;
230413
+ client.resolve(fullParsedTicker, messageHash);
230414
+ client.resolve(fullParsedTicker, 'alltickers');
229956
230415
  }
229957
- client.resolve(tickers, 'instrument');
229958
230416
  return message;
229959
230417
  }
229960
230418
  async watchBalance(params = {}) {
@@ -230934,7 +231392,7 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
230934
231392
  const messageHash = table + ':' + market['id'];
230935
231393
  const result = [
230936
231394
  this.parse8601(this.safeString(candle, 'timestamp')) - duration * 1000,
230937
- this.safeFloat(candle, 'open'),
231395
+ undefined,
230938
231396
  this.safeFloat(candle, 'high'),
230939
231397
  this.safeFloat(candle, 'low'),
230940
231398
  this.safeFloat(candle, 'close'),
@@ -237860,7 +238318,10 @@ class cex extends _cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
237860
238318
  for (let i = 0; i < sorted.length; i++) {
237861
238319
  stored.append(this.parseOHLCV(sorted[i], market));
237862
238320
  }
237863
- this.ohlcvs[symbol] = stored;
238321
+ if (!(symbol in this.ohlcvs)) {
238322
+ this.ohlcvs[symbol] = {};
238323
+ }
238324
+ this.ohlcvs[symbol]['unknown'] = stored;
237864
238325
  client.resolve(stored, messageHash);
237865
238326
  }
237866
238327
  handleOHLCV24(client, message) {
@@ -237919,7 +238380,8 @@ class cex extends _cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
237919
238380
  const pair = this.safeString(message, 'pair');
237920
238381
  const symbol = this.pairToSymbol(pair);
237921
238382
  const messageHash = 'ohlcv:' + symbol;
237922
- const stored = this.safeValue(this.ohlcvs, symbol);
238383
+ // const stored = this.safeValue (this.ohlcvs, symbol);
238384
+ const stored = this.ohlcvs[symbol]['unknown'];
237923
238385
  for (let i = 0; i < data.length; i++) {
237924
238386
  const ohlcv = [
237925
238387
  this.safeTimestamp(data[i], 0),
@@ -240444,14 +240906,17 @@ class coinex extends _coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
240444
240906
  const keys = Object.keys(this.ohlcvs);
240445
240907
  const keysLength = keys.length;
240446
240908
  if (keysLength === 0) {
240909
+ this.ohlcvs['unknown'] = {};
240447
240910
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
240448
- this.ohlcvs = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
240911
+ const stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
240912
+ this.ohlcvs['unknown']['unknown'] = stored;
240449
240913
  }
240914
+ const ohlcv = this.ohlcvs['unknown']['unknown'];
240450
240915
  for (let i = 0; i < ohlcvs.length; i++) {
240451
240916
  const candle = ohlcvs[i];
240452
- this.ohlcvs.append(candle);
240917
+ ohlcv.append(candle);
240453
240918
  }
240454
- client.resolve(this.ohlcvs, messageHash);
240919
+ client.resolve(ohlcv, messageHash);
240455
240920
  }
240456
240921
  async watchTicker(symbol, params = {}) {
240457
240922
  /**
@@ -259427,7 +259892,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
259427
259892
  // "d": {
259428
259893
  // "e": "spot@public.kline.v3.api",
259429
259894
  // "k": {
259430
- // "t": 1678642260,
259895
+ // "t": 1678642261,
259431
259896
  // "o": 20626.94,
259432
259897
  // "c": 20599.69,
259433
259898
  // "h": 20626.94,
@@ -259640,7 +260105,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
259640
260105
  client.subscriptions[messageHash] = 1;
259641
260106
  this.orderbooks[symbol] = this.countedOrderBook({});
259642
260107
  }
259643
- const storedOrderBook = this.safeValue(this.orderbooks, symbol);
260108
+ const storedOrderBook = this.orderbooks[symbol];
259644
260109
  const nonce = this.safeInteger(storedOrderBook, 'nonce');
259645
260110
  if (nonce === undefined) {
259646
260111
  const cacheLength = storedOrderBook.cache.length;
@@ -270673,15 +271138,19 @@ class whitebit extends _whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
270673
271138
  const symbol = market['symbol'];
270674
271139
  const messageHash = 'candles' + ':' + symbol;
270675
271140
  const parsed = this.parseOHLCV(data, market);
270676
- this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol);
270677
- let stored = this.ohlcvs[symbol];
270678
- if (stored === undefined) {
271141
+ // this.ohlcvs[symbol] = this.safeValue (this.ohlcvs, symbol);
271142
+ if (!(symbol in this.ohlcvs)) {
271143
+ this.ohlcvs[symbol] = {};
271144
+ }
271145
+ // let stored = this.ohlcvs[symbol]['unknown']; // we don't know the timeframe but we need to respect the type
271146
+ if (!('unknown' in this.ohlcvs[symbol])) {
270679
271147
  const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
270680
- stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
270681
- this.ohlcvs[symbol] = stored;
271148
+ const stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
271149
+ this.ohlcvs[symbol]['unknown'] = stored;
270682
271150
  }
270683
- stored.append(parsed);
270684
- client.resolve(stored, messageHash);
271151
+ const ohlcv = this.ohlcvs[symbol]['unknown'];
271152
+ ohlcv.append(parsed);
271153
+ client.resolve(ohlcv, messageHash);
270685
271154
  }
270686
271155
  return message;
270687
271156
  }
@@ -271423,12 +271892,10 @@ class whitebit extends _whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
271423
271892
  if (!this.handleErrorMessage(client, message)) {
271424
271893
  return;
271425
271894
  }
271426
- const result = this.safeValue(message, 'result', {});
271427
- if (result !== undefined) {
271428
- if (result === 'pong') {
271429
- this.handlePong(client, message);
271430
- return;
271431
- }
271895
+ const result = this.safeString(message, 'result');
271896
+ if (result === 'pong') {
271897
+ this.handlePong(client, message);
271898
+ return;
271432
271899
  }
271433
271900
  const id = this.safeInteger(message, 'id');
271434
271901
  if (id !== undefined) {
@@ -273956,7 +274423,7 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
273956
274423
  // ]
273957
274424
  // }
273958
274425
  //
273959
- const data = this.safeValue(response, 'data', {});
274426
+ const data = this.safeList(response, 'data', []);
273960
274427
  return this.parseTransactions(data, currency, since, limit);
273961
274428
  }
273962
274429
  parseTransaction(transaction, currency = undefined) {
@@ -290760,7 +291227,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
290760
291227
  'amountAsset': amountAsset,
290761
291228
  'priceAsset': priceAsset,
290762
291229
  };
290763
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
291230
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
290764
291231
  const chainId = (sandboxMode) ? 84 : 87;
290765
291232
  const body = {
290766
291233
  'senderPublicKey': this.apiKey,
@@ -297937,7 +298404,17 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
297937
298404
  return response;
297938
298405
  }
297939
298406
  async fetchLeverage(symbol, params = {}) {
298407
+ /**
298408
+ * @method
298409
+ * @name woo#fetchLeverage
298410
+ * @description fetch the set leverage for a market
298411
+ * @see https://docs.woo.org/#get-account-information-new
298412
+ * @param {string} symbol unified market symbol
298413
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
298414
+ * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
298415
+ */
297940
298416
  await this.loadMarkets();
298417
+ const market = this.market(symbol);
297941
298418
  const response = await this.v3PrivateGetAccountinfo(params);
297942
298419
  //
297943
298420
  // {
@@ -297967,11 +298444,17 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
297967
298444
  // "timestamp": 1673323685109
297968
298445
  // }
297969
298446
  //
297970
- const result = this.safeValue(response, 'data');
297971
- const leverage = this.safeNumber(result, 'leverage');
298447
+ const data = this.safeDict(response, 'data', {});
298448
+ return this.parseLeverage(data, market);
298449
+ }
298450
+ parseLeverage(leverage, market = undefined) {
298451
+ const leverageValue = this.safeInteger(leverage, 'leverage');
297972
298452
  return {
297973
- 'info': response,
297974
- 'leverage': leverage,
298453
+ 'info': leverage,
298454
+ 'symbol': market['symbol'],
298455
+ 'marginMode': undefined,
298456
+ 'longLeverage': leverageValue,
298457
+ 'shortLeverage': leverageValue,
297975
298458
  };
297976
298459
  }
297977
298460
  async setLeverage(leverage, symbol = undefined, params = {}) {
@@ -307689,7 +308172,7 @@ SOFTWARE.
307689
308172
 
307690
308173
  //-----------------------------------------------------------------------------
307691
308174
  // this is updated by vss.js when building
307692
- const version = '4.2.56';
308175
+ const version = '4.2.58';
307693
308176
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
307694
308177
  //-----------------------------------------------------------------------------
307695
308178