ccxt 4.2.57 → 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 (68) hide show
  1. package/README.md +4 -5
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +462 -280
  4. package/dist/ccxt.browser.min.js +7 -7
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/alpaca.js +90 -88
  7. package/dist/cjs/src/base/Exchange.js +22 -1
  8. package/dist/cjs/src/binance.js +41 -28
  9. package/dist/cjs/src/bingx.js +12 -1
  10. package/dist/cjs/src/bitget.js +71 -56
  11. package/dist/cjs/src/bitmex.js +12 -28
  12. package/dist/cjs/src/bitrue.js +24 -15
  13. package/dist/cjs/src/blofin.js +24 -1
  14. package/dist/cjs/src/bybit.js +11 -3
  15. package/dist/cjs/src/currencycom.js +15 -5
  16. package/dist/cjs/src/delta.js +14 -1
  17. package/dist/cjs/src/gate.js +1 -1
  18. package/dist/cjs/src/hitbtc.js +12 -1
  19. package/dist/cjs/src/krakenfutures.js +22 -7
  20. package/dist/cjs/src/kuna.js +14 -11
  21. package/dist/cjs/src/mexc.js +19 -19
  22. package/dist/cjs/src/okx.js +31 -1
  23. package/dist/cjs/src/pro/alpaca.js +1 -1
  24. package/dist/cjs/src/pro/whitebit.js +4 -6
  25. package/dist/cjs/src/probit.js +1 -1
  26. package/dist/cjs/src/wavesexchange.js +1 -1
  27. package/dist/cjs/src/woo.js +20 -4
  28. package/js/ccxt.d.ts +3 -3
  29. package/js/ccxt.js +1 -1
  30. package/js/src/alpaca.js +90 -88
  31. package/js/src/base/Exchange.d.ts +6 -4
  32. package/js/src/base/Exchange.js +22 -1
  33. package/js/src/base/types.d.ts +9 -0
  34. package/js/src/binance.d.ts +3 -2
  35. package/js/src/binance.js +41 -28
  36. package/js/src/bingx.d.ts +3 -2
  37. package/js/src/bingx.js +12 -1
  38. package/js/src/bitget.d.ts +3 -2
  39. package/js/src/bitget.js +71 -56
  40. package/js/src/bitmex.d.ts +3 -3
  41. package/js/src/bitmex.js +12 -28
  42. package/js/src/bitrue.js +24 -15
  43. package/js/src/blofin.d.ts +3 -2
  44. package/js/src/blofin.js +24 -1
  45. package/js/src/bybit.d.ts +3 -6
  46. package/js/src/bybit.js +11 -3
  47. package/js/src/currencycom.d.ts +3 -2
  48. package/js/src/currencycom.js +15 -5
  49. package/js/src/delta.d.ts +3 -2
  50. package/js/src/delta.js +14 -1
  51. package/js/src/gate.js +1 -1
  52. package/js/src/hitbtc.d.ts +3 -2
  53. package/js/src/hitbtc.js +12 -1
  54. package/js/src/krakenfutures.d.ts +3 -2
  55. package/js/src/krakenfutures.js +22 -7
  56. package/js/src/kuna.js +14 -11
  57. package/js/src/mexc.d.ts +3 -13
  58. package/js/src/mexc.js +19 -19
  59. package/js/src/okx.d.ts +3 -2
  60. package/js/src/okx.js +31 -1
  61. package/js/src/pro/alpaca.js +1 -1
  62. package/js/src/pro/whitebit.js +4 -6
  63. package/js/src/probit.js +1 -1
  64. package/js/src/wavesexchange.js +1 -1
  65. package/js/src/woo.d.ts +3 -5
  66. package/js/src/woo.js +20 -4
  67. package/package.json +1 -1
  68. package/skip-tests.json +6 -1
@@ -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) {
@@ -9005,7 +9007,13 @@ class Exchange {
9005
9007
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' setLeverage() is not supported yet');
9006
9008
  }
9007
9009
  async fetchLeverage(symbol, params = {}) {
9008
- 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
+ }
9009
9017
  }
9010
9018
  async fetchLeverages(symbols = undefined, params = {}) {
9011
9019
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' fetchLeverages() is not supported yet');
@@ -12604,6 +12612,21 @@ class Exchange {
12604
12612
  parseMarginMode(marginMode, market = undefined) {
12605
12613
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseMarginMode () is not supported yet');
12606
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
+ }
12607
12630
  }
