ccxt 4.2.56 → 4.2.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.js +818 -335
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/alpaca.js +90 -88
  6. package/dist/cjs/src/base/Exchange.js +53 -3
  7. package/dist/cjs/src/binance.js +196 -28
  8. package/dist/cjs/src/bingx.js +12 -1
  9. package/dist/cjs/src/bitget.js +71 -56
  10. package/dist/cjs/src/bitmex.js +26 -1
  11. package/dist/cjs/src/bitrue.js +24 -15
  12. package/dist/cjs/src/blofin.js +24 -1
  13. package/dist/cjs/src/bybit.js +11 -3
  14. package/dist/cjs/src/currencycom.js +15 -5
  15. package/dist/cjs/src/delta.js +14 -1
  16. package/dist/cjs/src/gate.js +1 -1
  17. package/dist/cjs/src/hitbtc.js +63 -55
  18. package/dist/cjs/src/krakenfutures.js +22 -7
  19. package/dist/cjs/src/kuna.js +14 -11
  20. package/dist/cjs/src/mexc.js +75 -0
  21. package/dist/cjs/src/okx.js +31 -1
  22. package/dist/cjs/src/pro/alpaca.js +1 -1
  23. package/dist/cjs/src/pro/bitmex.js +23 -32
  24. package/dist/cjs/src/pro/cex.js +6 -2
  25. package/dist/cjs/src/pro/coinex.js +6 -3
  26. package/dist/cjs/src/pro/mexc.js +2 -2
  27. package/dist/cjs/src/pro/whitebit.js +15 -13
  28. package/dist/cjs/src/probit.js +1 -1
  29. package/dist/cjs/src/wavesexchange.js +1 -1
  30. package/dist/cjs/src/woo.js +20 -4
  31. package/js/ccxt.d.ts +3 -3
  32. package/js/ccxt.js +1 -1
  33. package/js/src/alpaca.js +90 -88
  34. package/js/src/base/Exchange.d.ts +14 -6
  35. package/js/src/base/Exchange.js +53 -3
  36. package/js/src/base/types.d.ts +12 -1
  37. package/js/src/binance.d.ts +5 -2
  38. package/js/src/binance.js +196 -28
  39. package/js/src/bingx.d.ts +3 -2
  40. package/js/src/bingx.js +12 -1
  41. package/js/src/bitget.d.ts +3 -2
  42. package/js/src/bitget.js +71 -56
  43. package/js/src/bitmex.d.ts +3 -1
  44. package/js/src/bitmex.js +26 -1
  45. package/js/src/bitrue.js +24 -15
  46. package/js/src/blofin.d.ts +3 -2
  47. package/js/src/blofin.js +24 -1
  48. package/js/src/bybit.d.ts +3 -6
  49. package/js/src/bybit.js +11 -3
  50. package/js/src/currencycom.d.ts +3 -2
  51. package/js/src/currencycom.js +15 -5
  52. package/js/src/delta.d.ts +3 -2
  53. package/js/src/delta.js +14 -1
  54. package/js/src/gate.js +1 -1
  55. package/js/src/hitbtc.d.ts +5 -3
  56. package/js/src/hitbtc.js +63 -55
  57. package/js/src/krakenfutures.d.ts +3 -2
  58. package/js/src/krakenfutures.js +22 -7
  59. package/js/src/kuna.js +14 -11
  60. package/js/src/mexc.d.ts +3 -1
  61. package/js/src/mexc.js +75 -0
  62. package/js/src/okx.d.ts +3 -2
  63. package/js/src/okx.js +31 -1
  64. package/js/src/pro/alpaca.js +1 -1
  65. package/js/src/pro/bitmex.js +24 -31
  66. package/js/src/pro/cex.js +6 -2
  67. package/js/src/pro/coinex.js +6 -3
  68. package/js/src/pro/mexc.js +2 -2
  69. package/js/src/pro/whitebit.js +15 -13
  70. package/js/src/probit.js +1 -1
  71. package/js/src/wavesexchange.js +1 -1
  72. package/js/src/woo.d.ts +3 -5
  73. package/js/src/woo.js +20 -4
  74. package/package.json +1 -1
  75. package/skip-tests.json +26 -8
