ccxt 4.4.68 → 4.4.70

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 (51) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +0 -1
  5. package/dist/cjs/src/binance.js +20 -3
  6. package/dist/cjs/src/bitget.js +49 -335
  7. package/dist/cjs/src/bitstamp.js +2 -3
  8. package/dist/cjs/src/bybit.js +7 -0
  9. package/dist/cjs/src/coinbase.js +25 -9
  10. package/dist/cjs/src/cryptomus.js +214 -116
  11. package/dist/cjs/src/hyperliquid.js +19 -8
  12. package/dist/cjs/src/okx.js +4 -0
  13. package/dist/cjs/src/paradex.js +172 -4
  14. package/dist/cjs/src/phemex.js +2 -2
  15. package/dist/cjs/src/pro/bitget.js +40 -7
  16. package/dist/cjs/src/pro/bybit.js +86 -38
  17. package/dist/cjs/src/tradeogre.js +34 -11
  18. package/dist/cjs/src/whitebit.js +211 -1
  19. package/js/ccxt.d.ts +1 -1
  20. package/js/ccxt.js +1 -1
  21. package/js/src/abstract/bybit.d.ts +4 -0
  22. package/js/src/abstract/myokx.d.ts +3 -0
  23. package/js/src/abstract/okx.d.ts +3 -0
  24. package/js/src/abstract/paradex.d.ts +23 -0
  25. package/js/src/abstract/tradeogre.d.ts +2 -1
  26. package/js/src/base/Exchange.js +0 -1
  27. package/js/src/base/types.d.ts +2 -2
  28. package/js/src/binance.js +20 -3
  29. package/js/src/bitget.d.ts +0 -1
  30. package/js/src/bitget.js +49 -335
  31. package/js/src/bitstamp.js +2 -3
  32. package/js/src/bybit.js +7 -0
  33. package/js/src/coinbase.d.ts +0 -5
  34. package/js/src/coinbase.js +25 -9
  35. package/js/src/cryptomus.d.ts +127 -1
  36. package/js/src/cryptomus.js +214 -116
  37. package/js/src/hyperliquid.js +19 -8
  38. package/js/src/okx.d.ts +1 -0
  39. package/js/src/okx.js +4 -0
  40. package/js/src/paradex.d.ts +48 -1
  41. package/js/src/paradex.js +172 -4
  42. package/js/src/phemex.d.ts +1 -1
  43. package/js/src/phemex.js +2 -2
  44. package/js/src/pro/bitget.js +40 -7
  45. package/js/src/pro/bybit.d.ts +1 -0
  46. package/js/src/pro/bybit.js +86 -38
  47. package/js/src/tradeogre.d.ts +1 -0
  48. package/js/src/tradeogre.js +34 -11
  49. package/js/src/whitebit.d.ts +35 -1
  50. package/js/src/whitebit.js +211 -1
  51. 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);
