ccxt 4.4.68__py2.py3-none-any.whl → 4.4.70__py2.py3-none-any.whl

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 (43) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bybit.py +4 -0
  3. ccxt/abstract/myokx.py +3 -0
  4. ccxt/abstract/okx.py +3 -0
  5. ccxt/abstract/paradex.py +23 -0
  6. ccxt/abstract/tradeogre.py +2 -1
  7. ccxt/async_support/__init__.py +1 -1
  8. ccxt/async_support/base/exchange.py +5 -1
  9. ccxt/async_support/binance.py +17 -3
  10. ccxt/async_support/bitget.py +47 -262
  11. ccxt/async_support/bitstamp.py +2 -3
  12. ccxt/async_support/bybit.py +7 -0
  13. ccxt/async_support/coinbase.py +24 -9
  14. ccxt/async_support/cryptomus.py +122 -6
  15. ccxt/async_support/hyperliquid.py +17 -8
  16. ccxt/async_support/okx.py +4 -0
  17. ccxt/async_support/paradex.py +173 -5
  18. ccxt/async_support/phemex.py +2 -2
  19. ccxt/async_support/tradeogre.py +31 -11
  20. ccxt/async_support/whitebit.py +210 -2
  21. ccxt/base/exchange.py +1 -2
  22. ccxt/binance.py +17 -3
  23. ccxt/bitget.py +47 -262
  24. ccxt/bitstamp.py +2 -3
  25. ccxt/bybit.py +7 -0
  26. ccxt/coinbase.py +24 -9
  27. ccxt/cryptomus.py +122 -6
  28. ccxt/hyperliquid.py +17 -8
  29. ccxt/okx.py +4 -0
  30. ccxt/paradex.py +173 -5
  31. ccxt/phemex.py +2 -2
  32. ccxt/pro/__init__.py +1 -1
  33. ccxt/pro/bitget.py +28 -3
  34. ccxt/pro/bybit.py +81 -37
  35. ccxt/test/tests_async.py +25 -3
  36. ccxt/test/tests_sync.py +25 -3
  37. ccxt/tradeogre.py +31 -11
  38. ccxt/whitebit.py +210 -2
  39. {ccxt-4.4.68.dist-info → ccxt-4.4.70.dist-info}/METADATA +4 -4
  40. {ccxt-4.4.68.dist-info → ccxt-4.4.70.dist-info}/RECORD +43 -43
  41. {ccxt-4.4.68.dist-info → ccxt-4.4.70.dist-info}/LICENSE.txt +0 -0
  42. {ccxt-4.4.68.dist-info → ccxt-4.4.70.dist-info}/WHEEL +0 -0
  43. {ccxt-4.4.68.dist-info → ccxt-4.4.70.dist-info}/top_level.txt +0 -0
@@ -1691,33 +1691,6 @@ class bitget(Exchange, ImplicitAPI):
1691
1691
  def set_sandbox_mode(self, enabled):
1692
1692
  self.options['sandboxMode'] = enabled
1693
1693
 
1694
- def convert_symbol_for_sandbox(self, symbol):
1695
- if symbol.startswith('S'):
1696
- # handle using the exchange specified sandbox symbols
1697
- return symbol
1698
- convertedSymbol = None
1699
- if symbol.find('/') > -1:
1700
- if symbol.find(':') == -1:
1701
- raise NotSupported(self.id + ' sandbox supports swap and future markets only')
1702
- splitBase = symbol.split('/')
1703
- previousBase = self.safe_string(splitBase, 0)
1704
- previousQuoteSettleExpiry = self.safe_string(splitBase, 1)
1705
- splitQuote = previousQuoteSettleExpiry.split(':')
1706
- previousQuote = self.safe_string(splitQuote, 0)
1707
- previousSettleExpiry = self.safe_string(splitQuote, 1)
1708
- splitSettle = previousSettleExpiry.split('-')
1709
- previousSettle = self.safe_string(splitSettle, 0)
1710
- expiry = self.safe_string(splitSettle, 1)
1711
- convertedSymbol = 'S' + previousBase + '/S' + previousQuote + ':S' + previousSettle
1712
- if expiry is not None:
1713
- convertedSymbol = convertedSymbol + '-' + expiry
1714
- else:
1715
- # handle using a market id instead of a unified symbol
1716
- base = symbol[0:3]
1717
- remaining = symbol[3:]
1718
- convertedSymbol = 'S' + base + 'S' + remaining
1719
- return convertedSymbol
1720
-
1721
1694
  def handle_product_type_and_params(self, market=None, params={}):