package/js/src/bitget.js CHANGED
@@ -1428,7 +1428,7 @@ export default class bitget extends Exchange {
1428
1428
  let defaultProductType = undefined;
1429
1429
  if ((subType !== undefined) && (market === undefined)) {
1430
1430
  // set default only if subType is defined and market is not defined, since there is also USDC productTypes which are also linear
1431
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
1431
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1432
1432
  if (sandboxMode) {
1433
1433
  defaultProductType = (subType === 'linear') ? 'SUSDT-FUTURES' : 'SCOIN-FUTURES';
1434
1434
  }
@@ -1497,7 +1497,7 @@ export default class bitget extends Exchange {
1497
1497
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1498
1498
  * @returns {object[]} an array of objects representing market data
1499
1499
  */
1500
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
1500
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1501
1501
  let types = this.safeValue(this.options, 'fetchMarkets', ['spot', 'swap']);
1502
1502
  if (sandboxMode) {
1503
1503
  types = ['swap'];
@@ -1952,7 +1952,7 @@ export default class bitget extends Exchange {
1952
1952
  * @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}
1953
1953
  */
1954
1954
  await this.loadMarkets();
1955
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
1955
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1956
1956
  let market = undefined;
1957
1957
  if (sandboxMode) {
1958
1958
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -2488,7 +2488,7 @@ export default class bitget extends Exchange {
2488
2488
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
2489
2489
  */
2490
2490
  await this.loadMarkets();
2491
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
2491
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2492
2492
  let market = undefined;
2493
2493
  if (sandboxMode) {
2494
2494
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -2651,7 +2651,7 @@ export default class bitget extends Exchange {
2651
2651
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
2652
2652
  */
2653
2653
  await this.loadMarkets();
2654
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
2654
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2655
2655
  let market = undefined;
2656
2656
  if (sandboxMode) {
2657
2657
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -2755,7 +2755,7 @@ export default class bitget extends Exchange {
2755
2755
  let market = undefined;
2756
2756
  if (symbols !== undefined) {
2757
2757
  const symbol = this.safeValue(symbols, 0);
2758
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
2758
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2759
2759
  if (sandboxMode) {
2760
2760
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
2761
2761
  market = this.market(sandboxSymbol);
@@ -2973,7 +2973,7 @@ export default class bitget extends Exchange {
2973
2973
  if (paginate) {
2974
2974
  return await this.fetchPaginatedCallCursor('fetchTrades', symbol, since, limit, params, 'idLessThan', 'idLessThan');
2975
2975
  }
2976
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
2976
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2977
2977
  let market = undefined;
2978
2978
  if (sandboxMode) {
2979
2979
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -3292,7 +3292,7 @@ export default class bitget extends Exchange {
3292
3292
  if (paginate) {
3293
3293
  return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
3294
3294
  }
3295
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
3295
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
3296
3296
  let market = undefined;
3297
3297
  if (sandboxMode) {
3298
3298
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -4112,7 +4112,7 @@ export default class bitget extends Exchange {
4112
4112
  return this.parseOrder(data, market);
4113
4113
  }
4114
4114
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
4115
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
4115
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4116
4116
  let market = undefined;
4117
4117
  if (sandboxMode) {
4118
4118
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -4383,7 +4383,7 @@ export default class bitget extends Exchange {
4383
4383
  const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
4384
4384
  ordersRequests.push(orderRequest);
4385
4385
  }
4386
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
4386
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4387
4387
  let market = undefined;
4388
4388
  if (sandboxMode) {
4389
4389
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -4480,7 +4480,7 @@ export default class bitget extends Exchange {
4480
4480
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4481
4481
  */
4482
4482
  await this.loadMarkets();
4483
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
4483
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4484
4484
  let market = undefined;
4485
4485
  if (sandboxMode) {
4486
4486
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -4646,7 +4646,7 @@ export default class bitget extends Exchange {
4646
4646
  throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
4647
4647
  }
4648
4648
  await this.loadMarkets();
4649
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
4649
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4650
4650
  let market = undefined;
4651
4651
  if (sandboxMode) {
4652
4652
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -4786,7 +4786,7 @@ export default class bitget extends Exchange {
4786
4786
  throw new ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
4787
4787
  }
4788
4788
  await this.loadMarkets();
4789
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
4789
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4790
4790
  let market = undefined;
4791
4791
  if (sandboxMode) {
4792
4792
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -4880,7 +4880,7 @@ export default class bitget extends Exchange {
4880
4880
  throw new ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
4881
4881
  }
4882
4882
  await this.loadMarkets();
4883
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
4883
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4884
4884
  let market = undefined;
4885
4885
  if (sandboxMode) {
4886
4886
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -4984,7 +4984,7 @@ export default class bitget extends Exchange {
4984
4984
  throw new ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
4985
4985
  }
4986
4986
  await this.loadMarkets();
4987
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
4987
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4988
4988
  let market = undefined;
4989
4989
  if (sandboxMode) {
4990
4990
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -5100,7 +5100,7 @@ export default class bitget extends Exchange {
5100
5100
  * @param {int} [limit] the maximum number of open order structures to retrieve
5101
5101
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5102
5102
  * @param {int} [params.until] the latest time in ms to fetch orders for
5103
- * @param {string} [params.planType] *contract stop only* 'normal_plan': average trigger order, 'track_plan': trailing stop order, default is 'normal_plan'
5103
+ * @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'
5104
5104
  * @param {boolean} [params.stop] set to true for fetching trigger orders
5105
5105
  * @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)
5106
5106
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
@@ -5108,7 +5108,7 @@ export default class bitget extends Exchange {
5108
5108
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
5109
5109
  */
5110
5110
  await this.loadMarkets();
5111
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
5111
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5112
5112
  let market = undefined;
5113
5113
  let type = undefined;
5114
5114
  let request = {};
@@ -5146,8 +5146,10 @@ export default class bitget extends Exchange {
5146
5146
  return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
5147
5147
  }
5148
5148
  let response = undefined;
5149
- const trailing = this.safeValue(params, 'trailing');
5150
- const stop = this.safeValue2(params, 'stop', 'trigger');
5149
+ const trailing = this.safeBool(params, 'trailing');
5150
+ const stop = this.safeBool2(params, 'stop', 'trigger');
5151
+ const planTypeDefined = this.safeString(params, 'planType') !== undefined;
5152
+ const isStop = (stop || planTypeDefined);
5151
5153
  params = this.omit(params, ['stop', 'trigger', 'trailing']);
5152
5154
  [request, params] = this.handleUntilOption('endTime', request, params);
5153
5155
  if (since !== undefined) {
@@ -5196,7 +5198,7 @@ export default class bitget extends Exchange {
5196
5198
  request['planType'] = planType;
5197
5199
  response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
5198
5200
  }
5199
- else if (stop) {
5201
+ else if (isStop) {
5200
5202
  const planType = this.safeString(query, 'planType', 'normal_plan');
5201
5203
  request['planType'] = planType;
5202
5204
  response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
@@ -5463,7 +5465,7 @@ export default class bitget extends Exchange {
5463
5465
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
5464
5466
  */
5465
5467
  await this.loadMarkets();
5466
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
5468
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5467
5469
  let market = undefined;
5468
5470
  if (sandboxMode) {
5469
5471
  if (symbol !== undefined) {
@@ -5496,7 +5498,7 @@ export default class bitget extends Exchange {
5496
5498
  }
5497
5499
  let response = undefined;
5498
5500
  const trailing = this.safeValue(params, 'trailing');
5499
- const stop = this.safeValue2(params, 'stop', 'trigger');
5501
+ const stop = this.safeBool2(params, 'stop', 'trigger');
5500
5502
  params = this.omit(params, ['stop', 'trigger', 'trailing']);
5501
5503
  [request, params] = this.handleUntilOption('endTime', request, params);
5502
5504
  if (since !== undefined) {
@@ -5780,7 +5782,7 @@ export default class bitget extends Exchange {
5780
5782
  params = this.omit(params, 'symbol');
5781
5783
  let market = undefined;
5782
5784
  if (symbol !== undefined) {
5783
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
5785
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5784
5786
  if (sandboxMode) {
5785
5787
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5786
5788
  market = this.market(sandboxSymbol);
@@ -6000,7 +6002,7 @@ export default class bitget extends Exchange {
6000
6002
  throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
6001
6003
  }
6002
6004
  await this.loadMarkets();
6003
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
6005
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6004
6006
  let market = undefined;
6005
6007
  if (sandboxMode) {
6006
6008
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -6179,7 +6181,7 @@ export default class bitget extends Exchange {
6179
6181
  * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
6180
6182
  */
6181
6183
  await this.loadMarkets();
6182
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
6184
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6183
6185
  let market = undefined;
6184
6186
  if (sandboxMode) {
6185
6187
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -6255,7 +6257,7 @@ export default class bitget extends Exchange {
6255
6257
  let market = undefined;
6256
6258
  if (symbols !== undefined) {
6257
6259
  const first = this.safeString(symbols, 0);
6258
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
6260
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6259
6261
  if (sandboxMode) {
6260
6262
  const sandboxSymbol = this.convertSymbolForSandbox(first);
6261
6263
  market = this.market(sandboxSymbol);
@@ -6575,7 +6577,7 @@ export default class bitget extends Exchange {
6575
6577
  if (paginate) {
6576
6578
  return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'pageNo', 100);
6577
6579
  }
6578
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
6580
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6579
6581
  let market = undefined;
6580
6582
  if (sandboxMode) {
6581
6583
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -6639,7 +6641,7 @@ export default class bitget extends Exchange {
6639
6641
  * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
6640
6642
  */
6641
6643
  await this.loadMarkets();
6642
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
6644
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6643
6645
  let market = undefined;
6644
6646
  if (sandboxMode) {
6645
6647
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -6726,7 +6728,7 @@ export default class bitget extends Exchange {
6726
6728
  if (paginate) {
6727
6729
  return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'endId', 'idLessThan');
6728
6730
  }
6729
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
6731
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6730
6732
  let market = undefined;
6731
6733
  if (sandboxMode) {
6732
6734
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -6822,7 +6824,7 @@ export default class bitget extends Exchange {
6822
6824
  async modifyMarginHelper(symbol, amount, type, params = {}) {
6823
6825
  await this.loadMarkets();
6824
6826
  const holdSide = this.safeString(params, 'holdSide');
6825
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
6827
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6826
6828
  let market = undefined;
6827
6829
  if (sandboxMode) {
6828
6830
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -6915,7 +6917,7 @@ export default class bitget extends Exchange {
6915
6917
  * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
6916
6918
  */
6917
6919
  await this.loadMarkets();
6918
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
6920
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6919
6921
  let market = undefined;
6920
6922
  if (sandboxMode) {
6921
6923
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -6936,28 +6938,41 @@ export default class bitget extends Exchange {
6936
6938
  // {
6937
6939
  // "code": "00000",
6938
6940
  // "msg": "success",
6939
- // "requestTime": 1700625127294,
6940
- // "data": [
6941
- // {
6942
- // "marginCoin": "USDT",
6943
- // "locked": "0",
6944
- // "available": "0",
6945
- // "crossedMaxAvailable": "0",
6946
- // "isolatedMaxAvailable": "0",
6947
- // "maxTransferOut": "0",
6948
- // "accountEquity": "0",
6949
- // "usdtEquity": "0.000000005166",
6950
- // "btcEquity": "0",
6951
- // "crossedRiskRate": "0",
6952
- // "unrealizedPL": "0",
6953
- // "coupon": "0",
6954
- // "crossedUnrealizedPL": null,
6955
- // "isolatedUnrealizedPL": null
6956
- // }
6957
- // ]
6941
+ // "requestTime": 1709366911964,
6942
+ // "data": {
6943
+ // "marginCoin": "USDT",
6944
+ // "locked": "0",
6945
+ // "available": "0",
6946
+ // "crossedMaxAvailable": "0",
6947
+ // "isolatedMaxAvailable": "0",
6948
+ // "maxTransferOut": "0",
6949
+ // "accountEquity": "0",
6950
+ // "usdtEquity": "0.000000009166",
6951
+ // "btcEquity": "0",
6952
+ // "crossedRiskRate": "0",
6953
+ // "crossedMarginLeverage": 20,
6954
+ // "isolatedLongLever": 20,
6955
+ // "isolatedShortLever": 20,
6956
+ // "marginMode": "crossed",
6957
+ // "posMode": "hedge_mode",
6958
+ // "unrealizedPL": "0",
6959
+ // "coupon": "0",
6960
+ // "crossedUnrealizedPL": "0",
6961
+ // "isolatedUnrealizedPL": ""
6962
+ // }
6958
6963
  // }
6959
6964
  //
6960
- return response;
6965
+ const data = this.safeDict(response, 'data', {});
6966
+ return this.parseLeverage(data, market);
6967
+ }
6968
+ parseLeverage(leverage, market = undefined) {
6969
+ return {
6970
+ 'info': leverage,
6971
+ 'symbol': market['symbol'],
6972
+ 'marginMode': 'isolated',
6973
+ 'longLeverage': this.safeInteger(leverage, 'isolatedLongLever'),
6974
+ 'shortLeverage': this.safeInteger(leverage, 'isolatedShortLever'),
6975
+ };
6961
6976
  }
6962
6977
  async setLeverage(leverage, symbol = undefined, params = {}) {
6963
6978
  /**
@@ -6975,7 +6990,7 @@ export default class bitget extends Exchange {
6975
6990
  throw new ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
6976
6991
  }
6977
6992
  await this.loadMarkets();
6978
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
6993
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6979
6994
  let market = undefined;
6980
6995
  if (sandboxMode) {
6981
6996
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -7033,7 +7048,7 @@ export default class bitget extends Exchange {
7033
7048
  throw new ArgumentsRequired(this.id + ' setMarginMode() marginMode must be either isolated or crossed (cross)');
7034
7049
  }
7035
7050
  await this.loadMarkets();
7036
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
7051
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7037
7052
  let market = undefined;
7038
7053
  if (sandboxMode) {
7039
7054
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -7083,7 +7098,7 @@ export default class bitget extends Exchange {
7083
7098
  const posMode = hedged ? 'hedge_mode' : 'one_way_mode';
7084
7099
  let market = undefined;
7085
7100
  if (symbol !== undefined) {
7086
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
7101
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7087
7102
  if (sandboxMode) {
7088
7103
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7089
7104
  market = this.market(sandboxSymbol);
@@ -7122,7 +7137,7 @@ export default class bitget extends Exchange {
7122
7137
  * @returns {object} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure}
7123
7138
  */
7124
7139
  await this.loadMarkets();
7125
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
7140
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7126
7141
  let market = undefined;
7127
7142
  if (sandboxMode) {
7128
7143
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -8156,7 +8171,7 @@ export default class bitget extends Exchange {
8156
8171
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
8157
8172
  */
8158
8173
  await this.loadMarkets();
8159
- const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
8174
+ const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
8160
8175
  let market = undefined;
8161
8176
  if (sandboxMode) {
8162
8177
  const sandboxSymbol = this.convertSymbolForSandbox(symbol);
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitmex.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, Liquidation, OrderBook, Balances, Str, Transaction, Ticker, Tickers, Market, Strings, Currency } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, Liquidation, OrderBook, Balances, Str, Transaction, Ticker, Tickers, Market, Strings, Currency, Leverage, Leverages } from './base/types.js';
3
3
  /**
4
4
  * @class bitmex
5
5
  * @augments Exchange
@@ -62,6 +62,8 @@ export default class bitmex extends Exchange {
62
62
  cancelOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
63
63
  cancelOrders(ids: any, symbol?: Str, params?: {}): Promise<Order[]>;
64
64
  cancelAllOrders(symbol?: Str, params?: {}): Promise<Order[]>;
65
+ fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
66
+ parseLeverage(leverage: any, market?: any): Leverage;
65
67
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
66
68
  parsePosition(position: any, market?: Market): import("./base/types.js").Position;
67
69
  withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
package/js/src/bitmex.js CHANGED
@@ -62,7 +62,8 @@ export default class bitmex extends Exchange {
62
62
  'fetchFundingRates': true,
63
63
  'fetchIndexOHLCV': false,
64
64
  'fetchLedger': true,
65
- 'fetchLeverage': false,
65
+ 'fetchLeverage': 'emulated',
66
+ 'fetchLeverages': true,
66
67
  'fetchLeverageTiers': false,
67
68
  'fetchLiquidations': true,
68
69
  'fetchMarketLeverageTiers': false,
@@ -2117,6 +2118,30 @@ export default class bitmex extends Exchange {
2117
2118
  //
2118
2119
  return this.parseOrders(response, market);
2119
2120
  }
2121
+ async fetchLeverages(symbols = undefined, params = {}) {
2122
+ /**
2123
+ * @method
2124
+ * @name bitmex#fetchLeverages
2125
+ * @description fetch the set leverage for all contract markets
2126
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
2127
+ * @param {string[]} [symbols] a list of unified market symbols
2128
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
2129
+ * @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
2130
+ */
2131
+ await this.loadMarkets();
2132
+ const leverages = await this.fetchPositions(symbols, params);
2133
+ return this.parseLeverages(leverages, symbols, 'symbol');
2134
+ }
2135
+ parseLeverage(leverage, market = undefined) {
2136
+ const marketId = this.safeString(leverage, 'symbol');
2137
+ return {
2138
+ 'info': leverage,
2139
+ 'symbol': this.safeSymbol(marketId, market),
2140
+ 'marginMode': this.safeStringLower(leverage, 'marginMode'),
2141
+ 'longLeverage': this.safeInteger(leverage, 'leverage'),
2142
+ 'shortLeverage': this.safeInteger(leverage, 'leverage'),
2143
+ };
2144
+ }
2120
2145
  async fetchPositions(symbols = undefined, params = {}) {
2121
2146
  /**
2122
2147
  * @method
package/js/src/bitrue.js CHANGED
@@ -2606,20 +2606,29 @@ export default class bitrue extends Exchange {
2606
2606
  }
2607
2607
  const response = await this.spotV1PrivateGetWithdrawHistory(this.extend(request, params));
2608
2608
  //
2609
- // {
2610
- // "code": 200,
2611
- // "msg": "succ",
2612
- // "data": {
2613
- // "msg": null,
2614
- // "amount": 1000,
2615
- // "fee": 1,
2616
- // "ctime": null,
2617
- // "coin": "usdt_erc20",
2618
- // "addressTo": "0x2edfae3878d7b6db70ce4abed177ab2636f60c83"
2619
- // }
2620
- // }
2621
- //
2622
- const data = this.safeValue(response, 'data', {});
2609
+ // {
2610
+ // "code": 200,
2611
+ // "msg": "succ",
2612
+ // "data": [
2613
+ // {
2614
+ // "id": 183745,
2615
+ // "symbol": "usdt_erc20",
2616
+ // "amount": "8.4000000000000000",
2617
+ // "fee": "1.6000000000000000",
2618
+ // "payAmount": "0.0000000000000000",
2619
+ // "createdAt": 1595336441000,
2620
+ // "updatedAt": 1595336576000,
2621
+ // "addressFrom": "",
2622
+ // "addressTo": "0x2edfae3878d7b6db70ce4abed177ab2636f60c83",
2623
+ // "txid": "",
2624
+ // "confirmations": 0,
2625
+ // "status": 6,
2626
+ // "tagType": null
2627
+ // }
2628
+ // ]
2629
+ // }
2630
+ //
2631
+ const data = this.safeList(response, 'data', []);
2623
2632
  return this.parseTransactions(data, currency);
2624
2633
  }
2625
2634
  parseTransactionStatusByType(status, type = undefined) {
@@ -2962,7 +2971,7 @@ export default class bitrue extends Exchange {
2962
2971
  // }]
2963
2972
  // }
2964
2973
  //
2965
- const data = this.safeValue(response, 'data', {});
2974
+ const data = this.safeList(response, 'data', []);
2966
2975
  return this.parseTransfers(data, currency, since, limit);
2967
2976
  }
2968
2977
  async transfer(code, amount, fromAccount, toAccount, params = {}) {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/blofin.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, Str, Transaction, Ticker, OrderBook, Balances, Tickers, Market, Strings, Currency, Position, TransferEntry, Leverage } from './base/types.js';
3
3
  /**
4
4
  * @class blofin
5
5
  * @augments Exchange
@@ -110,7 +110,8 @@ export default class blofin extends Exchange {
110
110
  fetchPosition(symbol: string, params?: {}): Promise<Position>;
111
111
  fetchPositions(symbols?: string[], params?: {}): Promise<Position[]>;
112
112
  parsePosition(position: any, market?: Market): Position;
113
- fetchLeverage(symbol: string, params?: {}): Promise<any>;
113
+ fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
114
+ parseLeverage(leverage: any, market?: any): Leverage;
114
115
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
115
116
  closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
116
117
  fetchClosedOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
package/js/src/blofin.js CHANGED
@@ -1910,7 +1910,30 @@ export default class blofin extends Exchange {
1910
1910
  'marginMode': marginMode,
1911
1911
  };
1912
1912
  const response = await this.privateGetAccountLeverageInfo(this.extend(request, params));
1913
- return response;
1913
+ //
1914
+ // {
1915
+ // "code": "0",
1916
+ // "msg": "success",
1917
+ // "data": {
1918
+ // "leverage": "3",
1919
+ // "marginMode": "cross",
1920
+ // "instId": "BTC-USDT"
1921
+ // }
1922
+ // }
1923
+ //
1924
+ const data = this.safeDict(response, 'data', {});
1925
+ return this.parseLeverage(data, market);
1926
+ }
1927
+ parseLeverage(leverage, market = undefined) {
1928
+ const marketId = this.safeString(leverage, 'instId');
1929
+ const leverageValue = this.safeInteger(leverage, 'leverage');
1930
+ return {
1931
+ 'info': leverage,
1932
+ 'symbol': this.safeSymbol(marketId, market),
1933
+ 'marginMode': this.safeStringLower(leverage, 'marginMode'),
1934
+ 'longLeverage': leverageValue,
1935
+ 'shortLeverage': leverageValue,
1936
+ };
1914
1937
  }
1915
1938
  async setLeverage(leverage, symbol = undefined, params = {}) {
1916
1939
  /**
package/js/src/bybit.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bybit.js';
2
- import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation, Leverage } from './base/types.js';
3
3
  /**
4
4
  * @class bybit
5
5
  * @augments Exchange
@@ -126,11 +126,8 @@ export default class bybit extends Exchange {
126
126
  fetchUsdcPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
127
127
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
128
128
  parsePosition(position: any, market?: Market): import("./base/types.js").Position;
129
- fetchLeverage(symbol: string, params?: {}): Promise<{
130
- info: import("./base/types.js").Position;
131
- leverage: number;
132
- marginMode: number;
133
- }>;
129
+ fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
130
+ parseLeverage(leverage: any, market?: any): Leverage;
134
131
  setMarginMode(marginMode: string, symbol?: Str, params?: {}): Promise<any>;
135
132
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
136
133
  setPositionMode(hedged: boolean, symbol?: Str, params?: {}): Promise<any>;
package/js/src/bybit.js CHANGED
@@ -6359,11 +6359,19 @@ export default class bybit extends Exchange {
6359
6359
  * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
6360
6360
  */
6361
6361
  await this.loadMarkets();
6362
+ const market = this.market(symbol);
6362
6363
  const position = await this.fetchPosition(symbol, params);
6364
+ return this.parseLeverage(position, market);
6365
+ }
6366
+ parseLeverage(leverage, market = undefined) {
6367
+ const marketId = this.safeString(leverage, 'symbol');
6368
+ const leverageValue = this.safeInteger(leverage, 'leverage');
6363
6369
  return {
6364
- 'info': position,
6365
- 'leverage': this.safeInteger(position, 'leverage'),
6366
- 'marginMode': this.safeNumber(position, 'marginMode'),
6370
+ 'info': leverage,
6371
+ 'symbol': this.safeSymbol(marketId, market),
6372
+ 'marginMode': this.safeStringLower(leverage, 'marginMode'),
6373
+ 'longLeverage': leverageValue,
6374
+ 'shortLeverage': leverageValue,
6367
6375
  };
6368
6376
  }
6369
6377
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/currencycom.js';
2
- import type { Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction } from './base/types.js';
2
+ import type { Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, Leverage } from './base/types.js';
3
3
  /**
4
4
  * @class currencycom
5
5
  * @augments Exchange
@@ -59,7 +59,8 @@ export default class currencycom extends Exchange {
59
59
  };
60
60
  parseLedgerEntryStatus(status: any): string;
61
61
  parseLedgerEntryType(type: any): string;
62
- fetchLeverage(symbol: string, params?: {}): Promise<number>;
62
+ fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
63
+ parseLeverage(leverage: any, market?: any): Leverage;
63
64
  fetchDepositAddress(code: string, params?: {}): Promise<{
64
65
  currency: string;
65
66
  address: string;
@@ -1809,12 +1809,22 @@ export default class currencycom extends Exchange {
1809
1809
  };
1810
1810
  const response = await this.privateGetV2LeverageSettings(this.extend(request, params));
1811
1811
  //
1812
- // {
1813
- // "values": [ 1, 2, 5, 10, ],
1814
- // "value": "10",
1815
- // }
1812
+ // {
1813
+ // "values": [ 1, 2, 5, 10, ],
1814
+ // "value": "10",
1815
+ // }
1816
1816
  //
1817
- return this.safeNumber(response, 'value');
1817
+ return this.parseLeverage(response, market);
1818
+ }
1819
+ parseLeverage(leverage, market = undefined) {
1820
+ const leverageValue = this.safeInteger(leverage, 'value');
1821
+ return {
1822
+ 'info': leverage,
1823
+ 'symbol': market['symbol'],
1824
+ 'marginMode': undefined,
1825
+ 'longLeverage': leverageValue,
1826
+ 'shortLeverage': leverageValue,
1827
+ };
1818
1828
  }
1819
1829
  async fetchDepositAddress(code, params = {}) {
1820
1830
  /**