12608
12631
 
12609
12632
 
@@ -18209,7 +18232,8 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18209
18232
  'fetchLastPrices': true,
18210
18233
  'fetchLedger': true,
18211
18234
  'fetchLedgerEntry': true,
18212
- 'fetchLeverage': true,
18235
+ 'fetchLeverage': 'emulated',
18236
+ 'fetchLeverages': true,
18213
18237
  'fetchLeverageTiers': true,
18214
18238
  'fetchLiquidations': false,
18215
18239
  'fetchMarginMode': 'emulated',
@@ -28503,31 +28527,27 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28503
28527
  //
28504
28528
  return response;
28505
28529
  }
28506
- async fetchLeverage(symbol, params = {}) {
28530
+ async fetchLeverages(symbols = undefined, params = {}) {
28507
28531
  /**
28508
28532
  * @method
28509
- * @name binance#fetchLeverage
28510
- * @description fetch the set leverage for a market
28533
+ * @name binance#fetchLeverages
28534
+ * @description fetch the set leverage for all markets
28511
28535
  * @see https://binance-docs.github.io/apidocs/futures/en/#account-information-v2-user_data
28512
28536
  * @see https://binance-docs.github.io/apidocs/delivery/en/#account-information-user_data
28513
28537
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-um-account-detail-user_data
28514
28538
  * @see https://binance-docs.github.io/apidocs/pm/en/#get-cm-account-detail-user_data
28515
- * @param {string} symbol unified market symbol
28539
+ * @param {string[]} [symbols] a list of unified market symbols
28516
28540
  * @param {object} [params] extra parameters specific to the exchange API endpoint
28517
- * @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}
28518
28542
  */
28519
28543
  await this.loadMarkets();
28520
28544
  await this.loadLeverageBrackets(false, params);
28521
- const market = this.market(symbol);
28522
- if (!market['contract']) {
28523
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverage() supports linear and inverse contracts only');
28524
- }
28525
28545
  let type = undefined;
28526
- [type, params] = this.handleMarketTypeAndParams('fetchLeverage', market, params);
28546
+ [type, params] = this.handleMarketTypeAndParams('fetchLeverages', undefined, params);
28527
28547
  let subType = undefined;
28528
- [subType, params] = this.handleSubTypeAndParams('fetchLeverage', market, params, 'linear');
28548
+ [subType, params] = this.handleSubTypeAndParams('fetchLeverages', undefined, params, 'linear');
28529
28549
  let isPortfolioMargin = undefined;
28530
- [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverage', 'papi', 'portfolioMargin', false);
28550
+ [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'fetchLeverages', 'papi', 'portfolioMargin', false);
28531
28551
  let response = undefined;
28532
28552
  if (this.isLinear(type, subType)) {
28533
28553
  if (isPortfolioMargin) {
@@ -28546,23 +28566,39 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
28546
28566
  }
28547
28567
  }
28548
28568
  else {
28549
- 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');
28550
28570
  }
28551
- const positions = this.safeList(response, 'positions', []);
28552
- for (let i = 0; i < positions.length; i++) {
28553
- const position = positions[i];
28554
- const innerSymbol = this.safeString(position, 'symbol');
28555
- if (innerSymbol === market['id']) {
28556
- const isolated = this.safeBool(position, 'isolated');
28557
- const marginMode = isolated ? 'isolated' : 'cross';
28558
- return {
28559
- 'info': position,
28560
- 'marginMode': marginMode,
28561
- 'leverage': this.safeInteger(position, 'leverage'),
28562
- };
28563
- }
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';
28564
28580
  }
28565
- 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
+ };
28566
28602
  }
28567
28603
  async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
28568
28604
  /**
@@ -34272,7 +34308,18 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
34272
34308
  // }
34273
34309
  // }
34274
34310
  //
34275
- 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
+ };
34276
34323
  }
34277
34324
  async setLeverage(leverage, symbol = undefined, params = {}) {
34278
34325
  /**
@@ -46132,7 +46179,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
46132
46179
  let defaultProductType = undefined;
46133
46180
  if ((subType !== undefined) && (market === undefined)) {
46134
46181
  // set default only if subType is defined and market is not defined, since there is also USDC productTypes which are also linear
46135
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
46182
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
46136
46183
  if (sandboxMode) {
46137
46184
  defaultProductType = (subType === 'linear') ? 'SUSDT-FUTURES' : 'SCOIN-FUTURES';
46138
46185
  }
@@ -46201,7 +46248,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
46201
46248
  * @param {object} [params] extra parameters specific to the exchange API endpoint
46202
46249
  * @returns {object[]} an array of objects representing market data
46203
46250
  */
46204
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
46251
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
46205
46252
  let types = this.safeValue(this.options, 'fetchMarkets', ['spot', 'swap']);
46206
46253
  if (sandboxMode) {
46207
46254
  types = ['swap'];
@@ -46656,7 +46703,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
46656
46703
  * @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}
46657
46704
  */
46658
46705
  await this.loadMarkets();
46659
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
46706
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
46660
46707
  let market = undefined;
46661
46708
  if (sandboxMode) {
46662
46709
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -47192,7 +47239,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47192
47239
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
47193
47240
  */
47194
47241
  await this.loadMarkets();
47195
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
47242
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
47196
47243
  let market = undefined;
47197
47244
  if (sandboxMode) {
47198
47245
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -47355,7 +47402,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47355
47402
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
47356
47403
  */
47357
47404
  await this.loadMarkets();
47358
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
47405
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
47359
47406
  let market = undefined;
47360
47407
  if (sandboxMode) {
47361
47408
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -47459,7 +47506,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47459
47506
  let market = undefined;
47460
47507
  if (symbols !== undefined) {
47461
47508
  const symbol = this.safeValue(symbols, 0);
47462
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
47509
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
47463
47510
  if (sandboxMode) {
47464
47511
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
47465
47512
  market = this.market(sandboxSymbol);
@@ -47677,7 +47724,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47677
47724
  if (paginate) {
47678
47725
  return await this.fetchPaginatedCallCursor('fetchTrades', symbol, since, limit, params, 'idLessThan', 'idLessThan');
47679
47726
  }
47680
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
47727
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
47681
47728
  let market = undefined;
47682
47729
  if (sandboxMode) {
47683
47730
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -47996,7 +48043,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47996
48043
  if (paginate) {
47997
48044
  return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
47998
48045
  }
47999
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
48046
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
48000
48047
  let market = undefined;
48001
48048
  if (sandboxMode) {
48002
48049
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -48816,7 +48863,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
48816
48863
  return this.parseOrder(data, market);
48817
48864
  }
48818
48865
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
48819
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
48866
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
48820
48867
  let market = undefined;
48821
48868
  if (sandboxMode) {
48822
48869
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49087,7 +49134,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49087
49134
  const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
49088
49135
  ordersRequests.push(orderRequest);
49089
49136
  }
49090
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49137
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49091
49138
  let market = undefined;
49092
49139
  if (sandboxMode) {
49093
49140
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49184,7 +49231,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49184
49231
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
49185
49232
  */
49186
49233
  await this.loadMarkets();
49187
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49234
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49188
49235
  let market = undefined;
49189
49236
  if (sandboxMode) {
49190
49237
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49350,7 +49397,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49350
49397
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
49351
49398
  }
49352
49399
  await this.loadMarkets();
49353
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49400
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49354
49401
  let market = undefined;
49355
49402
  if (sandboxMode) {
49356
49403
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49490,7 +49537,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49490
49537
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
49491
49538
  }
49492
49539
  await this.loadMarkets();
49493
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49540
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49494
49541
  let market = undefined;
49495
49542
  if (sandboxMode) {
49496
49543
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49584,7 +49631,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49584
49631
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
49585
49632
  }
49586
49633
  await this.loadMarkets();
49587
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49634
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49588
49635
  let market = undefined;
49589
49636
  if (sandboxMode) {
49590
49637
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49688,7 +49735,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49688
49735
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
49689
49736
  }
49690
49737
  await this.loadMarkets();
49691
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49738
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49692
49739
  let market = undefined;
49693
49740
  if (sandboxMode) {
49694
49741
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -49804,7 +49851,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49804
49851
  * @param {int} [limit] the maximum number of open order structures to retrieve
49805
49852
  * @param {object} [params] extra parameters specific to the exchange API endpoint
49806
49853
  * @param {int} [params.until] the latest time in ms to fetch orders for
49807
- * @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'
49808
49855
  * @param {boolean} [params.stop] set to true for fetching trigger orders
49809
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)
49810
49857
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
@@ -49812,7 +49859,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49812
49859
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
49813
49860
  */
49814
49861
  await this.loadMarkets();
49815
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
49862
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
49816
49863
  let market = undefined;
49817
49864
  let type = undefined;
49818
49865
  let request = {};
@@ -49850,8 +49897,10 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49850
49897
  return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
49851
49898
  }
49852
49899
  let response = undefined;
49853
- const trailing = this.safeValue(params, 'trailing');
49854
- 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);
49855
49904
  params = this.omit(params, ['stop', 'trigger', 'trailing']);
49856
49905
  [request, params] = this.handleUntilOption('endTime', request, params);
49857
49906
  if (since !== undefined) {
@@ -49900,7 +49949,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
49900
49949
  request['planType'] = planType;
49901
49950
  response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
49902
49951
  }
49903
- else if (stop) {
49952
+ else if (isStop) {
49904
49953
  const planType = this.safeString(query, 'planType', 'normal_plan');
49905
49954
  request['planType'] = planType;
49906
49955
  response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
@@ -50167,7 +50216,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
50167
50216
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
50168
50217
  */
50169
50218
  await this.loadMarkets();
50170
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
50219
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
50171
50220
  let market = undefined;
50172
50221
  if (sandboxMode) {
50173
50222
  if (symbol !== undefined) {
@@ -50200,7 +50249,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
50200
50249
  }
50201
50250
  let response = undefined;
50202
50251
  const trailing = this.safeValue(params, 'trailing');
50203
- const stop = this.safeValue2(params, 'stop', 'trigger');
50252
+ const stop = this.safeBool2(params, 'stop', 'trigger');
50204
50253
  params = this.omit(params, ['stop', 'trigger', 'trailing']);
50205
50254
  [request, params] = this.handleUntilOption('endTime', request, params);
50206
50255
  if (since !== undefined) {
@@ -50484,7 +50533,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
50484
50533
  params = this.omit(params, 'symbol');
50485
50534
  let market = undefined;
50486
50535
  if (symbol !== undefined) {
50487
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
50536
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
50488
50537
  if (sandboxMode) {
50489
50538
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
50490
50539
  market = this.market(sandboxSymbol);
@@ -50704,7 +50753,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
50704
50753
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
50705
50754
  }
50706
50755
  await this.loadMarkets();
50707
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
50756
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
50708
50757
  let market = undefined;
50709
50758
  if (sandboxMode) {
50710
50759
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -50883,7 +50932,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
50883
50932
  * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
50884
50933
  */
50885
50934
  await this.loadMarkets();
50886
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
50935
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
50887
50936
  let market = undefined;
50888
50937
  if (sandboxMode) {
50889
50938
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -50959,7 +51008,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
50959
51008
  let market = undefined;
50960
51009
  if (symbols !== undefined) {
50961
51010
  const first = this.safeString(symbols, 0);
50962
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51011
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
50963
51012
  if (sandboxMode) {
50964
51013
  const sandboxSymbol = this.convertSymbolForSandbox(first);
50965
51014
  market = this.market(sandboxSymbol);
@@ -51279,7 +51328,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51279
51328
  if (paginate) {
51280
51329
  return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'pageNo', 100);
51281
51330
  }
51282
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51331
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51283
51332
  let market = undefined;
51284
51333
  if (sandboxMode) {
51285
51334
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51343,7 +51392,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51343
51392
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
51344
51393
  */
51345
51394
  await this.loadMarkets();
51346
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51395
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51347
51396
  let market = undefined;
51348
51397
  if (sandboxMode) {
51349
51398
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51430,7 +51479,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51430
51479
  if (paginate) {
51431
51480
  return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'endId', 'idLessThan');
51432
51481
  }
51433
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51482
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51434
51483
  let market = undefined;
51435
51484
  if (sandboxMode) {
51436
51485
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51526,7 +51575,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51526
51575
  async modifyMarginHelper(symbol, amount, type, params = {}) {
51527
51576
  await this.loadMarkets();
51528
51577
  const holdSide = this.safeString(params, 'holdSide');
51529
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51578
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51530
51579
  let market = undefined;
51531
51580
  if (sandboxMode) {
51532
51581
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51619,7 +51668,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51619
51668
  * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
51620
51669
  */
51621
51670
  await this.loadMarkets();
51622
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51671
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51623
51672
  let market = undefined;
51624
51673
  if (sandboxMode) {
51625
51674
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51640,28 +51689,41 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51640
51689
  // {
51641
51690
  // "code": "00000",
51642
51691
  // "msg": "success",
51643
- // "requestTime": 1700625127294,
51644
- // "data": [
51645
- // {
51646
- // "marginCoin": "USDT",
51647
- // "locked": "0",
51648
- // "available": "0",
51649
- // "crossedMaxAvailable": "0",
51650
- // "isolatedMaxAvailable": "0",
51651
- // "maxTransferOut": "0",
51652
- // "accountEquity": "0",
51653
- // "usdtEquity": "0.000000005166",
51654
- // "btcEquity": "0",
51655
- // "crossedRiskRate": "0",
51656
- // "unrealizedPL": "0",
51657
- // "coupon": "0",
51658
- // "crossedUnrealizedPL": null,
51659
- // "isolatedUnrealizedPL": null
51660
- // }
51661
- // ]
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
+ // }
51662
51714
  // }
51663
51715
  //
51664
- 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
+ };
51665
51727
  }
51666
51728
  async setLeverage(leverage, symbol = undefined, params = {}) {
51667
51729
  /**
@@ -51679,7 +51741,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51679
51741
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
51680
51742
  }
51681
51743
  await this.loadMarkets();
51682
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51744
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51683
51745
  let market = undefined;
51684
51746
  if (sandboxMode) {
51685
51747
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51737,7 +51799,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51737
51799
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' setMarginMode() marginMode must be either isolated or crossed (cross)');
51738
51800
  }
51739
51801
  await this.loadMarkets();
51740
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51802
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51741
51803
  let market = undefined;
51742
51804
  if (sandboxMode) {
51743
51805
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -51787,7 +51849,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51787
51849
  const posMode = hedged ? 'hedge_mode' : 'one_way_mode';
51788
51850
  let market = undefined;
51789
51851
  if (symbol !== undefined) {
51790
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51852
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51791
51853
  if (sandboxMode) {
51792
51854
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
51793
51855
  market = this.market(sandboxSymbol);
@@ -51826,7 +51888,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
51826
51888
  * @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
51827
51889
  */
51828
51890
  await this.loadMarkets();
51829
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
51891
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
51830
51892
  let market = undefined;
51831
51893
  if (sandboxMode) {
51832
51894
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -52860,7 +52922,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
52860
52922
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
52861
52923
  */
52862
52924
  await this.loadMarkets();
52863
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
52925
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
52864
52926
  let market = undefined;
52865
52927
  if (sandboxMode) {
52866
52928
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -58715,7 +58777,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
58715
58777
  'fetchFundingRates': true,
58716
58778
  'fetchIndexOHLCV': false,
58717
58779
  'fetchLedger': true,
58718
- 'fetchLeverage': true,
58780
+ 'fetchLeverage': 'emulated',
58719
58781
  'fetchLeverages': true,
58720
58782
  'fetchLeverageTiers': false,
58721
58783
  'fetchLiquidations': true,
@@ -60782,34 +60844,18 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
60782
60844
  * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
60783
60845
  */
60784
60846
  await this.loadMarkets();
60785
- const positions = await this.fetchPositions(symbols, params);
60786
- const result = [];
60787
- for (let i = 0; i < positions.length; i++) {
60788
- const entry = positions[i];
60789
- const marketId = this.safeString(entry, 'symbol');
60790
- const market = this.safeMarket(marketId, undefined, undefined, 'contract');
60791
- result.push({
60792
- 'info': entry,
60793
- 'symbol': market['symbol'],
60794
- 'leverage': this.safeInteger(entry, 'leverage'),
60795
- 'marginMode': this.safeString(entry, 'marginMode'),
60796
- });
60797
- }
60798
- return result;
60847
+ const leverages = await this.fetchPositions(symbols, params);
60848
+ return this.parseLeverages(leverages, symbols, 'symbol');
60799
60849
  }
60800
- async fetchLeverage(symbol, params = {}) {
60801
- /**
60802
- * @method
60803
- * @name bitmex#fetchLeverage
60804
- * @description fetch the set leverage for a market
60805
- * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
60806
- * @param {string} symbol unified market symbol
60807
- * @param {object} [params] extra parameters specific to the exchange API endpoint
60808
- * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
60809
- */
60810
- await this.loadMarkets();
60811
- const leverage = await this.fetchLeverages([symbol], params);
60812
- return leverage;
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
+ };
60813
60859
  }
60814
60860
  async fetchPositions(symbols = undefined, params = {}) {
60815
60861
  /**
@@ -65969,20 +66015,29 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
65969
66015
  }
65970
66016
  const response = await this.spotV1PrivateGetWithdrawHistory(this.extend(request, params));
65971
66017
  //
65972
- // {
65973
- // "code": 200,
65974
- // "msg": "succ",
65975
- // "data": {
65976
- // "msg": null,
65977
- // "amount": 1000,
65978
- // "fee": 1,
65979
- // "ctime": null,
65980
- // "coin": "usdt_erc20",
65981
- // "addressTo": "0x2edfae3878d7b6db70ce4abed177ab2636f60c83"
65982
- // }
65983
- // }
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
+ // }
65984
66039
  //
65985
- const data = this.safeValue(response, 'data', {});
66040
+ const data = this.safeList(response, 'data', []);
65986
66041
  return this.parseTransactions(data, currency);
65987
66042
  }
65988
66043
  parseTransactionStatusByType(status, type = undefined) {
@@ -66325,7 +66380,7 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
66325
66380
  // }]
66326
66381
  // }
66327
66382
  //
66328
- const data = this.safeValue(response, 'data', {});
66383
+ const data = this.safeList(response, 'data', []);
66329
66384
  return this.parseTransfers(data, currency, since, limit);
66330
66385
  }
66331
66386
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
@@ -78640,7 +78695,30 @@ class blofin extends _abstract_blofin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
78640
78695
  'marginMode': marginMode,
78641
78696
  };
78642
78697
  const response = await this.privateGetAccountLeverageInfo(this.extend(request, params));
78643
- 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
+ };
78644
78722
  }
78645
78723
  async setLeverage(leverage, symbol = undefined, params = {}) {
78646
78724
  /**
@@ -88964,11 +89042,19 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
88964
89042
  * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
88965
89043
  */
88966
89044
  await this.loadMarkets();
89045
+ const market = this.market(symbol);
88967
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');
88968
89052
  return {
88969
- 'info': position,
88970
- 'leverage': this.safeInteger(position, 'leverage'),
88971
- '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,
88972
89058
  };
88973
89059
  }
88974
89060
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
@@ -118369,12 +118455,22 @@ class currencycom extends _abstract_currencycom_js__WEBPACK_IMPORTED_MODULE_0__/
118369
118455
  };
118370
118456
  const response = await this.privateGetV2LeverageSettings(this.extend(request, params));
118371
118457
  //
118372
- // {
118373
- // "values": [ 1, 2, 5, 10, ],
118374
- // "value": "10",
118375
- // }
118458
+ // {
118459
+ // "values": [ 1, 2, 5, 10, ],
118460
+ // "value": "10",
118461
+ // }
118376
118462
  //
118377
- 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
+ };
118378
118474
  }
118379
118475
  async fetchDepositAddress(code, params = {}) {
118380
118476
  /**
@@ -121421,6 +121517,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
121421
121517
  const request = {
121422
121518
  'product_id': market['numericId'],
121423
121519
  };
121520
+ const response = await this.privateGetProductsProductIdOrdersLeverage(this.extend(request, params));
121424
121521
  //
121425
121522
  // {
121426
121523
  // "result": {
@@ -121434,7 +121531,19 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
121434
121531
  // "success": true
121435
121532
  // }
121436
121533
  //
121437
- 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
+ };
121438
121547
  }
121439
121548
  async setLeverage(leverage, symbol = undefined, params = {}) {
121440
121549
  /**
@@ -133416,7 +133525,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
133416
133525
  * @param {object} [params] extra parameters specific to the exchange API endpoint
133417
133526
  * @returns {object[]} an array of objects representing market data
133418
133527
  */
133419
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
133528
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
133420
133529
  let rawPromises = [
133421
133530
  this.fetchContractMarkets(params),
133422
133531
  this.fetchOptionMarkets(params),
@@ -144752,7 +144861,18 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
144752
144861
  // ]
144753
144862
  // }
144754
144863
  //
144755
- 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
+ };
144756
144876
  }
144757
144877
  async setLeverage(leverage, symbol = undefined, params = {}) {
144758
144878
  /**
@@ -167498,7 +167618,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
167498
167618
  //
167499
167619
  return await this.privatePutLeveragepreferences(this.extend(request, params));
167500
167620
  }
167501
- async fetchLeverage(symbol = undefined, params = {}) {
167621
+ async fetchLeverage(symbol, params = {}) {
167502
167622
  /**
167503
167623
  * @method
167504
167624
  * @name krakenfutures#fetchLeverage
@@ -167512,17 +167632,32 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
167512
167632
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchLeverage() requires a symbol argument');
167513
167633
  }
167514
167634
  await this.loadMarkets();
167635
+ const market = this.market(symbol);
167515
167636
  const request = {
167516
167637
  'symbol': this.marketId(symbol).toUpperCase(),
167517
167638
  };
167639
+ const response = await this.privateGetLeveragepreferences(this.extend(request, params));
167518
167640
  //
167519
- // {
167520
- // "result": "success",
167521
- // "serverTime": "2023-08-01T09:54:08.900Z",
167522
- // "leveragePreferences": [ { symbol: "PF_LTCUSD", maxLeverage: "5.00" } ]
167523
- // }
167641
+ // {
167642
+ // "result": "success",
167643
+ // "serverTime": "2023-08-01T09:54:08.900Z",
167644
+ // "leveragePreferences": [ { symbol: "PF_LTCUSD", maxLeverage: "5.00" } ]
167645
+ // }
167524
167646
  //
167525
- 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
+ };
167526
167661
  }
167527
167662
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
167528
167663
  if (response === undefined) {
@@ -175459,7 +175594,7 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175459
175594
  await this.loadMarkets();
175460
175595
  const market = this.market(symbol);
175461
175596
  const request = {
175462
- 'pair': market['id'],
175597
+ 'pairs': market['id'],
175463
175598
  };
175464
175599
  if (limit !== undefined) {
175465
175600
  request['limit'] = limit;
@@ -175467,18 +175602,21 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175467
175602
  const response = await this.v4PublicGetTradePublicBookPairs(this.extend(request, params));
175468
175603
  //
175469
175604
  // {
175470
- // "data": {
175471
- // "id": "3e5591ba-2778-4d85-8851-54284045ea44", // Unique identifier of a trade
175472
- // "pair": "BTC_USDT", // Market pair that is being traded
175473
- // "quoteQuantity": "11528.8118", // Qty of the quote asset, USDT in this example
175474
- // "matchPrice": "18649", // Exchange price at the moment of execution
175475
- // "matchQuantity": "0.6182", // Qty of the base asset, BTC in this example
175476
- // "createdAt": "2022-09-23T14:30:41.486Z", // Date-time of trade execution, UTC
175477
- // "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).
175478
- // }
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
+ // ]
175479
175617
  // }
175480
175618
  //
175481
- const data = this.safeValue(response, 'data', {});
175619
+ const data = this.safeList(response, 'data', []);
175482
175620
  return this.parseTrades(data, market, since, limit);
175483
175621
  }
175484
175622
  parseTrade(trade, market = undefined) {
@@ -190050,30 +190188,30 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
190050
190188
  // }
190051
190189
  //
190052
190190
  const data = this.safeList(response, 'data', []);
190053
- const longLeverage = this.safeDict(data, 0);
190054
- return this.parseLeverage(longLeverage, market);
190191
+ return this.parseLeverage(data, market);
190055
190192
  }
190056
190193
  parseLeverage(leverage, market = undefined) {
190057
- //
190058
- // {
190059
- // "level": 1,
190060
- // "maxVol": 463300,
190061
- // "mmr": 0.004,
190062
- // "imr": 0.005,
190063
- // "positionType": 1,
190064
- // "openType": 1,
190065
- // "leverage": 20,
190066
- // "limitBySys": false,
190067
- // "currentMmr": 0.004
190068
- // }
190069
- //
190070
- const marketId = this.safeString(leverage, 'symbol');
190071
- market = this.safeMarket(marketId, market, undefined, 'contract');
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
+ }
190072
190209
  return {
190073
190210
  'info': leverage,
190074
190211
  'symbol': market['symbol'],
190075
- 'leverage': this.safeInteger(leverage, 'leverage'),
190076
- 'marginMode': undefined,
190212
+ 'marginMode': marginMode,
190213
+ 'longLeverage': longLeverage,
190214
+ 'shortLeverage': shortLeverage,
190077
190215
  };
190078
190216
  }
190079
190217
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
@@ -203522,7 +203660,37 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
203522
203660
  // "msg": ""
203523
203661
  // }
203524
203662
  //
203525
- 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
+ };
203526
203694
  }
203527
203695
  async fetchPosition(symbol, params = {}) {
203528
203696
  /**
@@ -219216,7 +219384,7 @@ class alpaca extends _alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
219216
219384
  for (let i = 0; i < message.length; i++) {
219217
219385
  const data = message[i];
219218
219386
  const T = this.safeString(data, 'T');
219219
- const msg = this.safeValue(data, 'msg', {});
219387
+ const msg = this.safeString(data, 'msg');
219220
219388
  if (T === 'subscription') {
219221
219389
  this.handleSubscription(client, data);
219222
219390
  return;
@@ -271724,12 +271892,10 @@ class whitebit extends _whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
271724
271892
  if (!this.handleErrorMessage(client, message)) {
271725
271893
  return;
271726
271894
  }
271727
- const result = this.safeValue(message, 'result', {});
271728
- if (result !== undefined) {
271729
- if (result === 'pong') {
271730
- this.handlePong(client, message);
271731
- return;
271732
- }
271895
+ const result = this.safeString(message, 'result');
271896
+ if (result === 'pong') {
271897
+ this.handlePong(client, message);
271898
+ return;
271733
271899
  }
271734
271900
  const id = this.safeInteger(message, 'id');
271735
271901
  if (id !== undefined) {
@@ -274257,7 +274423,7 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
274257
274423
  // ]
274258
274424
  // }
274259
274425
  //
274260
- const data = this.safeValue(response, 'data', {});
274426
+ const data = this.safeList(response, 'data', []);
274261
274427
  return this.parseTransactions(data, currency, since, limit);
274262
274428
  }
274263
274429
  parseTransaction(transaction, currency = undefined) {
@@ -291061,7 +291227,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
291061
291227
  'amountAsset': amountAsset,
291062
291228
  'priceAsset': priceAsset,
291063
291229
  };
291064
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
291230
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
291065
291231
  const chainId = (sandboxMode) ? 84 : 87;
291066
291232
  const body = {
291067
291233
  'senderPublicKey': this.apiKey,
@@ -298238,7 +298404,17 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
298238
298404
  return response;
298239
298405
  }
298240
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
+ */
298241
298416
  await this.loadMarkets();
298417
+ const market = this.market(symbol);
298242
298418
  const response = await this.v3PrivateGetAccountinfo(params);
298243
298419
  //
298244
298420
  // {
@@ -298268,11 +298444,17 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
298268
298444
  // "timestamp": 1673323685109
298269
298445
  // }
298270
298446
  //
298271
- const result = this.safeValue(response, 'data');
298272
- 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');
298273
298452
  return {
298274
- 'info': response,
298275
- 'leverage': leverage,
298453
+ 'info': leverage,
298454
+ 'symbol': market['symbol'],
298455
+ 'marginMode': undefined,
298456
+ 'longLeverage': leverageValue,
298457
+ 'shortLeverage': leverageValue,
298276
298458
  };
298277
298459
  }
298278
298460
  async setLeverage(leverage, symbol = undefined, params = {}) {
@@ -307990,7 +308172,7 @@ SOFTWARE.
307990
308172
 
307991
308173
  //-----------------------------------------------------------------------------
307992
308174
  // this is updated by vss.js when building
307993
- const version = '4.2.57';
308175
+ const version = '4.2.58';
307994
308176
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
307995
308177
  //-----------------------------------------------------------------------------
307996
308178