ccxt 4.4.69 → 4.4.71

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 (80) hide show
  1. package/README.md +5 -8
  2. package/dist/ccxt.browser.min.js +7 -7
  3. package/dist/cjs/ccxt.js +1 -6
  4. package/dist/cjs/src/abstract/poloniexfutures.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +22 -1
  6. package/dist/cjs/src/binance.js +107 -102
  7. package/dist/cjs/src/bingx.js +64 -42
  8. package/dist/cjs/src/bitget.js +50 -340
  9. package/dist/cjs/src/bitmart.js +15 -1
  10. package/dist/cjs/src/bitopro.js +1 -0
  11. package/dist/cjs/src/bitrue.js +1 -0
  12. package/dist/cjs/src/bybit.js +7 -0
  13. package/dist/cjs/src/cex.js +1 -0
  14. package/dist/cjs/src/coinbase.js +24 -4
  15. package/dist/cjs/src/coinbaseexchange.js +1 -0
  16. package/dist/cjs/src/deribit.js +1 -0
  17. package/dist/cjs/src/hashkey.js +4 -2
  18. package/dist/cjs/src/hyperliquid.js +18 -7
  19. package/dist/cjs/src/kraken.js +83 -6
  20. package/dist/cjs/src/kucoin.js +4 -2
  21. package/dist/cjs/src/mexc.js +8 -4
  22. package/dist/cjs/src/okx.js +62 -46
  23. package/dist/cjs/src/poloniex.js +1311 -81
  24. package/dist/cjs/src/poloniexfutures.js +1 -1
  25. package/dist/cjs/src/pro/binance.js +94 -94
  26. package/dist/cjs/src/pro/bingx.js +63 -52
  27. package/dist/cjs/src/pro/bitget.js +40 -7
  28. package/dist/cjs/src/pro/bybit.js +86 -38
  29. package/dist/cjs/src/pro/poloniexfutures.js +1 -1
  30. package/dist/cjs/src/tradeogre.js +22 -4
  31. package/dist/cjs/src/whitebit.js +4 -2
  32. package/js/ccxt.d.ts +3 -9
  33. package/js/ccxt.js +2 -6
  34. package/js/src/abstract/bingx.d.ts +1 -0
  35. package/js/src/abstract/bitmart.d.ts +1 -0
  36. package/js/src/abstract/bybit.d.ts +4 -0
  37. package/js/src/abstract/myokx.d.ts +3 -0
  38. package/js/src/abstract/okx.d.ts +3 -0
  39. package/js/src/abstract/poloniex.d.ts +36 -0
  40. package/js/src/abstract/poloniexfutures.js +6 -0
  41. package/js/src/abstract/tradeogre.d.ts +1 -1
  42. package/js/src/base/Exchange.d.ts +11 -2
  43. package/js/src/base/Exchange.js +22 -1
  44. package/js/src/base/types.d.ts +33 -2
  45. package/js/src/binance.d.ts +98 -97
  46. package/js/src/binance.js +107 -102
  47. package/js/src/bingx.js +64 -42
  48. package/js/src/bitget.d.ts +0 -1
  49. package/js/src/bitget.js +50 -340
  50. package/js/src/bitmart.d.ts +1 -0
  51. package/js/src/bitmart.js +15 -1
  52. package/js/src/bitopro.js +1 -0
  53. package/js/src/bitrue.js +1 -0
  54. package/js/src/bybit.js +7 -0
  55. package/js/src/cex.js +1 -0
  56. package/js/src/coinbase.js +24 -4
  57. package/js/src/coinbaseexchange.js +1 -0
  58. package/js/src/deribit.js +1 -0
  59. package/js/src/hashkey.js +4 -2
  60. package/js/src/hyperliquid.js +18 -7
  61. package/js/src/kraken.d.ts +1 -0
  62. package/js/src/kraken.js +83 -6
  63. package/js/src/kucoin.js +4 -2
  64. package/js/src/mexc.js +8 -4
  65. package/js/src/okx.d.ts +1 -0
  66. package/js/src/okx.js +62 -46
  67. package/js/src/poloniex.d.ts +109 -1
  68. package/js/src/poloniex.js +1311 -81
  69. package/js/src/poloniexfutures.js +6 -0
  70. package/js/src/pro/binance.d.ts +94 -94
  71. package/js/src/pro/binance.js +94 -94
  72. package/js/src/pro/bingx.js +63 -52
  73. package/js/src/pro/bitget.js +40 -7
  74. package/js/src/pro/bybit.d.ts +1 -0
  75. package/js/src/pro/bybit.js +86 -38
  76. package/js/src/pro/poloniexfutures.js +6 -0
  77. package/js/src/tradeogre.d.ts +1 -0
  78. package/js/src/tradeogre.js +22 -4
  79. package/js/src/whitebit.js +4 -2
  80. package/package.json +1 -1