1722
1695
  subType = None
1723
1696
  subType, params = self.handle_sub_type_and_params('handleProductTypeAndParams', None, params)
@@ -1794,12 +1767,7 @@ class bitget(Exchange, ImplicitAPI):
1794
1767
  for i in range(0, len(types)):
1795
1768
  type = types[i]
1796
1769
  if (type == 'swap') or (type == 'future'):
1797
- subTypes = None
1798
- if sandboxMode:
1799
- # the following are simulated trading markets ['SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES']
1800
- subTypes = ['SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES']
1801
- else:
1802
- subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES']
1770
+ subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES', 'SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES']
1803
1771
  for j in range(0, len(subTypes)):
1804
1772
  promises.append(self.publicMixGetV2MixMarketContracts(self.extend(params, {
1805
1773
  'productType': subTypes[j],
@@ -2168,13 +2136,7 @@ class bitget(Exchange, ImplicitAPI):
2168
2136
  :returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
2169
2137
  """
2170
2138
  await self.load_markets()
2171
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
2172
- market = None
2173
- if sandboxMode:
2174
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
2175
- market = self.market(sandboxSymbol)
2176
- else:
2177
- market = self.market(symbol)
2139
+ market = self.market(symbol)
2178
2140
  request: dict = {}
2179
2141
  response = None
2180
2142
  marginMode = None
@@ -2660,13 +2622,7 @@ class bitget(Exchange, ImplicitAPI):
2660
2622
  :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
2661
2623
  """
2662
2624
  await self.load_markets()
2663
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
2664
- market = None
2665
- if sandboxMode:
2666
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
2667
- market = self.market(sandboxSymbol)
2668
- else:
2669
- market = self.market(symbol)
2625
+ market = self.market(symbol)
2670
2626
  request: dict = {
2671
2627
  'symbol': market['id'],
2672
2628
  }
@@ -2826,13 +2782,7 @@ class bitget(Exchange, ImplicitAPI):
2826
2782
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
2827
2783
  """
2828
2784
  await self.load_markets()
2829
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
2830
- market = None
2831
- if sandboxMode:
2832
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
2833
- market = self.market(sandboxSymbol)
2834
- else:
2835
- market = self.market(symbol)
2785
+ market = self.market(symbol)
2836
2786
  request: dict = {
2837
2787
  'symbol': market['id'],
2838
2788
  }
@@ -2921,13 +2871,7 @@ class bitget(Exchange, ImplicitAPI):
2921
2871
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
2922
2872
  """
2923
2873
  await self.load_markets()
2924
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
2925
- market = None
2926
- if sandboxMode:
2927
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
2928
- market = self.market(sandboxSymbol)
2929
- else:
2930
- market = self.market(symbol)
2874
+ market = self.market(symbol)
2931
2875
  request: dict = {
2932
2876
  'symbol': market['id'],
2933
2877
  }
@@ -2959,12 +2903,7 @@ class bitget(Exchange, ImplicitAPI):
2959
2903
  market = None
2960
2904
  if symbols is not None:
2961
2905
  symbol = self.safe_value(symbols, 0)
2962
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
2963
- if sandboxMode:
2964
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
2965
- market = self.market(sandboxSymbol)
2966
- else:
2967
- market = self.market(symbol)
2906
+ market = self.market(symbol)
2968
2907
  response = None
2969
2908
  request: dict = {}
2970
2909
  type = None
@@ -3180,13 +3119,7 @@ class bitget(Exchange, ImplicitAPI):
3180
3119
  paginate, params = self.handle_option_and_params(params, 'fetchTrades', 'paginate')
3181
3120
  if paginate:
3182
3121
  return await self.fetch_paginated_call_cursor('fetchTrades', symbol, since, limit, params, 'idLessThan', 'idLessThan')
3183
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
3184
- market = None
3185
- if sandboxMode:
3186
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
3187
- market = self.market(sandboxSymbol)
3188
- else:
3189
- market = self.market(symbol)
3122
+ market = self.market(symbol)
3190
3123
  request: dict = {
3191
3124
  'symbol': market['id'],
3192
3125
  }
@@ -3481,14 +3414,8 @@ class bitget(Exchange, ImplicitAPI):
3481
3414
  paginate, params = self.handle_option_and_params(params, 'fetchOHLCV', 'paginate')
3482
3415
  if paginate:
3483
3416
  return await self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimitForRecentEndpoint)
3484
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
3485
3417
  useHistoryEndpoint = self.safe_bool(params, 'useHistoryEndpoint', False)
3486
- market = None
3487
- if sandboxMode:
3488
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
3489
- market = self.market(sandboxSymbol)
3490
- else:
3491
- market = self.market(symbol)
3418
+ market = self.market(symbol)
3492
3419
  marketType = 'spot' if market['spot'] else 'swap'
3493
3420
  timeframes = self.options['timeframes'][marketType]
3494
3421
  msInDay = 86400000
@@ -4292,13 +4219,7 @@ class bitget(Exchange, ImplicitAPI):
4292
4219
  return self.parse_order(data, market)
4293
4220
 
4294
4221
  def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
4295
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
4296
- market = None
4297
- if sandboxMode:
4298
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
4299
- market = self.market(sandboxSymbol)
4300
- else:
4301
- market = self.market(symbol)
4222
+ market = self.market(symbol)
4302
4223
  marketType = None
4303
4224
  marginMode = None
4304
4225
  marketType, params = self.handle_market_type_and_params('createOrder', market, params)
@@ -4510,13 +4431,7 @@ class bitget(Exchange, ImplicitAPI):
4510
4431
  raise BadRequest(self.id + ' createOrders() requires all orders to have the same margin mode(isolated or cross)')
4511
4432
  orderRequest = self.create_order_request(marketId, type, side, amount, price, orderParams)
4512
4433
  ordersRequests.append(orderRequest)
4513
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
4514
- market = None
4515
- if sandboxMode:
4516
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
4517
- market = self.market(sandboxSymbol)
4518
- else:
4519
- market = self.market(symbol)
4434
+ market = self.market(symbol)
4520
4435
  request: dict = {
4521
4436
  'symbol': market['id'],
4522
4437
  'orderList': ordersRequests,
@@ -4600,13 +4515,7 @@ class bitget(Exchange, ImplicitAPI):
4600
4515
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4601
4516
  """
4602
4517
  await self.load_markets()
4603
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
4604
- market = None
4605
- if sandboxMode:
4606
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
4607
- market = self.market(sandboxSymbol)
4608
- else:
4609
- market = self.market(symbol)
4518
+ market = self.market(symbol)
4610
4519
  request: dict = {
4611
4520
  'orderId': id,
4612
4521
  }
@@ -4743,13 +4652,7 @@ class bitget(Exchange, ImplicitAPI):
4743
4652
  if symbol is None:
4744
4653
  raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
4745
4654
  await self.load_markets()
4746
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
4747
- market = None
4748
- if sandboxMode:
4749
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
4750
- market = self.market(sandboxSymbol)
4751
- else:
4752
- market = self.market(symbol)
4655
+ market = self.market(symbol)
4753
4656
  marginMode = None
4754
4657
  response = None
4755
4658
  marginMode, params = self.handle_margin_mode_and_params('cancelOrder', params)
@@ -4863,13 +4766,7 @@ class bitget(Exchange, ImplicitAPI):
4863
4766
  if symbol is None:
4864
4767
  raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
4865
4768
  await self.load_markets()
4866
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
4867
- market = None
4868
- if sandboxMode:
4869
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
4870
- market = self.market(sandboxSymbol)
4871
- else:
4872
- market = self.market(symbol)
4769
+ market = self.market(symbol)
4873
4770
  marginMode = None
4874
4771
  marginMode, params = self.handle_margin_mode_and_params('cancelOrders', params)
4875
4772
  trigger = self.safe_value_2(params, 'stop', 'trigger')
@@ -4944,13 +4841,7 @@ class bitget(Exchange, ImplicitAPI):
4944
4841
  if symbol is None:
4945
4842
  raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
4946
4843
  await self.load_markets()
4947
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
4948
- market = None
4949
- if sandboxMode:
4950
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
4951
- market = self.market(sandboxSymbol)
4952
- else:
4953
- market = self.market(symbol)
4844
+ market = self.market(symbol)
4954
4845
  marginMode = None
4955
4846
  marginMode, params = self.handle_margin_mode_and_params('cancelAllOrders', params)
4956
4847
  request: dict = {
@@ -5053,13 +4944,7 @@ class bitget(Exchange, ImplicitAPI):
5053
4944
  if symbol is None:
5054
4945
  raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
5055
4946
  await self.load_markets()
5056
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
5057
- market = None
5058
- if sandboxMode:
5059
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
5060
- market = self.market(sandboxSymbol)
5061
- else:
5062
- market = self.market(symbol)
4947
+ market = self.market(symbol)
5063
4948
  request: dict = {
5064
4949
  'orderId': id,
5065
4950
  }
@@ -5177,18 +5062,13 @@ class bitget(Exchange, ImplicitAPI):
5177
5062
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
5178
5063
  """
5179
5064
  await self.load_markets()
5180
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
5181
5065
  market = None
5182
5066
  type = None
5183
5067
  request: dict = {}
5184
5068
  marginMode = None
5185
5069
  marginMode, params = self.handle_margin_mode_and_params('fetchOpenOrders', params)
5186
5070
  if symbol is not None:
5187
- if sandboxMode:
5188
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
5189
- market = self.market(sandboxSymbol)
5190
- else:
5191
- market = self.market(symbol)
5071
+ market = self.market(symbol)
5192
5072
  request['symbol'] = market['id']
5193
5073
  defaultType = self.safe_string_2(self.options, 'fetchOpenOrders', 'defaultType', 'spot')
5194
5074
  marketType = market['type'] if ('type' in market) else defaultType
@@ -5515,12 +5395,7 @@ class bitget(Exchange, ImplicitAPI):
5515
5395
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
5516
5396
  """
5517
5397
  await self.load_markets()
5518
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
5519
5398
  market = None
5520
- if sandboxMode:
5521
- if symbol is not None:
5522
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
5523
- symbol = sandboxSymbol
5524
5399
  request: dict = {}
5525
5400
  if symbol is not None:
5526
5401
  market = self.market(symbol)
@@ -5802,12 +5677,7 @@ class bitget(Exchange, ImplicitAPI):
5802
5677
  params = self.omit(params, 'symbol')
5803
5678
  market = None
5804
5679
  if symbol is not None:
5805
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
5806
- if sandboxMode:
5807
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
5808
- market = self.market(sandboxSymbol)
5809
- else:
5810
- market = self.market(symbol)
5680
+ market = self.market(symbol)
5811
5681
  marketType = None
5812
5682
  marketType, params = self.handle_market_type_and_params('fetchLedger', market, params)
5813
5683
  paginate = False
@@ -6012,13 +5882,7 @@ class bitget(Exchange, ImplicitAPI):
6012
5882
  if symbol is None:
6013
5883
  raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol argument')
6014
5884
  await self.load_markets()
6015
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
6016
- market = None
6017
- if sandboxMode:
6018
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
6019
- market = self.market(sandboxSymbol)
6020
- else:
6021
- market = self.market(symbol)
5885
+ market = self.market(symbol)
6022
5886
  marginMode = None
6023
5887
  marginMode, params = self.handle_margin_mode_and_params('fetchMyTrades', params)
6024
5888
  paginate = False
@@ -6174,13 +6038,7 @@ class bitget(Exchange, ImplicitAPI):
6174
6038
  :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
6175
6039
  """
6176
6040
  await self.load_markets()
6177
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
6178
- market = None
6179
- if sandboxMode:
6180
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
6181
- market = self.market(sandboxSymbol)
6182
- else:
6183
- market = self.market(symbol)
6041
+ market = self.market(symbol)
6184
6042
  productType = None
6185
6043
  productType, params = self.handle_product_type_and_params(market, params)
6186
6044
  request: dict = {
@@ -6253,12 +6111,7 @@ class bitget(Exchange, ImplicitAPI):
6253
6111
  market = None
6254
6112
  if symbols is not None:
6255
6113
  first = self.safe_string(symbols, 0)
6256
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
6257
- if sandboxMode:
6258
- sandboxSymbol = self.convert_symbol_for_sandbox(first)
6259
- market = self.market(sandboxSymbol)
6260
- else:
6261
- market = self.market(first)
6114
+ market = self.market(first)
6262
6115
  productType = None
6263
6116
  productType, params = self.handle_product_type_and_params(market, params)
6264
6117
  request: dict = {
@@ -6545,13 +6398,7 @@ class bitget(Exchange, ImplicitAPI):
6545
6398
  paginate, params = self.handle_option_and_params(params, 'fetchFundingRateHistory', 'paginate')
6546
6399
  if paginate:
6547
6400
  return await self.fetch_paginated_call_incremental('fetchFundingRateHistory', symbol, since, limit, params, 'pageNo', 100)
6548
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
6549
- market = None
6550
- if sandboxMode:
6551
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
6552
- market = self.market(sandboxSymbol)
6553
- else:
6554
- market = self.market(symbol)
6401
+ market = self.market(symbol)
6555
6402
  productType = None
6556
6403
  productType, params = self.handle_product_type_and_params(market, params)
6557
6404
  request: dict = {
@@ -6605,13 +6452,7 @@ class bitget(Exchange, ImplicitAPI):
6605
6452
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
6606
6453
  """
6607
6454
  await self.load_markets()
6608
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
6609
- market = None
6610
- if sandboxMode:
6611
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
6612
- market = self.market(sandboxSymbol)
6613
- else:
6614
- market = self.market(symbol)
6455
+ market = self.market(symbol)
6615
6456
  if not market['swap']:
6616
6457
  raise BadSymbol(self.id + ' fetchFundingRate() supports swap contracts only')
6617
6458
  productType = None
@@ -6653,12 +6494,7 @@ class bitget(Exchange, ImplicitAPI):
6653
6494
  market = None
6654
6495
  if symbols is not None:
6655
6496
  symbol = self.safe_value(symbols, 0)
6656
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
6657
- if sandboxMode:
6658
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
6659
- market = self.market(sandboxSymbol)
6660
- else:
6661
- market = self.market(symbol)
6497
+ market = self.market(symbol)
6662
6498
  request: dict = {}
6663
6499
  productType = None
6664
6500
  productType, params = self.handle_product_type_and_params(market, params)
@@ -6794,13 +6630,7 @@ class bitget(Exchange, ImplicitAPI):
6794
6630
  paginate, params = self.handle_option_and_params(params, 'fetchFundingHistory', 'paginate')
6795
6631
  if paginate:
6796
6632
  return await self.fetch_paginated_call_cursor('fetchFundingHistory', symbol, since, limit, params, 'endId', 'idLessThan')
6797
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
6798
- market = None
6799
- if sandboxMode:
6800
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
6801
- market = self.market(sandboxSymbol)
6802
- else:
6803
- market = self.market(symbol)
6633
+ market = self.market(symbol)
6804
6634
  if not market['swap']:
6805
6635
  raise BadSymbol(self.id + ' fetchFundingHistory() supports swap contracts only')
6806
6636
  productType = None
@@ -6878,18 +6708,15 @@ class bitget(Exchange, ImplicitAPI):
6878
6708
  continue
6879
6709
  result.append(self.parse_funding_history(contract, market))
6880
6710
  sorted = self.sort_by(result, 'timestamp')
6881
- return self.filter_by_since_limit(sorted, since, limit)
6711
+ symbol = None
6712
+ if market is not None:
6713
+ symbol = market['symbol']
6714
+ return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
6882
6715
 
6883
6716
  async def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
6884
6717
  await self.load_markets()
6885
6718
  holdSide = self.safe_string(params, 'holdSide')
6886
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
6887
- market = None
6888
- if sandboxMode:
6889
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
6890
- market = self.market(sandboxSymbol)
6891
- else:
6892
- market = self.market(symbol)
6719
+ market = self.market(symbol)
6893
6720
  productType = None
6894
6721
  productType, params = self.handle_product_type_and_params(market, params)
6895
6722
  request: dict = {
@@ -6985,13 +6812,7 @@ class bitget(Exchange, ImplicitAPI):
6985
6812
  :returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
6986
6813
  """
6987
6814
  await self.load_markets()
6988
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
6989
- market = None
6990
- if sandboxMode:
6991
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
6992
- market = self.market(sandboxSymbol)
6993
- else:
6994
- market = self.market(symbol)
6815
+ market = self.market(symbol)
6995
6816
  productType = None
6996
6817
  productType, params = self.handle_product_type_and_params(market, params)
6997
6818
  request: dict = {
@@ -7032,12 +6853,15 @@ class bitget(Exchange, ImplicitAPI):
7032
6853
  return self.parse_leverage(data, market)
7033
6854
 
7034
6855
  def parse_leverage(self, leverage: dict, market: Market = None) -> Leverage:
6856
+ isCrossMarginMode = self.safe_string(leverage, 'marginMode') == 'crossed'
6857
+ longLevKey = 'crossedMarginLeverage' if isCrossMarginMode else 'isolatedLongLever'
6858
+ shortLevKey = 'crossedMarginLeverage' if isCrossMarginMode else 'isolatedShortLever'
7035
6859
  return {
7036
6860
  'info': leverage,
7037
6861
  'symbol': market['symbol'],
7038
- 'marginMode': 'isolated',
7039
- 'longLeverage': self.safe_integer(leverage, 'isolatedLongLever'),
7040
- 'shortLeverage': self.safe_integer(leverage, 'isolatedShortLever'),
6862
+ 'marginMode': 'cross' if isCrossMarginMode else 'isolated',
6863
+ 'longLeverage': self.safe_integer(leverage, longLevKey),
6864
+ 'shortLeverage': self.safe_integer(leverage, shortLevKey),
7041
6865
  }
7042
6866
 
7043
6867
  async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
@@ -7055,13 +6879,7 @@ class bitget(Exchange, ImplicitAPI):
7055
6879
  if symbol is None:
7056
6880
  raise ArgumentsRequired(self.id + ' setLeverage() requires a symbol argument')
7057
6881
  await self.load_markets()
7058
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
7059
- market = None
7060
- if sandboxMode:
7061
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
7062
- market = self.market(sandboxSymbol)
7063
- else:
7064
- market = self.market(symbol)
6882
+ market = self.market(symbol)
7065
6883
  productType = None
7066
6884
  productType, params = self.handle_product_type_and_params(market, params)
7067
6885
  request: dict = {
@@ -7108,13 +6926,7 @@ class bitget(Exchange, ImplicitAPI):
7108
6926
  if (marginMode != 'isolated') and (marginMode != 'crossed'):
7109
6927
  raise ArgumentsRequired(self.id + ' setMarginMode() marginMode must be either isolated or crossed(cross)')
7110
6928
  await self.load_markets()
7111
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
7112
- market = None
7113
- if sandboxMode:
7114
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
7115
- market = self.market(sandboxSymbol)
7116
- else:
7117
- market = self.market(symbol)
6929
+ market = self.market(symbol)
7118
6930
  productType = None
7119
6931
  productType, params = self.handle_product_type_and_params(market, params)
7120
6932
  request: dict = {
@@ -7156,12 +6968,7 @@ class bitget(Exchange, ImplicitAPI):
7156
6968
  posMode = 'hedge_mode' if hedged else 'one_way_mode'
7157
6969
  market = None
7158
6970
  if symbol is not None:
7159
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
7160
- if sandboxMode:
7161
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
7162
- market = self.market(sandboxSymbol)
7163
- else:
7164
- market = self.market(symbol)
6971
+ market = self.market(symbol)
7165
6972
  productType = None
7166
6973
  productType, params = self.handle_product_type_and_params(market, params)
7167
6974
  request: dict = {
@@ -7192,13 +6999,7 @@ class bitget(Exchange, ImplicitAPI):
7192
6999
  :returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
7193
7000
  """
7194
7001
  await self.load_markets()
7195
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
7196
- market = None
7197
- if sandboxMode:
7198
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
7199
- market = self.market(sandboxSymbol)
7200
- else:
7201
- market = self.market(symbol)
7002
+ market = self.market(symbol)
7202
7003
  if not market['contract']:
7203
7004
  raise BadRequest(self.id + ' fetchOpenInterest() supports contract markets only')
7204
7005
  productType = None
@@ -8198,13 +7999,7 @@ class bitget(Exchange, ImplicitAPI):
8198
7999
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
8199
8000
  """
8200
8001
  await self.load_markets()
8201
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
8202
- market = None
8203
- if sandboxMode:
8204
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
8205
- market = self.market(sandboxSymbol)
8206
- else:
8207
- market = self.market(symbol)
8002
+ market = self.market(symbol)
8208
8003
  productType = None
8209
8004
  productType, params = self.handle_product_type_and_params(market, params)
8210
8005
  request: dict = {
@@ -8284,13 +8079,7 @@ class bitget(Exchange, ImplicitAPI):
8284
8079
  :returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
8285
8080
  """
8286
8081
  await self.load_markets()
8287
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
8288
- market = None
8289
- if sandboxMode:
8290
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
8291
- market = self.market(sandboxSymbol)
8292
- else:
8293
- market = self.market(symbol)
8082
+ market = self.market(symbol)
8294
8083
  productType = None
8295
8084
  productType, params = self.handle_product_type_and_params(market, params)
8296
8085
  request: dict = {
@@ -8679,13 +8468,7 @@ class bitget(Exchange, ImplicitAPI):
8679
8468
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
8680
8469
  """
8681
8470
  await self.load_markets()
8682
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
8683
- market = None
8684
- if sandboxMode:
8685
- sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
8686
- market = self.market(sandboxSymbol)
8687
- else:
8688
- market = self.market(symbol)
8471
+ market = self.market(symbol)
8689
8472
  productType = None
8690
8473
  productType, params = self.handle_product_type_and_params(market, params)
8691
8474
  request: dict = {
@@ -8865,10 +8648,12 @@ class bitget(Exchange, ImplicitAPI):
8865
8648
  }
8866
8649
  if method == 'POST':
8867
8650
  headers['Content-Type'] = 'application/json'
8868
- sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
8651
+ sandboxMode = self.safe_bool_2(self.options, 'sandboxMode', 'sandbox', False)
8869
8652
  if sandboxMode and (path != 'v2/public/time'):
8870
8653
  # https://github.com/ccxt/ccxt/issues/25252#issuecomment-2662742336
8871
8654
  if headers is None:
8872
8655
  headers = {}
8873
- headers['PAPTRADING'] = '1'
8656
+ productType = self.safe_string(params, 'productType')
8657
+ if (productType != 'SCOIN-FUTURES') and (productType != 'SUSDT-FUTURES') and (productType != 'SUSDC-FUTURES'):
8658
+ headers['PAPTRADING'] = '1'
8874
8659
  return {'url': url, 'method': method, 'body': body, 'headers': headers}
@@ -1282,10 +1282,9 @@ class bitstamp(Exchange, ImplicitAPI):
1282
1282
 
1283
1283
  def parse_trading_fees(self, fees):
1284
1284
  result: dict = {'info': fees}
1285
- symbols = self.symbols
1286
- for i in range(0, len(symbols)):
1287
- symbol = symbols[i]
1285
+ for i in range(0, len(fees)):
1288
1286
  fee = self.parse_trading_fee(fees[i])
1287
+ symbol = fee['symbol']
1289
1288
  result[symbol] = fee
1290
1289
  return result
1291
1290
 
@@ -267,6 +267,8 @@ class bybit(Exchange, ImplicitAPI):
267
267
  # institutional lending
268
268
  'v5/ins-loan/product-infos': 5,
269
269
  'v5/ins-loan/ensure-tokens-convert': 5,
270
+ # earn
271
+ 'v5/earn/product': 5,
270
272
  },
271
273
  },
272
274
  'private': {
@@ -425,6 +427,9 @@ class bybit(Exchange, ImplicitAPI):
425
427
  'v5/broker/earnings-info': 5,
426
428
  'v5/broker/account-info': 5,
427
429
  'v5/broker/asset/query-sub-member-deposit-record': 10,
430
+ # earn
431
+ 'v5/earn/order': 5,
432
+ 'v5/earn/position': 5,
428
433
  },
429
434
  'post': {
430
435
  # spot
@@ -560,6 +565,8 @@ class bybit(Exchange, ImplicitAPI):
560
565
  'v5/broker/award/info': 5,
561
566
  'v5/broker/award/distribute-award': 5,
562
567
  'v5/broker/award/distribution-record': 5,
568
+ # earn
569
+ 'v5/earn/place-order': 5,
563
570
  },
564
571
  },
565
572
  },