@@ -1786,14 +1754,7 @@ export default class bitget extends Exchange {
1786
1754
  for (let i = 0; i < types.length; i++) {
1787
1755
  const type = types[i];
1788
1756
  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
- }
1757
+ const subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES', 'SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES'];
1797
1758
  for (let j = 0; j < subTypes.length; j++) {
1798
1759
  promises.push(this.publicMixGetV2MixMarketContracts(this.extend(params, {
1799
1760
  'productType': subTypes[j],
@@ -2186,15 +2147,7 @@ export default class bitget extends Exchange {
2186
2147
  */
2187
2148
  async fetchMarketLeverageTiers(symbol, params = {}) {
2188
2149
  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
- }
2150
+ const market = this.market(symbol);
2198
2151
  const request = {};
2199
2152
  let response = undefined;
2200
2153
  let marginMode = undefined;
@@ -2701,15 +2654,7 @@ export default class bitget extends Exchange {
2701
2654
  */
2702
2655
  async fetchOrderBook(symbol, limit = undefined, params = {}) {
2703
2656
  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
- }
2657
+ const market = this.market(symbol);
2713
2658
  const request = {
2714
2659
  'symbol': market['id'],
2715
2660
  };
@@ -2874,15 +2819,7 @@ export default class bitget extends Exchange {
2874
2819
  */
2875
2820
  async fetchTicker(symbol, params = {}) {
2876
2821
  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
- }
2822
+ const market = this.market(symbol);
2886
2823
  const request = {
2887
2824
  'symbol': market['id'],
2888
2825
  };
@@ -2973,15 +2910,7 @@ export default class bitget extends Exchange {
2973
2910
  */
2974
2911
  async fetchMarkPrice(symbol, params = {}) {
2975
2912
  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
- }
2913
+ const market = this.market(symbol);
2985
2914
  const request = {
2986
2915
  'symbol': market['id'],
2987
2916
  };
@@ -3015,14 +2944,7 @@ export default class bitget extends Exchange {
3015
2944
  let market = undefined;
3016
2945
  if (symbols !== undefined) {
3017
2946
  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
- }
2947
+ market = this.market(symbol);
3026
2948
  }
3027
2949
  let response = undefined;
3028
2950
  const request = {};
@@ -3245,15 +3167,7 @@ export default class bitget extends Exchange {
3245
3167
  if (paginate) {
3246
3168
  return await this.fetchPaginatedCallCursor('fetchTrades', symbol, since, limit, params, 'idLessThan', 'idLessThan');
3247
3169
  }
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
- }
3170
+ const market = this.market(symbol);
3257
3171
  let request = {
3258
3172
  'symbol': market['id'],
3259
3173
  };
@@ -3570,16 +3484,8 @@ export default class bitget extends Exchange {
3570
3484
  if (paginate) {
3571
3485
  return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimitForRecentEndpoint);
3572
3486
  }
3573
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
3574
3487
  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
- }
3488
+ const market = this.market(symbol);
3583
3489
  const marketType = market['spot'] ? 'spot' : 'swap';
3584
3490
  const timeframes = this.options['timeframes'][marketType];
3585
3491
  const msInDay = 86400000;
@@ -4437,15 +4343,7 @@ export default class bitget extends Exchange {
4437
4343
  return this.parseOrder(data, market);
4438
4344
  }
4439
4345
  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
- }
4346
+ const market = this.market(symbol);
4449
4347
  let marketType = undefined;
4450
4348
  let marginMode = undefined;
4451
4349
  [marketType, params] = this.handleMarketTypeAndParams('createOrder', market, params);
@@ -4714,15 +4612,7 @@ export default class bitget extends Exchange {
4714
4612
  const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
4715
4613
  ordersRequests.push(orderRequest);
4716
4614
  }
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
- }
4615
+ const market = this.market(symbol);
4726
4616
  const request = {
4727
4617
  'symbol': market['id'],
4728
4618
  'orderList': ordersRequests,
@@ -4811,15 +4701,7 @@ export default class bitget extends Exchange {
4811
4701
  */
4812
4702
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
4813
4703
  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
- }
4704
+ const market = this.market(symbol);
4823
4705
  const request = {
4824
4706
  'orderId': id,
4825
4707
  };
@@ -4982,15 +4864,7 @@ export default class bitget extends Exchange {
4982
4864
  throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
4983
4865
  }
4984
4866
  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
- }
4867
+ const market = this.market(symbol);
4994
4868
  let marginMode = undefined;
4995
4869
  let response = undefined;
4996
4870
  [marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
@@ -5122,15 +4996,7 @@ export default class bitget extends Exchange {
5122
4996
  throw new ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
5123
4997
  }
5124
4998
  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
- }
4999
+ const market = this.market(symbol);
5134
5000
  let marginMode = undefined;
5135
5001
  [marginMode, params] = this.handleMarginModeAndParams('cancelOrders', params);
5136
5002
  const trigger = this.safeValue2(params, 'stop', 'trigger');
@@ -5217,15 +5083,7 @@ export default class bitget extends Exchange {
5217
5083
  throw new ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument');
5218
5084
  }
5219
5085
  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
- }
5086
+ const market = this.market(symbol);
5229
5087
  let marginMode = undefined;
5230
5088
  [marginMode, params] = this.handleMarginModeAndParams('cancelAllOrders', params);
5231
5089
  const request = {
@@ -5339,15 +5197,7 @@ export default class bitget extends Exchange {
5339
5197
  throw new ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
5340
5198
  }
5341
5199
  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
- }
5200
+ const market = this.market(symbol);
5351
5201
  const request = {
5352
5202
  'orderId': id,
5353
5203
  };
@@ -5471,20 +5321,13 @@ export default class bitget extends Exchange {
5471
5321
  */
5472
5322
  async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5473
5323
  await this.loadMarkets();
5474
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5475
5324
  let market = undefined;
5476
5325
  let type = undefined;
5477
5326
  let request = {};
5478
5327
  let marginMode = undefined;
5479
5328
  [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
5480
5329
  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
- }
5330
+ market = this.market(symbol);
5488
5331
  request['symbol'] = market['id'];
5489
5332
  const defaultType = this.safeString2(this.options, 'fetchOpenOrders', 'defaultType', 'spot');
5490
5333
  const marketType = ('type' in market) ? market['type'] : defaultType;
@@ -5836,14 +5679,7 @@ export default class bitget extends Exchange {
5836
5679
  */
5837
5680
  async fetchCanceledAndClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
5838
5681
  await this.loadMarkets();
5839
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
5840
5682
  let market = undefined;
5841
- if (sandboxMode) {
5842
- if (symbol !== undefined) {
5843
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
5844
- symbol = sandboxSymbol;
5845
- }
5846
- }
5847
5683
  let request = {};
5848
5684
  if (symbol !== undefined) {
5849
5685
  market = this.market(symbol);
@@ -6152,14 +5988,7 @@ export default class bitget extends Exchange {
6152
5988
  params = this.omit(params, 'symbol');
6153
5989
  let market = undefined;
6154
5990
  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
- }
5991
+ market = this.market(symbol);
6163
5992
  }
6164
5993
  let marketType = undefined;
6165
5994
  [marketType, params] = this.handleMarketTypeAndParams('fetchLedger', market, params);
@@ -6376,15 +6205,7 @@ export default class bitget extends Exchange {
6376
6205
  throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
6377
6206
  }
6378
6207
  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
- }
6208
+ const market = this.market(symbol);
6388
6209
  let marginMode = undefined;
6389
6210
  [marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
6390
6211
  let paginate = false;
@@ -6555,15 +6376,7 @@ export default class bitget extends Exchange {
6555
6376
  */
6556
6377
  async fetchPosition(symbol, params = {}) {
6557
6378
  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
- }
6379
+ const market = this.market(symbol);
6567
6380
  let productType = undefined;
6568
6381
  [productType, params] = this.handleProductTypeAndParams(market, params);
6569
6382
  const request = {
@@ -6639,14 +6452,7 @@ export default class bitget extends Exchange {
6639
6452
  let market = undefined;
6640
6453
  if (symbols !== undefined) {
6641
6454
  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
- }
6455
+ market = this.market(first);
6650
6456
  }
6651
6457
  let productType = undefined;
6652
6458
  [productType, params] = this.handleProductTypeAndParams(market, params);
@@ -6959,15 +6765,7 @@ export default class bitget extends Exchange {
6959
6765
  if (paginate) {
6960
6766
  return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'pageNo', 100);
6961
6767
  }
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
- }
6768
+ const market = this.market(symbol);
6971
6769
  let productType = undefined;
6972
6770
  [productType, params] = this.handleProductTypeAndParams(market, params);
6973
6771
  const request = {
@@ -7023,15 +6821,7 @@ export default class bitget extends Exchange {
7023
6821
  */
7024
6822
  async fetchFundingRate(symbol, params = {}) {
7025
6823
  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
- }
6824
+ const market = this.market(symbol);
7035
6825
  if (!market['swap']) {
7036
6826
  throw new BadSymbol(this.id + ' fetchFundingRate() supports swap contracts only');
7037
6827
  }
@@ -7074,14 +6864,7 @@ export default class bitget extends Exchange {
7074
6864
  let market = undefined;
7075
6865
  if (symbols !== undefined) {
7076
6866
  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
- }
6867
+ market = this.market(symbol);
7085
6868
  }
7086
6869
  const request = {};
7087
6870
  let productType = undefined;
@@ -7221,15 +7004,7 @@ export default class bitget extends Exchange {
7221
7004
  if (paginate) {
7222
7005
  return await this.fetchPaginatedCallCursor('fetchFundingHistory', symbol, since, limit, params, 'endId', 'idLessThan');
7223
7006
  }
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
- }
7007
+ const market = this.market(symbol);
7233
7008
  if (!market['swap']) {
7234
7009
  throw new BadSymbol(this.id + ' fetchFundingHistory() supports swap contracts only');
7235
7010
  }
@@ -7312,20 +7087,16 @@ export default class bitget extends Exchange {
7312
7087
  result.push(this.parseFundingHistory(contract, market));
7313
7088
  }
7314
7089
  const sorted = this.sortBy(result, 'timestamp');
7315
- return this.filterBySinceLimit(sorted, since, limit);
7090
+ let symbol = undefined;
7091
+ if (market !== undefined) {
7092
+ symbol = market['symbol'];
7093
+ }
7094
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
7316
7095
  }
7317
7096
  async modifyMarginHelper(symbol, amount, type, params = {}) {
7318
7097
  await this.loadMarkets();
7319
7098
  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
- }
7099
+ const market = this.market(symbol);
7329
7100
  let productType = undefined;
7330
7101
  [productType, params] = this.handleProductTypeAndParams(market, params);
7331
7102
  const request = {
@@ -7424,15 +7195,7 @@ export default class bitget extends Exchange {
7424
7195
  */
7425
7196
  async fetchLeverage(symbol, params = {}) {
7426
7197
  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
- }
7198
+ const market = this.market(symbol);
7436
7199
  let productType = undefined;
7437
7200
  [productType, params] = this.handleProductTypeAndParams(market, params);
7438
7201
  const request = {
@@ -7473,12 +7236,15 @@ export default class bitget extends Exchange {
7473
7236
  return this.parseLeverage(data, market);
7474
7237
  }
7475
7238
  parseLeverage(leverage, market = undefined) {
7239
+ const isCrossMarginMode = this.safeString(leverage, 'marginMode') === 'crossed';
7240
+ const longLevKey = isCrossMarginMode ? 'crossedMarginLeverage' : 'isolatedLongLever';
7241
+ const shortLevKey = isCrossMarginMode ? 'crossedMarginLeverage' : 'isolatedShortLever';
7476
7242
  return {
7477
7243
  'info': leverage,
7478
7244
  'symbol': market['symbol'],
7479
- 'marginMode': 'isolated',
7480
- 'longLeverage': this.safeInteger(leverage, 'isolatedLongLever'),
7481
- 'shortLeverage': this.safeInteger(leverage, 'isolatedShortLever'),
7245
+ 'marginMode': isCrossMarginMode ? 'cross' : 'isolated',
7246
+ 'longLeverage': this.safeInteger(leverage, longLevKey),
7247
+ 'shortLeverage': this.safeInteger(leverage, shortLevKey),
7482
7248
  };
7483
7249
  }
7484
7250
  /**
@@ -7497,15 +7263,7 @@ export default class bitget extends Exchange {
7497
7263
  throw new ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
7498
7264
  }
7499
7265
  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
- }
7266
+ const market = this.market(symbol);
7509
7267
  let productType = undefined;
7510
7268
  [productType, params] = this.handleProductTypeAndParams(market, params);
7511
7269
  const request = {
@@ -7555,15 +7313,7 @@ export default class bitget extends Exchange {
7555
7313
  throw new ArgumentsRequired(this.id + ' setMarginMode() marginMode must be either isolated or crossed (cross)');
7556
7314
  }
7557
7315
  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
- }
7316
+ const market = this.market(symbol);
7567
7317
  let productType = undefined;
7568
7318
  [productType, params] = this.handleProductTypeAndParams(market, params);
7569
7319
  const request = {
@@ -7605,14 +7355,7 @@ export default class bitget extends Exchange {
7605
7355
  const posMode = hedged ? 'hedge_mode' : 'one_way_mode';
7606
7356
  let market = undefined;
7607
7357
  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
- }
7358
+ market = this.market(symbol);
7616
7359
  }
7617
7360
  let productType = undefined;
7618
7361
  [productType, params] = this.handleProductTypeAndParams(market, params);
@@ -7644,15 +7387,7 @@ export default class bitget extends Exchange {
7644
7387
  */
7645
7388
  async fetchOpenInterest(symbol, params = {}) {
7646
7389
  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
- }
7390
+ const market = this.market(symbol);
7656
7391
  if (!market['contract']) {
7657
7392
  throw new BadRequest(this.id + ' fetchOpenInterest() supports contract markets only');
7658
7393
  }
@@ -8678,15 +8413,7 @@ export default class bitget extends Exchange {
8678
8413
  */
8679
8414
  async closePosition(symbol, side = undefined, params = {}) {
8680
8415
  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
- }
8416
+ const market = this.market(symbol);
8690
8417
  let productType = undefined;
8691
8418
  [productType, params] = this.handleProductTypeAndParams(market, params);
8692
8419
  const request = {
@@ -8767,15 +8494,7 @@ export default class bitget extends Exchange {
8767
8494
  */
8768
8495
  async fetchMarginMode(symbol, params = {}) {
8769
8496
  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
- }
8497
+ const market = this.market(symbol);
8779
8498
  let productType = undefined;
8780
8499
  [productType, params] = this.handleProductTypeAndParams(market, params);
8781
8500
  const request = {
@@ -9177,15 +8896,7 @@ export default class bitget extends Exchange {
9177
8896
  */
9178
8897
  async fetchFundingInterval(symbol, params = {}) {
9179
8898
  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
- }
8899
+ const market = this.market(symbol);
9189
8900
  let productType = undefined;
9190
8901
  [productType, params] = this.handleProductTypeAndParams(market, params);
9191
8902
  const request = {
@@ -9380,13 +9091,16 @@ export default class bitget extends Exchange {
9380
9091
  headers['Content-Type'] = 'application/json';
9381
9092
  }
9382
9093
  }
9383
- const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
9094
+ const sandboxMode = this.safeBool2(this.options, 'sandboxMode', 'sandbox', false);
9384
9095
  if (sandboxMode && (path !== 'v2/public/time')) {
9385
9096
  // https://github.com/ccxt/ccxt/issues/25252#issuecomment-2662742336
9386
9097
  if (headers === undefined) {
9387
9098
  headers = {};
9388
9099
  }
9389
- headers['PAPTRADING'] = '1';
9100
+ const productType = this.safeString(params, 'productType');
9101
+ if ((productType !== 'SCOIN-FUTURES') && (productType !== 'SUSDT-FUTURES') && (productType !== 'SUSDC-FUTURES')) {
9102
+ headers['PAPTRADING'] = '1';
9103
+ }
9390
9104
  }
9391
9105
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
9392
9106
  }
@@ -1304,10 +1304,9 @@ export default class bitstamp extends Exchange {
1304
1304
  }
1305
1305
  parseTradingFees(fees) {
1306
1306
  const result = { 'info': fees };
1307
- const symbols = this.symbols;
1308
- for (let i = 0; i < symbols.length; i++) {
1309
- const symbol = symbols[i];
1307
+ for (let i = 0; i < fees.length; i++) {
1310
1308
  const fee = this.parseTradingFee(fees[i]);
1309
+ const symbol = fee['symbol'];
1311
1310
  result[symbol] = fee;
1312
1311
  }
1313
1312
  return result;