package/js/src/bitget.js CHANGED
@@ -1665,38 +1665,6 @@ export default class bitget extends Exchange {
1665
1665
  setSandboxMode(enabled) {
1666
1666
  this.options['sandboxMode'] = enabled;
1667
1667
  }
1668
- convertSymbolForSandbox(symbol) {
1669
- if (symbol.startsWith('S')) {
1670
- // handle using the exchange specified sandbox symbols
1671
- return symbol;
1672
- }
1673
- let convertedSymbol = undefined;
1674
- if (symbol.indexOf('/') > -1) {
1675
- if (symbol.indexOf(':') === -1) {
1676
- throw new NotSupported(this.id + ' sandbox supports swap and future markets only');
1677
- }
1678
- const splitBase = symbol.split('/');
1679
- const previousBase = this.safeString(splitBase, 0);
1680
- const previousQuoteSettleExpiry = this.safeString(splitBase, 1);
1681
- const splitQuote = previousQuoteSettleExpiry.split(':');
1682
- const previousQuote = this.safeString(splitQuote, 0);
1683
- const previousSettleExpiry = this.safeString(splitQuote, 1);
1684
- const splitSettle = previousSettleExpiry.split('-');
1685
- const previousSettle = this.safeString(splitSettle, 0);
1686
- const expiry = this.safeString(splitSettle, 1);
1687
- convertedSymbol = 'S' + previousBase + '/S' + previousQuote + ':S' + previousSettle;
1688
- if (expiry !== undefined) {
1689
- convertedSymbol = convertedSymbol + '-' + expiry;
1690
- }
1691
- }
1692
- else {
1693
- // handle using a market id instead of a unified symbol
1694
- const base = symbol.slice(0, 3);
1695
- const remaining = symbol.slice(3);
1696
- convertedSymbol = 'S' + base + 'S' + remaining;
1697
- }
1698
- return convertedSymbol;
1699
- }
1700
1668
  handleProductTypeAndParams(market = undefined, params = {}) {
1701
1669
  let subType = undefined;
1702
1670
  [subType, params] = this.handleSubTypeAndParams('handleProductTypeAndParams', undefined, params);
@@ -1776,24 +1744,13 @@ export default class bitget extends Exchange {
1776
1744
  if (this.options['adjustForTimeDifference']) {
1777
1745
  await this.loadTimeDifference();
1778
1746
  }
1779
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1780
- let types = this.safeValue(this.options, 'fetchMarkets', ['spot', 'swap']);
1781
- if (sandboxMode) {
1782
- types = ['swap'];
1783
- }
1747
+ const types = this.safeValue(this.options, 'fetchMarkets', ['spot', 'swap']);
1784
1748
  const promises = [];
1785
1749
  let fetchMargins = false;
1786
1750
  for (let i = 0; i < types.length; i++) {
1787
1751
  const type = types[i];
1788
1752
  if ((type === 'swap') || (type === 'future')) {
1789
- let subTypes = undefined;
1790
- if (sandboxMode) {
1791
- // the following are simulated trading markets [ 'SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES' ];
1792
- subTypes = ['SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES'];
1793
- }
1794
- else {
1795
- subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES'];
1796
- }
1753
+ const subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES', 'SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES'];
1797
1754
  for (let j = 0; j < subTypes.length; j++) {
1798
1755
  promises.push(this.publicMixGetV2MixMarketContracts(this.extend(params, {
1799
1756
  'productType': subTypes[j],
@@ -2186,15 +2143,7 @@ export default class bitget extends Exchange {
2186
2143
  */
2187
2144
  async fetchMarketLeverageTiers(symbol, params = {}) {
2188
2145
  await this.loadMarkets();
2189
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2190
- let market = undefined;
2191
- if (sandboxMode) {
2192
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
2193
- market = this.market(sandboxSymbol);
2194
- }
2195
- else {
2196
- market = this.market(symbol);
2197
- }
2146
+ const market = this.market(symbol);
2198
2147
  const request = {};
2199
2148
  let response = undefined;
2200
2149
  let marginMode = undefined;
@@ -2701,15 +2650,7 @@ export default class bitget extends Exchange {
2701
2650
  */
2702
2651
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
2703
2652
  await this.loadMarkets();
2704
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2705
- let market = undefined;
2706
- if (sandboxMode) {
2707
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
2708
- market = this.market(sandboxSymbol);
2709
- }
2710
- else {
2711
- market = this.market(symbol);
2712
- }
2653
+ const market = this.market(symbol);
2713
2654
  const request = {
2714
2655
  'symbol': market['id'],
2715
2656
  };
@@ -2874,15 +2815,7 @@ export default class bitget extends Exchange {
2874
2815
  */
2875
2816
  async fetchTicker(symbol, params = {}) {
2876
2817
  await this.loadMarkets();
2877
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2878
- let market = undefined;
2879
- if (sandboxMode) {
2880
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
2881
- market = this.market(sandboxSymbol);
2882
- }
2883
- else {
2884
- market = this.market(symbol);
2885
- }
2818
+ const market = this.market(symbol);
2886
2819
  const request = {
2887
2820
  'symbol': market['id'],
2888
2821
  };
@@ -2973,15 +2906,7 @@ export default class bitget extends Exchange {
2973
2906
  */
2974
2907
  async fetchMarkPrice(symbol, params = {}) {
2975
2908
  await this.loadMarkets();
2976
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2977
- let market = undefined;
2978
- if (sandboxMode) {
2979
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
2980
- market = this.market(sandboxSymbol);
2981
- }
2982
- else {
2983
- market = this.market(symbol);
2984
- }
2909
+ const market = this.market(symbol);
2985
2910
  const request = {
2986
2911
  'symbol': market['id'],
2987
2912
  };
@@ -3015,14 +2940,7 @@ export default class bitget extends Exchange {
3015
2940
  let market = undefined;
3016
2941
  if (symbols !== undefined) {
3017
2942
  const symbol = this.safeValue(symbols, 0);
3018
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
3019
- if (sandboxMode) {
3020
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
3021
- market = this.market(sandboxSymbol);
3022
- }
3023
- else {
3024
- market = this.market(symbol);
3025
- }
2943
+ market = this.market(symbol);
3026
2944
  }
3027
2945
  let response = undefined;
3028
2946
  const request = {};
@@ -3245,15 +3163,7 @@ export default class bitget extends Exchange {
3245
3163
  if (paginate) {
3246
3164
  return await this.fetchPaginatedCallCursor('fetchTrades', symbol, since, limit, params, 'idLessThan', 'idLessThan');
3247
3165
  }
3248
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
3249
- let market = undefined;
3250
- if (sandboxMode) {
3251
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
3252
- market = this.market(sandboxSymbol);
3253
- }
3254
- else {
3255
- market = this.market(symbol);
3256
- }
3166
+ const market = this.market(symbol);
3257
3167
  let request = {
3258
3168
  'symbol': market['id'],
3259
3169
  };
@@ -3570,16 +3480,8 @@ export default class bitget extends Exchange {
3570
3480
  if (paginate) {
3571
3481
  return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimitForRecentEndpoint);
3572
3482
  }
3573
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
3574
3483
  const useHistoryEndpoint = this.safeBool(params, 'useHistoryEndpoint', false);
3575
- let market = undefined;
3576
- if (sandboxMode) {
3577
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
3578
- market = this.market(sandboxSymbol);
3579
- }
3580
- else {
3581
- market = this.market(symbol);
3582
- }
3484
+ const market = this.market(symbol);
3583
3485
  const marketType = market['spot'] ? 'spot' : 'swap';
3584
3486
  const timeframes = this.options['timeframes'][marketType];
3585
3487
  const msInDay = 86400000;
@@ -4437,15 +4339,7 @@ export default class bitget extends Exchange {
4437
4339
  return this.parseOrder(data, market);
4438
4340
  }
4439
4341
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
4440
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4441
- let market = undefined;
4442
- if (sandboxMode) {
4443
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
4444
- market = this.market(sandboxSymbol);
4445
- }
4446
- else {
4447
- market = this.market(symbol);
4448
- }
4342
+ const market = this.market(symbol);
4449
4343
  let marketType = undefined;
4450
4344
  let marginMode = undefined;
4451
4345
  [marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params);
@@ -4714,15 +4608,7 @@ export default class bitget extends Exchange {
4714
4608
  const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
4715
4609
  ordersRequests.push(orderRequest);
4716
4610
  }
4717
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4718
- let market = undefined;
4719
- if (sandboxMode) {
4720
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
4721
- market = this.market(sandboxSymbol);
4722
- }
4723
- else {
4724
- market = this.market(symbol);
4725
- }
4611
+ const market = this.market(symbol);
4726
4612
  const request = {
4727
4613
  'symbol': market['id'],
4728
4614
  'orderList': ordersRequests,
@@ -4811,15 +4697,7 @@ export default class bitget extends Exchange {
4811
4697
  */
4812
4698
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
4813
4699
  await this.loadMarkets();
4814
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4815
- let market = undefined;
4816
- if (sandboxMode) {
4817
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
4818
- market = this.market(sandboxSymbol);
4819
- }
4820
- else {
4821
- market = this.market(symbol);
4822
- }
4700
+ const market = this.market(symbol);
4823
4701
  const request = {
4824
4702
  'orderId': id,
4825
4703
  };
@@ -4982,15 +4860,7 @@ export default class bitget extends Exchange {
4982
4860
  throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
4983
4861
  }
4984
4862
  await this.loadMarkets();
4985
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4986
- let market = undefined;
4987
- if (sandboxMode) {
4988
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
4989
- market = this.market(sandboxSymbol);
4990
- }
4991
- else {
4992
- market = this.market(symbol);
4993
- }
4863
+ const market = this.market(symbol);
4994
4864
  let marginMode = undefined;
4995
4865
  let response = undefined;
4996
4866
  [marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
@@ -5122,15 +4992,7 @@ export default class bitget extends Exchange {
5122
4992
  throw new ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
5123
4993
  }
5124
4994
  await this.loadMarkets();
5125
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5126
- let market = undefined;
5127
- if (sandboxMode) {
5128
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5129
- market = this.market(sandboxSymbol);
5130
- }
5131
- else {
5132
- market = this.market(symbol);
5133
- }
4995
+ const market = this.market(symbol);
5134
4996
  let marginMode = undefined;
5135
4997
  [marginMode, params] = this.handleMarginModeAndParams('cancelOrders', params);
5136
4998
  const trigger = this.safeValue2(params, 'stop', 'trigger');
@@ -5217,15 +5079,7 @@ export default class bitget extends Exchange {
5217
5079
  throw new ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
5218
5080
  }
5219
5081
  await this.loadMarkets();
5220
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5221
- let market = undefined;
5222
- if (sandboxMode) {
5223
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5224
- market = this.market(sandboxSymbol);
5225
- }
5226
- else {
5227
- market = this.market(symbol);
5228
- }
5082
+ const market = this.market(symbol);
5229
5083
  let marginMode = undefined;
5230
5084
  [marginMode, params] = this.handleMarginModeAndParams('cancelAllOrders', params);
5231
5085
  const request = {
@@ -5339,15 +5193,7 @@ export default class bitget extends Exchange {
5339
5193
  throw new ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
5340
5194
  }
5341
5195
  await this.loadMarkets();
5342
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5343
- let market = undefined;
5344
- if (sandboxMode) {
5345
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5346
- market = this.market(sandboxSymbol);
5347
- }
5348
- else {
5349
- market = this.market(symbol);
5350
- }
5196
+ const market = this.market(symbol);
5351
5197
  const request = {
5352
5198
  'orderId': id,
5353
5199
  };
@@ -5471,20 +5317,13 @@ export default class bitget extends Exchange {
5471
5317
  */
5472
5318
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5473
5319
  await this.loadMarkets();
5474
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5475
5320
  let market = undefined;
5476
5321
  let type = undefined;
5477
5322
  let request = {};
5478
5323
  let marginMode = undefined;
5479
5324
  [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
5480
5325
  if (symbol !== undefined) {
5481
- if (sandboxMode) {
5482
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5483
- market = this.market(sandboxSymbol);
5484
- }
5485
- else {
5486
- market = this.market(symbol);
5487
- }
5326
+ market = this.market(symbol);
5488
5327
  request['symbol'] = market['id'];
5489
5328
  const defaultType = this.safeString2(this.options, 'fetchOpenOrders', 'defaultType', 'spot');
5490
5329
  const marketType = ('type' in market) ? market['type'] : defaultType;
@@ -5836,14 +5675,7 @@ export default class bitget extends Exchange {
5836
5675
  */
5837
5676
  async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5838
5677
  await this.loadMarkets();
5839
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5840
5678
  let market = undefined;
5841
- if (sandboxMode) {
5842
- if (symbol !== undefined) {
5843
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5844
- symbol = sandboxSymbol;
5845
- }
5846
- }
5847
5679
  let request = {};
5848
5680
  if (symbol !== undefined) {
5849
5681
  market = this.market(symbol);
@@ -6152,14 +5984,7 @@ export default class bitget extends Exchange {
6152
5984
  params = this.omit(params, 'symbol');
6153
5985
  let market = undefined;
6154
5986
  if (symbol !== undefined) {
6155
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6156
- if (sandboxMode) {
6157
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
6158
- market = this.market(sandboxSymbol);
6159
- }
6160
- else {
6161
- market = this.market(symbol);
6162
- }
5987
+ market = this.market(symbol);
6163
5988
  }
6164
5989
  let marketType = undefined;
6165
5990
  [marketType, params] = this.handleMarketTypeAndParams('fetchLedger', market, params);
@@ -6376,15 +6201,7 @@ export default class bitget extends Exchange {
6376
6201
  throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
6377
6202
  }
6378
6203
  await this.loadMarkets();
6379
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6380
- let market = undefined;
6381
- if (sandboxMode) {
6382
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
6383
- market = this.market(sandboxSymbol);
6384
- }
6385
- else {
6386
- market = this.market(symbol);
6387
- }
6204
+ const market = this.market(symbol);
6388
6205
  let marginMode = undefined;
6389
6206
  [marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
6390
6207
  let paginate = false;
@@ -6555,15 +6372,7 @@ export default class bitget extends Exchange {
6555
6372
  */
6556
6373
  async fetchPosition(symbol, params = {}) {
6557
6374
  await this.loadMarkets();
6558
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6559
- let market = undefined;
6560
- if (sandboxMode) {
6561
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
6562
- market = this.market(sandboxSymbol);
6563
- }
6564
- else {
6565
- market = this.market(symbol);
6566
- }
6375
+ const market = this.market(symbol);
6567
6376
  let productType = undefined;
6568
6377
  [productType, params] = this.handleProductTypeAndParams(market, params);
6569
6378
  const request = {
@@ -6639,14 +6448,7 @@ export default class bitget extends Exchange {
6639
6448
  let market = undefined;
6640
6449
  if (symbols !== undefined) {
6641
6450
  const first = this.safeString(symbols, 0);
6642
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6643
- if (sandboxMode) {
6644
- const sandboxSymbol = this.convertSymbolForSandbox(first);
6645
- market = this.market(sandboxSymbol);
6646
- }
6647
- else {
6648
- market = this.market(first);
6649
- }
6451
+ market = this.market(first);
6650
6452
  }
6651
6453
  let productType = undefined;
6652
6454
  [productType, params] = this.handleProductTypeAndParams(market, params);
@@ -6959,15 +6761,7 @@ export default class bitget extends Exchange {
6959
6761
  if (paginate) {
6960
6762
  return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'pageNo', 100);
6961
6763
  }
6962
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6963
- let market = undefined;
6964
- if (sandboxMode) {
6965
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
6966
- market = this.market(sandboxSymbol);
6967
- }
6968
- else {
6969
- market = this.market(symbol);
6970
- }
6764
+ const market = this.market(symbol);
6971
6765
  let productType = undefined;
6972
6766
  [productType, params] = this.handleProductTypeAndParams(market, params);
6973
6767
  const request = {
@@ -7023,15 +6817,7 @@ export default class bitget extends Exchange {
7023
6817
  */
7024
6818
  async fetchFundingRate(symbol, params = {}) {
7025
6819
  await this.loadMarkets();
7026
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7027
- let market = undefined;
7028
- if (sandboxMode) {
7029
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7030
- market = this.market(sandboxSymbol);
7031
- }
7032
- else {
7033
- market = this.market(symbol);
7034
- }
6820
+ const market = this.market(symbol);
7035
6821
  if (!market['swap']) {
7036
6822
  throw new BadSymbol(this.id + ' fetchFundingRate() supports swap contracts only');
7037
6823
  }
@@ -7074,14 +6860,7 @@ export default class bitget extends Exchange {
7074
6860
  let market = undefined;
7075
6861
  if (symbols !== undefined) {
7076
6862
  const symbol = this.safeValue(symbols, 0);
7077
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7078
- if (sandboxMode) {
7079
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7080
- market = this.market(sandboxSymbol);
7081
- }
7082
- else {
7083
- market = this.market(symbol);
7084
- }
6863
+ market = this.market(symbol);
7085
6864
  }
7086
6865
  const request = {};
7087
6866
  let productType = undefined;
@@ -7221,15 +7000,7 @@ export default class bitget extends Exchange {
7221
7000
  if (paginate) {
7222
7001
  return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'endId', 'idLessThan');
7223
7002
  }
7224
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7225
- let market = undefined;
7226
- if (sandboxMode) {
7227
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7228
- market = this.market(sandboxSymbol);
7229
- }
7230
- else {
7231
- market = this.market(symbol);
7232
- }
7003
+ const market = this.market(symbol);
7233
7004
  if (!market['swap']) {
7234
7005
  throw new BadSymbol(this.id + ' fetchFundingHistory() supports swap contracts only');
7235
7006
  }
@@ -7312,20 +7083,16 @@ export default class bitget extends Exchange {
7312
7083
  result.push(this.parseFundingHistory(contract, market));
7313
7084
  }
7314
7085
  const sorted = this.sortBy(result, 'timestamp');
7315
- return this.filterBySinceLimit(sorted, since, limit);
7086
+ let symbol = undefined;
7087
+ if (market !== undefined) {
7088
+ symbol = market['symbol'];
7089
+ }
7090
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
7316
7091
  }
7317
7092
  async modifyMarginHelper(symbol, amount, type, params = {}) {
7318
7093
  await this.loadMarkets();
7319
7094
  const holdSide = this.safeString(params, 'holdSide');
7320
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7321
- let market = undefined;
7322
- if (sandboxMode) {
7323
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7324
- market = this.market(sandboxSymbol);
7325
- }
7326
- else {
7327
- market = this.market(symbol);
7328
- }
7095
+ const market = this.market(symbol);
7329
7096
  let productType = undefined;
7330
7097
  [productType, params] = this.handleProductTypeAndParams(market, params);
7331
7098
  const request = {
@@ -7424,15 +7191,7 @@ export default class bitget extends Exchange {
7424
7191
  */
7425
7192
  async fetchLeverage(symbol, params = {}) {
7426
7193
  await this.loadMarkets();
7427
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7428
- let market = undefined;
7429
- if (sandboxMode) {
7430
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7431
- market = this.market(sandboxSymbol);
7432
- }
7433
- else {
7434
- market = this.market(symbol);
7435
- }
7194
+ const market = this.market(symbol);
7436
7195
  let productType = undefined;
7437
7196
  [productType, params] = this.handleProductTypeAndParams(market, params);
7438
7197
  const request = {
@@ -7473,12 +7232,15 @@ export default class bitget extends Exchange {
7473
7232
  return this.parseLeverage(data, market);
7474
7233
  }
7475
7234
  parseLeverage(leverage, market = undefined) {
7235
+ const isCrossMarginMode = this.safeString(leverage, 'marginMode') === 'crossed';
7236
+ const longLevKey = isCrossMarginMode ? 'crossedMarginLeverage' : 'isolatedLongLever';
7237
+ const shortLevKey = isCrossMarginMode ? 'crossedMarginLeverage' : 'isolatedShortLever';
7476
7238
  return {
7477
7239
  'info': leverage,
7478
7240
  'symbol': market['symbol'],
7479
- 'marginMode': 'isolated',
7480
- 'longLeverage': this.safeInteger(leverage, 'isolatedLongLever'),
7481
- 'shortLeverage': this.safeInteger(leverage, 'isolatedShortLever'),
7241
+ 'marginMode': isCrossMarginMode ? 'cross' : 'isolated',
7242
+ 'longLeverage': this.safeInteger(leverage, longLevKey),
7243
+ 'shortLeverage': this.safeInteger(leverage, shortLevKey),
7482
7244
  };
7483
7245
  }
7484
7246
  /**
@@ -7497,15 +7259,7 @@ export default class bitget extends Exchange {
7497
7259
  throw new ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
7498
7260
  }
7499
7261
  await this.loadMarkets();
7500
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7501
- let market = undefined;
7502
- if (sandboxMode) {
7503
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7504
- market = this.market(sandboxSymbol);
7505
- }
7506
- else {
7507
- market = this.market(symbol);
7508
- }
7262
+ const market = this.market(symbol);
7509
7263
  let productType = undefined;
7510
7264
  [productType, params] = this.handleProductTypeAndParams(market, params);
7511
7265
  const request = {
@@ -7555,15 +7309,7 @@ export default class bitget extends Exchange {
7555
7309
  throw new ArgumentsRequired(this.id + ' setMarginMode() marginMode must be either isolated or crossed (cross)');
7556
7310
  }
7557
7311
  await this.loadMarkets();
7558
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7559
- let market = undefined;
7560
- if (sandboxMode) {
7561
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7562
- market = this.market(sandboxSymbol);
7563
- }
7564
- else {
7565
- market = this.market(symbol);
7566
- }
7312
+ const market = this.market(symbol);
7567
7313
  let productType = undefined;
7568
7314
  [productType, params] = this.handleProductTypeAndParams(market, params);
7569
7315
  const request = {
@@ -7605,14 +7351,7 @@ export default class bitget extends Exchange {
7605
7351
  const posMode = hedged ? 'hedge_mode' : 'one_way_mode';
7606
7352
  let market = undefined;
7607
7353
  if (symbol !== undefined) {
7608
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7609
- if (sandboxMode) {
7610
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7611
- market = this.market(sandboxSymbol);
7612
- }
7613
- else {
7614
- market = this.market(symbol);
7615
- }
7354
+ market = this.market(symbol);
7616
7355
  }
7617
7356
  let productType = undefined;
7618
7357
  [productType, params] = this.handleProductTypeAndParams(market, params);
@@ -7644,15 +7383,7 @@ export default class bitget extends Exchange {
7644
7383
  */
7645
7384
  async fetchOpenInterest(symbol, params = {}) {
7646
7385
  await this.loadMarkets();
7647
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7648
- let market = undefined;
7649
- if (sandboxMode) {
7650
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7651
- market = this.market(sandboxSymbol);
7652
- }
7653
- else {
7654
- market = this.market(symbol);
7655
- }
7386
+ const market = this.market(symbol);
7656
7387
  if (!market['contract']) {
7657
7388
  throw new BadRequest(this.id + ' fetchOpenInterest() supports contract markets only');
7658
7389
  }
@@ -8678,15 +8409,7 @@ export default class bitget extends Exchange {
8678
8409
  */
8679
8410
  async closePosition(symbol, side = undefined, params = {}) {
8680
8411
  await this.loadMarkets();
8681
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
8682
- let market = undefined;
8683
- if (sandboxMode) {
8684
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
8685
- market = this.market(sandboxSymbol);
8686
- }
8687
- else {
8688
- market = this.market(symbol);
8689
- }
8412
+ const market = this.market(symbol);
8690
8413
  let productType = undefined;
8691
8414
  [productType, params] = this.handleProductTypeAndParams(market, params);
8692
8415
  const request = {
@@ -8767,15 +8490,7 @@ export default class bitget extends Exchange {
8767
8490
  */
8768
8491
  async fetchMarginMode(symbol, params = {}) {
8769
8492
  await this.loadMarkets();
8770
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
8771
- let market = undefined;
8772
- if (sandboxMode) {
8773
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
8774
- market = this.market(sandboxSymbol);
8775
- }
8776
- else {
8777
- market = this.market(symbol);
8778
- }
8493
+ const market = this.market(symbol);
8779
8494
  let productType = undefined;
8780
8495
  [productType, params] = this.handleProductTypeAndParams(market, params);
8781
8496
  const request = {
@@ -9177,15 +8892,7 @@ export default class bitget extends Exchange {
9177
8892
  */
9178
8893
  async fetchFundingInterval(symbol, params = {}) {
9179
8894
  await this.loadMarkets();
9180
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
9181
- let market = undefined;
9182
- if (sandboxMode) {
9183
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
9184
- market = this.market(sandboxSymbol);
9185
- }
9186
- else {
9187
- market = this.market(symbol);
9188
- }
8895
+ const market = this.market(symbol);
9189
8896
  let productType = undefined;
9190
8897
  [productType, params] = this.handleProductTypeAndParams(market, params);
9191
8898
  const request = {
@@ -9380,13 +9087,16 @@ export default class bitget extends Exchange {
9380
9087
  headers['Content-Type'] = 'application/json';
9381
9088
  }
9382
9089
  }
9383
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
9090
+ const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
9384
9091
  if (sandboxMode && (path !== 'v2/public/time')) {
9385
9092
  // https://github.com/ccxt/ccxt/issues/25252#issuecomment-2662742336
9386
9093
  if (headers === undefined) {
9387
9094
  headers = {};
9388
9095
  }
9389
- headers['PAPTRADING'] = '1';
9096
+ const productType = this.safeString(params, 'productType');
9097
+ if ((productType !== 'SCOIN-FUTURES') && (productType !== 'SUSDT-FUTURES') && (productType !== 'SUSDC-FUTURES')) {
9098
+ headers['PAPTRADING'] = '1';
9099
+ }
9390
9100
  }
9391
9101
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
9392
9102
  }
@@ -634,6 +634,7 @@ export default class bitmart extends Exchange {
634
634
  * @see https://developer-pro.bitmart.com/en/futuresv2/#modify-plan-order-signed
635
635
  * @see https://developer-pro.bitmart.com/en/futuresv2/#modify-tp-sl-order-signed
636
636
  * @see https://developer-pro.bitmart.com/en/futuresv2/#modify-preset-plan-order-signed
637
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#modify-limit-order-signed
637
638
  * @param {string} id order id
638
639
  * @param {string} symbol unified symbol of the market to edit an order in
639
640
  * @param {string} type 'market' or 'limit'