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
@@ -1668,38 +1668,6 @@ class bitget extends bitget$1 {
1668
1668
  setSandboxMode(enabled) {
1669
1669
  this.options['sandboxMode'] = enabled;
1670
1670
  }
1671
- convertSymbolForSandbox(symbol) {
1672
- if (symbol.startsWith('S')) {
1673
- // handle using the exchange specified sandbox symbols
1674
- return symbol;
1675
- }
1676
- let convertedSymbol = undefined;
1677
- if (symbol.indexOf('/') > -1) {
1678
- if (symbol.indexOf(':') === -1) {
1679
- throw new errors.NotSupported(this.id + ' sandbox supports swap and future markets only');
1680
- }
1681
- const splitBase = symbol.split('/');
1682
- const previousBase = this.safeString(splitBase, 0);
1683
- const previousQuoteSettleExpiry = this.safeString(splitBase, 1);
1684
- const splitQuote = previousQuoteSettleExpiry.split(':');
1685
- const previousQuote = this.safeString(splitQuote, 0);
1686
- const previousSettleExpiry = this.safeString(splitQuote, 1);
1687
- const splitSettle = previousSettleExpiry.split('-');
1688
- const previousSettle = this.safeString(splitSettle, 0);
1689
- const expiry = this.safeString(splitSettle, 1);
1690
- convertedSymbol = 'S' + previousBase + '/S' + previousQuote + ':S' + previousSettle;
1691
- if (expiry !== undefined) {
1692
- convertedSymbol = convertedSymbol + '-' + expiry;
1693
- }
1694
- }
1695
- else {
1696
- // handle using a market id instead of a unified symbol
1697
- const base = symbol.slice(0, 3);
1698
- const remaining = symbol.slice(3);
1699
- convertedSymbol = 'S' + base + 'S' + remaining;
1700
- }
1701
- return convertedSymbol;
1702
- }
1703
1671
  handleProductTypeAndParams(market = undefined, params = {}) {
1704
1672
  let subType = undefined;
1705
1673
  [subType, params] = this.handleSubTypeAndParams('handleProductTypeAndParams', undefined, params);
@@ -1779,24 +1747,13 @@ class bitget extends bitget$1 {
1779
1747
  if (this.options['adjustForTimeDifference']) {
1780
1748
  await this.loadTimeDifference();
1781
1749
  }
1782
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1783
- let types = this.safeValue(this.options, 'fetchMarkets', ['spot', 'swap']);
1784
- if (sandboxMode) {
1785
- types = ['swap'];
1786
- }
1750
+ const types = this.safeValue(this.options, 'fetchMarkets', ['spot', 'swap']);
1787
1751
  const promises = [];
1788
1752
  let fetchMargins = false;
1789
1753
  for (let i = 0; i < types.length; i++) {
1790
1754
  const type = types[i];
1791
1755
  if ((type === 'swap') || (type === 'future')) {
1792
- let subTypes = undefined;
1793
- if (sandboxMode) {
1794
- // the following are simulated trading markets [ 'SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES' ];
1795
- subTypes = ['SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES'];
1796
- }
1797
- else {
1798
- subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES'];
1799
- }
1756
+ const subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES', 'SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES'];
1800
1757
  for (let j = 0; j < subTypes.length; j++) {
1801
1758
  promises.push(this.publicMixGetV2MixMarketContracts(this.extend(params, {
1802
1759
  'productType': subTypes[j],
@@ -2189,15 +2146,7 @@ class bitget extends bitget$1 {
2189
2146
  */
2190
2147
  async fetchMarketLeverageTiers(symbol, params = {}) {
2191
2148
  await this.loadMarkets();
2192
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2193
- let market = undefined;
2194
- if (sandboxMode) {
2195
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
2196
- market = this.market(sandboxSymbol);
2197
- }
2198
- else {
2199
- market = this.market(symbol);
2200
- }
2149
+ const market = this.market(symbol);
2201
2150
  const request = {};
2202
2151
  let response = undefined;
2203
2152
  let marginMode = undefined;
@@ -2704,15 +2653,7 @@ class bitget extends bitget$1 {
2704
2653
  */
2705
2654
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
2706
2655
  await this.loadMarkets();
2707
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2708
- let market = undefined;
2709
- if (sandboxMode) {
2710
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
2711
- market = this.market(sandboxSymbol);
2712
- }
2713
- else {
2714
- market = this.market(symbol);
2715
- }
2656
+ const market = this.market(symbol);
2716
2657
  const request = {
2717
2658
  'symbol': market['id'],
2718
2659
  };
@@ -2877,15 +2818,7 @@ class bitget extends bitget$1 {
2877
2818
  */
2878
2819
  async fetchTicker(symbol, params = {}) {
2879
2820
  await this.loadMarkets();
2880
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2881
- let market = undefined;
2882
- if (sandboxMode) {
2883
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
2884
- market = this.market(sandboxSymbol);
2885
- }
2886
- else {
2887
- market = this.market(symbol);
2888
- }
2821
+ const market = this.market(symbol);
2889
2822
  const request = {
2890
2823
  'symbol': market['id'],
2891
2824
  };
@@ -2976,15 +2909,7 @@ class bitget extends bitget$1 {
2976
2909
  */
2977
2910
  async fetchMarkPrice(symbol, params = {}) {
2978
2911
  await this.loadMarkets();
2979
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
2980
- let market = undefined;
2981
- if (sandboxMode) {
2982
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
2983
- market = this.market(sandboxSymbol);
2984
- }
2985
- else {
2986
- market = this.market(symbol);
2987
- }
2912
+ const market = this.market(symbol);
2988
2913
  const request = {
2989
2914
  'symbol': market['id'],
2990
2915
  };
@@ -3018,14 +2943,7 @@ class bitget extends bitget$1 {
3018
2943
  let market = undefined;
3019
2944
  if (symbols !== undefined) {
3020
2945
  const symbol = this.safeValue(symbols, 0);
3021
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
3022
- if (sandboxMode) {
3023
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
3024
- market = this.market(sandboxSymbol);
3025
- }
3026
- else {
3027
- market = this.market(symbol);
3028
- }
2946
+ market = this.market(symbol);
3029
2947
  }
3030
2948
  let response = undefined;
3031
2949
  const request = {};
@@ -3248,15 +3166,7 @@ class bitget extends bitget$1 {
3248
3166
  if (paginate) {
3249
3167
  return await this.fetchPaginatedCallCursor('fetchTrades', symbol, since, limit, params, 'idLessThan', 'idLessThan');
3250
3168
  }
3251
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
3252
- let market = undefined;
3253
- if (sandboxMode) {
3254
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
3255
- market = this.market(sandboxSymbol);
3256
- }
3257
- else {
3258
- market = this.market(symbol);
3259
- }
3169
+ const market = this.market(symbol);
3260
3170
  let request = {
3261
3171
  'symbol': market['id'],
3262
3172
  };
@@ -3573,16 +3483,8 @@ class bitget extends bitget$1 {
3573
3483
  if (paginate) {
3574
3484
  return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimitForRecentEndpoint);
3575
3485
  }
3576
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
3577
3486
  const useHistoryEndpoint = this.safeBool(params, 'useHistoryEndpoint', false);
3578
- let market = undefined;
3579
- if (sandboxMode) {
3580
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
3581
- market = this.market(sandboxSymbol);
3582
- }
3583
- else {
3584
- market = this.market(symbol);
3585
- }
3487
+ const market = this.market(symbol);
3586
3488
  const marketType = market['spot'] ? 'spot' : 'swap';
3587
3489
  const timeframes = this.options['timeframes'][marketType];
3588
3490
  const msInDay = 86400000;
@@ -4440,15 +4342,7 @@ class bitget extends bitget$1 {
4440
4342
  return this.parseOrder(data, market);
4441
4343
  }
4442
4344
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
4443
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4444
- let market = undefined;
4445
- if (sandboxMode) {
4446
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
4447
- market = this.market(sandboxSymbol);
4448
- }
4449
- else {
4450
- market = this.market(symbol);
4451
- }
4345
+ const market = this.market(symbol);
4452
4346
  let marketType = undefined;
4453
4347
  let marginMode = undefined;
4454
4348
  [marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params);
@@ -4717,15 +4611,7 @@ class bitget extends bitget$1 {
4717
4611
  const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
4718
4612
  ordersRequests.push(orderRequest);
4719
4613
  }
4720
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4721
- let market = undefined;
4722
- if (sandboxMode) {
4723
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
4724
- market = this.market(sandboxSymbol);
4725
- }
4726
- else {
4727
- market = this.market(symbol);
4728
- }
4614
+ const market = this.market(symbol);
4729
4615
  const request = {
4730
4616
  'symbol': market['id'],
4731
4617
  'orderList': ordersRequests,
@@ -4814,15 +4700,7 @@ class bitget extends bitget$1 {
4814
4700
  */
4815
4701
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
4816
4702
  await this.loadMarkets();
4817
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4818
- let market = undefined;
4819
- if (sandboxMode) {
4820
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
4821
- market = this.market(sandboxSymbol);
4822
- }
4823
- else {
4824
- market = this.market(symbol);
4825
- }
4703
+ const market = this.market(symbol);
4826
4704
  const request = {
4827
4705
  'orderId': id,
4828
4706
  };
@@ -4985,15 +4863,7 @@ class bitget extends bitget$1 {
4985
4863
  throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
4986
4864
  }
4987
4865
  await this.loadMarkets();
4988
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
4989
- let market = undefined;
4990
- if (sandboxMode) {
4991
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
4992
- market = this.market(sandboxSymbol);
4993
- }
4994
- else {
4995
- market = this.market(symbol);
4996
- }
4866
+ const market = this.market(symbol);
4997
4867
  let marginMode = undefined;
4998
4868
  let response = undefined;
4999
4869
  [marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
@@ -5125,15 +4995,7 @@ class bitget extends bitget$1 {
5125
4995
  throw new errors.ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
5126
4996
  }
5127
4997
  await this.loadMarkets();
5128
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5129
- let market = undefined;
5130
- if (sandboxMode) {
5131
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5132
- market = this.market(sandboxSymbol);
5133
- }
5134
- else {
5135
- market = this.market(symbol);
5136
- }
4998
+ const market = this.market(symbol);
5137
4999
  let marginMode = undefined;
5138
5000
  [marginMode, params] = this.handleMarginModeAndParams('cancelOrders', params);
5139
5001
  const trigger = this.safeValue2(params, 'stop', 'trigger');
@@ -5220,15 +5082,7 @@ class bitget extends bitget$1 {
5220
5082
  throw new errors.ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
5221
5083
  }
5222
5084
  await this.loadMarkets();
5223
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5224
- let market = undefined;
5225
- if (sandboxMode) {
5226
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5227
- market = this.market(sandboxSymbol);
5228
- }
5229
- else {
5230
- market = this.market(symbol);
5231
- }
5085
+ const market = this.market(symbol);
5232
5086
  let marginMode = undefined;
5233
5087
  [marginMode, params] = this.handleMarginModeAndParams('cancelAllOrders', params);
5234
5088
  const request = {
@@ -5342,15 +5196,7 @@ class bitget extends bitget$1 {
5342
5196
  throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
5343
5197
  }
5344
5198
  await this.loadMarkets();
5345
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5346
- let market = undefined;
5347
- if (sandboxMode) {
5348
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5349
- market = this.market(sandboxSymbol);
5350
- }
5351
- else {
5352
- market = this.market(symbol);
5353
- }
5199
+ const market = this.market(symbol);
5354
5200
  const request = {
5355
5201
  'orderId': id,
5356
5202
  };
@@ -5474,20 +5320,13 @@ class bitget extends bitget$1 {
5474
5320
  */
5475
5321
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5476
5322
  await this.loadMarkets();
5477
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5478
5323
  let market = undefined;
5479
5324
  let type = undefined;
5480
5325
  let request = {};
5481
5326
  let marginMode = undefined;
5482
5327
  [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
5483
5328
  if (symbol !== undefined) {
5484
- if (sandboxMode) {
5485
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5486
- market = this.market(sandboxSymbol);
5487
- }
5488
- else {
5489
- market = this.market(symbol);
5490
- }
5329
+ market = this.market(symbol);
5491
5330
  request['symbol'] = market['id'];
5492
5331
  const defaultType = this.safeString2(this.options, 'fetchOpenOrders', 'defaultType', 'spot');
5493
5332
  const marketType = ('type' in market) ? market['type'] : defaultType;
@@ -5839,14 +5678,7 @@ class bitget extends bitget$1 {
5839
5678
  */
5840
5679
  async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5841
5680
  await this.loadMarkets();
5842
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5843
5681
  let market = undefined;
5844
- if (sandboxMode) {
5845
- if (symbol !== undefined) {
5846
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5847
- symbol = sandboxSymbol;
5848
- }
5849
- }
5850
5682
  let request = {};
5851
5683
  if (symbol !== undefined) {
5852
5684
  market = this.market(symbol);
@@ -6155,14 +5987,7 @@ class bitget extends bitget$1 {
6155
5987
  params = this.omit(params, 'symbol');
6156
5988
  let market = undefined;
6157
5989
  if (symbol !== undefined) {
6158
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6159
- if (sandboxMode) {
6160
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
6161
- market = this.market(sandboxSymbol);
6162
- }
6163
- else {
6164
- market = this.market(symbol);
6165
- }
5990
+ market = this.market(symbol);
6166
5991
  }
6167
5992
  let marketType = undefined;
6168
5993
  [marketType, params] = this.handleMarketTypeAndParams('fetchLedger', market, params);
@@ -6379,15 +6204,7 @@ class bitget extends bitget$1 {
6379
6204
  throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
6380
6205
  }
6381
6206
  await this.loadMarkets();
6382
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6383
- let market = undefined;
6384
- if (sandboxMode) {
6385
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
6386
- market = this.market(sandboxSymbol);
6387
- }
6388
- else {
6389
- market = this.market(symbol);
6390
- }
6207
+ const market = this.market(symbol);
6391
6208
  let marginMode = undefined;
6392
6209
  [marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
6393
6210
  let paginate = false;
@@ -6558,15 +6375,7 @@ class bitget extends bitget$1 {
6558
6375
  */
6559
6376
  async fetchPosition(symbol, params = {}) {
6560
6377
  await this.loadMarkets();
6561
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6562
- let market = undefined;
6563
- if (sandboxMode) {
6564
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
6565
- market = this.market(sandboxSymbol);
6566
- }
6567
- else {
6568
- market = this.market(symbol);
6569
- }
6378
+ const market = this.market(symbol);
6570
6379
  let productType = undefined;
6571
6380
  [productType, params] = this.handleProductTypeAndParams(market, params);
6572
6381
  const request = {
@@ -6642,14 +6451,7 @@ class bitget extends bitget$1 {
6642
6451
  let market = undefined;
6643
6452
  if (symbols !== undefined) {
6644
6453
  const first = this.safeString(symbols, 0);
6645
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6646
- if (sandboxMode) {
6647
- const sandboxSymbol = this.convertSymbolForSandbox(first);
6648
- market = this.market(sandboxSymbol);
6649
- }
6650
- else {
6651
- market = this.market(first);
6652
- }
6454
+ market = this.market(first);
6653
6455
  }
6654
6456
  let productType = undefined;
6655
6457
  [productType, params] = this.handleProductTypeAndParams(market, params);
@@ -6962,15 +6764,7 @@ class bitget extends bitget$1 {
6962
6764
  if (paginate) {
6963
6765
  return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'pageNo', 100);
6964
6766
  }
6965
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
6966
- let market = undefined;
6967
- if (sandboxMode) {
6968
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
6969
- market = this.market(sandboxSymbol);
6970
- }
6971
- else {
6972
- market = this.market(symbol);
6973
- }
6767
+ const market = this.market(symbol);
6974
6768
  let productType = undefined;
6975
6769
  [productType, params] = this.handleProductTypeAndParams(market, params);
6976
6770
  const request = {
@@ -7026,15 +6820,7 @@ class bitget extends bitget$1 {
7026
6820
  */
7027
6821
  async fetchFundingRate(symbol, params = {}) {
7028
6822
  await this.loadMarkets();
7029
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7030
- let market = undefined;
7031
- if (sandboxMode) {
7032
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7033
- market = this.market(sandboxSymbol);
7034
- }
7035
- else {
7036
- market = this.market(symbol);
7037
- }
6823
+ const market = this.market(symbol);
7038
6824
  if (!market['swap']) {
7039
6825
  throw new errors.BadSymbol(this.id + ' fetchFundingRate() supports swap contracts only');
7040
6826
  }
@@ -7077,14 +6863,7 @@ class bitget extends bitget$1 {
7077
6863
  let market = undefined;
7078
6864
  if (symbols !== undefined) {
7079
6865
  const symbol = this.safeValue(symbols, 0);
7080
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7081
- if (sandboxMode) {
7082
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7083
- market = this.market(sandboxSymbol);
7084
- }
7085
- else {
7086
- market = this.market(symbol);
7087
- }
6866
+ market = this.market(symbol);
7088
6867
  }
7089
6868
  const request = {};
7090
6869
  let productType = undefined;
@@ -7224,15 +7003,7 @@ class bitget extends bitget$1 {
7224
7003
  if (paginate) {
7225
7004
  return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'endId', 'idLessThan');
7226
7005
  }
7227
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7228
- let market = undefined;
7229
- if (sandboxMode) {
7230
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7231
- market = this.market(sandboxSymbol);
7232
- }
7233
- else {
7234
- market = this.market(symbol);
7235
- }
7006
+ const market = this.market(symbol);
7236
7007
  if (!market['swap']) {
7237
7008
  throw new errors.BadSymbol(this.id + ' fetchFundingHistory() supports swap contracts only');
7238
7009
  }
@@ -7315,20 +7086,16 @@ class bitget extends bitget$1 {
7315
7086
  result.push(this.parseFundingHistory(contract, market));
7316
7087
  }
7317
7088
  const sorted = this.sortBy(result, 'timestamp');
7318
- return this.filterBySinceLimit(sorted, since, limit);
7089
+ let symbol = undefined;
7090
+ if (market !== undefined) {
7091
+ symbol = market['symbol'];
7092
+ }
7093
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
7319
7094
  }
7320
7095
  async modifyMarginHelper(symbol, amount, type, params = {}) {
7321
7096
  await this.loadMarkets();
7322
7097
  const holdSide = this.safeString(params, 'holdSide');
7323
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7324
- let market = undefined;
7325
- if (sandboxMode) {
7326
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7327
- market = this.market(sandboxSymbol);
7328
- }
7329
- else {
7330
- market = this.market(symbol);
7331
- }
7098
+ const market = this.market(symbol);
7332
7099
  let productType = undefined;
7333
7100
  [productType, params] = this.handleProductTypeAndParams(market, params);
7334
7101
  const request = {
@@ -7427,15 +7194,7 @@ class bitget extends bitget$1 {
7427
7194
  */
7428
7195
  async fetchLeverage(symbol, params = {}) {
7429
7196
  await this.loadMarkets();
7430
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7431
- let market = undefined;
7432
- if (sandboxMode) {
7433
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7434
- market = this.market(sandboxSymbol);
7435
- }
7436
- else {
7437
- market = this.market(symbol);
7438
- }
7197
+ const market = this.market(symbol);
7439
7198
  let productType = undefined;
7440
7199
  [productType, params] = this.handleProductTypeAndParams(market, params);
7441
7200
  const request = {
@@ -7476,12 +7235,15 @@ class bitget extends bitget$1 {
7476
7235
  return this.parseLeverage(data, market);
7477
7236
  }
7478
7237
  parseLeverage(leverage, market = undefined) {
7238
+ const isCrossMarginMode = this.safeString(leverage, 'marginMode') === 'crossed';
7239
+ const longLevKey = isCrossMarginMode ? 'crossedMarginLeverage' : 'isolatedLongLever';
7240
+ const shortLevKey = isCrossMarginMode ? 'crossedMarginLeverage' : 'isolatedShortLever';
7479
7241
  return {
7480
7242
  'info': leverage,
7481
7243
  'symbol': market['symbol'],
7482
- 'marginMode': 'isolated',
7483
- 'longLeverage': this.safeInteger(leverage, 'isolatedLongLever'),
7484
- 'shortLeverage': this.safeInteger(leverage, 'isolatedShortLever'),
7244
+ 'marginMode': isCrossMarginMode ? 'cross' : 'isolated',
7245
+ 'longLeverage': this.safeInteger(leverage, longLevKey),
7246
+ 'shortLeverage': this.safeInteger(leverage, shortLevKey),
7485
7247
  };
7486
7248
  }
7487
7249
  /**
@@ -7500,15 +7262,7 @@ class bitget extends bitget$1 {
7500
7262
  throw new errors.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
7501
7263
  }
7502
7264
  await this.loadMarkets();
7503
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7504
- let market = undefined;
7505
- if (sandboxMode) {
7506
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7507
- market = this.market(sandboxSymbol);
7508
- }
7509
- else {
7510
- market = this.market(symbol);
7511
- }
7265
+ const market = this.market(symbol);
7512
7266
  let productType = undefined;
7513
7267
  [productType, params] = this.handleProductTypeAndParams(market, params);
7514
7268
  const request = {
@@ -7558,15 +7312,7 @@ class bitget extends bitget$1 {
7558
7312
  throw new errors.ArgumentsRequired(this.id + ' setMarginMode() marginMode must be either isolated or crossed (cross)');
7559
7313
  }
7560
7314
  await this.loadMarkets();
7561
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7562
- let market = undefined;
7563
- if (sandboxMode) {
7564
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7565
- market = this.market(sandboxSymbol);
7566
- }
7567
- else {
7568
- market = this.market(symbol);
7569
- }
7315
+ const market = this.market(symbol);
7570
7316
  let productType = undefined;
7571
7317
  [productType, params] = this.handleProductTypeAndParams(market, params);
7572
7318
  const request = {
@@ -7608,14 +7354,7 @@ class bitget extends bitget$1 {
7608
7354
  const posMode = hedged ? 'hedge_mode' : 'one_way_mode';
7609
7355
  let market = undefined;
7610
7356
  if (symbol !== undefined) {
7611
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7612
- if (sandboxMode) {
7613
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7614
- market = this.market(sandboxSymbol);
7615
- }
7616
- else {
7617
- market = this.market(symbol);
7618
- }
7357
+ market = this.market(symbol);
7619
7358
  }
7620
7359
  let productType = undefined;
7621
7360
  [productType, params] = this.handleProductTypeAndParams(market, params);
@@ -7647,15 +7386,7 @@ class bitget extends bitget$1 {
7647
7386
  */
7648
7387
  async fetchOpenInterest(symbol, params = {}) {
7649
7388
  await this.loadMarkets();
7650
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
7651
- let market = undefined;
7652
- if (sandboxMode) {
7653
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
7654
- market = this.market(sandboxSymbol);
7655
- }
7656
- else {
7657
- market = this.market(symbol);
7658
- }
7389
+ const market = this.market(symbol);
7659
7390
  if (!market['contract']) {
7660
7391
  throw new errors.BadRequest(this.id + ' fetchOpenInterest() supports contract markets only');
7661
7392
  }
@@ -8681,15 +8412,7 @@ class bitget extends bitget$1 {
8681
8412
  */
8682
8413
  async closePosition(symbol, side = undefined, params = {}) {
8683
8414
  await this.loadMarkets();
8684
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
8685
- let market = undefined;
8686
- if (sandboxMode) {
8687
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
8688
- market = this.market(sandboxSymbol);
8689
- }
8690
- else {
8691
- market = this.market(symbol);
8692
- }
8415
+ const market = this.market(symbol);
8693
8416
  let productType = undefined;
8694
8417
  [productType, params] = this.handleProductTypeAndParams(market, params);
8695
8418
  const request = {
@@ -8770,15 +8493,7 @@ class bitget extends bitget$1 {
8770
8493
  */
8771
8494
  async fetchMarginMode(symbol, params = {}) {
8772
8495
  await this.loadMarkets();
8773
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
8774
- let market = undefined;
8775
- if (sandboxMode) {
8776
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
8777
- market = this.market(sandboxSymbol);
8778
- }
8779
- else {
8780
- market = this.market(symbol);
8781
- }
8496
+ const market = this.market(symbol);
8782
8497
  let productType = undefined;
8783
8498
  [productType, params] = this.handleProductTypeAndParams(market, params);
8784
8499
  const request = {
@@ -9180,15 +8895,7 @@ class bitget extends bitget$1 {
9180
8895
  */
9181
8896
  async fetchFundingInterval(symbol, params = {}) {
9182
8897
  await this.loadMarkets();
9183
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
9184
- let market = undefined;
9185
- if (sandboxMode) {
9186
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
9187
- market = this.market(sandboxSymbol);
9188
- }
9189
- else {
9190
- market = this.market(symbol);
9191
- }
8898
+ const market = this.market(symbol);
9192
8899
  let productType = undefined;
9193
8900
  [productType, params] = this.handleProductTypeAndParams(market, params);
9194
8901
  const request = {
@@ -9383,13 +9090,16 @@ class bitget extends bitget$1 {
9383
9090
  headers['Content-Type'] = 'application/json';
9384
9091
  }
9385
9092
  }
9386
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
9093
+ const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
9387
9094
  if (sandboxMode && (path !== 'v2/public/time')) {
9388
9095
  // https://github.com/ccxt/ccxt/issues/25252#issuecomment-2662742336
9389
9096
  if (headers === undefined) {
9390
9097
  headers = {};
9391
9098
  }
9392
- headers['PAPTRADING'] = '1';
9099
+ const productType = this.safeString(params, 'productType');
9100
+ if ((productType !== 'SCOIN-FUTURES') && (productType !== 'SUSDT-FUTURES') && (productType !== 'SUSDC-FUTURES')) {
9101
+ headers['PAPTRADING'] = '1';
9102
+ }
9393
9103
  }
9394
9104
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
9395
9105
  }