ccxt 4.4.69__py2.py3-none-any.whl → 4.4.71__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.
- ccxt/__init__.py +1 -3
- ccxt/abstract/bingx.py +1 -0
- ccxt/abstract/bitmart.py +1 -0
- ccxt/abstract/bybit.py +4 -0
- ccxt/abstract/myokx.py +3 -0
- ccxt/abstract/okx.py +3 -0
- ccxt/abstract/poloniex.py +36 -0
- ccxt/abstract/tradeogre.py +1 -1
- ccxt/async_support/__init__.py +1 -3
- ccxt/async_support/base/exchange.py +3 -3
- ccxt/async_support/binance.py +107 -102
- ccxt/async_support/bingx.py +64 -42
- ccxt/async_support/bitget.py +47 -265
- ccxt/async_support/bitmart.py +12 -1
- ccxt/async_support/bitopro.py +1 -0
- ccxt/async_support/bitrue.py +1 -0
- ccxt/async_support/bybit.py +7 -0
- ccxt/async_support/cex.py +1 -0
- ccxt/async_support/coinbase.py +23 -4
- ccxt/async_support/coinbaseexchange.py +1 -0
- ccxt/async_support/deribit.py +1 -0
- ccxt/async_support/hashkey.py +4 -2
- ccxt/async_support/hyperliquid.py +16 -7
- ccxt/async_support/kraken.py +77 -5
- ccxt/async_support/kucoin.py +4 -2
- ccxt/async_support/mexc.py +8 -4
- ccxt/async_support/okx.py +62 -46
- ccxt/async_support/poloniex.py +1263 -85
- ccxt/async_support/tradeogre.py +20 -4
- ccxt/async_support/whitebit.py +4 -2
- ccxt/base/exchange.py +23 -4
- ccxt/base/types.py +28 -0
- ccxt/binance.py +107 -102
- ccxt/bingx.py +64 -42
- ccxt/bitget.py +47 -265
- ccxt/bitmart.py +12 -1
- ccxt/bitopro.py +1 -0
- ccxt/bitrue.py +1 -0
- ccxt/bybit.py +7 -0
- ccxt/cex.py +1 -0
- ccxt/coinbase.py +23 -4
- ccxt/coinbaseexchange.py +1 -0
- ccxt/deribit.py +1 -0
- ccxt/hashkey.py +4 -2
- ccxt/hyperliquid.py +16 -7
- ccxt/kraken.py +77 -5
- ccxt/kucoin.py +4 -2
- ccxt/mexc.py +8 -4
- ccxt/okx.py +62 -46
- ccxt/poloniex.py +1262 -85
- ccxt/pro/__init__.py +1 -3
- ccxt/pro/binance.py +102 -102
- ccxt/pro/bingx.py +62 -51
- ccxt/pro/bitget.py +28 -3
- ccxt/pro/bybit.py +81 -37
- ccxt/test/tests_async.py +4 -3
- ccxt/test/tests_sync.py +4 -3
- ccxt/tradeogre.py +20 -4
- ccxt/whitebit.py +4 -2
- {ccxt-4.4.69.dist-info → ccxt-4.4.71.dist-info}/METADATA +6 -9
- {ccxt-4.4.69.dist-info → ccxt-4.4.71.dist-info}/RECORD +64 -65
- ccxt/abstract/poloniexfutures.py +0 -48
- {ccxt-4.4.69.dist-info → ccxt-4.4.71.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.69.dist-info → ccxt-4.4.71.dist-info}/WHEEL +0 -0
- {ccxt-4.4.69.dist-info → ccxt-4.4.71.dist-info}/top_level.txt +0 -0
ccxt/bitget.py
CHANGED
@@ -1690,33 +1690,6 @@ class bitget(Exchange, ImplicitAPI):
|
|
1690
1690
|
def set_sandbox_mode(self, enabled):
|
1691
1691
|
self.options['sandboxMode'] = enabled
|
1692
1692
|
|
1693
|
-
def convert_symbol_for_sandbox(self, symbol):
|
1694
|
-
if symbol.startswith('S'):
|
1695
|
-
# handle using the exchange specified sandbox symbols
|
1696
|
-
return symbol
|
1697
|
-
convertedSymbol = None
|
1698
|
-
if symbol.find('/') > -1:
|
1699
|
-
if symbol.find(':') == -1:
|
1700
|
-
raise NotSupported(self.id + ' sandbox supports swap and future markets only')
|
1701
|
-
splitBase = symbol.split('/')
|
1702
|
-
previousBase = self.safe_string(splitBase, 0)
|
1703
|
-
previousQuoteSettleExpiry = self.safe_string(splitBase, 1)
|
1704
|
-
splitQuote = previousQuoteSettleExpiry.split(':')
|
1705
|
-
previousQuote = self.safe_string(splitQuote, 0)
|
1706
|
-
previousSettleExpiry = self.safe_string(splitQuote, 1)
|
1707
|
-
splitSettle = previousSettleExpiry.split('-')
|
1708
|
-
previousSettle = self.safe_string(splitSettle, 0)
|
1709
|
-
expiry = self.safe_string(splitSettle, 1)
|
1710
|
-
convertedSymbol = 'S' + previousBase + '/S' + previousQuote + ':S' + previousSettle
|
1711
|
-
if expiry is not None:
|
1712
|
-
convertedSymbol = convertedSymbol + '-' + expiry
|
1713
|
-
else:
|
1714
|
-
# handle using a market id instead of a unified symbol
|
1715
|
-
base = symbol[0:3]
|
1716
|
-
remaining = symbol[3:]
|
1717
|
-
convertedSymbol = 'S' + base + 'S' + remaining
|
1718
|
-
return convertedSymbol
|
1719
|
-
|
1720
1693
|
def handle_product_type_and_params(self, market=None, params={}):
|
1721
1694
|
subType = None
|
1722
1695
|
subType, params = self.handle_sub_type_and_params('handleProductTypeAndParams', None, params)
|
@@ -1784,21 +1757,13 @@ class bitget(Exchange, ImplicitAPI):
|
|
1784
1757
|
"""
|
1785
1758
|
if self.options['adjustForTimeDifference']:
|
1786
1759
|
self.load_time_difference()
|
1787
|
-
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
1788
1760
|
types = self.safe_value(self.options, 'fetchMarkets', ['spot', 'swap'])
|
1789
|
-
if sandboxMode:
|
1790
|
-
types = ['swap']
|
1791
1761
|
promises = []
|
1792
1762
|
fetchMargins = False
|
1793
1763
|
for i in range(0, len(types)):
|
1794
1764
|
type = types[i]
|
1795
1765
|
if (type == 'swap') or (type == 'future'):
|
1796
|
-
subTypes =
|
1797
|
-
if sandboxMode:
|
1798
|
-
# the following are simulated trading markets ['SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES']
|
1799
|
-
subTypes = ['SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES']
|
1800
|
-
else:
|
1801
|
-
subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES']
|
1766
|
+
subTypes = ['USDT-FUTURES', 'COIN-FUTURES', 'USDC-FUTURES', 'SUSDT-FUTURES', 'SCOIN-FUTURES', 'SUSDC-FUTURES']
|
1802
1767
|
for j in range(0, len(subTypes)):
|
1803
1768
|
promises.append(self.publicMixGetV2MixMarketContracts(self.extend(params, {
|
1804
1769
|
'productType': subTypes[j],
|
@@ -2167,13 +2132,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2167
2132
|
:returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
|
2168
2133
|
"""
|
2169
2134
|
self.load_markets()
|
2170
|
-
|
2171
|
-
market = None
|
2172
|
-
if sandboxMode:
|
2173
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
2174
|
-
market = self.market(sandboxSymbol)
|
2175
|
-
else:
|
2176
|
-
market = self.market(symbol)
|
2135
|
+
market = self.market(symbol)
|
2177
2136
|
request: dict = {}
|
2178
2137
|
response = None
|
2179
2138
|
marginMode = None
|
@@ -2659,13 +2618,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2659
2618
|
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
|
2660
2619
|
"""
|
2661
2620
|
self.load_markets()
|
2662
|
-
|
2663
|
-
market = None
|
2664
|
-
if sandboxMode:
|
2665
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
2666
|
-
market = self.market(sandboxSymbol)
|
2667
|
-
else:
|
2668
|
-
market = self.market(symbol)
|
2621
|
+
market = self.market(symbol)
|
2669
2622
|
request: dict = {
|
2670
2623
|
'symbol': market['id'],
|
2671
2624
|
}
|
@@ -2825,13 +2778,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2825
2778
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
2826
2779
|
"""
|
2827
2780
|
self.load_markets()
|
2828
|
-
|
2829
|
-
market = None
|
2830
|
-
if sandboxMode:
|
2831
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
2832
|
-
market = self.market(sandboxSymbol)
|
2833
|
-
else:
|
2834
|
-
market = self.market(symbol)
|
2781
|
+
market = self.market(symbol)
|
2835
2782
|
request: dict = {
|
2836
2783
|
'symbol': market['id'],
|
2837
2784
|
}
|
@@ -2920,13 +2867,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2920
2867
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
2921
2868
|
"""
|
2922
2869
|
self.load_markets()
|
2923
|
-
|
2924
|
-
market = None
|
2925
|
-
if sandboxMode:
|
2926
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
2927
|
-
market = self.market(sandboxSymbol)
|
2928
|
-
else:
|
2929
|
-
market = self.market(symbol)
|
2870
|
+
market = self.market(symbol)
|
2930
2871
|
request: dict = {
|
2931
2872
|
'symbol': market['id'],
|
2932
2873
|
}
|
@@ -2958,12 +2899,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2958
2899
|
market = None
|
2959
2900
|
if symbols is not None:
|
2960
2901
|
symbol = self.safe_value(symbols, 0)
|
2961
|
-
|
2962
|
-
if sandboxMode:
|
2963
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
2964
|
-
market = self.market(sandboxSymbol)
|
2965
|
-
else:
|
2966
|
-
market = self.market(symbol)
|
2902
|
+
market = self.market(symbol)
|
2967
2903
|
response = None
|
2968
2904
|
request: dict = {}
|
2969
2905
|
type = None
|
@@ -3179,13 +3115,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
3179
3115
|
paginate, params = self.handle_option_and_params(params, 'fetchTrades', 'paginate')
|
3180
3116
|
if paginate:
|
3181
3117
|
return self.fetch_paginated_call_cursor('fetchTrades', symbol, since, limit, params, 'idLessThan', 'idLessThan')
|
3182
|
-
|
3183
|
-
market = None
|
3184
|
-
if sandboxMode:
|
3185
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
3186
|
-
market = self.market(sandboxSymbol)
|
3187
|
-
else:
|
3188
|
-
market = self.market(symbol)
|
3118
|
+
market = self.market(symbol)
|
3189
3119
|
request: dict = {
|
3190
3120
|
'symbol': market['id'],
|
3191
3121
|
}
|
@@ -3480,14 +3410,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
3480
3410
|
paginate, params = self.handle_option_and_params(params, 'fetchOHLCV', 'paginate')
|
3481
3411
|
if paginate:
|
3482
3412
|
return self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, maxLimitForRecentEndpoint)
|
3483
|
-
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
3484
3413
|
useHistoryEndpoint = self.safe_bool(params, 'useHistoryEndpoint', False)
|
3485
|
-
market =
|
3486
|
-
if sandboxMode:
|
3487
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
3488
|
-
market = self.market(sandboxSymbol)
|
3489
|
-
else:
|
3490
|
-
market = self.market(symbol)
|
3414
|
+
market = self.market(symbol)
|
3491
3415
|
marketType = 'spot' if market['spot'] else 'swap'
|
3492
3416
|
timeframes = self.options['timeframes'][marketType]
|
3493
3417
|
msInDay = 86400000
|
@@ -4291,13 +4215,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4291
4215
|
return self.parse_order(data, market)
|
4292
4216
|
|
4293
4217
|
def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
4294
|
-
|
4295
|
-
market = None
|
4296
|
-
if sandboxMode:
|
4297
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
4298
|
-
market = self.market(sandboxSymbol)
|
4299
|
-
else:
|
4300
|
-
market = self.market(symbol)
|
4218
|
+
market = self.market(symbol)
|
4301
4219
|
marketType = None
|
4302
4220
|
marginMode = None
|
4303
4221
|
marketType, params = self.handle_market_type_and_params('createOrder', market, params)
|
@@ -4509,13 +4427,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4509
4427
|
raise BadRequest(self.id + ' createOrders() requires all orders to have the same margin mode(isolated or cross)')
|
4510
4428
|
orderRequest = self.create_order_request(marketId, type, side, amount, price, orderParams)
|
4511
4429
|
ordersRequests.append(orderRequest)
|
4512
|
-
|
4513
|
-
market = None
|
4514
|
-
if sandboxMode:
|
4515
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
4516
|
-
market = self.market(sandboxSymbol)
|
4517
|
-
else:
|
4518
|
-
market = self.market(symbol)
|
4430
|
+
market = self.market(symbol)
|
4519
4431
|
request: dict = {
|
4520
4432
|
'symbol': market['id'],
|
4521
4433
|
'orderList': ordersRequests,
|
@@ -4599,13 +4511,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4599
4511
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
4600
4512
|
"""
|
4601
4513
|
self.load_markets()
|
4602
|
-
|
4603
|
-
market = None
|
4604
|
-
if sandboxMode:
|
4605
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
4606
|
-
market = self.market(sandboxSymbol)
|
4607
|
-
else:
|
4608
|
-
market = self.market(symbol)
|
4514
|
+
market = self.market(symbol)
|
4609
4515
|
request: dict = {
|
4610
4516
|
'orderId': id,
|
4611
4517
|
}
|
@@ -4742,13 +4648,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4742
4648
|
if symbol is None:
|
4743
4649
|
raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
|
4744
4650
|
self.load_markets()
|
4745
|
-
|
4746
|
-
market = None
|
4747
|
-
if sandboxMode:
|
4748
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
4749
|
-
market = self.market(sandboxSymbol)
|
4750
|
-
else:
|
4751
|
-
market = self.market(symbol)
|
4651
|
+
market = self.market(symbol)
|
4752
4652
|
marginMode = None
|
4753
4653
|
response = None
|
4754
4654
|
marginMode, params = self.handle_margin_mode_and_params('cancelOrder', params)
|
@@ -4862,13 +4762,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4862
4762
|
if symbol is None:
|
4863
4763
|
raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
|
4864
4764
|
self.load_markets()
|
4865
|
-
|
4866
|
-
market = None
|
4867
|
-
if sandboxMode:
|
4868
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
4869
|
-
market = self.market(sandboxSymbol)
|
4870
|
-
else:
|
4871
|
-
market = self.market(symbol)
|
4765
|
+
market = self.market(symbol)
|
4872
4766
|
marginMode = None
|
4873
4767
|
marginMode, params = self.handle_margin_mode_and_params('cancelOrders', params)
|
4874
4768
|
trigger = self.safe_value_2(params, 'stop', 'trigger')
|
@@ -4943,13 +4837,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4943
4837
|
if symbol is None:
|
4944
4838
|
raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
|
4945
4839
|
self.load_markets()
|
4946
|
-
|
4947
|
-
market = None
|
4948
|
-
if sandboxMode:
|
4949
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
4950
|
-
market = self.market(sandboxSymbol)
|
4951
|
-
else:
|
4952
|
-
market = self.market(symbol)
|
4840
|
+
market = self.market(symbol)
|
4953
4841
|
marginMode = None
|
4954
4842
|
marginMode, params = self.handle_margin_mode_and_params('cancelAllOrders', params)
|
4955
4843
|
request: dict = {
|
@@ -5052,13 +4940,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5052
4940
|
if symbol is None:
|
5053
4941
|
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
|
5054
4942
|
self.load_markets()
|
5055
|
-
|
5056
|
-
market = None
|
5057
|
-
if sandboxMode:
|
5058
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
5059
|
-
market = self.market(sandboxSymbol)
|
5060
|
-
else:
|
5061
|
-
market = self.market(symbol)
|
4943
|
+
market = self.market(symbol)
|
5062
4944
|
request: dict = {
|
5063
4945
|
'orderId': id,
|
5064
4946
|
}
|
@@ -5176,18 +5058,13 @@ class bitget(Exchange, ImplicitAPI):
|
|
5176
5058
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
5177
5059
|
"""
|
5178
5060
|
self.load_markets()
|
5179
|
-
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
5180
5061
|
market = None
|
5181
5062
|
type = None
|
5182
5063
|
request: dict = {}
|
5183
5064
|
marginMode = None
|
5184
5065
|
marginMode, params = self.handle_margin_mode_and_params('fetchOpenOrders', params)
|
5185
5066
|
if symbol is not None:
|
5186
|
-
|
5187
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
5188
|
-
market = self.market(sandboxSymbol)
|
5189
|
-
else:
|
5190
|
-
market = self.market(symbol)
|
5067
|
+
market = self.market(symbol)
|
5191
5068
|
request['symbol'] = market['id']
|
5192
5069
|
defaultType = self.safe_string_2(self.options, 'fetchOpenOrders', 'defaultType', 'spot')
|
5193
5070
|
marketType = market['type'] if ('type' in market) else defaultType
|
@@ -5514,12 +5391,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5514
5391
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
5515
5392
|
"""
|
5516
5393
|
self.load_markets()
|
5517
|
-
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
5518
5394
|
market = None
|
5519
|
-
if sandboxMode:
|
5520
|
-
if symbol is not None:
|
5521
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
5522
|
-
symbol = sandboxSymbol
|
5523
5395
|
request: dict = {}
|
5524
5396
|
if symbol is not None:
|
5525
5397
|
market = self.market(symbol)
|
@@ -5801,12 +5673,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5801
5673
|
params = self.omit(params, 'symbol')
|
5802
5674
|
market = None
|
5803
5675
|
if symbol is not None:
|
5804
|
-
|
5805
|
-
if sandboxMode:
|
5806
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
5807
|
-
market = self.market(sandboxSymbol)
|
5808
|
-
else:
|
5809
|
-
market = self.market(symbol)
|
5676
|
+
market = self.market(symbol)
|
5810
5677
|
marketType = None
|
5811
5678
|
marketType, params = self.handle_market_type_and_params('fetchLedger', market, params)
|
5812
5679
|
paginate = False
|
@@ -6011,13 +5878,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6011
5878
|
if symbol is None:
|
6012
5879
|
raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol argument')
|
6013
5880
|
self.load_markets()
|
6014
|
-
|
6015
|
-
market = None
|
6016
|
-
if sandboxMode:
|
6017
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
6018
|
-
market = self.market(sandboxSymbol)
|
6019
|
-
else:
|
6020
|
-
market = self.market(symbol)
|
5881
|
+
market = self.market(symbol)
|
6021
5882
|
marginMode = None
|
6022
5883
|
marginMode, params = self.handle_margin_mode_and_params('fetchMyTrades', params)
|
6023
5884
|
paginate = False
|
@@ -6173,13 +6034,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6173
6034
|
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
6174
6035
|
"""
|
6175
6036
|
self.load_markets()
|
6176
|
-
|
6177
|
-
market = None
|
6178
|
-
if sandboxMode:
|
6179
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
6180
|
-
market = self.market(sandboxSymbol)
|
6181
|
-
else:
|
6182
|
-
market = self.market(symbol)
|
6037
|
+
market = self.market(symbol)
|
6183
6038
|
productType = None
|
6184
6039
|
productType, params = self.handle_product_type_and_params(market, params)
|
6185
6040
|
request: dict = {
|
@@ -6252,12 +6107,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6252
6107
|
market = None
|
6253
6108
|
if symbols is not None:
|
6254
6109
|
first = self.safe_string(symbols, 0)
|
6255
|
-
|
6256
|
-
if sandboxMode:
|
6257
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(first)
|
6258
|
-
market = self.market(sandboxSymbol)
|
6259
|
-
else:
|
6260
|
-
market = self.market(first)
|
6110
|
+
market = self.market(first)
|
6261
6111
|
productType = None
|
6262
6112
|
productType, params = self.handle_product_type_and_params(market, params)
|
6263
6113
|
request: dict = {
|
@@ -6544,13 +6394,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6544
6394
|
paginate, params = self.handle_option_and_params(params, 'fetchFundingRateHistory', 'paginate')
|
6545
6395
|
if paginate:
|
6546
6396
|
return self.fetch_paginated_call_incremental('fetchFundingRateHistory', symbol, since, limit, params, 'pageNo', 100)
|
6547
|
-
|
6548
|
-
market = None
|
6549
|
-
if sandboxMode:
|
6550
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
6551
|
-
market = self.market(sandboxSymbol)
|
6552
|
-
else:
|
6553
|
-
market = self.market(symbol)
|
6397
|
+
market = self.market(symbol)
|
6554
6398
|
productType = None
|
6555
6399
|
productType, params = self.handle_product_type_and_params(market, params)
|
6556
6400
|
request: dict = {
|
@@ -6604,13 +6448,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6604
6448
|
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
6605
6449
|
"""
|
6606
6450
|
self.load_markets()
|
6607
|
-
|
6608
|
-
market = None
|
6609
|
-
if sandboxMode:
|
6610
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
6611
|
-
market = self.market(sandboxSymbol)
|
6612
|
-
else:
|
6613
|
-
market = self.market(symbol)
|
6451
|
+
market = self.market(symbol)
|
6614
6452
|
if not market['swap']:
|
6615
6453
|
raise BadSymbol(self.id + ' fetchFundingRate() supports swap contracts only')
|
6616
6454
|
productType = None
|
@@ -6652,12 +6490,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6652
6490
|
market = None
|
6653
6491
|
if symbols is not None:
|
6654
6492
|
symbol = self.safe_value(symbols, 0)
|
6655
|
-
|
6656
|
-
if sandboxMode:
|
6657
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
6658
|
-
market = self.market(sandboxSymbol)
|
6659
|
-
else:
|
6660
|
-
market = self.market(symbol)
|
6493
|
+
market = self.market(symbol)
|
6661
6494
|
request: dict = {}
|
6662
6495
|
productType = None
|
6663
6496
|
productType, params = self.handle_product_type_and_params(market, params)
|
@@ -6793,13 +6626,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6793
6626
|
paginate, params = self.handle_option_and_params(params, 'fetchFundingHistory', 'paginate')
|
6794
6627
|
if paginate:
|
6795
6628
|
return self.fetch_paginated_call_cursor('fetchFundingHistory', symbol, since, limit, params, 'endId', 'idLessThan')
|
6796
|
-
|
6797
|
-
market = None
|
6798
|
-
if sandboxMode:
|
6799
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
6800
|
-
market = self.market(sandboxSymbol)
|
6801
|
-
else:
|
6802
|
-
market = self.market(symbol)
|
6629
|
+
market = self.market(symbol)
|
6803
6630
|
if not market['swap']:
|
6804
6631
|
raise BadSymbol(self.id + ' fetchFundingHistory() supports swap contracts only')
|
6805
6632
|
productType = None
|
@@ -6877,18 +6704,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
6877
6704
|
continue
|
6878
6705
|
result.append(self.parse_funding_history(contract, market))
|
6879
6706
|
sorted = self.sort_by(result, 'timestamp')
|
6880
|
-
|
6707
|
+
symbol = None
|
6708
|
+
if market is not None:
|
6709
|
+
symbol = market['symbol']
|
6710
|
+
return self.filter_by_symbol_since_limit(sorted, symbol, since, limit)
|
6881
6711
|
|
6882
6712
|
def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
|
6883
6713
|
self.load_markets()
|
6884
6714
|
holdSide = self.safe_string(params, 'holdSide')
|
6885
|
-
|
6886
|
-
market = None
|
6887
|
-
if sandboxMode:
|
6888
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
6889
|
-
market = self.market(sandboxSymbol)
|
6890
|
-
else:
|
6891
|
-
market = self.market(symbol)
|
6715
|
+
market = self.market(symbol)
|
6892
6716
|
productType = None
|
6893
6717
|
productType, params = self.handle_product_type_and_params(market, params)
|
6894
6718
|
request: dict = {
|
@@ -6984,13 +6808,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6984
6808
|
:returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
|
6985
6809
|
"""
|
6986
6810
|
self.load_markets()
|
6987
|
-
|
6988
|
-
market = None
|
6989
|
-
if sandboxMode:
|
6990
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
6991
|
-
market = self.market(sandboxSymbol)
|
6992
|
-
else:
|
6993
|
-
market = self.market(symbol)
|
6811
|
+
market = self.market(symbol)
|
6994
6812
|
productType = None
|
6995
6813
|
productType, params = self.handle_product_type_and_params(market, params)
|
6996
6814
|
request: dict = {
|
@@ -7031,12 +6849,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
7031
6849
|
return self.parse_leverage(data, market)
|
7032
6850
|
|
7033
6851
|
def parse_leverage(self, leverage: dict, market: Market = None) -> Leverage:
|
6852
|
+
isCrossMarginMode = self.safe_string(leverage, 'marginMode') == 'crossed'
|
6853
|
+
longLevKey = 'crossedMarginLeverage' if isCrossMarginMode else 'isolatedLongLever'
|
6854
|
+
shortLevKey = 'crossedMarginLeverage' if isCrossMarginMode else 'isolatedShortLever'
|
7034
6855
|
return {
|
7035
6856
|
'info': leverage,
|
7036
6857
|
'symbol': market['symbol'],
|
7037
|
-
'marginMode': 'isolated',
|
7038
|
-
'longLeverage': self.safe_integer(leverage,
|
7039
|
-
'shortLeverage': self.safe_integer(leverage,
|
6858
|
+
'marginMode': 'cross' if isCrossMarginMode else 'isolated',
|
6859
|
+
'longLeverage': self.safe_integer(leverage, longLevKey),
|
6860
|
+
'shortLeverage': self.safe_integer(leverage, shortLevKey),
|
7040
6861
|
}
|
7041
6862
|
|
7042
6863
|
def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
|
@@ -7054,13 +6875,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7054
6875
|
if symbol is None:
|
7055
6876
|
raise ArgumentsRequired(self.id + ' setLeverage() requires a symbol argument')
|
7056
6877
|
self.load_markets()
|
7057
|
-
|
7058
|
-
market = None
|
7059
|
-
if sandboxMode:
|
7060
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
7061
|
-
market = self.market(sandboxSymbol)
|
7062
|
-
else:
|
7063
|
-
market = self.market(symbol)
|
6878
|
+
market = self.market(symbol)
|
7064
6879
|
productType = None
|
7065
6880
|
productType, params = self.handle_product_type_and_params(market, params)
|
7066
6881
|
request: dict = {
|
@@ -7107,13 +6922,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7107
6922
|
if (marginMode != 'isolated') and (marginMode != 'crossed'):
|
7108
6923
|
raise ArgumentsRequired(self.id + ' setMarginMode() marginMode must be either isolated or crossed(cross)')
|
7109
6924
|
self.load_markets()
|
7110
|
-
|
7111
|
-
market = None
|
7112
|
-
if sandboxMode:
|
7113
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
7114
|
-
market = self.market(sandboxSymbol)
|
7115
|
-
else:
|
7116
|
-
market = self.market(symbol)
|
6925
|
+
market = self.market(symbol)
|
7117
6926
|
productType = None
|
7118
6927
|
productType, params = self.handle_product_type_and_params(market, params)
|
7119
6928
|
request: dict = {
|
@@ -7155,12 +6964,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7155
6964
|
posMode = 'hedge_mode' if hedged else 'one_way_mode'
|
7156
6965
|
market = None
|
7157
6966
|
if symbol is not None:
|
7158
|
-
|
7159
|
-
if sandboxMode:
|
7160
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
7161
|
-
market = self.market(sandboxSymbol)
|
7162
|
-
else:
|
7163
|
-
market = self.market(symbol)
|
6967
|
+
market = self.market(symbol)
|
7164
6968
|
productType = None
|
7165
6969
|
productType, params = self.handle_product_type_and_params(market, params)
|
7166
6970
|
request: dict = {
|
@@ -7191,13 +6995,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
7191
6995
|
:returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
|
7192
6996
|
"""
|
7193
6997
|
self.load_markets()
|
7194
|
-
|
7195
|
-
market = None
|
7196
|
-
if sandboxMode:
|
7197
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
7198
|
-
market = self.market(sandboxSymbol)
|
7199
|
-
else:
|
7200
|
-
market = self.market(symbol)
|
6998
|
+
market = self.market(symbol)
|
7201
6999
|
if not market['contract']:
|
7202
7000
|
raise BadRequest(self.id + ' fetchOpenInterest() supports contract markets only')
|
7203
7001
|
productType = None
|
@@ -8197,13 +7995,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
8197
7995
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
8198
7996
|
"""
|
8199
7997
|
self.load_markets()
|
8200
|
-
|
8201
|
-
market = None
|
8202
|
-
if sandboxMode:
|
8203
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
8204
|
-
market = self.market(sandboxSymbol)
|
8205
|
-
else:
|
8206
|
-
market = self.market(symbol)
|
7998
|
+
market = self.market(symbol)
|
8207
7999
|
productType = None
|
8208
8000
|
productType, params = self.handle_product_type_and_params(market, params)
|
8209
8001
|
request: dict = {
|
@@ -8283,13 +8075,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
8283
8075
|
:returns dict: a `margin mode structure <https://docs.ccxt.com/#/?id=margin-mode-structure>`
|
8284
8076
|
"""
|
8285
8077
|
self.load_markets()
|
8286
|
-
|
8287
|
-
market = None
|
8288
|
-
if sandboxMode:
|
8289
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
8290
|
-
market = self.market(sandboxSymbol)
|
8291
|
-
else:
|
8292
|
-
market = self.market(symbol)
|
8078
|
+
market = self.market(symbol)
|
8293
8079
|
productType = None
|
8294
8080
|
productType, params = self.handle_product_type_and_params(market, params)
|
8295
8081
|
request: dict = {
|
@@ -8678,13 +8464,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
8678
8464
|
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
8679
8465
|
"""
|
8680
8466
|
self.load_markets()
|
8681
|
-
|
8682
|
-
market = None
|
8683
|
-
if sandboxMode:
|
8684
|
-
sandboxSymbol = self.convert_symbol_for_sandbox(symbol)
|
8685
|
-
market = self.market(sandboxSymbol)
|
8686
|
-
else:
|
8687
|
-
market = self.market(symbol)
|
8467
|
+
market = self.market(symbol)
|
8688
8468
|
productType = None
|
8689
8469
|
productType, params = self.handle_product_type_and_params(market, params)
|
8690
8470
|
request: dict = {
|
@@ -8864,10 +8644,12 @@ class bitget(Exchange, ImplicitAPI):
|
|
8864
8644
|
}
|
8865
8645
|
if method == 'POST':
|
8866
8646
|
headers['Content-Type'] = 'application/json'
|
8867
|
-
sandboxMode = self.
|
8647
|
+
sandboxMode = self.safe_bool_2(self.options, 'sandboxMode', 'sandbox', False)
|
8868
8648
|
if sandboxMode and (path != 'v2/public/time'):
|
8869
8649
|
# https://github.com/ccxt/ccxt/issues/25252#issuecomment-2662742336
|
8870
8650
|
if headers is None:
|
8871
8651
|
headers = {}
|
8872
|
-
|
8652
|
+
productType = self.safe_string(params, 'productType')
|
8653
|
+
if (productType != 'SCOIN-FUTURES') and (productType != 'SUSDT-FUTURES') and (productType != 'SUSDC-FUTURES'):
|
8654
|
+
headers['PAPTRADING'] = '1'
|
8873
8655
|
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
ccxt/bitmart.py
CHANGED
@@ -61,6 +61,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
61
61
|
'createOrder': True,
|
62
62
|
'createOrders': True,
|
63
63
|
'createPostOnlyOrder': True,
|
64
|
+
'createReduceOnlyOrder': True,
|
64
65
|
'createStopLimitOrder': False,
|
65
66
|
'createStopMarketOrder': False,
|
66
67
|
'createStopOrder': False,
|
@@ -278,6 +279,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
278
279
|
'contract/private/submit-tp-sl-order': 2.5,
|
279
280
|
'contract/private/modify-plan-order': 2.5,
|
280
281
|
'contract/private/modify-preset-plan-order': 2.5,
|
282
|
+
'contract/private/modify-limit-order': 2.5,
|
281
283
|
'contract/private/modify-tp-sl-order': 2.5,
|
282
284
|
'contract/private/submit-trail-order': 2.5, # weight is not provided by the exchange, is set order
|
283
285
|
'contract/private/cancel-trail-order': 1.5, # weight is not provided by the exchange, is set order
|
@@ -4875,6 +4877,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
4875
4877
|
https://developer-pro.bitmart.com/en/futuresv2/#modify-plan-order-signed
|
4876
4878
|
https://developer-pro.bitmart.com/en/futuresv2/#modify-tp-sl-order-signed
|
4877
4879
|
https://developer-pro.bitmart.com/en/futuresv2/#modify-preset-plan-order-signed
|
4880
|
+
https://developer-pro.bitmart.com/en/futuresv2/#modify-limit-order-signed
|
4878
4881
|
|
4879
4882
|
:param str id: order id
|
4880
4883
|
:param str symbol: unified symbol of the market to edit an order in
|
@@ -4909,6 +4912,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
4909
4912
|
isTakeProfit = takeProfitPrice is not None
|
4910
4913
|
isPresetStopLoss = presetStopLoss is not None
|
4911
4914
|
isPresetTakeProfit = presetTakeProfit is not None
|
4915
|
+
isLimitOrder = (type == 'limit')
|
4912
4916
|
request: dict = {
|
4913
4917
|
'symbol': market['id'],
|
4914
4918
|
}
|
@@ -4973,8 +4977,15 @@ class bitmart(Exchange, ImplicitAPI):
|
|
4973
4977
|
# "trace": "a5c3234534534a836bc476a203.123452.172716624359200197"
|
4974
4978
|
# }
|
4975
4979
|
#
|
4980
|
+
elif isLimitOrder:
|
4981
|
+
request['order_id'] = self.parse_to_int(id) # reparse id self endpoint is the only one requiring it
|
4982
|
+
if amount is not None:
|
4983
|
+
request['size'] = self.amount_to_precision(symbol, amount)
|
4984
|
+
if price is not None:
|
4985
|
+
request['price'] = self.price_to_precision(symbol, price)
|
4986
|
+
response = self.privatePostContractPrivateModifyLimitOrder(self.extend(request, params))
|
4976
4987
|
else:
|
4977
|
-
raise NotSupported(self.id + ' editOrder() only supports trigger, stop loss and take profit orders')
|
4988
|
+
raise NotSupported(self.id + ' editOrder() only supports limit, trigger, stop loss and take profit orders')
|
4978
4989
|
data = self.safe_dict(response, 'data', {})
|
4979
4990
|
return self.parse_order(data, market)
|
4980
4991
|
|
ccxt/bitopro.py
CHANGED
ccxt/bitrue.py
CHANGED
@@ -56,6 +56,7 @@ class bitrue(Exchange, ImplicitAPI):
|
|
56
56
|
'createMarketOrderWithCost': False,
|
57
57
|
'createMarketSellOrderWithCost': False,
|
58
58
|
'createOrder': True,
|
59
|
+
'createReduceOnlyOrder': True,
|
59
60
|
'createStopLimitOrder': True,
|
60
61
|
'createStopMarketOrder': True,
|
61
62
|
'createStopOrder': True,
|