ccxt 4.4.98__py2.py3-none-any.whl → 4.4.100__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 +3 -1
- ccxt/abstract/bingx.py +1 -0
- ccxt/abstract/bitget.py +6 -0
- ccxt/abstract/hibachi.py +26 -0
- ccxt/alpaca.py +1 -1
- ccxt/apex.py +1 -1
- ccxt/ascendex.py +1 -1
- ccxt/async_support/__init__.py +3 -1
- ccxt/async_support/alpaca.py +1 -1
- ccxt/async_support/apex.py +1 -1
- ccxt/async_support/ascendex.py +1 -1
- ccxt/async_support/base/exchange.py +44 -9
- ccxt/async_support/base/ws/client.py +3 -1
- ccxt/async_support/bigone.py +1 -1
- ccxt/async_support/binance.py +10 -8
- ccxt/async_support/bingx.py +33 -4
- ccxt/async_support/bitbank.py +1 -1
- ccxt/async_support/bitfinex.py +4 -1
- ccxt/async_support/bitflyer.py +1 -1
- ccxt/async_support/bitget.py +2040 -561
- ccxt/async_support/bithumb.py +1 -1
- ccxt/async_support/bitmart.py +2 -2
- ccxt/async_support/bitmex.py +3 -2
- ccxt/async_support/bitopro.py +1 -1
- ccxt/async_support/bitrue.py +2 -2
- ccxt/async_support/bitso.py +1 -1
- ccxt/async_support/bitstamp.py +1 -1
- ccxt/async_support/bittrade.py +1 -1
- ccxt/async_support/bitvavo.py +1 -1
- ccxt/async_support/blockchaincom.py +1 -1
- ccxt/async_support/blofin.py +1 -1
- ccxt/async_support/btcmarkets.py +1 -1
- ccxt/async_support/bybit.py +7 -3
- ccxt/async_support/coinbase.py +1 -1
- ccxt/async_support/coinbaseexchange.py +1 -1
- ccxt/async_support/coinbaseinternational.py +1 -1
- ccxt/async_support/coincatch.py +2 -2
- ccxt/async_support/coinex.py +67 -6
- ccxt/async_support/coinmate.py +1 -1
- ccxt/async_support/coinsph.py +1 -1
- ccxt/async_support/cryptocom.py +2 -2
- ccxt/async_support/defx.py +2 -2
- ccxt/async_support/delta.py +1 -1
- ccxt/async_support/deribit.py +1 -1
- ccxt/async_support/digifinex.py +2 -2
- ccxt/async_support/ellipx.py +1 -1
- ccxt/async_support/exmo.py +1 -1
- ccxt/async_support/foxbit.py +3 -3
- ccxt/async_support/gate.py +18 -4
- ccxt/async_support/gemini.py +1 -1
- ccxt/async_support/hashkey.py +2 -2
- ccxt/async_support/hibachi.py +2080 -0
- ccxt/async_support/hitbtc.py +2 -2
- ccxt/async_support/hollaex.py +1 -1
- ccxt/async_support/htx.py +4 -3
- ccxt/async_support/hyperliquid.py +71 -29
- ccxt/async_support/independentreserve.py +1 -1
- ccxt/async_support/indodax.py +1 -1
- ccxt/async_support/kraken.py +1 -1
- ccxt/async_support/krakenfutures.py +2 -1
- ccxt/async_support/kucoin.py +2 -2
- ccxt/async_support/kucoinfutures.py +2 -1
- ccxt/async_support/lbank.py +2 -2
- ccxt/async_support/mercado.py +1 -1
- ccxt/async_support/mexc.py +9 -2
- ccxt/async_support/modetrade.py +93 -2
- ccxt/async_support/ndax.py +1 -1
- ccxt/async_support/novadax.py +35 -1
- ccxt/async_support/okcoin.py +1 -1
- ccxt/async_support/okx.py +2 -2
- ccxt/async_support/onetrading.py +33 -0
- ccxt/async_support/oxfun.py +1 -1
- ccxt/async_support/p2b.py +32 -0
- ccxt/async_support/paradex.py +2 -1
- ccxt/async_support/phemex.py +2 -2
- ccxt/async_support/poloniex.py +2 -2
- ccxt/async_support/probit.py +36 -1
- ccxt/async_support/tokocrypto.py +1 -1
- ccxt/async_support/upbit.py +1 -1
- ccxt/async_support/vertex.py +1 -1
- ccxt/async_support/wavesexchange.py +1 -1
- ccxt/async_support/whitebit.py +2 -2
- ccxt/async_support/woo.py +4 -4
- ccxt/async_support/woofipro.py +93 -2
- ccxt/async_support/xt.py +2 -2
- ccxt/async_support/yobit.py +1 -1
- ccxt/async_support/zaif.py +1 -1
- ccxt/async_support/zonda.py +1 -1
- ccxt/base/errors.py +0 -6
- ccxt/base/exchange.py +11 -9
- ccxt/base/types.py +1 -0
- ccxt/bigone.py +1 -1
- ccxt/binance.py +10 -8
- ccxt/bingx.py +33 -4
- ccxt/bitbank.py +1 -1
- ccxt/bitfinex.py +4 -1
- ccxt/bitflyer.py +1 -1
- ccxt/bitget.py +2040 -561
- ccxt/bithumb.py +1 -1
- ccxt/bitmart.py +2 -2
- ccxt/bitmex.py +3 -2
- ccxt/bitopro.py +1 -1
- ccxt/bitrue.py +2 -2
- ccxt/bitso.py +1 -1
- ccxt/bitstamp.py +1 -1
- ccxt/bittrade.py +1 -1
- ccxt/bitvavo.py +1 -1
- ccxt/blockchaincom.py +1 -1
- ccxt/blofin.py +1 -1
- ccxt/btcmarkets.py +1 -1
- ccxt/bybit.py +7 -3
- ccxt/coinbase.py +1 -1
- ccxt/coinbaseexchange.py +1 -1
- ccxt/coinbaseinternational.py +1 -1
- ccxt/coincatch.py +2 -2
- ccxt/coinex.py +67 -6
- ccxt/coinmate.py +1 -1
- ccxt/coinsph.py +1 -1
- ccxt/cryptocom.py +2 -2
- ccxt/defx.py +2 -2
- ccxt/delta.py +1 -1
- ccxt/deribit.py +1 -1
- ccxt/digifinex.py +2 -2
- ccxt/ellipx.py +1 -1
- ccxt/exmo.py +1 -1
- ccxt/foxbit.py +3 -3
- ccxt/gate.py +18 -4
- ccxt/gemini.py +1 -1
- ccxt/hashkey.py +2 -2
- ccxt/hibachi.py +2079 -0
- ccxt/hitbtc.py +2 -2
- ccxt/hollaex.py +1 -1
- ccxt/htx.py +4 -3
- ccxt/hyperliquid.py +71 -29
- ccxt/independentreserve.py +1 -1
- ccxt/indodax.py +1 -1
- ccxt/kraken.py +1 -1
- ccxt/krakenfutures.py +2 -1
- ccxt/kucoin.py +2 -2
- ccxt/kucoinfutures.py +2 -1
- ccxt/lbank.py +2 -2
- ccxt/mercado.py +1 -1
- ccxt/mexc.py +9 -2
- ccxt/modetrade.py +93 -2
- ccxt/ndax.py +1 -1
- ccxt/novadax.py +35 -1
- ccxt/okcoin.py +1 -1
- ccxt/okx.py +2 -2
- ccxt/onetrading.py +33 -0
- ccxt/oxfun.py +1 -1
- ccxt/p2b.py +32 -0
- ccxt/paradex.py +2 -1
- ccxt/phemex.py +2 -2
- ccxt/poloniex.py +2 -2
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/alpaca.py +2 -2
- ccxt/pro/apex.py +2 -2
- ccxt/pro/ascendex.py +2 -2
- ccxt/pro/binance.py +4 -5
- ccxt/pro/bitget.py +3 -3
- ccxt/pro/bithumb.py +2 -2
- ccxt/pro/bitmart.py +2 -2
- ccxt/pro/bitmex.py +3 -3
- ccxt/pro/bitstamp.py +3 -3
- ccxt/pro/bittrade.py +2 -2
- ccxt/pro/bitvavo.py +5 -3
- ccxt/pro/bybit.py +5 -4
- ccxt/pro/cex.py +3 -2
- ccxt/pro/coinbaseexchange.py +4 -4
- ccxt/pro/coinbaseinternational.py +2 -2
- ccxt/pro/coincatch.py +1 -1
- ccxt/pro/coinex.py +1 -1
- ccxt/pro/coinone.py +2 -2
- ccxt/pro/cryptocom.py +2 -2
- ccxt/pro/derive.py +2 -2
- ccxt/pro/gate.py +3 -3
- ccxt/pro/hollaex.py +2 -2
- ccxt/pro/htx.py +3 -3
- ccxt/pro/hyperliquid.py +101 -14
- ccxt/pro/kraken.py +2 -2
- ccxt/pro/krakenfutures.py +4 -3
- ccxt/pro/kucoin.py +4 -3
- ccxt/pro/kucoinfutures.py +4 -3
- ccxt/pro/mexc.py +328 -139
- ccxt/pro/modetrade.py +2 -2
- ccxt/pro/okcoin.py +2 -2
- ccxt/pro/okx.py +7 -6
- ccxt/pro/onetrading.py +2 -2
- ccxt/pro/oxfun.py +1 -1
- ccxt/pro/p2b.py +2 -2
- ccxt/pro/paradex.py +2 -2
- ccxt/pro/poloniex.py +2 -2
- ccxt/pro/probit.py +2 -2
- ccxt/pro/vertex.py +2 -2
- ccxt/pro/whitebit.py +2 -2
- ccxt/pro/woo.py +2 -2
- ccxt/pro/woofipro.py +2 -2
- ccxt/probit.py +36 -1
- ccxt/protobuf/__init__.py +0 -0
- ccxt/protobuf/mexc/PrivateAccountV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PrivateDealsV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PrivateOrdersV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PublicAggreBookTickerV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PublicAggreDealsV3Api_pb2.py +39 -0
- ccxt/protobuf/mexc/PublicAggreDepthsV3Api_pb2.py +39 -0
- ccxt/protobuf/mexc/PublicBookTickerBatchV3Api_pb2.py +38 -0
- ccxt/protobuf/mexc/PublicBookTickerV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PublicDealsV3Api_pb2.py +39 -0
- ccxt/protobuf/mexc/PublicIncreaseDepthsBatchV3Api_pb2.py +38 -0
- ccxt/protobuf/mexc/PublicIncreaseDepthsV3Api_pb2.py +39 -0
- ccxt/protobuf/mexc/PublicLimitDepthsV3Api_pb2.py +39 -0
- ccxt/protobuf/mexc/PublicMiniTickerV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PublicMiniTickersV3Api_pb2.py +38 -0
- ccxt/protobuf/mexc/PublicSpotKlineV3Api_pb2.py +37 -0
- ccxt/protobuf/mexc/PushDataV3ApiWrapper_pb2.py +52 -0
- ccxt/protobuf/mexc/__init__.py +0 -0
- ccxt/test/tests_async.py +1 -1
- ccxt/test/tests_sync.py +1 -1
- ccxt/tokocrypto.py +1 -1
- ccxt/upbit.py +1 -1
- ccxt/vertex.py +1 -1
- ccxt/wavesexchange.py +1 -1
- ccxt/whitebit.py +2 -2
- ccxt/woo.py +4 -4
- ccxt/woofipro.py +93 -2
- ccxt/xt.py +2 -2
- ccxt/yobit.py +1 -1
- ccxt/zaif.py +1 -1
- ccxt/zonda.py +1 -1
- {ccxt-4.4.98.dist-info → ccxt-4.4.100.dist-info}/METADATA +8 -7
- {ccxt-4.4.98.dist-info → ccxt-4.4.100.dist-info}/RECORD +234 -213
- {ccxt-4.4.98.dist-info → ccxt-4.4.100.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.98.dist-info → ccxt-4.4.100.dist-info}/WHEEL +0 -0
- {ccxt-4.4.98.dist-info → ccxt-4.4.100.dist-info}/top_level.txt +0 -0
ccxt/bitget.py
CHANGED
@@ -826,6 +826,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
826
826
|
'get': {
|
827
827
|
'v3/account/assets': 1,
|
828
828
|
'v3/account/settings': 1,
|
829
|
+
'v3/account/deposit-records': 2,
|
829
830
|
'v3/account/financial-records': 1,
|
830
831
|
'v3/account/repayable-coins': 2,
|
831
832
|
'v3/account/payment-coins': 2,
|
@@ -844,7 +845,9 @@ class bitget(Exchange, ImplicitAPI):
|
|
844
845
|
'v3/position/history-position': 1,
|
845
846
|
'v3/trade/order-info': 1,
|
846
847
|
'v3/trade/unfilled-orders': 1,
|
848
|
+
'v3/trade/unfilled-strategy-orders': 1,
|
847
849
|
'v3/trade/history-orders': 1,
|
850
|
+
'v3/trade/history-strategy-orders': 1,
|
848
851
|
'v3/trade/fills': 1,
|
849
852
|
'v3/user/sub-list': 2,
|
850
853
|
'v3/user/sub-api-list': 2,
|
@@ -858,8 +861,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
858
861
|
'v3/account/max-open-available': 4,
|
859
862
|
'v3/ins-loan/bind-uid': 6.6667,
|
860
863
|
'v3/trade/place-order': 2,
|
864
|
+
'v3/trade/place-strategy-order': 2,
|
861
865
|
'v3/trade/modify-order': 2,
|
866
|
+
'v3/trade/modify-strategy-order': 2,
|
862
867
|
'v3/trade/cancel-order': 2,
|
868
|
+
'v3/trade/cancel-strategy-order': 2,
|
863
869
|
'v3/trade/place-batch': 4,
|
864
870
|
'v3/trade/batch-modify-order': 2,
|
865
871
|
'v3/trade/cancel-batch': 4,
|
@@ -905,6 +911,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
905
911
|
# '0': ExchangeError, # 200 successful,when the order placement / cancellation / operation is successful
|
906
912
|
'4001': ExchangeError, # no data received in 30s
|
907
913
|
'4002': ExchangeError, # Buffer full. cannot write data
|
914
|
+
'40020': BadRequest, # {"code":"40020","msg":"Parameter orderId error","requestTime":1754305078588,"data":null}
|
908
915
|
# --------------------------------------------------------
|
909
916
|
'30001': AuthenticationError, # {"code": 30001, "message": 'request header "OK_ACCESS_KEY" cannot be blank'}
|
910
917
|
'30002': AuthenticationError, # {"code": 30002, "message": 'request header "OK_ACCESS_SIGN" cannot be blank'}
|
@@ -1449,6 +1456,19 @@ class bitget(Exchange, ImplicitAPI):
|
|
1449
1456
|
'1w': '1Wutc',
|
1450
1457
|
'1M': '1Mutc',
|
1451
1458
|
},
|
1459
|
+
'uta': {
|
1460
|
+
'1m': '1m',
|
1461
|
+
'3m': '3m',
|
1462
|
+
'5m': '5m',
|
1463
|
+
'15m': '15m',
|
1464
|
+
'30m': '30m',
|
1465
|
+
'1h': '1H',
|
1466
|
+
'2h': '2H',
|
1467
|
+
'4h': '4H',
|
1468
|
+
'6h': '6H',
|
1469
|
+
'12h': '12H',
|
1470
|
+
'1d': '1D',
|
1471
|
+
},
|
1452
1472
|
},
|
1453
1473
|
'fetchMarkets': {
|
1454
1474
|
'types': ['spot', 'swap'], # there is future markets but they use the same endpoints
|
@@ -1538,7 +1558,6 @@ class bitget(Exchange, ImplicitAPI):
|
|
1538
1558
|
'ERC20': 'ERC20',
|
1539
1559
|
'BEP20': 'BSC',
|
1540
1560
|
# 'BEP20': 'BEP20', # different for BEP20
|
1541
|
-
'BSC': 'BEP20',
|
1542
1561
|
'ATOM': 'ATOM',
|
1543
1562
|
'ACA': 'AcalaToken',
|
1544
1563
|
'APT': 'Aptos',
|
@@ -1792,10 +1811,17 @@ class bitget(Exchange, ImplicitAPI):
|
|
1792
1811
|
# else:
|
1793
1812
|
defaultProductType = 'USDT-FUTURES' if (subType == 'linear') else 'COIN-FUTURES'
|
1794
1813
|
# }
|
1795
|
-
productType = self.
|
1814
|
+
productType = self.safe_string_2(params, 'productType', 'category', defaultProductType)
|
1796
1815
|
if (productType is None) and (market is not None):
|
1797
1816
|
settle = market['settle']
|
1798
|
-
if
|
1817
|
+
if market['spot']:
|
1818
|
+
marginMode = None
|
1819
|
+
marginMode, params = self.handle_margin_mode_and_params('handleProductTypeAndParams', params)
|
1820
|
+
if marginMode is not None:
|
1821
|
+
productType = 'MARGIN'
|
1822
|
+
else:
|
1823
|
+
productType = 'SPOT'
|
1824
|
+
elif settle == 'USDT':
|
1799
1825
|
productType = 'USDT-FUTURES'
|
1800
1826
|
elif settle == 'USDC':
|
1801
1827
|
productType = 'USDC-FUTURES'
|
@@ -1808,8 +1834,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
1808
1834
|
else:
|
1809
1835
|
productType = 'COIN-FUTURES'
|
1810
1836
|
if productType is None:
|
1811
|
-
raise ArgumentsRequired(self.id + ' requires a productType param, one of "USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES", "SUSDT-FUTURES", "SUSDC-FUTURES"
|
1812
|
-
params = self.omit(params, 'productType')
|
1837
|
+
raise ArgumentsRequired(self.id + ' requires a productType param, one of "USDT-FUTURES", "USDC-FUTURES", "COIN-FUTURES", "SUSDT-FUTURES", "SUSDC-FUTURES", "SCOIN-FUTURES" or for uta only "SPOT"')
|
1838
|
+
params = self.omit(params, ['productType', 'category'])
|
1813
1839
|
return [productType, params]
|
1814
1840
|
|
1815
1841
|
def fetch_time(self, params={}) -> Int:
|
@@ -1842,10 +1868,10 @@ class bitget(Exchange, ImplicitAPI):
|
|
1842
1868
|
https://www.bitget.com/api-doc/spot/market/Get-Symbols
|
1843
1869
|
https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
|
1844
1870
|
https://www.bitget.com/api-doc/margin/common/support-currencies
|
1845
|
-
https://www.bitget.
|
1871
|
+
https://www.bitget.com/api-doc/uta/public/Instruments
|
1846
1872
|
|
1847
1873
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1848
|
-
:param
|
1874
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
1849
1875
|
:returns dict[]: an array of objects representing market data
|
1850
1876
|
"""
|
1851
1877
|
if self.options['adjustForTimeDifference']:
|
@@ -2452,12 +2478,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
2452
2478
|
https://www.bitget.com/api-doc/contract/position/Get-Query-Position-Lever
|
2453
2479
|
https://www.bitget.com/api-doc/margin/cross/account/Cross-Tier-Data
|
2454
2480
|
https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Tier-Data
|
2481
|
+
https://www.bitget.com/api-doc/uta/public/Get-Position-Tier-Data
|
2455
2482
|
|
2456
2483
|
:param str symbol: unified market symbol
|
2457
2484
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2458
2485
|
:param str [params.marginMode]: for spot margin 'cross' or 'isolated', default is 'isolated'
|
2459
2486
|
:param str [params.code]: required for cross spot margin
|
2460
|
-
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
2487
|
+
:param str [params.productType]: *contract and uta only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
2488
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
2461
2489
|
:returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
|
2462
2490
|
"""
|
2463
2491
|
self.load_markets()
|
@@ -2465,10 +2493,19 @@ class bitget(Exchange, ImplicitAPI):
|
|
2465
2493
|
request: dict = {}
|
2466
2494
|
response = None
|
2467
2495
|
marginMode = None
|
2496
|
+
productType = None
|
2497
|
+
uta = None
|
2468
2498
|
marginMode, params = self.handle_margin_mode_and_params('fetchMarketLeverageTiers', params, 'isolated')
|
2469
|
-
|
2470
|
-
|
2471
|
-
|
2499
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
2500
|
+
uta, params = self.handle_option_and_params(params, 'fetchMarketLeverageTiers', 'uta', False)
|
2501
|
+
if uta:
|
2502
|
+
if productType == 'SPOT':
|
2503
|
+
if marginMode is not None:
|
2504
|
+
productType = 'MARGIN'
|
2505
|
+
request['symbol'] = market['id']
|
2506
|
+
request['category'] = productType
|
2507
|
+
response = self.publicUtaGetV3MarketPositionTier(self.extend(request, params))
|
2508
|
+
elif (market['swap']) or (market['future']):
|
2472
2509
|
request['productType'] = productType
|
2473
2510
|
request['symbol'] = market['id']
|
2474
2511
|
response = self.publicMixGetV2MixMarketQueryPositionLever(self.extend(request, params))
|
@@ -2542,6 +2579,23 @@ class bitget(Exchange, ImplicitAPI):
|
|
2542
2579
|
# ]
|
2543
2580
|
# }
|
2544
2581
|
#
|
2582
|
+
# uta
|
2583
|
+
#
|
2584
|
+
# {
|
2585
|
+
# "code": "00000",
|
2586
|
+
# "msg": "success",
|
2587
|
+
# "requestTime": 1752735673127,
|
2588
|
+
# "data": [
|
2589
|
+
# {
|
2590
|
+
# "tier": "1",
|
2591
|
+
# "minTierValue": "0",
|
2592
|
+
# "maxTierValue": "150000",
|
2593
|
+
# "leverage": "125",
|
2594
|
+
# "mmr": "0.004"
|
2595
|
+
# },
|
2596
|
+
# ]
|
2597
|
+
# }
|
2598
|
+
#
|
2545
2599
|
result = self.safe_value(response, 'data', [])
|
2546
2600
|
return self.parse_market_leverage_tiers(result, market)
|
2547
2601
|
|
@@ -2582,14 +2636,24 @@ class bitget(Exchange, ImplicitAPI):
|
|
2582
2636
|
# "maintainMarginRate": "0.1"
|
2583
2637
|
# }
|
2584
2638
|
#
|
2639
|
+
# uta
|
2640
|
+
#
|
2641
|
+
# {
|
2642
|
+
# "tier": "1",
|
2643
|
+
# "minTierValue": "0",
|
2644
|
+
# "maxTierValue": "150000",
|
2645
|
+
# "leverage": "125",
|
2646
|
+
# "mmr": "0.004"
|
2647
|
+
# }
|
2648
|
+
#
|
2585
2649
|
tiers = []
|
2586
2650
|
minNotional = 0
|
2587
2651
|
for i in range(0, len(info)):
|
2588
2652
|
item = info[i]
|
2589
|
-
minimumNotional = self.
|
2653
|
+
minimumNotional = self.safe_number_2(item, 'startUnit', 'minTierValue')
|
2590
2654
|
if minimumNotional is not None:
|
2591
2655
|
minNotional = minimumNotional
|
2592
|
-
maxNotional = self.safe_number_n(item, ['endUnit', 'maxBorrowableAmount', 'baseMaxBorrowableAmount'])
|
2656
|
+
maxNotional = self.safe_number_n(item, ['endUnit', 'maxBorrowableAmount', 'baseMaxBorrowableAmount', 'maxTierValue'])
|
2593
2657
|
marginCurrency = self.safe_string_2(item, 'coin', 'baseCoin')
|
2594
2658
|
currencyId = marginCurrency if (marginCurrency is not None) else market['base']
|
2595
2659
|
marketId = self.safe_string(item, 'symbol')
|
@@ -2599,7 +2663,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2599
2663
|
'currency': self.safe_currency_code(currencyId),
|
2600
2664
|
'minNotional': minNotional,
|
2601
2665
|
'maxNotional': maxNotional,
|
2602
|
-
'maintenanceMarginRate': self.
|
2666
|
+
'maintenanceMarginRate': self.safe_number_n(item, ['keepMarginRate', 'maintainMarginRate', 'mmr']),
|
2603
2667
|
'maxLeverage': self.safe_number(item, 'leverage'),
|
2604
2668
|
'info': item,
|
2605
2669
|
})
|
@@ -2666,7 +2730,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2666
2730
|
rawTransactions = self.safe_list(response, 'data', [])
|
2667
2731
|
return self.parse_transactions(rawTransactions, None, since, limit)
|
2668
2732
|
|
2669
|
-
def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
|
2733
|
+
def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
|
2670
2734
|
"""
|
2671
2735
|
make a withdrawal
|
2672
2736
|
|
@@ -2941,10 +3005,12 @@ class bitget(Exchange, ImplicitAPI):
|
|
2941
3005
|
|
2942
3006
|
https://www.bitget.com/api-doc/spot/market/Get-Orderbook
|
2943
3007
|
https://www.bitget.com/api-doc/contract/market/Get-Merge-Depth
|
3008
|
+
https://www.bitget.com/api-doc/uta/public/OrderBook
|
2944
3009
|
|
2945
3010
|
:param str symbol: unified symbol of the market to fetch the order book for
|
2946
3011
|
:param int [limit]: the maximum amount of order book entries to return
|
2947
3012
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3013
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
2948
3014
|
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
|
2949
3015
|
"""
|
2950
3016
|
self.load_markets()
|
@@ -2954,12 +3020,17 @@ class bitget(Exchange, ImplicitAPI):
|
|
2954
3020
|
}
|
2955
3021
|
if limit is not None:
|
2956
3022
|
request['limit'] = limit
|
3023
|
+
productType = None
|
3024
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
2957
3025
|
response = None
|
2958
|
-
|
3026
|
+
uta = None
|
3027
|
+
uta, params = self.handle_option_and_params(params, 'fetchOrderBook', 'uta', False)
|
3028
|
+
if uta:
|
3029
|
+
request['category'] = productType
|
3030
|
+
response = self.publicUtaGetV3MarketOrderbook(self.extend(request, params))
|
3031
|
+
elif market['spot']:
|
2959
3032
|
response = self.publicSpotGetV2SpotMarketOrderbook(self.extend(request, params))
|
2960
3033
|
else:
|
2961
|
-
productType = None
|
2962
|
-
productType, params = self.handle_product_type_and_params(market, params)
|
2963
3034
|
request['productType'] = productType
|
2964
3035
|
response = self.publicMixGetV2MixMarketMergeDepth(self.extend(request, params))
|
2965
3036
|
#
|
@@ -2974,9 +3045,24 @@ class bitget(Exchange, ImplicitAPI):
|
|
2974
3045
|
# }
|
2975
3046
|
# }
|
2976
3047
|
#
|
3048
|
+
# uta
|
3049
|
+
#
|
3050
|
+
# {
|
3051
|
+
# "code": "00000",
|
3052
|
+
# "msg": "success",
|
3053
|
+
# "requestTime": 1750329437753,
|
3054
|
+
# "data": {
|
3055
|
+
# "a": [[104992.60, 0.018411]],
|
3056
|
+
# "b":[[104927.40, 0.229914]],
|
3057
|
+
# "ts": "1750329437763"
|
3058
|
+
# }
|
3059
|
+
# }
|
3060
|
+
#
|
2977
3061
|
data = self.safe_value(response, 'data', {})
|
3062
|
+
bidsKey = 'b' if uta else 'bids'
|
3063
|
+
asksKey = 'a' if uta else 'asks'
|
2978
3064
|
timestamp = self.safe_integer(data, 'ts')
|
2979
|
-
return self.parse_order_book(data, market['symbol'], timestamp)
|
3065
|
+
return self.parse_order_book(data, market['symbol'], timestamp, bidsKey, asksKey)
|
2980
3066
|
|
2981
3067
|
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
2982
3068
|
#
|
@@ -2988,7 +3074,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
2988
3074
|
# "ts": "1695793390482"
|
2989
3075
|
# }
|
2990
3076
|
#
|
2991
|
-
# spot
|
3077
|
+
# spot
|
2992
3078
|
#
|
2993
3079
|
# {
|
2994
3080
|
# "open": "37202.46",
|
@@ -3009,90 +3095,115 @@ class bitget(Exchange, ImplicitAPI):
|
|
3009
3095
|
# "change24h": "0.00321"
|
3010
3096
|
# }
|
3011
3097
|
#
|
3012
|
-
# swap and future
|
3098
|
+
# swap and future
|
3013
3099
|
#
|
3014
3100
|
# {
|
3015
3101
|
# "symbol": "BTCUSDT",
|
3016
|
-
# "lastPr": "
|
3017
|
-
# "askPr": "
|
3018
|
-
# "bidPr": "
|
3019
|
-
# "bidSz": "
|
3020
|
-
# "askSz": "
|
3021
|
-
# "high24h": "
|
3022
|
-
# "low24h": "
|
3023
|
-
# "ts": "
|
3024
|
-
# "change24h": "0.
|
3025
|
-
# "baseVolume": "
|
3026
|
-
# "quoteVolume": "
|
3027
|
-
# "usdtVolume": "
|
3028
|
-
# "openUtc": "
|
3029
|
-
# "changeUtc24h": "0.
|
3030
|
-
# "indexPrice": "
|
3031
|
-
# "fundingRate": "0.
|
3032
|
-
# "holdingAmount": "
|
3102
|
+
# "lastPr": "104823.8",
|
3103
|
+
# "askPr": "104823.8",
|
3104
|
+
# "bidPr": "104823.5",
|
3105
|
+
# "bidSz": "0.703",
|
3106
|
+
# "askSz": "13.894",
|
3107
|
+
# "high24h": "105289.3",
|
3108
|
+
# "low24h": "103447.9",
|
3109
|
+
# "ts": "1750332210370",
|
3110
|
+
# "change24h": "0.00471",
|
3111
|
+
# "baseVolume": "79089.5675",
|
3112
|
+
# "quoteVolume": "8274870921.80485",
|
3113
|
+
# "usdtVolume": "8274870921.80485",
|
3114
|
+
# "openUtc": "104833",
|
3115
|
+
# "changeUtc24h": "-0.00009",
|
3116
|
+
# "indexPrice": "104881.953125",
|
3117
|
+
# "fundingRate": "-0.000014",
|
3118
|
+
# "holdingAmount": "7452.6421",
|
3033
3119
|
# "deliveryStartTime": null,
|
3034
3120
|
# "deliveryTime": null,
|
3035
3121
|
# "deliveryStatus": "",
|
3036
|
-
# "open24h": "
|
3122
|
+
# "open24h": "104332.3",
|
3123
|
+
# "markPrice": "104824.2"
|
3124
|
+
# }
|
3125
|
+
#
|
3126
|
+
# spot uta
|
3127
|
+
#
|
3128
|
+
# {
|
3129
|
+
# "category": "SPOT",
|
3130
|
+
# "symbol": "BTCUSDT",
|
3131
|
+
# "ts": "1750330651972",
|
3132
|
+
# "lastPrice": "104900.2",
|
3133
|
+
# "openPrice24h": "104321.2",
|
3134
|
+
# "highPrice24h": "107956.8",
|
3135
|
+
# "lowPrice24h": "103600.1",
|
3136
|
+
# "ask1Price": "104945.8",
|
3137
|
+
# "bid1Price": "104880.6",
|
3138
|
+
# "bid1Size": "0.266534",
|
3139
|
+
# "ask1Size": "0.014001",
|
3140
|
+
# "price24hPcnt": "0.00555",
|
3141
|
+
# "volume24h": "355.941109",
|
3142
|
+
# "turnover24h": "37302936.008134"
|
3037
3143
|
# }
|
3038
3144
|
#
|
3039
|
-
# swap and future
|
3145
|
+
# swap and future uta
|
3040
3146
|
#
|
3041
3147
|
# {
|
3042
|
-
# "
|
3043
|
-
# "symbol": "
|
3044
|
-
# "
|
3045
|
-
# "
|
3046
|
-
# "
|
3047
|
-
# "
|
3048
|
-
# "
|
3049
|
-
# "
|
3050
|
-
# "
|
3051
|
-
# "
|
3052
|
-
# "
|
3053
|
-
# "
|
3054
|
-
# "
|
3055
|
-
# "
|
3056
|
-
# "
|
3057
|
-
# "
|
3148
|
+
# "category": "USDT-FUTURES",
|
3149
|
+
# "symbol": "BTCUSDT",
|
3150
|
+
# "ts": "1750332730472",
|
3151
|
+
# "lastPrice": "104738",
|
3152
|
+
# "openPrice24h": "104374",
|
3153
|
+
# "highPrice24h": "105289.3",
|
3154
|
+
# "lowPrice24h": "103447.9",
|
3155
|
+
# "ask1Price": "104738",
|
3156
|
+
# "bid1Price": "104737.7",
|
3157
|
+
# "bid1Size": "2.036",
|
3158
|
+
# "ask1Size": "8.094",
|
3159
|
+
# "price24hPcnt": "0.00349",
|
3160
|
+
# "volume24h": "79101.6477",
|
3161
|
+
# "turnover24h": "8276293391.45973",
|
3162
|
+
# "indexPrice": "104785.956168",
|
3163
|
+
# "markPrice": "104738",
|
3164
|
+
# "fundingRate": "-0.000007",
|
3165
|
+
# "openInterest": "7465.5938",
|
3166
|
+
# "deliveryStartTime": "",
|
3167
|
+
# "deliveryTime": "",
|
3168
|
+
# "deliveryStatus": ""
|
3058
3169
|
# }
|
3059
3170
|
#
|
3060
3171
|
marketId = self.safe_string(ticker, 'symbol')
|
3061
|
-
close = self.
|
3172
|
+
close = self.safe_string_2(ticker, 'lastPr', 'lastPrice')
|
3062
3173
|
timestamp = self.safe_integer_omit_zero(ticker, 'ts') # exchange bitget provided 0
|
3063
3174
|
change = self.safe_string(ticker, 'change24h')
|
3064
|
-
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3068
|
-
|
3069
|
-
symbol = self.safe_symbol(marketId, market, None, 'contract')
|
3070
|
-
openValue = open24
|
3175
|
+
category = self.safe_string(ticker, 'category')
|
3176
|
+
markPrice = self.safe_string(ticker, 'markPrice')
|
3177
|
+
marketType: str
|
3178
|
+
if (markPrice is not None) and (category != 'SPOT'):
|
3179
|
+
marketType = 'contract'
|
3071
3180
|
else:
|
3072
|
-
|
3073
|
-
|
3181
|
+
marketType = 'spot'
|
3182
|
+
percentage = self.safe_string(ticker, 'price24hPcnt')
|
3183
|
+
if percentage is None:
|
3184
|
+
percentage = Precise.string_mul(change, '100')
|
3074
3185
|
return self.safe_ticker({
|
3075
|
-
'symbol':
|
3186
|
+
'symbol': self.safe_symbol(marketId, market, None, marketType),
|
3076
3187
|
'timestamp': timestamp,
|
3077
3188
|
'datetime': self.iso8601(timestamp),
|
3078
|
-
'high': self.
|
3079
|
-
'low': self.
|
3080
|
-
'bid': self.
|
3081
|
-
'bidVolume': self.
|
3082
|
-
'ask': self.
|
3083
|
-
'askVolume': self.
|
3189
|
+
'high': self.safe_string_2(ticker, 'high24h', 'highPrice24h'),
|
3190
|
+
'low': self.safe_string_2(ticker, 'low24h', 'lowPrice24h'),
|
3191
|
+
'bid': self.safe_string_2(ticker, 'bidPr', 'bid1Price'),
|
3192
|
+
'bidVolume': self.safe_string_2(ticker, 'bidSz', 'bid1Size'),
|
3193
|
+
'ask': self.safe_string_2(ticker, 'askPr', 'ask1Price'),
|
3194
|
+
'askVolume': self.safe_string_2(ticker, 'askSz', 'ask1Size'),
|
3084
3195
|
'vwap': None,
|
3085
|
-
'open':
|
3196
|
+
'open': self.safe_string_n(ticker, ['open', 'open24h', 'openPrice24h']),
|
3086
3197
|
'close': close,
|
3087
3198
|
'last': close,
|
3088
3199
|
'previousClose': None,
|
3089
3200
|
'change': change,
|
3090
|
-
'percentage':
|
3201
|
+
'percentage': percentage,
|
3091
3202
|
'average': None,
|
3092
|
-
'baseVolume': self.
|
3093
|
-
'quoteVolume': self.
|
3203
|
+
'baseVolume': self.safe_string_2(ticker, 'baseVolume', 'volume24h'),
|
3204
|
+
'quoteVolume': self.safe_string_2(ticker, 'quoteVolume', 'turnover24h'),
|
3094
3205
|
'indexPrice': self.safe_string(ticker, 'indexPrice'),
|
3095
|
-
'markPrice':
|
3206
|
+
'markPrice': markPrice,
|
3096
3207
|
'info': ticker,
|
3097
3208
|
}, market)
|
3098
3209
|
|
@@ -3102,9 +3213,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
3102
3213
|
|
3103
3214
|
https://www.bitget.com/api-doc/spot/market/Get-Tickers
|
3104
3215
|
https://www.bitget.com/api-doc/contract/market/Get-Ticker
|
3216
|
+
https://www.bitget.com/api-doc/uta/public/Tickers
|
3105
3217
|
|
3106
3218
|
:param str symbol: unified symbol of the market to fetch the ticker for
|
3107
3219
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3220
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
3108
3221
|
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
3109
3222
|
"""
|
3110
3223
|
self.load_markets()
|
@@ -3112,12 +3225,17 @@ class bitget(Exchange, ImplicitAPI):
|
|
3112
3225
|
request: dict = {
|
3113
3226
|
'symbol': market['id'],
|
3114
3227
|
}
|
3228
|
+
productType = None
|
3229
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
3115
3230
|
response = None
|
3116
|
-
|
3231
|
+
uta = None
|
3232
|
+
uta, params = self.handle_option_and_params(params, 'fetchTicker', 'uta', False)
|
3233
|
+
if uta:
|
3234
|
+
request['category'] = productType
|
3235
|
+
response = self.publicUtaGetV3MarketTickers(self.extend(request, params))
|
3236
|
+
elif market['spot']:
|
3117
3237
|
response = self.publicSpotGetV2SpotMarketTickers(self.extend(request, params))
|
3118
3238
|
else:
|
3119
|
-
productType = None
|
3120
|
-
productType, params = self.handle_product_type_and_params(market, params)
|
3121
3239
|
request['productType'] = productType
|
3122
3240
|
response = self.publicMixGetV2MixMarketTicker(self.extend(request, params))
|
3123
3241
|
#
|
@@ -3151,34 +3269,94 @@ class bitget(Exchange, ImplicitAPI):
|
|
3151
3269
|
#
|
3152
3270
|
# swap and future
|
3153
3271
|
#
|
3154
|
-
#
|
3272
|
+
# {
|
3155
3273
|
# "code": "00000",
|
3156
3274
|
# "msg": "success",
|
3157
|
-
# "requestTime":
|
3275
|
+
# "requestTime": 1750332210369,
|
3158
3276
|
# "data": [
|
3159
3277
|
# {
|
3160
3278
|
# "symbol": "BTCUSDT",
|
3161
|
-
# "lastPr": "
|
3162
|
-
# "askPr": "
|
3163
|
-
# "bidPr": "
|
3164
|
-
# "bidSz": "
|
3165
|
-
# "askSz": "
|
3166
|
-
# "high24h": "
|
3167
|
-
# "low24h": "
|
3168
|
-
# "ts": "
|
3169
|
-
# "change24h": "0.
|
3170
|
-
# "baseVolume": "
|
3171
|
-
# "quoteVolume": "
|
3172
|
-
# "usdtVolume": "
|
3173
|
-
# "openUtc": "
|
3174
|
-
# "changeUtc24h": "0.
|
3175
|
-
# "indexPrice": "
|
3176
|
-
# "fundingRate": "0.
|
3177
|
-
# "holdingAmount": "
|
3279
|
+
# "lastPr": "104823.8",
|
3280
|
+
# "askPr": "104823.8",
|
3281
|
+
# "bidPr": "104823.5",
|
3282
|
+
# "bidSz": "0.703",
|
3283
|
+
# "askSz": "13.894",
|
3284
|
+
# "high24h": "105289.3",
|
3285
|
+
# "low24h": "103447.9",
|
3286
|
+
# "ts": "1750332210370",
|
3287
|
+
# "change24h": "0.00471",
|
3288
|
+
# "baseVolume": "79089.5675",
|
3289
|
+
# "quoteVolume": "8274870921.80485",
|
3290
|
+
# "usdtVolume": "8274870921.80485",
|
3291
|
+
# "openUtc": "104833",
|
3292
|
+
# "changeUtc24h": "-0.00009",
|
3293
|
+
# "indexPrice": "104881.953125",
|
3294
|
+
# "fundingRate": "-0.000014",
|
3295
|
+
# "holdingAmount": "7452.6421",
|
3178
3296
|
# "deliveryStartTime": null,
|
3179
3297
|
# "deliveryTime": null,
|
3180
3298
|
# "deliveryStatus": "",
|
3181
|
-
# "open24h": "
|
3299
|
+
# "open24h": "104332.3",
|
3300
|
+
# "markPrice": "104824.2"
|
3301
|
+
# }
|
3302
|
+
# ]
|
3303
|
+
# }
|
3304
|
+
#
|
3305
|
+
# spot uta
|
3306
|
+
#
|
3307
|
+
# {
|
3308
|
+
# "code": "00000",
|
3309
|
+
# "msg": "success",
|
3310
|
+
# "requestTime": 1750330653575,
|
3311
|
+
# "data": [
|
3312
|
+
# {
|
3313
|
+
# "category": "SPOT",
|
3314
|
+
# "symbol": "BTCUSDT",
|
3315
|
+
# "ts": "1750330651972",
|
3316
|
+
# "lastPrice": "104900.2",
|
3317
|
+
# "openPrice24h": "104321.2",
|
3318
|
+
# "highPrice24h": "107956.8",
|
3319
|
+
# "lowPrice24h": "103600.1",
|
3320
|
+
# "ask1Price": "104945.8",
|
3321
|
+
# "bid1Price": "104880.6",
|
3322
|
+
# "bid1Size": "0.266534",
|
3323
|
+
# "ask1Size": "0.014001",
|
3324
|
+
# "price24hPcnt": "0.00555",
|
3325
|
+
# "volume24h": "355.941109",
|
3326
|
+
# "turnover24h": "37302936.008134"
|
3327
|
+
# }
|
3328
|
+
# ]
|
3329
|
+
# }
|
3330
|
+
#
|
3331
|
+
# swap and future uta
|
3332
|
+
#
|
3333
|
+
# {
|
3334
|
+
# "code": "00000",
|
3335
|
+
# "msg": "success",
|
3336
|
+
# "requestTime": 1750332731203,
|
3337
|
+
# "data": [
|
3338
|
+
# {
|
3339
|
+
# "category": "USDT-FUTURES",
|
3340
|
+
# "symbol": "BTCUSDT",
|
3341
|
+
# "ts": "1750332730472",
|
3342
|
+
# "lastPrice": "104738",
|
3343
|
+
# "openPrice24h": "104374",
|
3344
|
+
# "highPrice24h": "105289.3",
|
3345
|
+
# "lowPrice24h": "103447.9",
|
3346
|
+
# "ask1Price": "104738",
|
3347
|
+
# "bid1Price": "104737.7",
|
3348
|
+
# "bid1Size": "2.036",
|
3349
|
+
# "ask1Size": "8.094",
|
3350
|
+
# "price24hPcnt": "0.00349",
|
3351
|
+
# "volume24h": "79101.6477",
|
3352
|
+
# "turnover24h": "8276293391.45973",
|
3353
|
+
# "indexPrice": "104785.956168",
|
3354
|
+
# "markPrice": "104738",
|
3355
|
+
# "fundingRate": "-0.000007",
|
3356
|
+
# "openInterest": "7465.5938",
|
3357
|
+
# "deliveryStartTime": "",
|
3358
|
+
# "deliveryTime": "",
|
3359
|
+
# "deliveryStatus": ""
|
3182
3360
|
# }
|
3183
3361
|
# ]
|
3184
3362
|
# }
|
@@ -3218,9 +3396,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
3218
3396
|
|
3219
3397
|
https://www.bitget.com/api-doc/spot/market/Get-Tickers
|
3220
3398
|
https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker
|
3399
|
+
https://www.bitget.com/api-doc/uta/public/Tickers
|
3221
3400
|
|
3222
3401
|
:param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
3223
3402
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3403
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
3224
3404
|
:param str [params.subType]: *contract only* 'linear', 'inverse'
|
3225
3405
|
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
3226
3406
|
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
@@ -3241,7 +3421,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
3241
3421
|
productType = None
|
3242
3422
|
productType, params = self.handle_product_type_and_params(market, params)
|
3243
3423
|
# only if passedSubType and productType is None, then use spot
|
3244
|
-
|
3424
|
+
uta = None
|
3425
|
+
uta, params = self.handle_option_and_params(params, 'fetchTickers', 'uta', False)
|
3426
|
+
if uta:
|
3427
|
+
symbolsLength = len(symbols)
|
3428
|
+
if (symbols is not None) and (symbolsLength == 1):
|
3429
|
+
request['symbol'] = market['id']
|
3430
|
+
request['category'] = productType
|
3431
|
+
response = self.publicUtaGetV3MarketTickers(self.extend(request, params))
|
3432
|
+
elif type == 'spot' and passedSubType is None:
|
3245
3433
|
response = self.publicSpotGetV2SpotMarketTickers(self.extend(request, params))
|
3246
3434
|
else:
|
3247
3435
|
request['productType'] = productType
|
@@ -3303,6 +3491,65 @@ class bitget(Exchange, ImplicitAPI):
|
|
3303
3491
|
# ]
|
3304
3492
|
# }
|
3305
3493
|
#
|
3494
|
+
# spot uta
|
3495
|
+
#
|
3496
|
+
# {
|
3497
|
+
# "code": "00000",
|
3498
|
+
# "msg": "success",
|
3499
|
+
# "requestTime": 1750330653575,
|
3500
|
+
# "data": [
|
3501
|
+
# {
|
3502
|
+
# "category": "SPOT",
|
3503
|
+
# "symbol": "BTCUSDT",
|
3504
|
+
# "ts": "1750330651972",
|
3505
|
+
# "lastPrice": "104900.2",
|
3506
|
+
# "openPrice24h": "104321.2",
|
3507
|
+
# "highPrice24h": "107956.8",
|
3508
|
+
# "lowPrice24h": "103600.1",
|
3509
|
+
# "ask1Price": "104945.8",
|
3510
|
+
# "bid1Price": "104880.6",
|
3511
|
+
# "bid1Size": "0.266534",
|
3512
|
+
# "ask1Size": "0.014001",
|
3513
|
+
# "price24hPcnt": "0.00555",
|
3514
|
+
# "volume24h": "355.941109",
|
3515
|
+
# "turnover24h": "37302936.008134"
|
3516
|
+
# }
|
3517
|
+
# ]
|
3518
|
+
# }
|
3519
|
+
#
|
3520
|
+
# swap and future uta
|
3521
|
+
#
|
3522
|
+
# {
|
3523
|
+
# "code": "00000",
|
3524
|
+
# "msg": "success",
|
3525
|
+
# "requestTime": 1750332731203,
|
3526
|
+
# "data": [
|
3527
|
+
# {
|
3528
|
+
# "category": "USDT-FUTURES",
|
3529
|
+
# "symbol": "BTCUSDT",
|
3530
|
+
# "ts": "1750332730472",
|
3531
|
+
# "lastPrice": "104738",
|
3532
|
+
# "openPrice24h": "104374",
|
3533
|
+
# "highPrice24h": "105289.3",
|
3534
|
+
# "lowPrice24h": "103447.9",
|
3535
|
+
# "ask1Price": "104738",
|
3536
|
+
# "bid1Price": "104737.7",
|
3537
|
+
# "bid1Size": "2.036",
|
3538
|
+
# "ask1Size": "8.094",
|
3539
|
+
# "price24hPcnt": "0.00349",
|
3540
|
+
# "volume24h": "79101.6477",
|
3541
|
+
# "turnover24h": "8276293391.45973",
|
3542
|
+
# "indexPrice": "104785.956168",
|
3543
|
+
# "markPrice": "104738",
|
3544
|
+
# "fundingRate": "-0.000007",
|
3545
|
+
# "openInterest": "7465.5938",
|
3546
|
+
# "deliveryStartTime": "",
|
3547
|
+
# "deliveryTime": "",
|
3548
|
+
# "deliveryStatus": ""
|
3549
|
+
# }
|
3550
|
+
# ]
|
3551
|
+
# }
|
3552
|
+
#
|
3306
3553
|
data = self.safe_list(response, 'data', [])
|
3307
3554
|
return self.parse_tickers(data, symbols)
|
3308
3555
|
|
@@ -3389,19 +3636,53 @@ class bitget(Exchange, ImplicitAPI):
|
|
3389
3636
|
# "cTime": "1700720700342"
|
3390
3637
|
# }
|
3391
3638
|
#
|
3639
|
+
# uta fetchTrades
|
3640
|
+
#
|
3641
|
+
# {
|
3642
|
+
# "execId": "1319896716324937729",
|
3643
|
+
# "price": "105909.1",
|
3644
|
+
# "size": "6.3090",
|
3645
|
+
# "side": "sell",
|
3646
|
+
# "ts": "1750413820344"
|
3647
|
+
# }
|
3648
|
+
#
|
3649
|
+
# uta fetchMyTrades
|
3650
|
+
#
|
3651
|
+
# {
|
3652
|
+
# "execId": "1322441401010528257",
|
3653
|
+
# "orderId": "1322441400976261120",
|
3654
|
+
# "category": "USDT-FUTURES",
|
3655
|
+
# "symbol": "BTCUSDT",
|
3656
|
+
# "orderType": "market",
|
3657
|
+
# "side": "sell",
|
3658
|
+
# "execPrice": "107005.4",
|
3659
|
+
# "execQty": "0.0001",
|
3660
|
+
# "execValue": "10.7005",
|
3661
|
+
# "tradeScope": "taker",
|
3662
|
+
# "feeDetail": [{
|
3663
|
+
# "feeCoin": "USDT",
|
3664
|
+
# "fee":"0.00642032"
|
3665
|
+
# }],
|
3666
|
+
# "createdTime": "1751020520451",
|
3667
|
+
# "updatedTime": "1751020520458",
|
3668
|
+
# "execPnl": "0.00017"
|
3669
|
+
# }
|
3670
|
+
#
|
3392
3671
|
marketId = self.safe_string(trade, 'symbol')
|
3393
3672
|
symbol = self.safe_symbol(marketId, market)
|
3394
|
-
timestamp = self.
|
3673
|
+
timestamp = self.safe_integer_n(trade, ['cTime', 'ts', 'createdTime'])
|
3395
3674
|
fee = None
|
3396
3675
|
feeDetail = self.safe_value(trade, 'feeDetail')
|
3397
3676
|
posMode = self.safe_string(trade, 'posMode')
|
3398
|
-
|
3677
|
+
category = self.safe_string(trade, 'category')
|
3678
|
+
isFeeStructure = (posMode is not None) or (category is not None)
|
3679
|
+
feeStructure = feeDetail[0] if isFeeStructure else feeDetail
|
3399
3680
|
if feeStructure is not None:
|
3400
3681
|
currencyCode = self.safe_currency_code(self.safe_string(feeStructure, 'feeCoin'))
|
3401
3682
|
fee = {
|
3402
3683
|
'currency': currencyCode,
|
3403
3684
|
}
|
3404
|
-
feeCostString = self.
|
3685
|
+
feeCostString = self.safe_string_2(feeStructure, 'totalFee', 'fee')
|
3405
3686
|
deduction = self.safe_string(feeStructure, 'deduction') is True if 'yes' else False
|
3406
3687
|
if deduction:
|
3407
3688
|
fee['cost'] = feeCostString
|
@@ -3409,15 +3690,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
3409
3690
|
fee['cost'] = Precise.string_neg(feeCostString)
|
3410
3691
|
return self.safe_trade({
|
3411
3692
|
'info': trade,
|
3412
|
-
'id': self.
|
3693
|
+
'id': self.safe_string_2(trade, 'tradeId', 'execId'),
|
3413
3694
|
'order': self.safe_string(trade, 'orderId'),
|
3414
3695
|
'symbol': symbol,
|
3415
3696
|
'side': self.safe_string_lower(trade, 'side'),
|
3416
3697
|
'type': self.safe_string(trade, 'orderType'),
|
3417
3698
|
'takerOrMaker': self.safe_string(trade, 'tradeScope'),
|
3418
|
-
'price': self.
|
3419
|
-
'amount': self.
|
3420
|
-
'cost': self.
|
3699
|
+
'price': self.safe_string_n(trade, ['priceAvg', 'price', 'execPrice']),
|
3700
|
+
'amount': self.safe_string_n(trade, ['baseVolume', 'size', 'execQty']),
|
3701
|
+
'cost': self.safe_string_n(trade, ['quoteVolume', 'amount', 'execValue']),
|
3421
3702
|
'timestamp': timestamp,
|
3422
3703
|
'datetime': self.iso8601(timestamp),
|
3423
3704
|
'fee': fee,
|
@@ -3431,11 +3712,13 @@ class bitget(Exchange, ImplicitAPI):
|
|
3431
3712
|
https://www.bitget.com/api-doc/spot/market/Get-Market-Trades
|
3432
3713
|
https://www.bitget.com/api-doc/contract/market/Get-Recent-Fills
|
3433
3714
|
https://www.bitget.com/api-doc/contract/market/Get-Fills-History
|
3715
|
+
https://www.bitget.com/api-doc/uta/public/Fills
|
3434
3716
|
|
3435
3717
|
:param str symbol: unified symbol of the market to fetch trades for
|
3436
3718
|
:param int [since]: timestamp in ms of the earliest trade to fetch
|
3437
3719
|
:param int [limit]: the maximum amount of trades to fetch
|
3438
3720
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3721
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
3439
3722
|
:param int [params.until]: *only applies to publicSpotGetV2SpotMarketFillsHistory and publicMixGetV2MixMarketFillsHistory* the latest time in ms to fetch trades for
|
3440
3723
|
:param boolean [params.paginate]: *only applies to publicSpotGetV2SpotMarketFillsHistory and publicMixGetV2MixMarketFillsHistory* default False, when True will automatically paginate by calling self endpoint multiple times
|
3441
3724
|
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
|
@@ -3449,14 +3732,28 @@ class bitget(Exchange, ImplicitAPI):
|
|
3449
3732
|
request: dict = {
|
3450
3733
|
'symbol': market['id'],
|
3451
3734
|
}
|
3735
|
+
uta = None
|
3736
|
+
uta, params = self.handle_option_and_params(params, 'fetchTrades', 'uta', False)
|
3452
3737
|
if limit is not None:
|
3453
|
-
if
|
3738
|
+
if uta:
|
3739
|
+
request['limit'] = min(limit, 100)
|
3740
|
+
elif market['contract']:
|
3454
3741
|
request['limit'] = min(limit, 1000)
|
3455
3742
|
else:
|
3456
3743
|
request['limit'] = limit
|
3457
3744
|
options = self.safe_value(self.options, 'fetchTrades', {})
|
3458
3745
|
response = None
|
3459
|
-
|
3746
|
+
productType = None
|
3747
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
3748
|
+
if uta:
|
3749
|
+
if productType == 'SPOT':
|
3750
|
+
marginMode = None
|
3751
|
+
marginMode, params = self.handle_margin_mode_and_params('fetchTrades', params)
|
3752
|
+
if marginMode is not None:
|
3753
|
+
productType = 'MARGIN'
|
3754
|
+
request['category'] = productType
|
3755
|
+
response = self.publicUtaGetV3MarketFills(self.extend(request, params))
|
3756
|
+
elif market['spot']:
|
3460
3757
|
spotOptions = self.safe_value(options, 'spot', {})
|
3461
3758
|
defaultSpotMethod = self.safe_string(spotOptions, 'method', 'publicSpotGetV2SpotMarketFillsHistory')
|
3462
3759
|
spotMethod = self.safe_string(params, 'method', defaultSpotMethod)
|
@@ -3473,8 +3770,6 @@ class bitget(Exchange, ImplicitAPI):
|
|
3473
3770
|
defaultSwapMethod = self.safe_string(swapOptions, 'method', 'publicMixGetV2MixMarketFillsHistory')
|
3474
3771
|
swapMethod = self.safe_string(params, 'method', defaultSwapMethod)
|
3475
3772
|
params = self.omit(params, 'method')
|
3476
|
-
productType = None
|
3477
|
-
productType, params = self.handle_product_type_and_params(market, params)
|
3478
3773
|
request['productType'] = productType
|
3479
3774
|
if swapMethod == 'publicMixGetV2MixMarketFillsHistory':
|
3480
3775
|
request, params = self.handle_until_option('endTime', request, params)
|
@@ -3520,6 +3815,23 @@ class bitget(Exchange, ImplicitAPI):
|
|
3520
3815
|
# ]
|
3521
3816
|
# }
|
3522
3817
|
#
|
3818
|
+
# uta
|
3819
|
+
#
|
3820
|
+
# {
|
3821
|
+
# "code": "00000",
|
3822
|
+
# "msg": "success",
|
3823
|
+
# "requestTime": 1750413823980,
|
3824
|
+
# "data": [
|
3825
|
+
# {
|
3826
|
+
# "execId": "1319896716324937729",
|
3827
|
+
# "price": "105909.1",
|
3828
|
+
# "size": "6.3090",
|
3829
|
+
# "side": "sell",
|
3830
|
+
# "ts": "1750413820344"
|
3831
|
+
# }
|
3832
|
+
# ]
|
3833
|
+
# }
|
3834
|
+
#
|
3523
3835
|
data = self.safe_list(response, 'data', [])
|
3524
3836
|
return self.parse_trades(data, market, since, limit)
|
3525
3837
|
|
@@ -3701,13 +4013,15 @@ class bitget(Exchange, ImplicitAPI):
|
|
3701
4013
|
# "1399132.341"
|
3702
4014
|
# ]
|
3703
4015
|
#
|
4016
|
+
inverse = self.safe_bool(market, 'inverse')
|
4017
|
+
volumeIndex = 6 if inverse else 5
|
3704
4018
|
return [
|
3705
4019
|
self.safe_integer(ohlcv, 0),
|
3706
4020
|
self.safe_number(ohlcv, 1),
|
3707
4021
|
self.safe_number(ohlcv, 2),
|
3708
4022
|
self.safe_number(ohlcv, 3),
|
3709
4023
|
self.safe_number(ohlcv, 4),
|
3710
|
-
self.safe_number(ohlcv,
|
4024
|
+
self.safe_number(ohlcv, volumeIndex),
|
3711
4025
|
]
|
3712
4026
|
|
3713
4027
|
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
@@ -3720,12 +4034,14 @@ class bitget(Exchange, ImplicitAPI):
|
|
3720
4034
|
https://www.bitget.com/api-doc/contract/market/Get-History-Candle-Data
|
3721
4035
|
https://www.bitget.com/api-doc/contract/market/Get-History-Index-Candle-Data
|
3722
4036
|
https://www.bitget.com/api-doc/contract/market/Get-History-Mark-Candle-Data
|
4037
|
+
https://www.bitget.com/api-doc/uta/public/Get-Candle-Data
|
3723
4038
|
|
3724
4039
|
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
3725
4040
|
:param str timeframe: the length of time each candle represents
|
3726
4041
|
:param int [since]: timestamp in ms of the earliest candle to fetch
|
3727
4042
|
:param int [limit]: the maximum amount of candles to fetch
|
3728
4043
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4044
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
3729
4045
|
:param int [params.until]: timestamp in ms of the latest candle to fetch
|
3730
4046
|
:param boolean [params.useHistoryEndpoint]: whether to force to use historical endpoint(it has max limit of 200)
|
3731
4047
|
:param boolean [params.useHistoryEndpointForPagination]: whether to force to use historical endpoint for pagination(default True)
|
@@ -3745,12 +4061,20 @@ class bitget(Exchange, ImplicitAPI):
|
|
3745
4061
|
limitForPagination = maxLimitForHistoryEndpoint if useHistoryEndpointForPagination else maxLimitForRecentEndpoint
|
3746
4062
|
return self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, limitForPagination)
|
3747
4063
|
market = self.market(symbol)
|
3748
|
-
marketType = 'spot' if market['spot'] else 'swap'
|
3749
|
-
timeframes = self.options['timeframes'][marketType]
|
3750
4064
|
request: dict = {
|
3751
4065
|
'symbol': market['id'],
|
3752
|
-
'granularity': self.safe_string(timeframes, timeframe, timeframe),
|
3753
4066
|
}
|
4067
|
+
marketType = None
|
4068
|
+
timeframes = None
|
4069
|
+
uta = None
|
4070
|
+
uta, params = self.handle_option_and_params(params, 'fetchOHLCV', 'uta', False)
|
4071
|
+
if uta:
|
4072
|
+
timeframes = self.options['timeframes']['uta']
|
4073
|
+
request['interval'] = self.safe_string(timeframes, timeframe, timeframe)
|
4074
|
+
else:
|
4075
|
+
marketType = 'spot' if market['spot'] else 'swap'
|
4076
|
+
timeframes = self.options['timeframes'][marketType]
|
4077
|
+
request['granularity'] = self.safe_string(timeframes, timeframe, timeframe)
|
3754
4078
|
msInDay = 86400000
|
3755
4079
|
now = self.milliseconds()
|
3756
4080
|
duration = self.parse_timeframe(timeframe) * 1000
|
@@ -3811,7 +4135,19 @@ class bitget(Exchange, ImplicitAPI):
|
|
3811
4135
|
request['limit'] = limit
|
3812
4136
|
# make request
|
3813
4137
|
response = None
|
3814
|
-
|
4138
|
+
productType = None
|
4139
|
+
priceType = None
|
4140
|
+
priceType, params = self.handle_param_string(params, 'price')
|
4141
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
4142
|
+
if uta:
|
4143
|
+
if priceType is not None:
|
4144
|
+
if priceType == 'mark':
|
4145
|
+
request['type'] = 'MARK'
|
4146
|
+
elif priceType == 'index':
|
4147
|
+
request['type'] = 'INDEX'
|
4148
|
+
request['category'] = productType
|
4149
|
+
response = self.publicUtaGetV3MarketCandles(self.extend(request, params))
|
4150
|
+
elif market['spot']:
|
3815
4151
|
# checks if we need history endpoint
|
3816
4152
|
if historicalEndpointNeeded:
|
3817
4153
|
response = self.publicSpotGetV2SpotMarketHistoryCandles(self.extend(request, params))
|
@@ -3821,10 +4157,6 @@ class bitget(Exchange, ImplicitAPI):
|
|
3821
4157
|
limit = 1000
|
3822
4158
|
response = self.publicSpotGetV2SpotMarketCandles(self.extend(request, params))
|
3823
4159
|
else:
|
3824
|
-
priceType = None
|
3825
|
-
priceType, params = self.handle_param_string(params, 'price')
|
3826
|
-
productType = None
|
3827
|
-
productType, params = self.handle_product_type_and_params(market, params)
|
3828
4160
|
request['productType'] = productType
|
3829
4161
|
extended = self.extend(request, params)
|
3830
4162
|
if not historicalEndpointNeeded and (priceType == 'mark' or priceType == 'index'):
|
@@ -3862,9 +4194,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
3862
4194
|
https://www.bitget.com/api-doc/margin/isolated/account/Get-Isolated-Assets
|
3863
4195
|
https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-assets
|
3864
4196
|
https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-assets
|
4197
|
+
https://www.bitget.com/api-doc/uta/account/Get-Account
|
3865
4198
|
|
3866
4199
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3867
4200
|
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
4201
|
+
:param str [params.uta]: set to True for the unified trading account(uta), defaults to False
|
3868
4202
|
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
3869
4203
|
"""
|
3870
4204
|
self.load_markets()
|
@@ -3872,9 +4206,16 @@ class bitget(Exchange, ImplicitAPI):
|
|
3872
4206
|
marketType = None
|
3873
4207
|
marginMode = None
|
3874
4208
|
response = None
|
4209
|
+
uta = None
|
4210
|
+
uta, params = self.handle_option_and_params(params, 'fetchBalance', 'uta', False)
|
3875
4211
|
marketType, params = self.handle_market_type_and_params('fetchBalance', None, params)
|
3876
4212
|
marginMode, params = self.handle_margin_mode_and_params('fetchBalance', params)
|
3877
|
-
if
|
4213
|
+
if uta:
|
4214
|
+
response = self.privateUtaGetV3AccountAssets(self.extend(request, params))
|
4215
|
+
results = self.safe_dict(response, 'data', {})
|
4216
|
+
assets = self.safe_list(results, 'assets', [])
|
4217
|
+
return self.parse_uta_balance(assets)
|
4218
|
+
elif (marketType == 'swap') or (marketType == 'future'):
|
3878
4219
|
productType = None
|
3879
4220
|
productType, params = self.handle_product_type_and_params(None, params)
|
3880
4221
|
request['productType'] = productType
|
@@ -3974,9 +4315,66 @@ class bitget(Exchange, ImplicitAPI):
|
|
3974
4315
|
# ]
|
3975
4316
|
# }
|
3976
4317
|
#
|
4318
|
+
# uta
|
4319
|
+
#
|
4320
|
+
# {
|
4321
|
+
# "code": "00000",
|
4322
|
+
# "msg": "success",
|
4323
|
+
# "requestTime": 1749980065089,
|
4324
|
+
# "data": {
|
4325
|
+
# "accountEquity": "11.13919278",
|
4326
|
+
# "usdtEquity": "11.13921165",
|
4327
|
+
# "btcEquity": "0.00011256",
|
4328
|
+
# "unrealisedPnl": "0",
|
4329
|
+
# "usdtUnrealisedPnl": "0",
|
4330
|
+
# "btcUnrealizedPnl": "0",
|
4331
|
+
# "effEquity": "6.19299777",
|
4332
|
+
# "mmr": "0",
|
4333
|
+
# "imr": "0",
|
4334
|
+
# "mgnRatio": "0",
|
4335
|
+
# "positionMgnRatio": "0",
|
4336
|
+
# "assets": [
|
4337
|
+
# {
|
4338
|
+
# "coin": "USDT",
|
4339
|
+
# "equity": "6.19300826",
|
4340
|
+
# "usdValue": "6.19299777",
|
4341
|
+
# "balance": "6.19300826",
|
4342
|
+
# "available": "6.19300826",
|
4343
|
+
# "debt": "0",
|
4344
|
+
# "locked": "0"
|
4345
|
+
# }
|
4346
|
+
# ]
|
4347
|
+
# }
|
4348
|
+
# }
|
4349
|
+
#
|
3977
4350
|
data = self.safe_value(response, 'data', [])
|
3978
4351
|
return self.parse_balance(data)
|
3979
4352
|
|
4353
|
+
def parse_uta_balance(self, balance) -> Balances:
|
4354
|
+
result: dict = {'info': balance}
|
4355
|
+
#
|
4356
|
+
# {
|
4357
|
+
# "coin": "USDT",
|
4358
|
+
# "equity": "6.19300826",
|
4359
|
+
# "usdValue": "6.19299777",
|
4360
|
+
# "balance": "6.19300826",
|
4361
|
+
# "available": "6.19300826",
|
4362
|
+
# "debt": "0",
|
4363
|
+
# "locked": "0"
|
4364
|
+
# }
|
4365
|
+
#
|
4366
|
+
for i in range(0, len(balance)):
|
4367
|
+
entry = balance[i]
|
4368
|
+
account = self.account()
|
4369
|
+
currencyId = self.safe_string(entry, 'coin')
|
4370
|
+
code = self.safe_currency_code(currencyId)
|
4371
|
+
account['debt'] = self.safe_string(entry, 'debt')
|
4372
|
+
account['used'] = self.safe_string(entry, 'locked')
|
4373
|
+
account['free'] = self.safe_string(entry, 'available')
|
4374
|
+
account['total'] = self.safe_string(entry, 'balance')
|
4375
|
+
result[code] = account
|
4376
|
+
return self.safe_balance(result)
|
4377
|
+
|
3980
4378
|
def parse_balance(self, balance) -> Balances:
|
3981
4379
|
result: dict = {'info': balance}
|
3982
4380
|
#
|
@@ -4110,7 +4508,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4110
4508
|
# },
|
4111
4509
|
# ]
|
4112
4510
|
#
|
4113
|
-
# spot, swap, future
|
4511
|
+
# spot, swap, future, spot margin and uta: cancelOrder, cancelOrders, cancelAllOrders
|
4114
4512
|
#
|
4115
4513
|
# {
|
4116
4514
|
# "orderId": "1098758604547850241",
|
@@ -4239,6 +4637,66 @@ class bitget(Exchange, ImplicitAPI):
|
|
4239
4637
|
# "stopLossTriggerType": "fill_price",
|
4240
4638
|
# }
|
4241
4639
|
#
|
4640
|
+
# uta: fetchOrder, fetchOpenOrders, fetchCanceledAndClosedOrders
|
4641
|
+
#
|
4642
|
+
# {
|
4643
|
+
# "orderId": "1320244799629316096",
|
4644
|
+
# "clientOid": "1320244799633510400",
|
4645
|
+
# "category": "USDT-FUTURES",
|
4646
|
+
# "symbol": "BTCUSDT",
|
4647
|
+
# "orderType": "limit",
|
4648
|
+
# "side": "buy",
|
4649
|
+
# "price": "50000",
|
4650
|
+
# "qty": "0.001",
|
4651
|
+
# "amount": "0",
|
4652
|
+
# "cumExecQty": "0",
|
4653
|
+
# "cumExecValue": "0",
|
4654
|
+
# "avgPrice": "0",
|
4655
|
+
# "timeInForce": "gtc",
|
4656
|
+
# "orderStatus": "live",
|
4657
|
+
# "posSide": "long",
|
4658
|
+
# "holdMode": "hedge_mode",
|
4659
|
+
# "reduceOnly": "NO",
|
4660
|
+
# "feeDetail": [{
|
4661
|
+
# "feeCoin": "",
|
4662
|
+
# "fee": ""
|
4663
|
+
# }],
|
4664
|
+
# "createdTime": "1750496809871",
|
4665
|
+
# "updatedTime": "1750496809886",
|
4666
|
+
# "cancelReason": "",
|
4667
|
+
# "execType": "normal",
|
4668
|
+
# "stpMode": "none",
|
4669
|
+
# "tpTriggerBy": null,
|
4670
|
+
# "slTriggerBy": null,
|
4671
|
+
# "takeProfit": null,
|
4672
|
+
# "stopLoss": null,
|
4673
|
+
# "tpOrderType": null,
|
4674
|
+
# "slOrderType": null,
|
4675
|
+
# "tpLimitPrice": null,
|
4676
|
+
# "slLimitPrice": null
|
4677
|
+
# }
|
4678
|
+
#
|
4679
|
+
# uta trigger: fetchClosedOrders, fetchCanceledOrders
|
4680
|
+
#
|
4681
|
+
# {
|
4682
|
+
# "orderId": "1330984742276198400",
|
4683
|
+
# "clientOid": "1330984742276198400",
|
4684
|
+
# "symbol": "BTCUSDT",
|
4685
|
+
# "category": "USDT-FUTURES",
|
4686
|
+
# "qty": "0.001",
|
4687
|
+
# "posSide": "long",
|
4688
|
+
# "tpTriggerBy": "market",
|
4689
|
+
# "slTriggerBy": "mark",
|
4690
|
+
# "takeProfit": "",
|
4691
|
+
# "stopLoss": "112000",
|
4692
|
+
# "tpOrderType": "market",
|
4693
|
+
# "slOrderType": "limit",
|
4694
|
+
# "tpLimitPrice": "",
|
4695
|
+
# "slLimitPrice": "111000",
|
4696
|
+
# "createdTime": "1753057411736",
|
4697
|
+
# "updatedTime": "1753058267412"
|
4698
|
+
# }
|
4699
|
+
#
|
4242
4700
|
errorMessage = self.safe_string(order, 'errorMsg')
|
4243
4701
|
if errorMessage is not None:
|
4244
4702
|
return self.safe_order({
|
@@ -4247,16 +4705,16 @@ class bitget(Exchange, ImplicitAPI):
|
|
4247
4705
|
'clientOrderId': self.safe_string_2(order, 'clientOrderId', 'clientOid'),
|
4248
4706
|
'status': 'rejected',
|
4249
4707
|
}, market)
|
4250
|
-
|
4708
|
+
posSide = self.safe_string(order, 'posSide')
|
4709
|
+
isContractOrder = (posSide is not None)
|
4251
4710
|
marketType = 'contract' if isContractOrder else 'spot'
|
4252
4711
|
if market is not None:
|
4253
4712
|
marketType = market['type']
|
4254
4713
|
marketId = self.safe_string(order, 'symbol')
|
4255
4714
|
market = self.safe_market(marketId, market, None, marketType)
|
4256
|
-
timestamp = self.
|
4257
|
-
updateTimestamp = self.
|
4258
|
-
rawStatus = self.
|
4259
|
-
rawStatus = self.safe_string(order, 'planStatus', rawStatus)
|
4715
|
+
timestamp = self.safe_integer_n(order, ['cTime', 'ctime', 'createdTime'])
|
4716
|
+
updateTimestamp = self.safe_integer_2(order, 'uTime', 'updatedTime')
|
4717
|
+
rawStatus = self.safe_string_n(order, ['status', 'state', 'orderStatus', 'planStatus'])
|
4260
4718
|
fee = None
|
4261
4719
|
feeCostString = self.safe_string(order, 'fee')
|
4262
4720
|
if feeCostString is not None:
|
@@ -4266,21 +4724,30 @@ class bitget(Exchange, ImplicitAPI):
|
|
4266
4724
|
'currency': market['settle'],
|
4267
4725
|
}
|
4268
4726
|
feeDetail = self.safe_value(order, 'feeDetail')
|
4269
|
-
|
4270
|
-
|
4271
|
-
|
4272
|
-
|
4273
|
-
for i in range(0, len(feeValues)):
|
4274
|
-
feeValue = feeValues[i]
|
4275
|
-
if self.safe_value(feeValue, 'feeCoinCode') is not None:
|
4276
|
-
feeObject = feeValue
|
4277
|
-
break
|
4727
|
+
uta = self.safe_string(order, 'category') is not None
|
4728
|
+
if uta:
|
4729
|
+
feeResult = self.safe_dict(feeDetail, 0, {})
|
4730
|
+
utaFee = self.safe_string(feeResult, 'fee')
|
4278
4731
|
fee = {
|
4279
|
-
'cost': self.parse_number(Precise.string_neg(
|
4280
|
-
'currency':
|
4732
|
+
'cost': self.parse_number(Precise.string_neg(utaFee)),
|
4733
|
+
'currency': market['settle'],
|
4281
4734
|
}
|
4735
|
+
else:
|
4736
|
+
if feeDetail is not None:
|
4737
|
+
parsedFeeDetail = json.loads(feeDetail)
|
4738
|
+
feeValues = list(parsedFeeDetail.values())
|
4739
|
+
feeObject = None
|
4740
|
+
for i in range(0, len(feeValues)):
|
4741
|
+
feeValue = feeValues[i]
|
4742
|
+
if self.safe_value(feeValue, 'feeCoinCode') is not None:
|
4743
|
+
feeObject = feeValue
|
4744
|
+
break
|
4745
|
+
fee = {
|
4746
|
+
'cost': self.parse_number(Precise.string_neg(self.safe_string(feeObject, 'totalFee'))),
|
4747
|
+
'currency': self.safe_currency_code(self.safe_string(feeObject, 'feeCoinCode')),
|
4748
|
+
}
|
4282
4749
|
postOnly = None
|
4283
|
-
timeInForce = self.
|
4750
|
+
timeInForce = self.safe_string_upper_2(order, 'force', 'timeInForce')
|
4284
4751
|
if timeInForce == 'POST_ONLY':
|
4285
4752
|
postOnly = True
|
4286
4753
|
timeInForce = 'PO'
|
@@ -4296,7 +4763,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4296
4763
|
price = self.safe_string(order, 'priceAvg')
|
4297
4764
|
average = self.safe_string(order, 'basePrice')
|
4298
4765
|
else:
|
4299
|
-
price = self.
|
4766
|
+
price = self.safe_string_n(order, ['price', 'executePrice', 'slLimitPrice', 'tpLimitPrice'])
|
4300
4767
|
average = self.safe_string(order, 'priceAvg')
|
4301
4768
|
size = None
|
4302
4769
|
filled = None
|
@@ -4306,8 +4773,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
4306
4773
|
size = baseSize
|
4307
4774
|
filled = self.safe_string(order, 'size')
|
4308
4775
|
else:
|
4309
|
-
size = self.
|
4310
|
-
filled = self.
|
4776
|
+
size = self.safe_string_2(order, 'size', 'qty')
|
4777
|
+
filled = self.safe_string_2(order, 'baseVolume', 'cumExecQty')
|
4311
4778
|
side = self.safe_string(order, 'side')
|
4312
4779
|
posMode = self.safe_string(order, 'posMode')
|
4313
4780
|
if posMode == 'hedge_mode' and reduceOnly:
|
@@ -4340,8 +4807,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
4340
4807
|
'postOnly': postOnly,
|
4341
4808
|
'reduceOnly': reduceOnly,
|
4342
4809
|
'triggerPrice': self.safe_number(order, 'triggerPrice'),
|
4343
|
-
'takeProfitPrice': self.
|
4344
|
-
'stopLossPrice': self.
|
4810
|
+
'takeProfitPrice': self.safe_number_n(order, ['presetStopSurplusPrice', 'stopSurplusTriggerPrice', 'takeProfit']),
|
4811
|
+
'stopLossPrice': self.safe_number_n(order, ['presetStopLossPrice', 'stopLossTriggerPrice', 'stopLoss']),
|
4345
4812
|
'status': self.parse_order_status(rawStatus),
|
4346
4813
|
'fee': fee,
|
4347
4814
|
'trades': None,
|
@@ -4380,6 +4847,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
4380
4847
|
https://www.bitget.com/api-doc/contract/plan/Place-Plan-Order
|
4381
4848
|
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Place-Order
|
4382
4849
|
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order
|
4850
|
+
https://www.bitget.com/api-doc/uta/trade/Place-Order
|
4851
|
+
https://www.bitget.com/api-doc/uta/strategy/Place-Strategy-Order
|
4383
4852
|
|
4384
4853
|
:param str symbol: unified symbol of the market to create an order in
|
4385
4854
|
:param str type: 'market' or 'limit'
|
@@ -4409,6 +4878,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
4409
4878
|
:param boolean [params.oneWayMode]: *swap and future only* required to set self to True in one_way_mode and you can leave self in hedge_mode, can adjust the mode using the setPositionMode() method
|
4410
4879
|
:param bool [params.hedged]: *swap and future only* True for hedged mode, False for one way mode, default is False
|
4411
4880
|
:param bool [params.reduceOnly]: True or False whether the order is reduce-only
|
4881
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
4882
|
+
:param str [params.posSide]: *uta only* hedged two-way position side, long or short
|
4412
4883
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
4413
4884
|
"""
|
4414
4885
|
self.load_markets()
|
@@ -4424,24 +4895,33 @@ class bitget(Exchange, ImplicitAPI):
|
|
4424
4895
|
isStopLossTriggerOrder = stopLossTriggerPrice is not None
|
4425
4896
|
isTakeProfitTriggerOrder = takeProfitTriggerPrice is not None
|
4426
4897
|
isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder or isTakeProfitTriggerOrder
|
4427
|
-
request = self.create_order_request(symbol, type, side, amount, price, params)
|
4428
4898
|
response = None
|
4429
|
-
|
4430
|
-
|
4431
|
-
|
4432
|
-
|
4433
|
-
|
4434
|
-
|
4435
|
-
response = self.privateMarginPostV2MarginCrossedPlaceOrder(request)
|
4899
|
+
uta = None
|
4900
|
+
uta, params = self.handle_option_and_params(params, 'createOrder', 'uta', False)
|
4901
|
+
if uta:
|
4902
|
+
request = self.create_uta_order_request(symbol, type, side, amount, price, params)
|
4903
|
+
if isStopLossOrTakeProfitTrigger:
|
4904
|
+
response = self.privateUtaPostV3TradePlaceStrategyOrder(request)
|
4436
4905
|
else:
|
4437
|
-
response = self.
|
4906
|
+
response = self.privateUtaPostV3TradePlaceOrder(request)
|
4438
4907
|
else:
|
4439
|
-
|
4440
|
-
|
4441
|
-
|
4442
|
-
|
4908
|
+
request = self.create_order_request(symbol, type, side, amount, price, params)
|
4909
|
+
if market['spot']:
|
4910
|
+
if isTriggerOrder:
|
4911
|
+
response = self.privateSpotPostV2SpotTradePlacePlanOrder(request)
|
4912
|
+
elif marginMode == 'isolated':
|
4913
|
+
response = self.privateMarginPostV2MarginIsolatedPlaceOrder(request)
|
4914
|
+
elif marginMode == 'cross':
|
4915
|
+
response = self.privateMarginPostV2MarginCrossedPlaceOrder(request)
|
4916
|
+
else:
|
4917
|
+
response = self.privateSpotPostV2SpotTradePlaceOrder(request)
|
4443
4918
|
else:
|
4444
|
-
|
4919
|
+
if isTriggerOrder or isTrailingPercentOrder:
|
4920
|
+
response = self.privateMixPostV2MixOrderPlacePlanOrder(request)
|
4921
|
+
elif isStopLossOrTakeProfitTrigger:
|
4922
|
+
response = self.privateMixPostV2MixOrderPlaceTpslOrder(request)
|
4923
|
+
else:
|
4924
|
+
response = self.privateMixPostV2MixOrderPlaceOrder(request)
|
4445
4925
|
#
|
4446
4926
|
# {
|
4447
4927
|
# "code": "00000",
|
@@ -4456,24 +4936,124 @@ class bitget(Exchange, ImplicitAPI):
|
|
4456
4936
|
data = self.safe_dict(response, 'data', {})
|
4457
4937
|
return self.parse_order(data, market)
|
4458
4938
|
|
4459
|
-
def
|
4939
|
+
def create_uta_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
4460
4940
|
market = self.market(symbol)
|
4461
|
-
|
4462
|
-
|
4463
|
-
|
4464
|
-
|
4941
|
+
productType = None
|
4942
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
4943
|
+
if productType == 'SPOT':
|
4944
|
+
marginMode = None
|
4945
|
+
marginMode, params = self.handle_margin_mode_and_params('createOrder', params)
|
4946
|
+
if marginMode is not None:
|
4947
|
+
productType = 'MARGIN'
|
4465
4948
|
request: dict = {
|
4949
|
+
'category': productType,
|
4466
4950
|
'symbol': market['id'],
|
4467
|
-
'
|
4951
|
+
'qty': self.amount_to_precision(symbol, amount),
|
4952
|
+
'side': side,
|
4468
4953
|
}
|
4469
|
-
|
4470
|
-
|
4471
|
-
|
4472
|
-
|
4954
|
+
clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId')
|
4955
|
+
if clientOrderId is not None:
|
4956
|
+
request['clientOid'] = clientOrderId
|
4957
|
+
params = self.omit(params, 'clientOrderId')
|
4958
|
+
stopLossTriggerPrice = self.safe_number(params, 'stopLossPrice')
|
4959
|
+
takeProfitTriggerPrice = self.safe_number(params, 'takeProfitPrice')
|
4473
4960
|
stopLoss = self.safe_value(params, 'stopLoss')
|
4474
4961
|
takeProfit = self.safe_value(params, 'takeProfit')
|
4475
|
-
|
4476
|
-
|
4962
|
+
isStopLoss = stopLoss is not None
|
4963
|
+
isTakeProfit = takeProfit is not None
|
4964
|
+
isStopLossTrigger = stopLossTriggerPrice is not None
|
4965
|
+
isTakeProfitTrigger = takeProfitTriggerPrice is not None
|
4966
|
+
isStopLossOrTakeProfitTrigger = isStopLossTrigger or isTakeProfitTrigger
|
4967
|
+
if isStopLossOrTakeProfitTrigger:
|
4968
|
+
if isStopLossTrigger:
|
4969
|
+
slType = self.safe_string(params, 'slTriggerBy', 'mark')
|
4970
|
+
request['slTriggerBy'] = slType
|
4971
|
+
request['stopLoss'] = self.price_to_precision(symbol, stopLossTriggerPrice)
|
4972
|
+
if price is not None:
|
4973
|
+
request['slLimitPrice'] = self.price_to_precision(symbol, price)
|
4974
|
+
request['slOrderType'] = self.safe_string(params, 'slOrderType', 'limit')
|
4975
|
+
else:
|
4976
|
+
request['slOrderType'] = self.safe_string(params, 'slOrderType', 'market')
|
4977
|
+
elif isTakeProfitTrigger:
|
4978
|
+
tpType = self.safe_string(params, 'tpTriggerBy', 'mark')
|
4979
|
+
request['tpTriggerBy'] = tpType
|
4980
|
+
request['takeProfit'] = self.price_to_precision(symbol, takeProfitTriggerPrice)
|
4981
|
+
if price is not None:
|
4982
|
+
request['tpLimitPrice'] = self.price_to_precision(symbol, price)
|
4983
|
+
request['tpOrderType'] = self.safe_string(params, 'tpOrderType', 'limit')
|
4984
|
+
else:
|
4985
|
+
request['tpOrderType'] = self.safe_string(params, 'tpOrderType', 'market')
|
4986
|
+
params = self.omit(params, ['stopLossPrice', 'takeProfitPrice'])
|
4987
|
+
else:
|
4988
|
+
if isStopLoss:
|
4989
|
+
slTriggerPrice = self.safe_number_2(stopLoss, 'triggerPrice', 'stopPrice')
|
4990
|
+
slLimitPrice = self.safe_number(stopLoss, 'price')
|
4991
|
+
request['stopLoss'] = self.price_to_precision(symbol, slTriggerPrice)
|
4992
|
+
if slLimitPrice is not None:
|
4993
|
+
request['slLimitPrice'] = self.price_to_precision(symbol, slLimitPrice)
|
4994
|
+
request['slOrderType'] = self.safe_string(params, 'slOrderType', 'limit')
|
4995
|
+
else:
|
4996
|
+
request['slOrderType'] = self.safe_string(params, 'slOrderType', 'market')
|
4997
|
+
if isTakeProfit:
|
4998
|
+
tpTriggerPrice = self.safe_number_2(takeProfit, 'triggerPrice', 'stopPrice')
|
4999
|
+
tpLimitPrice = self.safe_number(takeProfit, 'price')
|
5000
|
+
request['takeProfit'] = self.price_to_precision(symbol, tpTriggerPrice)
|
5001
|
+
if tpLimitPrice is not None:
|
5002
|
+
request['tpLimitPrice'] = self.price_to_precision(symbol, tpLimitPrice)
|
5003
|
+
request['tpOrderType'] = self.safe_string(params, 'tpOrderType', 'limit')
|
5004
|
+
else:
|
5005
|
+
request['tpOrderType'] = self.safe_string(params, 'tpOrderType', 'market')
|
5006
|
+
isMarketOrder = type == 'market'
|
5007
|
+
if not isMarketOrder:
|
5008
|
+
request['price'] = self.price_to_precision(symbol, price)
|
5009
|
+
request['orderType'] = type
|
5010
|
+
exchangeSpecificTifParam = self.safe_string(params, 'timeInForce')
|
5011
|
+
postOnly = None
|
5012
|
+
postOnly, params = self.handle_post_only(isMarketOrder, exchangeSpecificTifParam == 'post_only', params)
|
5013
|
+
defaultTimeInForce = self.safe_string_upper(self.options, 'defaultTimeInForce')
|
5014
|
+
timeInForce = self.safe_string_upper(params, 'timeInForce', defaultTimeInForce)
|
5015
|
+
if postOnly:
|
5016
|
+
request['timeInForce'] = 'post_only'
|
5017
|
+
elif timeInForce == 'GTC':
|
5018
|
+
request['timeInForce'] = 'gtc'
|
5019
|
+
elif timeInForce == 'FOK':
|
5020
|
+
request['timeInForce'] = 'fok'
|
5021
|
+
elif timeInForce == 'IOC':
|
5022
|
+
request['timeInForce'] = 'ioc'
|
5023
|
+
reduceOnly = self.safe_bool(params, 'reduceOnly', False)
|
5024
|
+
hedged = None
|
5025
|
+
hedged, params = self.handle_param_bool(params, 'hedged', False)
|
5026
|
+
if reduceOnly:
|
5027
|
+
if hedged or isStopLossOrTakeProfitTrigger:
|
5028
|
+
reduceOnlyPosSide = 'long' if (side == 'sell') else 'short'
|
5029
|
+
request['posSide'] = reduceOnlyPosSide
|
5030
|
+
elif not isStopLossOrTakeProfitTrigger:
|
5031
|
+
request['reduceOnly'] = 'yes'
|
5032
|
+
else:
|
5033
|
+
if hedged:
|
5034
|
+
posSide = 'long' if (side == 'buy') else 'short'
|
5035
|
+
request['posSide'] = posSide
|
5036
|
+
params = self.omit(params, ['stopLoss', 'takeProfit', 'postOnly', 'reduceOnly', 'hedged'])
|
5037
|
+
return self.extend(request, params)
|
5038
|
+
|
5039
|
+
def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
5040
|
+
market = self.market(symbol)
|
5041
|
+
marketType = None
|
5042
|
+
marginMode = None
|
5043
|
+
marketType, params = self.handle_market_type_and_params('createOrder', market, params)
|
5044
|
+
marginMode, params = self.handle_margin_mode_and_params('createOrder', params)
|
5045
|
+
request: dict = {
|
5046
|
+
'symbol': market['id'],
|
5047
|
+
'orderType': type,
|
5048
|
+
}
|
5049
|
+
isMarketOrder = type == 'market'
|
5050
|
+
triggerPrice = self.safe_value_2(params, 'stopPrice', 'triggerPrice')
|
5051
|
+
stopLossTriggerPrice = self.safe_value(params, 'stopLossPrice')
|
5052
|
+
takeProfitTriggerPrice = self.safe_value(params, 'takeProfitPrice')
|
5053
|
+
stopLoss = self.safe_value(params, 'stopLoss')
|
5054
|
+
takeProfit = self.safe_value(params, 'takeProfit')
|
5055
|
+
isTriggerOrder = triggerPrice is not None
|
5056
|
+
isStopLossTriggerOrder = stopLossTriggerPrice is not None
|
4477
5057
|
isTakeProfitTriggerOrder = takeProfitTriggerPrice is not None
|
4478
5058
|
isStopLoss = stopLoss is not None
|
4479
5059
|
isTakeProfit = takeProfit is not None
|
@@ -4527,16 +5107,16 @@ class bitget(Exchange, ImplicitAPI):
|
|
4527
5107
|
if price is not None:
|
4528
5108
|
request['executePrice'] = self.price_to_precision(symbol, price)
|
4529
5109
|
if isStopLoss:
|
4530
|
-
slTriggerPrice = self.
|
5110
|
+
slTriggerPrice = self.safe_string_2(stopLoss, 'triggerPrice', 'stopPrice')
|
4531
5111
|
request['stopLossTriggerPrice'] = self.price_to_precision(symbol, slTriggerPrice)
|
4532
|
-
slPrice = self.
|
5112
|
+
slPrice = self.safe_string(stopLoss, 'price')
|
4533
5113
|
request['stopLossExecutePrice'] = self.price_to_precision(symbol, slPrice)
|
4534
5114
|
slType = self.safe_string(stopLoss, 'type', 'mark_price')
|
4535
5115
|
request['stopLossTriggerType'] = slType
|
4536
5116
|
if isTakeProfit:
|
4537
|
-
tpTriggerPrice = self.
|
5117
|
+
tpTriggerPrice = self.safe_string_2(takeProfit, 'triggerPrice', 'stopPrice')
|
4538
5118
|
request['stopSurplusTriggerPrice'] = self.price_to_precision(symbol, tpTriggerPrice)
|
4539
|
-
tpPrice = self.
|
5119
|
+
tpPrice = self.safe_string(takeProfit, 'price')
|
4540
5120
|
request['stopSurplusExecutePrice'] = self.price_to_precision(symbol, tpPrice)
|
4541
5121
|
tpType = self.safe_string(takeProfit, 'type', 'mark_price')
|
4542
5122
|
request['stopSurplusTriggerType'] = tpType
|
@@ -4629,6 +5209,52 @@ class bitget(Exchange, ImplicitAPI):
|
|
4629
5209
|
raise NotSupported(self.id + ' createOrder() does not support ' + marketType + ' orders')
|
4630
5210
|
return self.extend(request, params)
|
4631
5211
|
|
5212
|
+
def create_uta_orders(self, orders: List[OrderRequest], params={}):
|
5213
|
+
self.load_markets()
|
5214
|
+
ordersRequests = []
|
5215
|
+
symbol = None
|
5216
|
+
marginMode = None
|
5217
|
+
for i in range(0, len(orders)):
|
5218
|
+
rawOrder = orders[i]
|
5219
|
+
marketId = self.safe_string(rawOrder, 'symbol')
|
5220
|
+
if symbol is None:
|
5221
|
+
symbol = marketId
|
5222
|
+
else:
|
5223
|
+
if symbol != marketId:
|
5224
|
+
raise BadRequest(self.id + ' createOrders() requires all orders to have the same symbol')
|
5225
|
+
type = self.safe_string(rawOrder, 'type')
|
5226
|
+
side = self.safe_string(rawOrder, 'side')
|
5227
|
+
amount = self.safe_value(rawOrder, 'amount')
|
5228
|
+
price = self.safe_value(rawOrder, 'price')
|
5229
|
+
orderParams = self.safe_value(rawOrder, 'params', {})
|
5230
|
+
marginResult = self.handle_margin_mode_and_params('createOrders', orderParams)
|
5231
|
+
currentMarginMode = marginResult[0]
|
5232
|
+
if currentMarginMode is not None:
|
5233
|
+
if marginMode is None:
|
5234
|
+
marginMode = currentMarginMode
|
5235
|
+
else:
|
5236
|
+
if marginMode != currentMarginMode:
|
5237
|
+
raise BadRequest(self.id + ' createOrders() requires all orders to have the same margin mode(isolated or cross)')
|
5238
|
+
orderRequest = self.create_uta_order_request(marketId, type, side, amount, price, orderParams)
|
5239
|
+
ordersRequests.append(orderRequest)
|
5240
|
+
market = self.market(symbol)
|
5241
|
+
response = self.privateUtaPostV3TradePlaceBatch(ordersRequests)
|
5242
|
+
#
|
5243
|
+
# {
|
5244
|
+
# "code": "00000",
|
5245
|
+
# "msg": "success",
|
5246
|
+
# "requestTime": 1752810184560,
|
5247
|
+
# "data": [
|
5248
|
+
# {
|
5249
|
+
# "orderId": "1329947796441513984",
|
5250
|
+
# "clientOid": "1329947796483457024"
|
5251
|
+
# },
|
5252
|
+
# ]
|
5253
|
+
# }
|
5254
|
+
#
|
5255
|
+
data = self.safe_list(response, 'data', [])
|
5256
|
+
return self.parse_orders(data, market)
|
5257
|
+
|
4632
5258
|
def create_orders(self, orders: List[OrderRequest], params={}):
|
4633
5259
|
"""
|
4634
5260
|
create a list of trade orders(all orders should be of the same symbol)
|
@@ -4637,12 +5263,18 @@ class bitget(Exchange, ImplicitAPI):
|
|
4637
5263
|
https://www.bitget.com/api-doc/contract/trade/Batch-Order
|
4638
5264
|
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Order
|
4639
5265
|
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Order
|
5266
|
+
https://www.bitget.com/api-doc/uta/trade/Place-Batch
|
4640
5267
|
|
4641
5268
|
:param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
4642
5269
|
:param dict [params]: extra parameters specific to the api endpoint
|
5270
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
4643
5271
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
4644
5272
|
"""
|
4645
5273
|
self.load_markets()
|
5274
|
+
uta = None
|
5275
|
+
uta, params = self.handle_option_and_params(params, 'createOrders', 'uta', False)
|
5276
|
+
if uta:
|
5277
|
+
return self.create_uta_orders(orders, params)
|
4646
5278
|
ordersRequests = []
|
4647
5279
|
symbol = None
|
4648
5280
|
marginMode = None
|
@@ -4728,6 +5360,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
4728
5360
|
https://www.bitget.com/api-doc/contract/trade/Modify-Order
|
4729
5361
|
https://www.bitget.com/api-doc/contract/plan/Modify-Tpsl-Order
|
4730
5362
|
https://www.bitget.com/api-doc/contract/plan/Modify-Plan-Order
|
5363
|
+
https://www.bitget.com/api-doc/uta/trade/Modify-Order
|
5364
|
+
https://www.bitget.com/api-doc/uta/strategy/Modify-Strategy-Order
|
4731
5365
|
|
4732
5366
|
:param str id: cancel order id
|
4733
5367
|
:param str symbol: unified symbol of the market to create an order in
|
@@ -4750,6 +5384,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
4750
5384
|
:param str [params.trailingPercent]: *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
|
4751
5385
|
:param str [params.trailingTriggerPrice]: *swap and future only* the price to trigger a trailing stop order, default uses the price argument
|
4752
5386
|
:param str [params.newTriggerType]: *swap and future only* 'fill_price', 'mark_price' or 'index_price'
|
5387
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
4753
5388
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
4754
5389
|
"""
|
4755
5390
|
self.load_markets()
|
@@ -4778,7 +5413,39 @@ class bitget(Exchange, ImplicitAPI):
|
|
4778
5413
|
request['clientOid'] = clientOrderId
|
4779
5414
|
params = self.omit(params, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice', 'stopLoss', 'takeProfit', 'clientOrderId', 'trailingTriggerPrice', 'trailingPercent'])
|
4780
5415
|
response = None
|
4781
|
-
|
5416
|
+
productType = None
|
5417
|
+
uta = None
|
5418
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
5419
|
+
uta, params = self.handle_option_and_params(params, 'editOrder', 'uta', False)
|
5420
|
+
if uta:
|
5421
|
+
if amount is not None:
|
5422
|
+
request['qty'] = self.amount_to_precision(symbol, amount)
|
5423
|
+
if isStopLossOrder or isTakeProfitOrder:
|
5424
|
+
if isStopLossOrder:
|
5425
|
+
slType = self.safe_string(params, 'slTriggerBy', 'mark')
|
5426
|
+
request['slTriggerBy'] = slType
|
5427
|
+
request['stopLoss'] = self.price_to_precision(symbol, stopLossPrice)
|
5428
|
+
if price is not None:
|
5429
|
+
request['slLimitPrice'] = self.price_to_precision(symbol, price)
|
5430
|
+
request['slOrderType'] = self.safe_string(params, 'slOrderType', 'limit')
|
5431
|
+
else:
|
5432
|
+
request['slOrderType'] = self.safe_string(params, 'slOrderType', 'market')
|
5433
|
+
elif isTakeProfitOrder:
|
5434
|
+
tpType = self.safe_string(params, 'tpTriggerBy', 'mark')
|
5435
|
+
request['tpTriggerBy'] = tpType
|
5436
|
+
request['takeProfit'] = self.price_to_precision(symbol, takeProfitPrice)
|
5437
|
+
if price is not None:
|
5438
|
+
request['tpLimitPrice'] = self.price_to_precision(symbol, price)
|
5439
|
+
request['tpOrderType'] = self.safe_string(params, 'tpOrderType', 'limit')
|
5440
|
+
else:
|
5441
|
+
request['tpOrderType'] = self.safe_string(params, 'tpOrderType', 'market')
|
5442
|
+
params = self.omit(params, ['stopLossPrice', 'takeProfitPrice'])
|
5443
|
+
response = self.privateUtaPostV3TradeModifyStrategyOrder(self.extend(request, params))
|
5444
|
+
else:
|
5445
|
+
if price is not None:
|
5446
|
+
request['price'] = self.price_to_precision(symbol, price)
|
5447
|
+
response = self.privateUtaPostV3TradeModifyOrder(self.extend(request, params))
|
5448
|
+
elif market['spot']:
|
4782
5449
|
if triggerPrice is None:
|
4783
5450
|
raise NotSupported(self.id + ' editOrder() only supports plan/trigger spot orders')
|
4784
5451
|
editMarketBuyOrderRequiresPrice = self.safe_bool(self.options, 'editMarketBuyOrderRequiresPrice', True)
|
@@ -4800,8 +5467,6 @@ class bitget(Exchange, ImplicitAPI):
|
|
4800
5467
|
if (not market['swap']) and (not market['future']):
|
4801
5468
|
raise NotSupported(self.id + ' editOrder() does not support ' + market['type'] + ' orders')
|
4802
5469
|
request['symbol'] = market['id']
|
4803
|
-
productType = None
|
4804
|
-
productType, params = self.handle_product_type_and_params(market, params)
|
4805
5470
|
request['productType'] = productType
|
4806
5471
|
if not isTakeProfitOrder and not isStopLossOrder:
|
4807
5472
|
request['newSize'] = self.amount_to_precision(symbol, amount)
|
@@ -4877,6 +5542,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
4877
5542
|
https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
|
4878
5543
|
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Cancel-Order
|
4879
5544
|
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Cancel-Order
|
5545
|
+
https://www.bitget.com/api-doc/uta/trade/Cancel-Order
|
5546
|
+
https://www.bitget.com/api-doc/uta/strategy/Cancel-Strategy-Order
|
4880
5547
|
|
4881
5548
|
:param str id: order id
|
4882
5549
|
:param str symbol: unified symbol of the market the order was made in
|
@@ -4885,6 +5552,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
4885
5552
|
:param boolean [params.trigger]: set to True for canceling trigger orders
|
4886
5553
|
:param str [params.planType]: *swap only* either profit_plan, loss_plan, normal_plan, pos_profit, pos_loss, moving_plan or track_plan
|
4887
5554
|
:param boolean [params.trailing]: set to True if you want to cancel a trailing order
|
5555
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
5556
|
+
:param str [params.clientOrderId]: the clientOrderId of the order, id does not need to be provided if clientOrderId is provided
|
4888
5557
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
4889
5558
|
"""
|
4890
5559
|
if symbol is None:
|
@@ -4900,19 +5569,37 @@ class bitget(Exchange, ImplicitAPI):
|
|
4900
5569
|
params = self.omit(params, ['stop', 'trigger', 'trailing'])
|
4901
5570
|
if not (market['spot'] and trigger):
|
4902
5571
|
request['symbol'] = market['id']
|
4903
|
-
|
4904
|
-
|
4905
|
-
|
5572
|
+
uta = None
|
5573
|
+
uta, params = self.handle_option_and_params(params, 'cancelOrder', 'uta', False)
|
5574
|
+
isPlanOrder = trigger or trailing
|
5575
|
+
isContract = market['swap'] or market['future']
|
5576
|
+
isContractTriggerEndpoint = isContract and isPlanOrder and not uta
|
5577
|
+
clientOrderId = self.safe_string_2(params, 'clientOrderId', 'clientOid')
|
5578
|
+
if isContractTriggerEndpoint:
|
5579
|
+
orderIdList = []
|
5580
|
+
orderId: dict = {}
|
5581
|
+
if clientOrderId is not None:
|
5582
|
+
params = self.omit(params, 'clientOrderId')
|
5583
|
+
orderId['clientOid'] = clientOrderId
|
5584
|
+
else:
|
5585
|
+
orderId['orderId'] = id
|
5586
|
+
orderIdList.append(orderId)
|
5587
|
+
request['orderIdList'] = orderIdList
|
5588
|
+
else:
|
5589
|
+
if clientOrderId is not None:
|
5590
|
+
params = self.omit(params, 'clientOrderId')
|
5591
|
+
request['clientOid'] = clientOrderId
|
5592
|
+
else:
|
5593
|
+
request['orderId'] = id
|
5594
|
+
if uta:
|
5595
|
+
if trigger:
|
5596
|
+
response = self.privateUtaPostV3TradeCancelStrategyOrder(self.extend(request, params))
|
5597
|
+
else:
|
5598
|
+
response = self.privateUtaPostV3TradeCancelOrder(self.extend(request, params))
|
5599
|
+
elif (market['swap']) or (market['future']):
|
4906
5600
|
productType = None
|
4907
5601
|
productType, params = self.handle_product_type_and_params(market, params)
|
4908
5602
|
request['productType'] = productType
|
4909
|
-
if trigger or trailing:
|
4910
|
-
orderIdList = []
|
4911
|
-
orderId: dict = {
|
4912
|
-
'orderId': id,
|
4913
|
-
}
|
4914
|
-
orderIdList.append(orderId)
|
4915
|
-
request['orderIdList'] = orderIdList
|
4916
5603
|
if trailing:
|
4917
5604
|
planType = self.safe_string(params, 'planType', 'track_plan')
|
4918
5605
|
request['planType'] = planType
|
@@ -4975,15 +5662,60 @@ class bitget(Exchange, ImplicitAPI):
|
|
4975
5662
|
# }
|
4976
5663
|
# }
|
4977
5664
|
#
|
5665
|
+
# uta trigger
|
5666
|
+
#
|
5667
|
+
# {
|
5668
|
+
# "code": "00000",
|
5669
|
+
# "msg": "success",
|
5670
|
+
# "requestTime": "1753058267399",
|
5671
|
+
# "data": null
|
5672
|
+
# }
|
5673
|
+
#
|
4978
5674
|
data = self.safe_value(response, 'data', {})
|
4979
5675
|
order = None
|
4980
|
-
if
|
5676
|
+
if isContractTriggerEndpoint:
|
4981
5677
|
orderInfo = self.safe_value(data, 'successList', [])
|
4982
5678
|
order = orderInfo[0]
|
4983
5679
|
else:
|
4984
|
-
|
5680
|
+
if uta and trigger:
|
5681
|
+
order = response
|
5682
|
+
else:
|
5683
|
+
order = data
|
4985
5684
|
return self.parse_order(order, market)
|
4986
5685
|
|
5686
|
+
def cancel_uta_orders(self, ids, symbol: Str = None, params={}):
|
5687
|
+
if symbol is None:
|
5688
|
+
raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
|
5689
|
+
self.load_markets()
|
5690
|
+
market = self.market(symbol)
|
5691
|
+
productType = None
|
5692
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
5693
|
+
requestList = []
|
5694
|
+
for i in range(0, len(ids)):
|
5695
|
+
individualId = ids[i]
|
5696
|
+
order: dict = {
|
5697
|
+
'orderId': individualId,
|
5698
|
+
'symbol': market['id'],
|
5699
|
+
'category': productType,
|
5700
|
+
}
|
5701
|
+
requestList.append(order)
|
5702
|
+
response = self.privateUtaPostV3TradeCancelBatch(requestList)
|
5703
|
+
#
|
5704
|
+
# {
|
5705
|
+
# "code": "00000",
|
5706
|
+
# "msg": "success",
|
5707
|
+
# "requestTime": 1752813731517,
|
5708
|
+
# "data": [
|
5709
|
+
# {
|
5710
|
+
# "orderId": "1329948909442023424",
|
5711
|
+
# "clientOid": "1329948909446217728"
|
5712
|
+
# },
|
5713
|
+
# ]
|
5714
|
+
# }
|
5715
|
+
#
|
5716
|
+
data = self.safe_list(response, 'data', [])
|
5717
|
+
return self.parse_orders(data, market)
|
5718
|
+
|
4987
5719
|
def cancel_orders(self, ids, symbol: Str = None, params={}):
|
4988
5720
|
"""
|
4989
5721
|
cancel multiple orders
|
@@ -4993,18 +5725,24 @@ class bitget(Exchange, ImplicitAPI):
|
|
4993
5725
|
https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
|
4994
5726
|
https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Cancel-Order
|
4995
5727
|
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Cancel-Orders
|
5728
|
+
https://www.bitget.com/api-doc/uta/trade/Cancel-Batch
|
4996
5729
|
|
4997
5730
|
:param str[] ids: order ids
|
4998
5731
|
:param str symbol: unified market symbol, default is None
|
4999
5732
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5000
5733
|
:param str [params.marginMode]: 'isolated' or 'cross' for spot margin trading
|
5001
5734
|
:param boolean [params.trigger]: *contract only* set to True for canceling trigger orders
|
5735
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
5002
5736
|
:returns dict: an array of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
5003
5737
|
"""
|
5004
5738
|
if symbol is None:
|
5005
5739
|
raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
|
5006
5740
|
self.load_markets()
|
5007
5741
|
market = self.market(symbol)
|
5742
|
+
uta = None
|
5743
|
+
uta, params = self.handle_option_and_params(params, 'cancelOrders', 'uta', False)
|
5744
|
+
if uta:
|
5745
|
+
return self.cancel_uta_orders(ids, symbol, params)
|
5008
5746
|
marginMode = None
|
5009
5747
|
marginMode, params = self.handle_margin_mode_and_params('cancelOrders', params)
|
5010
5748
|
trigger = self.safe_value_2(params, 'stop', 'trigger')
|
@@ -5069,11 +5807,13 @@ class bitget(Exchange, ImplicitAPI):
|
|
5069
5807
|
https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
|
5070
5808
|
https://bitgetlimited.github.io/apidoc/en/margin/#isolated-batch-cancel-orders
|
5071
5809
|
https://bitgetlimited.github.io/apidoc/en/margin/#cross-batch-cancel-order
|
5810
|
+
https://www.bitget.com/api-doc/uta/trade/Cancel-All-Order
|
5072
5811
|
|
5073
5812
|
:param str symbol: unified market symbol
|
5074
5813
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5075
5814
|
:param str [params.marginMode]: 'isolated' or 'cross' for spot margin trading
|
5076
5815
|
:param boolean [params.trigger]: *contract only* set to True for canceling trigger orders
|
5816
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
5077
5817
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
5078
5818
|
"""
|
5079
5819
|
if symbol is None:
|
@@ -5082,13 +5822,38 @@ class bitget(Exchange, ImplicitAPI):
|
|
5082
5822
|
market = self.market(symbol)
|
5083
5823
|
marginMode = None
|
5084
5824
|
marginMode, params = self.handle_margin_mode_and_params('cancelAllOrders', params)
|
5825
|
+
productType = None
|
5826
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
5085
5827
|
request: dict = {
|
5086
5828
|
'symbol': market['id'],
|
5087
5829
|
}
|
5088
5830
|
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
5089
5831
|
params = self.omit(params, ['stop', 'trigger'])
|
5090
5832
|
response = None
|
5091
|
-
|
5833
|
+
uta = None
|
5834
|
+
uta, params = self.handle_option_and_params(params, 'cancelAllOrders', 'uta', False)
|
5835
|
+
if uta:
|
5836
|
+
if productType == 'SPOT':
|
5837
|
+
if marginMode is not None:
|
5838
|
+
productType = 'MARGIN'
|
5839
|
+
request['category'] = productType
|
5840
|
+
response = self.privateUtaPostV3TradeCancelSymbolOrder(self.extend(request, params))
|
5841
|
+
#
|
5842
|
+
# {
|
5843
|
+
# "code": "00000",
|
5844
|
+
# "msg": "success",
|
5845
|
+
# "requestTime": 1750751578138,
|
5846
|
+
# "data": {
|
5847
|
+
# "list": [
|
5848
|
+
# {
|
5849
|
+
# "orderId": "1321313242969427968",
|
5850
|
+
# "clientOid": "1321313242969427969"
|
5851
|
+
# }
|
5852
|
+
# ]
|
5853
|
+
# }
|
5854
|
+
# }
|
5855
|
+
#
|
5856
|
+
elif market['spot']:
|
5092
5857
|
if marginMode is not None:
|
5093
5858
|
if marginMode == 'cross':
|
5094
5859
|
response = self.privateMarginPostMarginV1CrossOrderBatchCancelOrder(self.extend(request, params))
|
@@ -5140,8 +5905,6 @@ class bitget(Exchange, ImplicitAPI):
|
|
5140
5905
|
}),
|
5141
5906
|
]
|
5142
5907
|
else:
|
5143
|
-
productType = None
|
5144
|
-
productType, params = self.handle_product_type_and_params(market, params)
|
5145
5908
|
request['productType'] = productType
|
5146
5909
|
if trigger:
|
5147
5910
|
response = self.privateMixPostV2MixOrderCancelPlanOrder(self.extend(request, params))
|
@@ -5162,9 +5925,13 @@ class bitget(Exchange, ImplicitAPI):
|
|
5162
5925
|
# }
|
5163
5926
|
# }
|
5164
5927
|
data = self.safe_dict(response, 'data')
|
5165
|
-
resultList = self.
|
5928
|
+
resultList = self.safe_list_n(data, ['resultList', 'successList', 'list'])
|
5166
5929
|
failureList = self.safe_list_2(data, 'failure', 'failureList')
|
5167
|
-
responseList =
|
5930
|
+
responseList = None
|
5931
|
+
if (resultList is not None) and (failureList is not None):
|
5932
|
+
responseList = self.array_concat(resultList, failureList)
|
5933
|
+
else:
|
5934
|
+
responseList = resultList
|
5168
5935
|
return self.parse_orders(responseList)
|
5169
5936
|
|
5170
5937
|
def fetch_order(self, id: str, symbol: Str = None, params={}):
|
@@ -5173,10 +5940,13 @@ class bitget(Exchange, ImplicitAPI):
|
|
5173
5940
|
|
5174
5941
|
https://www.bitget.com/api-doc/spot/trade/Get-Order-Info
|
5175
5942
|
https://www.bitget.com/api-doc/contract/trade/Get-Order-Details
|
5943
|
+
https://www.bitget.com/api-doc/uta/trade/Get-Order-Details
|
5176
5944
|
|
5177
5945
|
:param str id: the order id
|
5178
5946
|
:param str symbol: unified symbol of the market the order was made in
|
5179
5947
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5948
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
5949
|
+
:param str [params.clientOrderId]: the clientOrderId of the order, id does not need to be provided if clientOrderId is provided
|
5180
5950
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
5181
5951
|
"""
|
5182
5952
|
if symbol is None:
|
@@ -5184,10 +5954,20 @@ class bitget(Exchange, ImplicitAPI):
|
|
5184
5954
|
self.load_markets()
|
5185
5955
|
market = self.market(symbol)
|
5186
5956
|
request: dict = {
|
5187
|
-
'orderId': id,
|
5957
|
+
# 'orderId': id,
|
5188
5958
|
}
|
5959
|
+
clientOrderId = self.safe_string_2(params, 'clientOrderId', 'clientOid')
|
5960
|
+
if clientOrderId is not None:
|
5961
|
+
params = self.omit(params, ['clientOrderId'])
|
5962
|
+
request['clientOid'] = clientOrderId
|
5963
|
+
else:
|
5964
|
+
request['orderId'] = id
|
5189
5965
|
response = None
|
5190
|
-
|
5966
|
+
uta = None
|
5967
|
+
uta, params = self.handle_option_and_params(params, 'fetchOrder', 'uta', False)
|
5968
|
+
if uta:
|
5969
|
+
response = self.privateUtaGetV3TradeOrderInfo(self.extend(request, params))
|
5970
|
+
elif market['spot']:
|
5191
5971
|
response = self.privateSpotGetV2SpotTradeOrderInfo(self.extend(request, params))
|
5192
5972
|
elif market['swap'] or market['future']:
|
5193
5973
|
request['symbol'] = market['id']
|
@@ -5264,13 +6044,60 @@ class bitget(Exchange, ImplicitAPI):
|
|
5264
6044
|
# }
|
5265
6045
|
# }
|
5266
6046
|
#
|
5267
|
-
|
6047
|
+
# uta
|
6048
|
+
#
|
6049
|
+
# {
|
6050
|
+
# "code": "00000",
|
6051
|
+
# "msg": "success",
|
6052
|
+
# "requestTime": 1750496858333,
|
6053
|
+
# "data": {
|
6054
|
+
# "orderId": "1320244799629316096",
|
6055
|
+
# "clientOid": "1320244799633510400",
|
6056
|
+
# "category": "USDT-FUTURES",
|
6057
|
+
# "symbol": "BTCUSDT",
|
6058
|
+
# "orderType": "limit",
|
6059
|
+
# "side": "buy",
|
6060
|
+
# "price": "50000",
|
6061
|
+
# "qty": "0.001",
|
6062
|
+
# "amount": "0",
|
6063
|
+
# "cumExecQty": "0",
|
6064
|
+
# "cumExecValue": "0",
|
6065
|
+
# "avgPrice": "0",
|
6066
|
+
# "timeInForce": "gtc",
|
6067
|
+
# "orderStatus": "live",
|
6068
|
+
# "posSide": "long",
|
6069
|
+
# "holdMode": "hedge_mode",
|
6070
|
+
# "reduceOnly": "NO",
|
6071
|
+
# "feeDetail": [{
|
6072
|
+
# "feeCoin": "",
|
6073
|
+
# "fee": ""
|
6074
|
+
# }],
|
6075
|
+
# "createdTime": "1750496809871",
|
6076
|
+
# "updatedTime": "1750496809886",
|
6077
|
+
# "cancelReason": "",
|
6078
|
+
# "execType": "normal",
|
6079
|
+
# "stpMode": "none",
|
6080
|
+
# "tpTriggerBy": null,
|
6081
|
+
# "slTriggerBy": null,
|
6082
|
+
# "takeProfit": null,
|
6083
|
+
# "stopLoss": null,
|
6084
|
+
# "tpOrderType": null,
|
6085
|
+
# "slOrderType": null,
|
6086
|
+
# "tpLimitPrice": null,
|
6087
|
+
# "slLimitPrice": null
|
6088
|
+
# }
|
6089
|
+
# }
|
6090
|
+
#
|
6091
|
+
if not uta and (isinstance(response, str)):
|
5268
6092
|
response = json.loads(response)
|
5269
6093
|
data = self.safe_dict(response, 'data')
|
5270
6094
|
if (data is not None):
|
5271
6095
|
if not isinstance(data, list):
|
5272
6096
|
return self.parse_order(data, market)
|
5273
6097
|
dataList = self.safe_list(response, 'data', [])
|
6098
|
+
dataListLength = len(dataList)
|
6099
|
+
if dataListLength == 0:
|
6100
|
+
raise OrderNotFound(self.id + ' fetchOrder() could not find order id ' + id + ' in ' + self.json(response))
|
5274
6101
|
first = self.safe_dict(dataList, 0, {})
|
5275
6102
|
return self.parse_order(first, market)
|
5276
6103
|
# first = self.safe_dict(data, 0, data)
|
@@ -5286,6 +6113,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5286
6113
|
https://www.bitget.com/api-doc/contract/plan/get-orders-plan-pending
|
5287
6114
|
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Open-Orders
|
5288
6115
|
https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Open-Orders
|
6116
|
+
https://www.bitget.com/api-doc/uta/strategy/Get-Unfilled-Strategy-Orders
|
5289
6117
|
|
5290
6118
|
:param str symbol: unified market symbol
|
5291
6119
|
:param int [since]: the earliest time in ms to fetch open orders for
|
@@ -5297,6 +6125,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5297
6125
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
5298
6126
|
:param str [params.isPlan]: *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
|
5299
6127
|
:param boolean [params.trailing]: set to True if you want to fetch trailing orders
|
6128
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
5300
6129
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
5301
6130
|
"""
|
5302
6131
|
self.load_markets()
|
@@ -5305,6 +6134,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
5305
6134
|
request: dict = {}
|
5306
6135
|
marginMode = None
|
5307
6136
|
marginMode, params = self.handle_margin_mode_and_params('fetchOpenOrders', params)
|
6137
|
+
uta = None
|
6138
|
+
uta, params = self.handle_option_and_params(params, 'fetchOpenOrders', 'uta', False)
|
5308
6139
|
if symbol is not None:
|
5309
6140
|
market = self.market(symbol)
|
5310
6141
|
request['symbol'] = market['id']
|
@@ -5318,58 +6149,71 @@ class bitget(Exchange, ImplicitAPI):
|
|
5318
6149
|
paginate, params = self.handle_option_and_params(params, 'fetchOpenOrders', 'paginate')
|
5319
6150
|
if paginate:
|
5320
6151
|
cursorReceived = None
|
5321
|
-
|
6152
|
+
cursorSent = None
|
6153
|
+
if uta:
|
6154
|
+
cursorReceived = 'cursor'
|
6155
|
+
cursorSent = 'cursor'
|
6156
|
+
elif type == 'spot':
|
5322
6157
|
if marginMode is not None:
|
5323
6158
|
cursorReceived = 'minId'
|
6159
|
+
cursorSent = 'idLessThan'
|
5324
6160
|
else:
|
5325
6161
|
cursorReceived = 'endId'
|
5326
|
-
|
6162
|
+
cursorSent = 'idLessThan'
|
6163
|
+
return self.fetch_paginated_call_cursor('fetchOpenOrders', symbol, since, limit, params, cursorReceived, cursorSent)
|
5327
6164
|
response = None
|
5328
6165
|
trailing = self.safe_bool(params, 'trailing')
|
5329
6166
|
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
5330
6167
|
planTypeDefined = self.safe_string(params, 'planType') is not None
|
5331
6168
|
isTrigger = (trigger or planTypeDefined)
|
5332
|
-
params = self.omit(params, ['stop', 'trigger', 'trailing'])
|
5333
6169
|
request, params = self.handle_until_option('endTime', request, params)
|
5334
6170
|
if since is not None:
|
5335
6171
|
request['startTime'] = since
|
5336
6172
|
if limit is not None:
|
5337
6173
|
request['limit'] = limit
|
5338
|
-
if (type == 'swap') or (type == 'future') or (marginMode is not None):
|
6174
|
+
if not uta and ((type == 'swap') or (type == 'future') or (marginMode is not None)):
|
5339
6175
|
clientOrderId = self.safe_string_2(params, 'clientOid', 'clientOrderId')
|
5340
6176
|
params = self.omit(params, 'clientOrderId')
|
5341
6177
|
if clientOrderId is not None:
|
5342
6178
|
request['clientOid'] = clientOrderId
|
5343
|
-
|
5344
|
-
|
5345
|
-
|
6179
|
+
productType = None
|
6180
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
6181
|
+
params = self.omit(params, ['type', 'stop', 'trigger', 'trailing'])
|
6182
|
+
if uta:
|
6183
|
+
if type == 'spot':
|
6184
|
+
if marginMode is not None:
|
6185
|
+
productType = 'MARGIN'
|
6186
|
+
request['category'] = productType
|
6187
|
+
if trigger:
|
6188
|
+
response = self.privateUtaGetV3TradeUnfilledStrategyOrders(self.extend(request, params))
|
6189
|
+
else:
|
6190
|
+
response = self.privateUtaGetV3TradeUnfilledOrders(self.extend(request, params))
|
6191
|
+
elif type == 'spot':
|
5346
6192
|
if marginMode is not None:
|
5347
6193
|
if since is None:
|
5348
6194
|
since = self.milliseconds() - 7776000000
|
5349
6195
|
request['startTime'] = since
|
5350
6196
|
if marginMode == 'isolated':
|
5351
|
-
response = self.privateMarginGetV2MarginIsolatedOpenOrders(self.extend(request,
|
6197
|
+
response = self.privateMarginGetV2MarginIsolatedOpenOrders(self.extend(request, params))
|
5352
6198
|
elif marginMode == 'cross':
|
5353
|
-
response = self.privateMarginGetV2MarginCrossedOpenOrders(self.extend(request,
|
6199
|
+
response = self.privateMarginGetV2MarginCrossedOpenOrders(self.extend(request, params))
|
5354
6200
|
else:
|
5355
6201
|
if trigger:
|
5356
|
-
response = self.privateSpotGetV2SpotTradeCurrentPlanOrder(self.extend(request,
|
6202
|
+
response = self.privateSpotGetV2SpotTradeCurrentPlanOrder(self.extend(request, params))
|
5357
6203
|
else:
|
5358
|
-
response = self.privateSpotGetV2SpotTradeUnfilledOrders(self.extend(request,
|
6204
|
+
response = self.privateSpotGetV2SpotTradeUnfilledOrders(self.extend(request, params))
|
5359
6205
|
else:
|
5360
|
-
productType = None
|
5361
|
-
productType, query = self.handle_product_type_and_params(market, query)
|
5362
6206
|
request['productType'] = productType
|
5363
6207
|
if trailing:
|
5364
6208
|
planType = self.safe_string(params, 'planType', 'track_plan')
|
5365
6209
|
request['planType'] = planType
|
5366
|
-
response = self.privateMixGetV2MixOrderOrdersPlanPending(self.extend(request,
|
6210
|
+
response = self.privateMixGetV2MixOrderOrdersPlanPending(self.extend(request, params))
|
5367
6211
|
elif isTrigger:
|
5368
|
-
planType = self.safe_string(
|
6212
|
+
planType = self.safe_string(params, 'planType', 'normal_plan')
|
5369
6213
|
request['planType'] = planType
|
5370
|
-
response = self.privateMixGetV2MixOrderOrdersPlanPending(self.extend(request,
|
6214
|
+
response = self.privateMixGetV2MixOrderOrdersPlanPending(self.extend(request, params))
|
5371
6215
|
else:
|
5372
|
-
response = self.privateMixGetV2MixOrderOrdersPending(self.extend(request,
|
6216
|
+
response = self.privateMixGetV2MixOrderOrdersPending(self.extend(request, params))
|
5373
6217
|
#
|
5374
6218
|
# spot
|
5375
6219
|
#
|
@@ -5545,8 +6389,92 @@ class bitget(Exchange, ImplicitAPI):
|
|
5545
6389
|
# }
|
5546
6390
|
# }
|
5547
6391
|
#
|
6392
|
+
# uta
|
6393
|
+
#
|
6394
|
+
# {
|
6395
|
+
# "code": "00000",
|
6396
|
+
# "msg": "success",
|
6397
|
+
# "requestTime": 1750753395850,
|
6398
|
+
# "data": {
|
6399
|
+
# "list": [
|
6400
|
+
# {
|
6401
|
+
# "orderId": "1321320757371228160",
|
6402
|
+
# "clientOid": "1321320757371228161",
|
6403
|
+
# "category": "USDT-FUTURES",
|
6404
|
+
# "symbol": "BTCUSDT",
|
6405
|
+
# "orderType": "limit",
|
6406
|
+
# "side": "buy",
|
6407
|
+
# "price": "50000",
|
6408
|
+
# "qty": "0.001",
|
6409
|
+
# "amount": "0",
|
6410
|
+
# "cumExecQty": "0",
|
6411
|
+
# "cumExecValue": "0",
|
6412
|
+
# "avgPrice": "0",
|
6413
|
+
# "timeInForce": "gtc",
|
6414
|
+
# "orderStatus": "live",
|
6415
|
+
# "posSide": "long",
|
6416
|
+
# "holdMode": "hedge_mode",
|
6417
|
+
# "reduceOnly": "NO",
|
6418
|
+
# "feeDetail": [
|
6419
|
+
# {
|
6420
|
+
# "feeCoin": "",
|
6421
|
+
# "fee": ""
|
6422
|
+
# }
|
6423
|
+
# ],
|
6424
|
+
# "createdTime": "1750753338186",
|
6425
|
+
# "updatedTime": "1750753338203",
|
6426
|
+
# "stpMode": "none",
|
6427
|
+
# "tpTriggerBy": null,
|
6428
|
+
# "slTriggerBy": null,
|
6429
|
+
# "takeProfit": null,
|
6430
|
+
# "stopLoss": null,
|
6431
|
+
# "tpOrderType": null,
|
6432
|
+
# "slOrderType": null,
|
6433
|
+
# "tpLimitPrice": null,
|
6434
|
+
# "slLimitPrice": null
|
6435
|
+
# }
|
6436
|
+
# ],
|
6437
|
+
# "cursor": "1321320757371228160"
|
6438
|
+
# }
|
6439
|
+
# }
|
6440
|
+
#
|
6441
|
+
# uta trigger
|
6442
|
+
#
|
6443
|
+
# {
|
6444
|
+
# "code": "00000",
|
6445
|
+
# "msg": "success",
|
6446
|
+
# "requestTime": 1753057527060,
|
6447
|
+
# "data": [
|
6448
|
+
# {
|
6449
|
+
# "orderId": "1330984742276198400",
|
6450
|
+
# "clientOid": "1330984742276198400",
|
6451
|
+
# "symbol": "BTCUSDT",
|
6452
|
+
# "category": "USDT-FUTURES",
|
6453
|
+
# "qty": "0.001",
|
6454
|
+
# "posSide": "long",
|
6455
|
+
# "tpTriggerBy": "market",
|
6456
|
+
# "slTriggerBy": "mark",
|
6457
|
+
# "takeProfit": "",
|
6458
|
+
# "stopLoss":"114000",
|
6459
|
+
# "tpOrderType": "market",
|
6460
|
+
# "slOrderType": "limit",
|
6461
|
+
# "tpLimitPrice": "",
|
6462
|
+
# "slLimitPrice": "113000",
|
6463
|
+
# "createdTime": "1753057411736",
|
6464
|
+
# "updatedTime": "1753057411747"
|
6465
|
+
# }
|
6466
|
+
# ]
|
6467
|
+
# }
|
6468
|
+
#
|
5548
6469
|
data = self.safe_value(response, 'data')
|
5549
|
-
if
|
6470
|
+
if uta:
|
6471
|
+
result = None
|
6472
|
+
if trigger:
|
6473
|
+
result = self.safe_list(response, 'data', [])
|
6474
|
+
else:
|
6475
|
+
result = self.safe_list(data, 'list', [])
|
6476
|
+
return self.parse_orders(result, market, since, limit)
|
6477
|
+
elif type == 'spot':
|
5550
6478
|
if (marginMode is not None) or trigger:
|
5551
6479
|
resultList = self.safe_list(data, 'orderList', [])
|
5552
6480
|
return self.parse_orders(resultList, market, since, limit)
|
@@ -5565,6 +6493,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5565
6493
|
https://www.bitget.com/api-doc/contract/plan/orders-plan-history
|
5566
6494
|
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
|
5567
6495
|
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
|
6496
|
+
https://www.bitget.com/api-doc/uta/trade/Get-Order-History
|
5568
6497
|
|
5569
6498
|
:param str symbol: unified market symbol of the closed orders
|
5570
6499
|
:param int [since]: timestamp in ms of the earliest order
|
@@ -5592,6 +6521,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
5592
6521
|
https://www.bitget.com/api-doc/contract/plan/orders-plan-history
|
5593
6522
|
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
|
5594
6523
|
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
|
6524
|
+
https://www.bitget.com/api-doc/uta/trade/Get-Order-History
|
5595
6525
|
|
5596
6526
|
:param str symbol: unified market symbol of the canceled orders
|
5597
6527
|
:param int [since]: timestamp in ms of the earliest order
|
@@ -5618,6 +6548,8 @@ class bitget(Exchange, ImplicitAPI):
|
|
5618
6548
|
https://www.bitget.com/api-doc/contract/plan/orders-plan-history
|
5619
6549
|
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
|
5620
6550
|
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
|
6551
|
+
https://www.bitget.com/api-doc/uta/trade/Get-Order-History
|
6552
|
+
https://www.bitget.com/api-doc/uta/strategy/Get-History-Strategy-Orders
|
5621
6553
|
|
5622
6554
|
fetches information on multiple canceled and closed orders made by the user
|
5623
6555
|
:param str symbol: unified market symbol of the market orders were made in
|
@@ -5630,8 +6562,13 @@ class bitget(Exchange, ImplicitAPI):
|
|
5630
6562
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
5631
6563
|
:param str [params.isPlan]: *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
|
5632
6564
|
:param boolean [params.trailing]: set to True if you want to fetch trailing orders
|
6565
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
5633
6566
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
5634
6567
|
"""
|
6568
|
+
uta = None
|
6569
|
+
uta, params = self.handle_option_and_params(params, 'fetchCanceledAndClosedOrders', 'uta', False)
|
6570
|
+
if uta:
|
6571
|
+
return self.fetch_uta_canceled_and_closed_orders(symbol, since, limit, params)
|
5635
6572
|
self.load_markets()
|
5636
6573
|
market = None
|
5637
6574
|
request: dict = {}
|
@@ -5893,32 +6830,150 @@ class bitget(Exchange, ImplicitAPI):
|
|
5893
6830
|
orders = self.safe_list(response, 'data', [])
|
5894
6831
|
return self.parse_orders(orders, market, since, limit)
|
5895
6832
|
|
5896
|
-
def
|
5897
|
-
"""
|
5898
|
-
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
5899
|
-
|
5900
|
-
https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
|
5901
|
-
https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
|
5902
|
-
|
5903
|
-
:param str [code]: unified currency code, default is None
|
5904
|
-
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
5905
|
-
:param int [limit]: max number of ledger entries to return, default is None
|
5906
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
5907
|
-
:param int [params.until]: end time in ms
|
5908
|
-
:param str [params.symbol]: *contract only* unified market symbol
|
5909
|
-
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
5910
|
-
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
5911
|
-
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
|
5912
|
-
"""
|
6833
|
+
def fetch_uta_canceled_and_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
5913
6834
|
self.load_markets()
|
5914
|
-
symbol = self.safe_string(params, 'symbol')
|
5915
|
-
params = self.omit(params, 'symbol')
|
5916
6835
|
market = None
|
5917
6836
|
if symbol is not None:
|
5918
6837
|
market = self.market(symbol)
|
5919
|
-
|
5920
|
-
|
5921
|
-
|
6838
|
+
productType = None
|
6839
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
6840
|
+
if productType == 'SPOT':
|
6841
|
+
marginMode = None
|
6842
|
+
marginMode, params = self.handle_margin_mode_and_params('fetchCanceledAndClosedOrders', params)
|
6843
|
+
if marginMode is not None:
|
6844
|
+
productType = 'MARGIN'
|
6845
|
+
request: dict = {
|
6846
|
+
'category': productType,
|
6847
|
+
}
|
6848
|
+
paginate = False
|
6849
|
+
paginate, params = self.handle_option_and_params(params, 'fetchCanceledAndClosedOrders', 'paginate')
|
6850
|
+
if paginate:
|
6851
|
+
return self.fetch_paginated_call_cursor('fetchCanceledAndClosedOrders', symbol, since, limit, params, 'cursor', 'cursor')
|
6852
|
+
request, params = self.handle_until_option('endTime', request, params)
|
6853
|
+
if since is not None:
|
6854
|
+
request['startTime'] = since
|
6855
|
+
if limit is not None:
|
6856
|
+
request['limit'] = limit
|
6857
|
+
response = None
|
6858
|
+
trigger = self.safe_bool_2(params, 'stop', 'trigger')
|
6859
|
+
params = self.omit(params, ['stop', 'trigger'])
|
6860
|
+
if trigger:
|
6861
|
+
response = self.privateUtaGetV3TradeHistoryStrategyOrders(self.extend(request, params))
|
6862
|
+
else:
|
6863
|
+
response = self.privateUtaGetV3TradeHistoryOrders(self.extend(request, params))
|
6864
|
+
#
|
6865
|
+
# uta
|
6866
|
+
#
|
6867
|
+
# {
|
6868
|
+
# "code": "00000",
|
6869
|
+
# "msg": "success",
|
6870
|
+
# "requestTime": 1752531592855,
|
6871
|
+
# "data": {
|
6872
|
+
# "list": [
|
6873
|
+
# {
|
6874
|
+
# "orderId": "1322441400976261120",
|
6875
|
+
# "clientOid": "1322441400976261121",
|
6876
|
+
# "category": "USDT-FUTURES",
|
6877
|
+
# "symbol": "BTCUSDT",
|
6878
|
+
# "orderType": "market",
|
6879
|
+
# "side": "sell",
|
6880
|
+
# "price": "0",
|
6881
|
+
# "qty": "0.0001",
|
6882
|
+
# "amount": "0",
|
6883
|
+
# "cumExecQty": "0.0001",
|
6884
|
+
# "cumExecValue": "10.7005",
|
6885
|
+
# "avgPrice": "107005.4",
|
6886
|
+
# "timeInForce": "gtc",
|
6887
|
+
# "orderStatus": "filled",
|
6888
|
+
# "posSide": "long",
|
6889
|
+
# "holdMode": "hedge_mode",
|
6890
|
+
# "reduceOnly": "NO",
|
6891
|
+
# "feeDetail": [
|
6892
|
+
# {
|
6893
|
+
# "feeCoin": "USDT",
|
6894
|
+
# "fee": "0.00642032"
|
6895
|
+
# }
|
6896
|
+
# ],
|
6897
|
+
# "createdTime": "1751020520442",
|
6898
|
+
# "updatedTime": "1751020520457",
|
6899
|
+
# "cancelReason": "",
|
6900
|
+
# "execType": "normal",
|
6901
|
+
# "stpMode": "none",
|
6902
|
+
# "tpTriggerBy": null,
|
6903
|
+
# "slTriggerBy": null,
|
6904
|
+
# "takeProfit": null,
|
6905
|
+
# "stopLoss": null,
|
6906
|
+
# "tpOrderType": null,
|
6907
|
+
# "slOrderType": null,
|
6908
|
+
# "tpLimitPrice": null,
|
6909
|
+
# "slLimitPrice": null
|
6910
|
+
# },
|
6911
|
+
# ],
|
6912
|
+
# "cursor": "1322441328637100035"
|
6913
|
+
# }
|
6914
|
+
# }
|
6915
|
+
#
|
6916
|
+
# uta trigger
|
6917
|
+
#
|
6918
|
+
# {
|
6919
|
+
# "code": "00000",
|
6920
|
+
# "msg": "success",
|
6921
|
+
# "requestTime": 1753058447920,
|
6922
|
+
# "data": {
|
6923
|
+
# "list": [
|
6924
|
+
# {
|
6925
|
+
# "orderId": "1330984742276198400",
|
6926
|
+
# "clientOid": "1330984742276198400",
|
6927
|
+
# "symbol": "BTCUSDT",
|
6928
|
+
# "category": "USDT-FUTURES",
|
6929
|
+
# "qty": "0.001",
|
6930
|
+
# "posSide": "long",
|
6931
|
+
# "tpTriggerBy": "market",
|
6932
|
+
# "slTriggerBy": "mark",
|
6933
|
+
# "takeProfit": "",
|
6934
|
+
# "stopLoss": "112000",
|
6935
|
+
# "tpOrderType": "market",
|
6936
|
+
# "slOrderType": "limit",
|
6937
|
+
# "tpLimitPrice": "",
|
6938
|
+
# "slLimitPrice": "111000",
|
6939
|
+
# "createdTime": "1753057411736",
|
6940
|
+
# "updatedTime": "1753058267412"
|
6941
|
+
# },
|
6942
|
+
# ],
|
6943
|
+
# "cursor": 1330960754317619202
|
6944
|
+
# }
|
6945
|
+
# }
|
6946
|
+
#
|
6947
|
+
data = self.safe_dict(response, 'data', {})
|
6948
|
+
orders = self.safe_list(data, 'list', [])
|
6949
|
+
return self.parse_orders(orders, market, since, limit)
|
6950
|
+
|
6951
|
+
def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
6952
|
+
"""
|
6953
|
+
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
6954
|
+
|
6955
|
+
https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
|
6956
|
+
https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
|
6957
|
+
|
6958
|
+
:param str [code]: unified currency code, default is None
|
6959
|
+
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
6960
|
+
:param int [limit]: max number of ledger entries to return, default is None
|
6961
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
6962
|
+
:param int [params.until]: end time in ms
|
6963
|
+
:param str [params.symbol]: *contract only* unified market symbol
|
6964
|
+
:param str [params.productType]: *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
6965
|
+
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
6966
|
+
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
|
6967
|
+
"""
|
6968
|
+
self.load_markets()
|
6969
|
+
symbol = self.safe_string(params, 'symbol')
|
6970
|
+
params = self.omit(params, 'symbol')
|
6971
|
+
market = None
|
6972
|
+
if symbol is not None:
|
6973
|
+
market = self.market(symbol)
|
6974
|
+
marketType = None
|
6975
|
+
marketType, params = self.handle_market_type_and_params('fetchLedger', market, params)
|
6976
|
+
paginate = False
|
5922
6977
|
paginate, params = self.handle_option_and_params(params, 'fetchLedger', 'paginate')
|
5923
6978
|
if paginate:
|
5924
6979
|
cursorReceived = None
|
@@ -6108,55 +7163,67 @@ class bitget(Exchange, ImplicitAPI):
|
|
6108
7163
|
https://www.bitget.com/api-doc/contract/trade/Get-Order-Fills
|
6109
7164
|
https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-Fills
|
6110
7165
|
https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Transaction-Details
|
7166
|
+
https://www.bitget.com/api-doc/uta/trade/Get-Order-Fills
|
6111
7167
|
|
6112
7168
|
:param str symbol: unified market symbol
|
6113
7169
|
:param int [since]: the earliest time in ms to fetch trades for
|
6114
7170
|
:param int [limit]: the maximum number of trades structures to retrieve
|
6115
7171
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
6116
7172
|
:param int [params.until]: the latest time in ms to fetch trades for
|
7173
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
6117
7174
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
6118
7175
|
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
6119
7176
|
"""
|
6120
|
-
|
7177
|
+
uta = None
|
7178
|
+
uta, params = self.handle_option_and_params(params, 'fetchMyTrades', 'uta', False)
|
7179
|
+
if not uta and (symbol is None):
|
6121
7180
|
raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol argument')
|
6122
7181
|
self.load_markets()
|
6123
7182
|
market = self.market(symbol)
|
6124
|
-
|
6125
|
-
|
7183
|
+
request: dict = {}
|
7184
|
+
request, params = self.handle_until_option('endTime', request, params)
|
7185
|
+
if since is not None:
|
7186
|
+
request['startTime'] = since
|
7187
|
+
if limit is not None:
|
7188
|
+
request['limit'] = limit
|
6126
7189
|
paginate = False
|
7190
|
+
marginMode = None
|
6127
7191
|
paginate, params = self.handle_option_and_params(params, 'fetchMyTrades', 'paginate')
|
7192
|
+
marginMode, params = self.handle_margin_mode_and_params('fetchMyTrades', params)
|
6128
7193
|
if paginate:
|
6129
7194
|
cursorReceived = None
|
6130
|
-
|
7195
|
+
cursorSent = None
|
7196
|
+
if uta:
|
7197
|
+
cursorReceived = 'cursor'
|
7198
|
+
cursorSent = 'cursor'
|
7199
|
+
elif market['spot']:
|
6131
7200
|
if marginMode is not None:
|
6132
7201
|
cursorReceived = 'minId'
|
7202
|
+
cursorSent = 'idLessThan'
|
6133
7203
|
else:
|
6134
7204
|
cursorReceived = 'endId'
|
6135
|
-
|
7205
|
+
cursorSent = 'idLessThan'
|
7206
|
+
return self.fetch_paginated_call_cursor('fetchMyTrades', symbol, since, limit, params, cursorReceived, cursorSent)
|
6136
7207
|
response = None
|
6137
|
-
|
6138
|
-
|
6139
|
-
}
|
6140
|
-
request, params = self.handle_until_option('endTime', request, params)
|
6141
|
-
if since is not None:
|
6142
|
-
request['startTime'] = since
|
6143
|
-
if limit is not None:
|
6144
|
-
request['limit'] = limit
|
6145
|
-
if market['spot']:
|
6146
|
-
if marginMode is not None:
|
6147
|
-
if since is None:
|
6148
|
-
request['startTime'] = self.milliseconds() - 7776000000
|
6149
|
-
if marginMode == 'isolated':
|
6150
|
-
response = self.privateMarginGetV2MarginIsolatedFills(self.extend(request, params))
|
6151
|
-
elif marginMode == 'cross':
|
6152
|
-
response = self.privateMarginGetV2MarginCrossedFills(self.extend(request, params))
|
6153
|
-
else:
|
6154
|
-
response = self.privateSpotGetV2SpotTradeFills(self.extend(request, params))
|
7208
|
+
if uta:
|
7209
|
+
response = self.privateUtaGetV3TradeFills(self.extend(request, params))
|
6155
7210
|
else:
|
6156
|
-
|
6157
|
-
|
6158
|
-
|
6159
|
-
|
7211
|
+
request['symbol'] = market['id']
|
7212
|
+
if market['spot']:
|
7213
|
+
if marginMode is not None:
|
7214
|
+
if since is None:
|
7215
|
+
request['startTime'] = self.milliseconds() - 7776000000
|
7216
|
+
if marginMode == 'isolated':
|
7217
|
+
response = self.privateMarginGetV2MarginIsolatedFills(self.extend(request, params))
|
7218
|
+
elif marginMode == 'cross':
|
7219
|
+
response = self.privateMarginGetV2MarginCrossedFills(self.extend(request, params))
|
7220
|
+
else:
|
7221
|
+
response = self.privateSpotGetV2SpotTradeFills(self.extend(request, params))
|
7222
|
+
else:
|
7223
|
+
productType = None
|
7224
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
7225
|
+
request['productType'] = productType
|
7226
|
+
response = self.privateMixGetV2MixOrderFills(self.extend(request, params))
|
6160
7227
|
#
|
6161
7228
|
# spot
|
6162
7229
|
#
|
@@ -6256,10 +7323,45 @@ class bitget(Exchange, ImplicitAPI):
|
|
6256
7323
|
# }
|
6257
7324
|
# }
|
6258
7325
|
#
|
7326
|
+
# uta
|
7327
|
+
#
|
7328
|
+
# {
|
7329
|
+
# "code": "00000",
|
7330
|
+
# "msg": "success",
|
7331
|
+
# "requestTime": 1751099666579,
|
7332
|
+
# "data": {
|
7333
|
+
# "list": [
|
7334
|
+
# {
|
7335
|
+
# "execId": "1322441401010528257",
|
7336
|
+
# "orderId": "1322441400976261120",
|
7337
|
+
# "category": "USDT-FUTURES",
|
7338
|
+
# "symbol": "BTCUSDT",
|
7339
|
+
# "orderType": "market",
|
7340
|
+
# "side": "sell",
|
7341
|
+
# "execPrice": "107005.4",
|
7342
|
+
# "execQty": "0.0001",
|
7343
|
+
# "execValue": "10.7005",
|
7344
|
+
# "tradeScope": "taker",
|
7345
|
+
# "feeDetail": [{
|
7346
|
+
# "feeCoin": "USDT",
|
7347
|
+
# "fee":"0.00642032"
|
7348
|
+
# }],
|
7349
|
+
# "createdTime": "1751020520451",
|
7350
|
+
# "updatedTime": "1751020520458",
|
7351
|
+
# "execPnl": "0.00017"
|
7352
|
+
# },
|
7353
|
+
# ],
|
7354
|
+
# "cursor": "1322061241878880257"
|
7355
|
+
# }
|
7356
|
+
# }
|
7357
|
+
#
|
6259
7358
|
data = self.safe_value(response, 'data')
|
6260
|
-
if
|
6261
|
-
|
6262
|
-
return self.parse_trades(
|
7359
|
+
if uta:
|
7360
|
+
fills = self.safe_list(data, 'list', [])
|
7361
|
+
return self.parse_trades(fills, market, since, limit)
|
7362
|
+
elif (market['swap'] or (market['future'])):
|
7363
|
+
fills = self.safe_list(data, 'fillList', [])
|
7364
|
+
return self.parse_trades(fills, market, since, limit)
|
6263
7365
|
elif marginMode is not None:
|
6264
7366
|
fills = self.safe_list(data, 'fills', [])
|
6265
7367
|
return self.parse_trades(fills, market, since, limit)
|
@@ -6270,9 +7372,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
6270
7372
|
fetch data on a single open contract trade position
|
6271
7373
|
|
6272
7374
|
https://www.bitget.com/api-doc/contract/position/get-single-position
|
7375
|
+
https://www.bitget.com/api-doc/uta/trade/Get-Position
|
6273
7376
|
|
6274
7377
|
:param str symbol: unified market symbol of the market the position is held in
|
6275
7378
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7379
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
6276
7380
|
:returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
6277
7381
|
"""
|
6278
7382
|
self.load_markets()
|
@@ -6281,42 +7385,90 @@ class bitget(Exchange, ImplicitAPI):
|
|
6281
7385
|
productType, params = self.handle_product_type_and_params(market, params)
|
6282
7386
|
request: dict = {
|
6283
7387
|
'symbol': market['id'],
|
6284
|
-
'marginCoin': market['settleId'],
|
6285
|
-
'productType': productType,
|
6286
7388
|
}
|
6287
|
-
response =
|
6288
|
-
|
6289
|
-
|
6290
|
-
|
6291
|
-
|
6292
|
-
|
6293
|
-
|
6294
|
-
|
6295
|
-
|
6296
|
-
|
6297
|
-
|
6298
|
-
|
6299
|
-
|
6300
|
-
|
6301
|
-
|
6302
|
-
|
6303
|
-
|
6304
|
-
|
6305
|
-
|
6306
|
-
|
6307
|
-
|
6308
|
-
|
6309
|
-
|
6310
|
-
|
6311
|
-
|
6312
|
-
|
6313
|
-
|
6314
|
-
|
6315
|
-
|
6316
|
-
|
6317
|
-
|
6318
|
-
|
6319
|
-
|
7389
|
+
response = None
|
7390
|
+
uta = None
|
7391
|
+
result = None
|
7392
|
+
uta, params = self.handle_option_and_params(params, 'fetchPosition', 'uta', False)
|
7393
|
+
if uta:
|
7394
|
+
request['category'] = productType
|
7395
|
+
response = self.privateUtaGetV3PositionCurrentPosition(self.extend(request, params))
|
7396
|
+
#
|
7397
|
+
# {
|
7398
|
+
# "code": "00000",
|
7399
|
+
# "msg": "success",
|
7400
|
+
# "requestTime": 1750929905423,
|
7401
|
+
# "data": {
|
7402
|
+
# "list": [
|
7403
|
+
# {
|
7404
|
+
# "category": "USDT-FUTURES",
|
7405
|
+
# "symbol": "BTCUSDT",
|
7406
|
+
# "marginCoin": "USDT",
|
7407
|
+
# "holdMode": "hedge_mode",
|
7408
|
+
# "posSide": "long",
|
7409
|
+
# "marginMode": "crossed",
|
7410
|
+
# "positionBalance": "5.435199",
|
7411
|
+
# "available": "0.001",
|
7412
|
+
# "frozen": "0",
|
7413
|
+
# "total": "0.001",
|
7414
|
+
# "leverage": "20",
|
7415
|
+
# "curRealisedPnl": "0",
|
7416
|
+
# "avgPrice": "107410.3",
|
7417
|
+
# "positionStatus": "normal",
|
7418
|
+
# "unrealisedPnl": "0.0047",
|
7419
|
+
# "liquidationPrice": "0",
|
7420
|
+
# "mmr": "0.004",
|
7421
|
+
# "profitRate": "0.0008647337475591",
|
7422
|
+
# "markPrice": "107415.3",
|
7423
|
+
# "breakEvenPrice": "107539.2",
|
7424
|
+
# "totalFunding": "0",
|
7425
|
+
# "openFeeTotal": "-0.06444618",
|
7426
|
+
# "closeFeeTotal": "0",
|
7427
|
+
# "createdTime": "1750495670699",
|
7428
|
+
# "updatedTime": "1750929883465"
|
7429
|
+
# }
|
7430
|
+
# ]
|
7431
|
+
# }
|
7432
|
+
# }
|
7433
|
+
#
|
7434
|
+
data = self.safe_dict(response, 'data', {})
|
7435
|
+
result = self.safe_list(data, 'list', [])
|
7436
|
+
else:
|
7437
|
+
request['marginCoin'] = market['settleId']
|
7438
|
+
request['productType'] = productType
|
7439
|
+
response = self.privateMixGetV2MixPositionSinglePosition(self.extend(request, params))
|
7440
|
+
#
|
7441
|
+
# {
|
7442
|
+
# "code": "00000",
|
7443
|
+
# "msg": "success",
|
7444
|
+
# "requestTime": 1700807531673,
|
7445
|
+
# "data": [
|
7446
|
+
# {
|
7447
|
+
# "marginCoin": "USDT",
|
7448
|
+
# "symbol": "BTCUSDT",
|
7449
|
+
# "holdSide": "long",
|
7450
|
+
# "openDelegateSize": "0",
|
7451
|
+
# "marginSize": "3.73555",
|
7452
|
+
# "available": "0.002",
|
7453
|
+
# "locked": "0",
|
7454
|
+
# "total": "0.002",
|
7455
|
+
# "leverage": "20",
|
7456
|
+
# "achievedProfits": "0",
|
7457
|
+
# "openPriceAvg": "37355.5",
|
7458
|
+
# "marginMode": "crossed",
|
7459
|
+
# "posMode": "hedge_mode",
|
7460
|
+
# "unrealizedPL": "0.007",
|
7461
|
+
# "liquidationPrice": "31724.970702417",
|
7462
|
+
# "keepMarginRate": "0.004",
|
7463
|
+
# "markPrice": "37359",
|
7464
|
+
# "marginRatio": "0.029599540355",
|
7465
|
+
# "cTime": "1700807507275"
|
7466
|
+
# }
|
7467
|
+
# ]
|
7468
|
+
# }
|
7469
|
+
#
|
7470
|
+
result = self.safe_list(response, 'data', [])
|
7471
|
+
first = self.safe_dict(result, 0, {})
|
6320
7472
|
return self.parse_position(first, market)
|
6321
7473
|
|
6322
7474
|
def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
|
@@ -6479,6 +7631,36 @@ class bitget(Exchange, ImplicitAPI):
|
|
6479
7631
|
# "cTime": "1700807507275"
|
6480
7632
|
# }
|
6481
7633
|
#
|
7634
|
+
# uta: fetchPosition
|
7635
|
+
#
|
7636
|
+
# {
|
7637
|
+
# "category": "USDT-FUTURES",
|
7638
|
+
# "symbol": "BTCUSDT",
|
7639
|
+
# "marginCoin": "USDT",
|
7640
|
+
# "holdMode": "hedge_mode",
|
7641
|
+
# "posSide": "long",
|
7642
|
+
# "marginMode": "crossed",
|
7643
|
+
# "positionBalance": "5.435199",
|
7644
|
+
# "available": "0.001",
|
7645
|
+
# "frozen": "0",
|
7646
|
+
# "total": "0.001",
|
7647
|
+
# "leverage": "20",
|
7648
|
+
# "curRealisedPnl": "0",
|
7649
|
+
# "avgPrice": "107410.3",
|
7650
|
+
# "positionStatus": "normal",
|
7651
|
+
# "unrealisedPnl": "0.0047",
|
7652
|
+
# "liquidationPrice": "0",
|
7653
|
+
# "mmr": "0.004",
|
7654
|
+
# "profitRate": "0.0008647337475591",
|
7655
|
+
# "markPrice": "107415.3",
|
7656
|
+
# "breakEvenPrice": "107539.2",
|
7657
|
+
# "totalFunding": "0",
|
7658
|
+
# "openFeeTotal": "-0.06444618",
|
7659
|
+
# "closeFeeTotal": "0",
|
7660
|
+
# "createdTime": "1750495670699",
|
7661
|
+
# "updatedTime": "1750929883465"
|
7662
|
+
# }
|
7663
|
+
#
|
6482
7664
|
# fetchPositions: privateMixGetV2MixPositionAllPosition
|
6483
7665
|
#
|
6484
7666
|
# {
|
@@ -6530,32 +7712,55 @@ class bitget(Exchange, ImplicitAPI):
|
|
6530
7712
|
# "clientOid": "1120923953904893956"
|
6531
7713
|
# }
|
6532
7714
|
#
|
7715
|
+
# uta: fetchPositionsHistory
|
7716
|
+
#
|
7717
|
+
# {
|
7718
|
+
# "positionId": "1322441328637100049",
|
7719
|
+
# "category": "USDT-FUTURES",
|
7720
|
+
# "symbol": "BTCUSDT",
|
7721
|
+
# "marginCoin": "USDT",
|
7722
|
+
# "holdMode": "hedge_mode",
|
7723
|
+
# "posSide": "long",
|
7724
|
+
# "marginMode": "crossed",
|
7725
|
+
# "openPriceAvg": "107003.7",
|
7726
|
+
# "closePriceAvg": "107005.4",
|
7727
|
+
# "openTotalPos": "0.0001",
|
7728
|
+
# "closeTotalPos": "0.0001",
|
7729
|
+
# "cumRealisedPnl": "0.00017",
|
7730
|
+
# "netProfit": "-0.01267055",
|
7731
|
+
# "totalFunding": "0",
|
7732
|
+
# "openFeeTotal": "-0.00642022",
|
7733
|
+
# "closeFeeTotal": "-0.00642032",
|
7734
|
+
# "createdTime": "1751020503195",
|
7735
|
+
# "updatedTime": "1751020520458"
|
7736
|
+
# }
|
7737
|
+
#
|
6533
7738
|
marketId = self.safe_string(position, 'symbol')
|
6534
7739
|
market = self.safe_market(marketId, market, None, 'contract')
|
6535
7740
|
symbol = market['symbol']
|
6536
|
-
timestamp = self.
|
7741
|
+
timestamp = self.safe_integer_n(position, ['cTime', 'ctime', 'createdTime'])
|
6537
7742
|
marginMode = self.safe_string(position, 'marginMode')
|
6538
7743
|
collateral = None
|
6539
7744
|
initialMargin = None
|
6540
|
-
unrealizedPnl = self.
|
6541
|
-
rawCollateral = self.
|
7745
|
+
unrealizedPnl = self.safe_string_2(position, 'unrealizedPL', 'unrealisedPnl')
|
7746
|
+
rawCollateral = self.safe_string_2(position, 'marginSize', 'positionBalance')
|
6542
7747
|
if marginMode == 'isolated':
|
6543
7748
|
collateral = Precise.string_add(rawCollateral, unrealizedPnl)
|
6544
7749
|
elif marginMode == 'crossed':
|
6545
7750
|
marginMode = 'cross'
|
6546
7751
|
initialMargin = rawCollateral
|
6547
|
-
holdMode = self.
|
7752
|
+
holdMode = self.safe_string_2(position, 'posMode', 'holdMode')
|
6548
7753
|
hedged = None
|
6549
7754
|
if holdMode == 'hedge_mode':
|
6550
7755
|
hedged = True
|
6551
7756
|
elif holdMode == 'one_way_mode':
|
6552
7757
|
hedged = False
|
6553
|
-
side = self.
|
7758
|
+
side = self.safe_string_2(position, 'holdSide', 'posSide')
|
6554
7759
|
leverage = self.safe_string(position, 'leverage')
|
6555
7760
|
contractSizeNumber = self.safe_value(market, 'contractSize')
|
6556
7761
|
contractSize = self.number_to_string(contractSizeNumber)
|
6557
|
-
baseAmount = self.
|
6558
|
-
entryPrice = self.
|
7762
|
+
baseAmount = self.safe_string_2(position, 'total', 'openTotalPos')
|
7763
|
+
entryPrice = self.safe_string_n(position, ['openPriceAvg', 'openAvgPrice', 'avgPrice'])
|
6559
7764
|
maintenanceMarginPercentage = self.safe_string(position, 'keepMarginRate')
|
6560
7765
|
openNotional = Precise.string_mul(entryPrice, baseAmount)
|
6561
7766
|
if initialMargin is None:
|
@@ -6587,31 +7792,31 @@ class bitget(Exchange, ImplicitAPI):
|
|
6587
7792
|
percentage = Precise.string_mul(Precise.string_div(unrealizedPnl, initialMargin, 4), '100')
|
6588
7793
|
return self.safe_position({
|
6589
7794
|
'info': position,
|
6590
|
-
'id': self.
|
7795
|
+
'id': self.safe_string_2(position, 'orderId', 'positionId'),
|
6591
7796
|
'symbol': symbol,
|
6592
7797
|
'notional': self.parse_number(notional),
|
6593
7798
|
'marginMode': marginMode,
|
6594
7799
|
'liquidationPrice': liquidationPrice,
|
6595
7800
|
'entryPrice': self.parse_number(entryPrice),
|
6596
7801
|
'unrealizedPnl': self.parse_number(unrealizedPnl),
|
6597
|
-
'realizedPnl': self.
|
7802
|
+
'realizedPnl': self.safe_number_n(position, ['pnl', 'curRealisedPnl', 'cumRealisedPnl']),
|
6598
7803
|
'percentage': self.parse_number(percentage),
|
6599
7804
|
'contracts': contracts,
|
6600
7805
|
'contractSize': contractSizeNumber,
|
6601
7806
|
'markPrice': self.parse_number(markPrice),
|
6602
|
-
'lastPrice': self.
|
7807
|
+
'lastPrice': self.safe_number_2(position, 'closeAvgPrice', 'closePriceAvg'),
|
6603
7808
|
'side': side,
|
6604
7809
|
'hedged': hedged,
|
6605
7810
|
'timestamp': timestamp,
|
6606
7811
|
'datetime': self.iso8601(timestamp),
|
6607
|
-
'lastUpdateTimestamp': self.
|
7812
|
+
'lastUpdateTimestamp': self.safe_integer_2(position, 'utime', 'updatedTime'),
|
6608
7813
|
'maintenanceMargin': self.parse_number(maintenanceMargin),
|
6609
7814
|
'maintenanceMarginPercentage': self.parse_number(maintenanceMarginPercentage),
|
6610
7815
|
'collateral': self.parse_number(collateral),
|
6611
7816
|
'initialMargin': self.parse_number(initialMargin),
|
6612
7817
|
'initialMarginPercentage': self.parse_number(initialMarginPercentage),
|
6613
7818
|
'leverage': self.parse_number(leverage),
|
6614
|
-
'marginRatio': self.
|
7819
|
+
'marginRatio': self.safe_number_2(position, 'marginRatio', 'mmr'),
|
6615
7820
|
'stopLossPrice': None,
|
6616
7821
|
'takeProfitPrice': None,
|
6617
7822
|
})
|
@@ -6621,54 +7826,82 @@ class bitget(Exchange, ImplicitAPI):
|
|
6621
7826
|
fetches historical funding rate prices
|
6622
7827
|
|
6623
7828
|
https://www.bitget.com/api-doc/contract/market/Get-History-Funding-Rate
|
7829
|
+
https://www.bitget.com/api-doc/uta/public/Get-History-Funding-Rate
|
6624
7830
|
|
6625
7831
|
:param str symbol: unified symbol of the market to fetch the funding rate history for
|
6626
7832
|
:param int [since]: timestamp in ms of the earliest funding rate to fetch
|
6627
7833
|
:param int [limit]: the maximum amount of funding rate structures to fetch
|
6628
7834
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7835
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
6629
7836
|
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
6630
7837
|
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
|
6631
7838
|
"""
|
6632
7839
|
if symbol is None:
|
6633
7840
|
raise ArgumentsRequired(self.id + ' fetchFundingRateHistory() requires a symbol argument')
|
6634
7841
|
self.load_markets()
|
6635
|
-
paginate = False
|
6636
|
-
paginate, params = self.handle_option_and_params(params, 'fetchFundingRateHistory', 'paginate')
|
6637
|
-
if paginate:
|
6638
|
-
return self.fetch_paginated_call_incremental('fetchFundingRateHistory', symbol, since, limit, params, 'pageNo', 100)
|
6639
7842
|
market = self.market(symbol)
|
6640
|
-
productType = None
|
6641
|
-
productType, params = self.handle_product_type_and_params(market, params)
|
6642
7843
|
request: dict = {
|
6643
7844
|
'symbol': market['id'],
|
6644
|
-
'productType': productType,
|
6645
|
-
# 'pageSize': limit, # default 20
|
6646
|
-
# 'pageNo': 1,
|
6647
7845
|
}
|
6648
|
-
|
6649
|
-
|
6650
|
-
response =
|
6651
|
-
|
6652
|
-
|
6653
|
-
|
6654
|
-
|
6655
|
-
|
6656
|
-
|
6657
|
-
|
6658
|
-
|
6659
|
-
|
6660
|
-
|
6661
|
-
|
6662
|
-
|
6663
|
-
|
6664
|
-
|
6665
|
-
|
7846
|
+
productType = None
|
7847
|
+
uta = None
|
7848
|
+
response = None
|
7849
|
+
result = None
|
7850
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
7851
|
+
uta, params = self.handle_option_and_params(params, 'fetchFundingRateHistory', 'uta', False)
|
7852
|
+
if uta:
|
7853
|
+
if limit is not None:
|
7854
|
+
request['limit'] = limit
|
7855
|
+
request['category'] = productType
|
7856
|
+
response = self.publicUtaGetV3MarketHistoryFundRate(self.extend(request, params))
|
7857
|
+
#
|
7858
|
+
# {
|
7859
|
+
# "code": "00000",
|
7860
|
+
# "msg": "success",
|
7861
|
+
# "requestTime": 1750435113658,
|
7862
|
+
# "data": {
|
7863
|
+
# "resultList": [
|
7864
|
+
# {
|
7865
|
+
# "symbol": "BTCUSDT",
|
7866
|
+
# "fundingRate": "-0.000017",
|
7867
|
+
# "fundingRateTimestamp": "1750431600000"
|
7868
|
+
# },
|
7869
|
+
# ]
|
7870
|
+
# }
|
7871
|
+
# }
|
7872
|
+
#
|
7873
|
+
data = self.safe_dict(response, 'data', {})
|
7874
|
+
result = self.safe_list(data, 'resultList', [])
|
7875
|
+
else:
|
7876
|
+
paginate = False
|
7877
|
+
paginate, params = self.handle_option_and_params(params, 'fetchFundingRateHistory', 'paginate')
|
7878
|
+
if paginate:
|
7879
|
+
return self.fetch_paginated_call_incremental('fetchFundingRateHistory', symbol, since, limit, params, 'pageNo', 100)
|
7880
|
+
if limit is not None:
|
7881
|
+
request['pageSize'] = limit
|
7882
|
+
request['productType'] = productType
|
7883
|
+
response = self.publicMixGetV2MixMarketHistoryFundRate(self.extend(request, params))
|
7884
|
+
#
|
7885
|
+
# {
|
7886
|
+
# "code": "00000",
|
7887
|
+
# "msg": "success",
|
7888
|
+
# "requestTime": 1652406728393,
|
7889
|
+
# "data": [
|
7890
|
+
# {
|
7891
|
+
# "symbol": "BTCUSDT",
|
7892
|
+
# "fundingRate": "-0.0003",
|
7893
|
+
# "fundingTime": "1652396400000"
|
7894
|
+
# },
|
7895
|
+
# ]
|
7896
|
+
# }
|
7897
|
+
#
|
7898
|
+
result = self.safe_list(response, 'data', [])
|
6666
7899
|
rates = []
|
6667
|
-
for i in range(0, len(
|
6668
|
-
entry =
|
7900
|
+
for i in range(0, len(result)):
|
7901
|
+
entry = result[i]
|
6669
7902
|
marketId = self.safe_string(entry, 'symbol')
|
6670
7903
|
symbolInner = self.safe_symbol(marketId, market)
|
6671
|
-
timestamp = self.
|
7904
|
+
timestamp = self.safe_integer_2(entry, 'fundingTime', 'fundingRateTimestamp')
|
6672
7905
|
rates.append({
|
6673
7906
|
'info': entry,
|
6674
7907
|
'symbol': symbolInner,
|
@@ -6685,9 +7918,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
6685
7918
|
|
6686
7919
|
https://www.bitget.com/api-doc/contract/market/Get-Current-Funding-Rate
|
6687
7920
|
https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
|
7921
|
+
https://www.bitget.com/api-doc/uta/public/Get-Current-Funding-Rate
|
6688
7922
|
|
6689
7923
|
:param str symbol: unified market symbol
|
6690
7924
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7925
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
6691
7926
|
:param str [params.method]: either(default) 'publicMixGetV2MixMarketCurrentFundRate' or 'publicMixGetV2MixMarketFundingTime'
|
6692
7927
|
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
6693
7928
|
"""
|
@@ -6699,46 +7934,68 @@ class bitget(Exchange, ImplicitAPI):
|
|
6699
7934
|
productType, params = self.handle_product_type_and_params(market, params)
|
6700
7935
|
request: dict = {
|
6701
7936
|
'symbol': market['id'],
|
6702
|
-
'productType': productType,
|
6703
7937
|
}
|
6704
|
-
|
6705
|
-
method, params = self.handle_option_and_params(params, 'fetchFundingRate', 'method', 'publicMixGetV2MixMarketCurrentFundRate')
|
7938
|
+
uta = None
|
6706
7939
|
response = None
|
6707
|
-
|
6708
|
-
|
7940
|
+
uta, params = self.handle_option_and_params(params, 'fetchFundingRate', 'uta', False)
|
7941
|
+
if uta:
|
7942
|
+
response = self.publicUtaGetV3MarketCurrentFundRate(self.extend(request, params))
|
6709
7943
|
#
|
6710
7944
|
# {
|
6711
7945
|
# "code": "00000",
|
6712
7946
|
# "msg": "success",
|
6713
|
-
# "requestTime":
|
7947
|
+
# "requestTime": 1750897372153,
|
6714
7948
|
# "data": [
|
6715
7949
|
# {
|
6716
7950
|
# "symbol": "BTCUSDT",
|
6717
|
-
# "fundingRate": "
|
7951
|
+
# "fundingRate": "0.00001",
|
6718
7952
|
# "fundingRateInterval": "8",
|
6719
|
-
# "nextUpdate": "
|
7953
|
+
# "nextUpdate": "1750924800000",
|
6720
7954
|
# "minFundingRate": "-0.003",
|
6721
7955
|
# "maxFundingRate": "0.003"
|
6722
7956
|
# }
|
6723
7957
|
# ]
|
6724
7958
|
# }
|
6725
7959
|
#
|
6726
|
-
|
6727
|
-
|
6728
|
-
|
6729
|
-
|
6730
|
-
|
6731
|
-
|
6732
|
-
|
6733
|
-
|
6734
|
-
|
6735
|
-
|
6736
|
-
|
6737
|
-
|
6738
|
-
|
6739
|
-
|
6740
|
-
|
6741
|
-
|
7960
|
+
else:
|
7961
|
+
request['productType'] = productType
|
7962
|
+
method = None
|
7963
|
+
method, params = self.handle_option_and_params(params, 'fetchFundingRate', 'method', 'publicMixGetV2MixMarketCurrentFundRate')
|
7964
|
+
if method == 'publicMixGetV2MixMarketCurrentFundRate':
|
7965
|
+
response = self.publicMixGetV2MixMarketCurrentFundRate(self.extend(request, params))
|
7966
|
+
#
|
7967
|
+
# {
|
7968
|
+
# "code": "00000",
|
7969
|
+
# "msg": "success",
|
7970
|
+
# "requestTime": 1745500709429,
|
7971
|
+
# "data": [
|
7972
|
+
# {
|
7973
|
+
# "symbol": "BTCUSDT",
|
7974
|
+
# "fundingRate": "-0.000013",
|
7975
|
+
# "fundingRateInterval": "8",
|
7976
|
+
# "nextUpdate": "1745510400000",
|
7977
|
+
# "minFundingRate": "-0.003",
|
7978
|
+
# "maxFundingRate": "0.003"
|
7979
|
+
# }
|
7980
|
+
# ]
|
7981
|
+
# }
|
7982
|
+
#
|
7983
|
+
elif method == 'publicMixGetV2MixMarketFundingTime':
|
7984
|
+
response = self.publicMixGetV2MixMarketFundingTime(self.extend(request, params))
|
7985
|
+
#
|
7986
|
+
# {
|
7987
|
+
# "code": "00000",
|
7988
|
+
# "msg": "success",
|
7989
|
+
# "requestTime": 1745402092428,
|
7990
|
+
# "data": [
|
7991
|
+
# {
|
7992
|
+
# "symbol": "BTCUSDT",
|
7993
|
+
# "nextFundingTime": "1745424000000",
|
7994
|
+
# "ratePeriod": "8"
|
7995
|
+
# }
|
7996
|
+
# ]
|
7997
|
+
# }
|
7998
|
+
#
|
6742
7999
|
data = self.safe_list(response, 'data', [])
|
6743
8000
|
return self.parse_funding_rate(data[0], market)
|
6744
8001
|
|
@@ -6802,7 +8059,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6802
8059
|
|
6803
8060
|
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
6804
8061
|
#
|
6805
|
-
# fetchFundingRate: publicMixGetV2MixMarketCurrentFundRate
|
8062
|
+
# fetchFundingRate: publicMixGetV2MixMarketCurrentFundRate, publicUtaGetV3MarketCurrentFundRate
|
6806
8063
|
#
|
6807
8064
|
# {
|
6808
8065
|
# "symbol": "BTCUSDT",
|
@@ -7143,16 +8400,19 @@ class bitget(Exchange, ImplicitAPI):
|
|
7143
8400
|
'shortLeverage': self.safe_integer(leverage, shortLevKey),
|
7144
8401
|
}
|
7145
8402
|
|
7146
|
-
def set_leverage(self, leverage:
|
8403
|
+
def set_leverage(self, leverage: int, symbol: Str = None, params={}):
|
7147
8404
|
"""
|
7148
8405
|
set the level of leverage for a market
|
7149
8406
|
|
7150
8407
|
https://www.bitget.com/api-doc/contract/account/Change-Leverage
|
8408
|
+
https://www.bitget.com/api-doc/uta/account/Change-Leverage
|
7151
8409
|
|
7152
8410
|
:param int leverage: the rate of leverage
|
7153
8411
|
:param str symbol: unified market symbol
|
7154
8412
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7155
8413
|
:param str [params.holdSide]: *isolated only* position direction, 'long' or 'short'
|
8414
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
8415
|
+
:param boolean [params.posSide]: required for uta isolated margin, long or short
|
7156
8416
|
:returns dict: response from the exchange
|
7157
8417
|
"""
|
7158
8418
|
if symbol is None:
|
@@ -7163,27 +8423,47 @@ class bitget(Exchange, ImplicitAPI):
|
|
7163
8423
|
productType, params = self.handle_product_type_and_params(market, params)
|
7164
8424
|
request: dict = {
|
7165
8425
|
'symbol': market['id'],
|
7166
|
-
'marginCoin': market['settleId'],
|
7167
8426
|
'leverage': self.number_to_string(leverage),
|
7168
|
-
'productType': productType,
|
7169
|
-
# 'holdSide': 'long',
|
7170
8427
|
}
|
7171
|
-
|
7172
|
-
|
7173
|
-
|
7174
|
-
|
7175
|
-
|
7176
|
-
|
7177
|
-
|
7178
|
-
|
7179
|
-
|
7180
|
-
|
7181
|
-
|
7182
|
-
|
7183
|
-
|
7184
|
-
|
7185
|
-
|
7186
|
-
|
8428
|
+
uta = None
|
8429
|
+
response = None
|
8430
|
+
uta, params = self.handle_option_and_params(params, 'setLeverage', 'uta', False)
|
8431
|
+
if uta:
|
8432
|
+
if productType == 'SPOT':
|
8433
|
+
marginMode = None
|
8434
|
+
marginMode, params = self.handle_margin_mode_and_params('fetchTrades', params)
|
8435
|
+
if marginMode is not None:
|
8436
|
+
productType = 'MARGIN'
|
8437
|
+
request['coin'] = market['settleId']
|
8438
|
+
request['category'] = productType
|
8439
|
+
response = self.privateUtaPostV3AccountSetLeverage(self.extend(request, params))
|
8440
|
+
#
|
8441
|
+
# {
|
8442
|
+
# "code": "00000",
|
8443
|
+
# "msg": "success",
|
8444
|
+
# "requestTime": 1752815940833,
|
8445
|
+
# "data": "success"
|
8446
|
+
# }
|
8447
|
+
#
|
8448
|
+
else:
|
8449
|
+
request['marginCoin'] = market['settleId']
|
8450
|
+
request['productType'] = productType
|
8451
|
+
response = self.privateMixPostV2MixAccountSetLeverage(self.extend(request, params))
|
8452
|
+
#
|
8453
|
+
# {
|
8454
|
+
# "code": "00000",
|
8455
|
+
# "msg": "success",
|
8456
|
+
# "requestTime": 1700864711517,
|
8457
|
+
# "data": {
|
8458
|
+
# "symbol": "BTCUSDT",
|
8459
|
+
# "marginCoin": "USDT",
|
8460
|
+
# "longLeverage": "25",
|
8461
|
+
# "shortLeverage": "25",
|
8462
|
+
# "crossMarginLeverage": "25",
|
8463
|
+
# "marginMode": "crossed"
|
8464
|
+
# }
|
8465
|
+
# }
|
8466
|
+
#
|
7187
8467
|
return response
|
7188
8468
|
|
7189
8469
|
def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
|
@@ -7236,35 +8516,51 @@ class bitget(Exchange, ImplicitAPI):
|
|
7236
8516
|
set hedged to True or False for a market
|
7237
8517
|
|
7238
8518
|
https://www.bitget.com/api-doc/contract/account/Change-Hold-Mode
|
8519
|
+
https://www.bitget.com/api-doc/uta/account/Change-Position-Mode
|
7239
8520
|
|
7240
8521
|
:param bool hedged: set to True to use dualSidePosition
|
7241
8522
|
:param str symbol: not used by bitget setPositionMode()
|
7242
8523
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
7243
|
-
:param str [params.productType]: required if symbol is None: 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
8524
|
+
:param str [params.productType]: required if not uta and symbol is None: 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
8525
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
7244
8526
|
:returns dict: response from the exchange
|
7245
8527
|
"""
|
7246
8528
|
self.load_markets()
|
7247
8529
|
posMode = 'hedge_mode' if hedged else 'one_way_mode'
|
8530
|
+
request: dict = {}
|
7248
8531
|
market = None
|
7249
8532
|
if symbol is not None:
|
7250
8533
|
market = self.market(symbol)
|
7251
8534
|
productType = None
|
8535
|
+
uta = None
|
8536
|
+
response = None
|
7252
8537
|
productType, params = self.handle_product_type_and_params(market, params)
|
7253
|
-
|
7254
|
-
|
7255
|
-
'
|
7256
|
-
|
7257
|
-
|
7258
|
-
|
7259
|
-
|
7260
|
-
|
7261
|
-
|
7262
|
-
|
7263
|
-
|
7264
|
-
|
7265
|
-
|
7266
|
-
|
7267
|
-
|
8538
|
+
uta, params = self.handle_option_and_params(params, 'setPositionMode', 'uta', False)
|
8539
|
+
if uta:
|
8540
|
+
request['holdMode'] = posMode
|
8541
|
+
response = self.privateUtaPostV3AccountSetHoldMode(self.extend(request, params))
|
8542
|
+
#
|
8543
|
+
# {
|
8544
|
+
# "code": "00000",
|
8545
|
+
# "msg": "success",
|
8546
|
+
# "requestTime": 1752816734592,
|
8547
|
+
# "data": "success"
|
8548
|
+
# }
|
8549
|
+
#
|
8550
|
+
else:
|
8551
|
+
request['posMode'] = posMode
|
8552
|
+
request['productType'] = productType
|
8553
|
+
response = self.privateMixPostV2MixAccountSetPositionMode(self.extend(request, params))
|
8554
|
+
#
|
8555
|
+
# {
|
8556
|
+
# "code": "00000",
|
8557
|
+
# "msg": "success",
|
8558
|
+
# "requestTime": 1700865608009,
|
8559
|
+
# "data": {
|
8560
|
+
# "posMode": "hedge_mode"
|
8561
|
+
# }
|
8562
|
+
# }
|
8563
|
+
#
|
7268
8564
|
return response
|
7269
8565
|
|
7270
8566
|
def fetch_open_interest(self, symbol: str, params={}):
|
@@ -7272,9 +8568,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
7272
8568
|
retrieves the open interest of a contract trading pair
|
7273
8569
|
|
7274
8570
|
https://www.bitget.com/api-doc/contract/market/Get-Open-Interest
|
8571
|
+
https://www.bitget.com/api-doc/uta/public/Get-Open-Interest
|
7275
8572
|
|
7276
8573
|
:param str symbol: unified CCXT market symbol
|
7277
8574
|
:param dict [params]: exchange specific parameters
|
8575
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
7278
8576
|
:returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
|
7279
8577
|
"""
|
7280
8578
|
self.load_markets()
|
@@ -7285,29 +8583,54 @@ class bitget(Exchange, ImplicitAPI):
|
|
7285
8583
|
productType, params = self.handle_product_type_and_params(market, params)
|
7286
8584
|
request: dict = {
|
7287
8585
|
'symbol': market['id'],
|
7288
|
-
'productType': productType,
|
7289
8586
|
}
|
7290
|
-
|
7291
|
-
|
7292
|
-
|
7293
|
-
|
7294
|
-
|
7295
|
-
|
7296
|
-
|
7297
|
-
|
7298
|
-
|
7299
|
-
|
7300
|
-
|
7301
|
-
|
7302
|
-
|
7303
|
-
|
7304
|
-
|
7305
|
-
|
7306
|
-
|
8587
|
+
uta = None
|
8588
|
+
response = None
|
8589
|
+
uta, params = self.handle_option_and_params(params, 'fetchOpenInterest', 'uta', False)
|
8590
|
+
if uta:
|
8591
|
+
request['category'] = productType
|
8592
|
+
response = self.publicUtaGetV3MarketOpenInterest(self.extend(request, params))
|
8593
|
+
#
|
8594
|
+
# {
|
8595
|
+
# "code": "00000",
|
8596
|
+
# "msg": "success",
|
8597
|
+
# "requestTime": 1751101221545,
|
8598
|
+
# "data": {
|
8599
|
+
# "list": [
|
8600
|
+
# {
|
8601
|
+
# "symbol": "BTCUSDT",
|
8602
|
+
# "openInterest": "18166.3583"
|
8603
|
+
# }
|
8604
|
+
# ],
|
8605
|
+
# "ts": "1751101220993"
|
8606
|
+
# }
|
8607
|
+
# }
|
8608
|
+
#
|
8609
|
+
else:
|
8610
|
+
request['productType'] = productType
|
8611
|
+
response = self.publicMixGetV2MixMarketOpenInterest(self.extend(request, params))
|
8612
|
+
#
|
8613
|
+
# {
|
8614
|
+
# "code": "00000",
|
8615
|
+
# "msg": "success",
|
8616
|
+
# "requestTime": 1700866041022,
|
8617
|
+
# "data": {
|
8618
|
+
# "openInterestList": [
|
8619
|
+
# {
|
8620
|
+
# "symbol": "BTCUSDT",
|
8621
|
+
# "size": "52234.134"
|
8622
|
+
# }
|
8623
|
+
# ],
|
8624
|
+
# "ts": "1700866041023"
|
8625
|
+
# }
|
8626
|
+
# }
|
8627
|
+
#
|
7307
8628
|
data = self.safe_dict(response, 'data', {})
|
7308
8629
|
return self.parse_open_interest(data, market)
|
7309
8630
|
|
7310
8631
|
def parse_open_interest(self, interest, market: Market = None):
|
8632
|
+
#
|
8633
|
+
# default
|
7311
8634
|
#
|
7312
8635
|
# {
|
7313
8636
|
# "openInterestList": [
|
@@ -7319,12 +8642,24 @@ class bitget(Exchange, ImplicitAPI):
|
|
7319
8642
|
# "ts": "1700866041023"
|
7320
8643
|
# }
|
7321
8644
|
#
|
7322
|
-
|
8645
|
+
# uta
|
8646
|
+
#
|
8647
|
+
# {
|
8648
|
+
# "list": [
|
8649
|
+
# {
|
8650
|
+
# "symbol": "BTCUSDT",
|
8651
|
+
# "openInterest": "18166.3583"
|
8652
|
+
# }
|
8653
|
+
# ],
|
8654
|
+
# "ts": "1751101220993"
|
8655
|
+
# }
|
8656
|
+
#
|
8657
|
+
data = self.safe_list_2(interest, 'openInterestList', 'list', [])
|
7323
8658
|
timestamp = self.safe_integer(interest, 'ts')
|
7324
8659
|
marketId = self.safe_string(data[0], 'symbol')
|
7325
8660
|
return self.safe_open_interest({
|
7326
8661
|
'symbol': self.safe_symbol(marketId, market, None, 'contract'),
|
7327
|
-
'openInterestAmount': self.
|
8662
|
+
'openInterestAmount': self.safe_number_2(data[0], 'size', 'openInterest'),
|
7328
8663
|
'openInterestValue': None,
|
7329
8664
|
'timestamp': timestamp,
|
7330
8665
|
'datetime': self.iso8601(timestamp),
|
@@ -8047,10 +9382,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
8047
9382
|
fetch the rate of interest to borrow a currency for margin trading
|
8048
9383
|
|
8049
9384
|
https://www.bitget.com/api-doc/margin/cross/account/Get-Cross-Margin-Interest-Rate-And-Borrowable
|
9385
|
+
https://www.bitget.com/api-doc/uta/public/Get-Margin-Loans
|
8050
9386
|
|
8051
9387
|
:param str code: unified currency code
|
8052
9388
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8053
|
-
:param
|
9389
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
8054
9390
|
:returns dict: a `borrow rate structure <https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure>`
|
8055
9391
|
"""
|
8056
9392
|
self.load_markets()
|
@@ -8058,40 +9394,62 @@ class bitget(Exchange, ImplicitAPI):
|
|
8058
9394
|
request: dict = {
|
8059
9395
|
'coin': currency['id'],
|
8060
9396
|
}
|
8061
|
-
|
8062
|
-
|
8063
|
-
|
8064
|
-
|
8065
|
-
|
8066
|
-
|
8067
|
-
|
8068
|
-
|
8069
|
-
|
8070
|
-
|
8071
|
-
|
8072
|
-
|
8073
|
-
|
8074
|
-
|
8075
|
-
|
8076
|
-
|
8077
|
-
|
8078
|
-
|
8079
|
-
|
8080
|
-
|
8081
|
-
|
8082
|
-
|
8083
|
-
|
8084
|
-
|
8085
|
-
|
8086
|
-
|
8087
|
-
|
9397
|
+
uta = None
|
9398
|
+
response = None
|
9399
|
+
result = None
|
9400
|
+
uta, params = self.handle_option_and_params(params, 'fetchCrossBorrowRate', 'uta', False)
|
9401
|
+
if uta:
|
9402
|
+
response = self.publicUtaGetV3MarketMarginLoans(self.extend(request, params))
|
9403
|
+
#
|
9404
|
+
# {
|
9405
|
+
# "code": "00000",
|
9406
|
+
# "msg": "success",
|
9407
|
+
# "requestTime": 1752817798893,
|
9408
|
+
# "data": {
|
9409
|
+
# "dailyInterest": "0.00100008",
|
9410
|
+
# "annualInterest": "0.3650292",
|
9411
|
+
# "limit": "100"
|
9412
|
+
# }
|
9413
|
+
# }
|
9414
|
+
#
|
9415
|
+
result = self.safe_dict(response, 'data', {})
|
9416
|
+
else:
|
9417
|
+
response = self.privateMarginGetV2MarginCrossedInterestRateAndLimit(self.extend(request, params))
|
9418
|
+
#
|
9419
|
+
# {
|
9420
|
+
# "code": "00000",
|
9421
|
+
# "msg": "success",
|
9422
|
+
# "requestTime": 1700879047861,
|
9423
|
+
# "data": [
|
9424
|
+
# {
|
9425
|
+
# "coin": "BTC",
|
9426
|
+
# "leverage": "3",
|
9427
|
+
# "transferable": True,
|
9428
|
+
# "borrowable": True,
|
9429
|
+
# "dailyInterestRate": "0.00007",
|
9430
|
+
# "annualInterestRate": "0.02555",
|
9431
|
+
# "maxBorrowableAmount": "26",
|
9432
|
+
# "vipList": [
|
9433
|
+
# {"level":"0","limit":"26","dailyInterestRate":"0.00007","annualInterestRate":"0.02555","discountRate":"1"},
|
9434
|
+
# {"level":"1","limit":"26.78","dailyInterestRate":"0.0000679","annualInterestRate":"0.0247835","discountRate":"0.97"},
|
9435
|
+
# {"level":"2","limit":"28.08","dailyInterestRate":"0.0000644","annualInterestRate":"0.023506","discountRate":"0.92"},
|
9436
|
+
# {"level":"3","limit":"30.16","dailyInterestRate":"0.0000602","annualInterestRate":"0.021973","discountRate":"0.86"},
|
9437
|
+
# {"level":"4","limit":"34.58","dailyInterestRate":"0.0000525","annualInterestRate":"0.0191625","discountRate":"0.75"},
|
9438
|
+
# {"level":"5","limit":"43.16","dailyInterestRate":"0.000042","annualInterestRate":"0.01533","discountRate":"0.6"}
|
9439
|
+
# ]
|
9440
|
+
# }
|
9441
|
+
# ]
|
9442
|
+
# }
|
9443
|
+
#
|
9444
|
+
data = self.safe_value(response, 'data', [])
|
9445
|
+
result = self.safe_value(data, 0, {})
|
8088
9446
|
timestamp = self.safe_integer(response, 'requestTime')
|
8089
|
-
|
8090
|
-
|
8091
|
-
first['timestamp'] = timestamp
|
8092
|
-
return self.parse_borrow_rate(first, currency)
|
9447
|
+
result['timestamp'] = timestamp
|
9448
|
+
return self.parse_borrow_rate(result, currency)
|
8093
9449
|
|
8094
9450
|
def parse_borrow_rate(self, info, currency: Currency = None):
|
9451
|
+
#
|
9452
|
+
# default
|
8095
9453
|
#
|
8096
9454
|
# {
|
8097
9455
|
# "coin": "BTC",
|
@@ -8111,11 +9469,19 @@ class bitget(Exchange, ImplicitAPI):
|
|
8111
9469
|
# ]
|
8112
9470
|
# }
|
8113
9471
|
#
|
9472
|
+
# uta
|
9473
|
+
#
|
9474
|
+
# {
|
9475
|
+
# "dailyInterest": "0.00100008",
|
9476
|
+
# "annualInterest": "0.3650292",
|
9477
|
+
# "limit": "100"
|
9478
|
+
# }
|
9479
|
+
#
|
8114
9480
|
currencyId = self.safe_string(info, 'coin')
|
8115
9481
|
timestamp = self.safe_integer(info, 'timestamp')
|
8116
9482
|
return {
|
8117
9483
|
'currency': self.safe_currency_code(currencyId, currency),
|
8118
|
-
'rate': self.
|
9484
|
+
'rate': self.safe_number_2(info, 'dailyInterestRate', 'dailyInterest'),
|
8119
9485
|
'period': 86400000, # 1-Day
|
8120
9486
|
'timestamp': timestamp,
|
8121
9487
|
'datetime': self.iso8601(timestamp),
|
@@ -8271,42 +9637,68 @@ class bitget(Exchange, ImplicitAPI):
|
|
8271
9637
|
closes an open position for a market
|
8272
9638
|
|
8273
9639
|
https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
|
9640
|
+
https://www.bitget.com/api-doc/uta/trade/Close-All-Positions
|
8274
9641
|
|
8275
9642
|
:param str symbol: unified CCXT market symbol
|
8276
9643
|
:param str [side]: one-way mode: 'buy' or 'sell', hedge-mode: 'long' or 'short'
|
8277
9644
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
9645
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
8278
9646
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
8279
9647
|
"""
|
8280
9648
|
self.load_markets()
|
8281
9649
|
market = self.market(symbol)
|
8282
|
-
productType = None
|
8283
|
-
productType, params = self.handle_product_type_and_params(market, params)
|
8284
9650
|
request: dict = {
|
8285
9651
|
'symbol': market['id'],
|
8286
|
-
'productType': productType,
|
8287
9652
|
}
|
8288
|
-
|
8289
|
-
|
8290
|
-
response =
|
8291
|
-
|
8292
|
-
|
8293
|
-
|
8294
|
-
|
8295
|
-
|
8296
|
-
|
8297
|
-
|
8298
|
-
|
8299
|
-
|
8300
|
-
|
8301
|
-
|
8302
|
-
|
8303
|
-
|
8304
|
-
|
8305
|
-
|
8306
|
-
|
8307
|
-
|
9653
|
+
productType = None
|
9654
|
+
uta = None
|
9655
|
+
response = None
|
9656
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
9657
|
+
uta, params = self.handle_option_and_params(params, 'closePosition', 'uta', False)
|
9658
|
+
if uta:
|
9659
|
+
if side is not None:
|
9660
|
+
request['posSide'] = side
|
9661
|
+
request['category'] = productType
|
9662
|
+
response = self.privateUtaPostV3TradeClosePositions(self.extend(request, params))
|
9663
|
+
#
|
9664
|
+
# {
|
9665
|
+
# "code": "00000",
|
9666
|
+
# "msg": "success",
|
9667
|
+
# "requestTime": 1751020218384,
|
9668
|
+
# "data": {
|
9669
|
+
# "list": [
|
9670
|
+
# {
|
9671
|
+
# "orderId": "1322440134099320832",
|
9672
|
+
# "clientOid": "1322440134099320833"
|
9673
|
+
# }
|
9674
|
+
# ]
|
9675
|
+
# }
|
9676
|
+
# }
|
9677
|
+
#
|
9678
|
+
else:
|
9679
|
+
if side is not None:
|
9680
|
+
request['holdSide'] = side
|
9681
|
+
request['productType'] = productType
|
9682
|
+
response = self.privateMixPostV2MixOrderClosePositions(self.extend(request, params))
|
9683
|
+
#
|
9684
|
+
# {
|
9685
|
+
# "code": "00000",
|
9686
|
+
# "msg": "success",
|
9687
|
+
# "requestTime": 1702975017017,
|
9688
|
+
# "data": {
|
9689
|
+
# "successList": [
|
9690
|
+
# {
|
9691
|
+
# "orderId": "1120923953904893955",
|
9692
|
+
# "clientOid": "1120923953904893956"
|
9693
|
+
# }
|
9694
|
+
# ],
|
9695
|
+
# "failureList": [],
|
9696
|
+
# "result": False
|
9697
|
+
# }
|
9698
|
+
# }
|
9699
|
+
#
|
8308
9700
|
data = self.safe_value(response, 'data', {})
|
8309
|
-
order = self.
|
9701
|
+
order = self.safe_list_2(data, 'successList', 'list', [])
|
8310
9702
|
return self.parse_order(order[0], market)
|
8311
9703
|
|
8312
9704
|
def close_all_positions(self, params={}) -> List[Position]:
|
@@ -8314,37 +9706,60 @@ class bitget(Exchange, ImplicitAPI):
|
|
8314
9706
|
closes all open positions for a market type
|
8315
9707
|
|
8316
9708
|
https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
|
9709
|
+
https://www.bitget.com/api-doc/uta/trade/Close-All-Positions
|
8317
9710
|
|
8318
9711
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
8319
9712
|
:param str [params.productType]: 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
|
9713
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
8320
9714
|
:returns dict[]: A list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
|
8321
9715
|
"""
|
8322
9716
|
self.load_markets()
|
9717
|
+
request: dict = {}
|
8323
9718
|
productType = None
|
9719
|
+
uta = None
|
9720
|
+
response = None
|
8324
9721
|
productType, params = self.handle_product_type_and_params(None, params)
|
8325
|
-
|
8326
|
-
|
8327
|
-
|
8328
|
-
|
8329
|
-
|
8330
|
-
|
8331
|
-
|
8332
|
-
|
8333
|
-
|
8334
|
-
|
8335
|
-
|
8336
|
-
|
8337
|
-
|
8338
|
-
|
8339
|
-
|
8340
|
-
|
8341
|
-
|
8342
|
-
|
8343
|
-
|
8344
|
-
|
8345
|
-
|
9722
|
+
uta, params = self.handle_option_and_params(params, 'closeAllPositions', 'uta', False)
|
9723
|
+
if uta:
|
9724
|
+
request['category'] = productType
|
9725
|
+
response = self.privateUtaPostV3TradeClosePositions(self.extend(request, params))
|
9726
|
+
#
|
9727
|
+
# {
|
9728
|
+
# "code": "00000",
|
9729
|
+
# "msg": "success",
|
9730
|
+
# "requestTime": 1751020218384,
|
9731
|
+
# "data": {
|
9732
|
+
# "list": [
|
9733
|
+
# {
|
9734
|
+
# "orderId": "1322440134099320832",
|
9735
|
+
# "clientOid": "1322440134099320833"
|
9736
|
+
# }
|
9737
|
+
# ]
|
9738
|
+
# }
|
9739
|
+
# }
|
9740
|
+
#
|
9741
|
+
else:
|
9742
|
+
request['productType'] = productType
|
9743
|
+
response = self.privateMixPostV2MixOrderClosePositions(self.extend(request, params))
|
9744
|
+
#
|
9745
|
+
# {
|
9746
|
+
# "code": "00000",
|
9747
|
+
# "msg": "success",
|
9748
|
+
# "requestTime": 1702975017017,
|
9749
|
+
# "data": {
|
9750
|
+
# "successList": [
|
9751
|
+
# {
|
9752
|
+
# "orderId": "1120923953904893955",
|
9753
|
+
# "clientOid": "1120923953904893956"
|
9754
|
+
# }
|
9755
|
+
# ],
|
9756
|
+
# "failureList": [],
|
9757
|
+
# "result": False
|
9758
|
+
# }
|
9759
|
+
# }
|
9760
|
+
#
|
8346
9761
|
data = self.safe_value(response, 'data', {})
|
8347
|
-
orderInfo = self.
|
9762
|
+
orderInfo = self.safe_list_2(data, 'successList', 'list', [])
|
8348
9763
|
return self.parse_positions(orderInfo, None, params)
|
8349
9764
|
|
8350
9765
|
def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
|
@@ -8412,21 +9827,23 @@ class bitget(Exchange, ImplicitAPI):
|
|
8412
9827
|
fetches historical positions
|
8413
9828
|
|
8414
9829
|
https://www.bitget.com/api-doc/contract/position/Get-History-Position
|
9830
|
+
https://www.bitget.com/api-doc/uta/trade/Get-Position-History
|
8415
9831
|
|
8416
9832
|
:param str[] [symbols]: unified contract symbols
|
8417
9833
|
:param int [since]: timestamp in ms of the earliest position to fetch, default=3 months ago, max range for params["until"] - since is 3 months
|
8418
9834
|
:param int [limit]: the maximum amount of records to fetch, default=20, max=100
|
8419
9835
|
:param dict params: extra parameters specific to the exchange api endpoint
|
8420
9836
|
:param int [params.until]: timestamp in ms of the latest position to fetch, max range for params["until"] - since is 3 months
|
8421
|
-
|
8422
|
-
EXCHANGE SPECIFIC PARAMETERS
|
8423
9837
|
:param str [params.productType]: USDT-FUTURES(default), COIN-FUTURES, USDC-FUTURES, SUSDT-FUTURES, SCOIN-FUTURES, or SUSDC-FUTURES
|
9838
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
8424
9839
|
:returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
|
8425
9840
|
"""
|
8426
9841
|
self.load_markets()
|
8427
|
-
until = self.safe_integer(params, 'until')
|
8428
|
-
params = self.omit(params, 'until')
|
8429
9842
|
request: dict = {}
|
9843
|
+
market = None
|
9844
|
+
productType = None
|
9845
|
+
uta = None
|
9846
|
+
response = None
|
8430
9847
|
if symbols is not None:
|
8431
9848
|
symbolsLength = len(symbols)
|
8432
9849
|
if symbolsLength > 0:
|
@@ -8436,40 +9853,77 @@ class bitget(Exchange, ImplicitAPI):
|
|
8436
9853
|
request['startTime'] = since
|
8437
9854
|
if limit is not None:
|
8438
9855
|
request['limit'] = limit
|
8439
|
-
|
8440
|
-
|
8441
|
-
|
8442
|
-
|
8443
|
-
|
8444
|
-
|
8445
|
-
|
8446
|
-
|
8447
|
-
|
8448
|
-
|
8449
|
-
|
8450
|
-
|
8451
|
-
|
8452
|
-
|
8453
|
-
|
8454
|
-
|
8455
|
-
|
8456
|
-
|
8457
|
-
|
8458
|
-
|
8459
|
-
|
8460
|
-
|
8461
|
-
|
8462
|
-
|
8463
|
-
|
8464
|
-
|
8465
|
-
|
8466
|
-
|
8467
|
-
|
8468
|
-
|
8469
|
-
|
8470
|
-
|
8471
|
-
|
8472
|
-
|
9856
|
+
request, params = self.handle_until_option('endTime', request, params)
|
9857
|
+
productType, params = self.handle_product_type_and_params(market, params)
|
9858
|
+
uta, params = self.handle_option_and_params(params, 'fetchPositionsHistory', 'uta', False)
|
9859
|
+
if uta:
|
9860
|
+
request['category'] = productType
|
9861
|
+
response = self.privateUtaGetV3PositionHistoryPosition(self.extend(request, params))
|
9862
|
+
#
|
9863
|
+
# {
|
9864
|
+
# "code": "00000",
|
9865
|
+
# "msg": "success",
|
9866
|
+
# "requestTime": 1751020950427,
|
9867
|
+
# "data": {
|
9868
|
+
# "list": [
|
9869
|
+
# {
|
9870
|
+
# "positionId": "1322441328637100049",
|
9871
|
+
# "category": "USDT-FUTURES",
|
9872
|
+
# "symbol": "BTCUSDT",
|
9873
|
+
# "marginCoin": "USDT",
|
9874
|
+
# "holdMode": "hedge_mode",
|
9875
|
+
# "posSide": "long",
|
9876
|
+
# "marginMode": "crossed",
|
9877
|
+
# "openPriceAvg": "107003.7",
|
9878
|
+
# "closePriceAvg": "107005.4",
|
9879
|
+
# "openTotalPos": "0.0001",
|
9880
|
+
# "closeTotalPos": "0.0001",
|
9881
|
+
# "cumRealisedPnl": "0.00017",
|
9882
|
+
# "netProfit": "-0.01267055",
|
9883
|
+
# "totalFunding": "0",
|
9884
|
+
# "openFeeTotal": "-0.00642022",
|
9885
|
+
# "closeFeeTotal": "-0.00642032",
|
9886
|
+
# "createdTime": "1751020503195",
|
9887
|
+
# "updatedTime": "1751020520458"
|
9888
|
+
# },
|
9889
|
+
# ],
|
9890
|
+
# "cursor": "1322440134158041089"
|
9891
|
+
# }
|
9892
|
+
# }
|
9893
|
+
#
|
9894
|
+
else:
|
9895
|
+
response = self.privateMixGetV2MixPositionHistoryPosition(self.extend(request, params))
|
9896
|
+
#
|
9897
|
+
# {
|
9898
|
+
# code: '00000',
|
9899
|
+
# msg: 'success',
|
9900
|
+
# requestTime: '1712794148791',
|
9901
|
+
# data: {
|
9902
|
+
# list: [
|
9903
|
+
# {
|
9904
|
+
# symbol: 'XRPUSDT',
|
9905
|
+
# marginCoin: 'USDT',
|
9906
|
+
# holdSide: 'long',
|
9907
|
+
# openAvgPrice: '0.64967',
|
9908
|
+
# closeAvgPrice: '0.58799',
|
9909
|
+
# marginMode: 'isolated',
|
9910
|
+
# openTotalPos: '10',
|
9911
|
+
# closeTotalPos: '10',
|
9912
|
+
# pnl: '-0.62976205',
|
9913
|
+
# netProfit: '-0.65356802',
|
9914
|
+
# totalFunding: '-0.01638',
|
9915
|
+
# openFee: '-0.00389802',
|
9916
|
+
# closeFee: '-0.00352794',
|
9917
|
+
# ctime: '1709590322199',
|
9918
|
+
# utime: '1709667583395'
|
9919
|
+
# },
|
9920
|
+
# ...
|
9921
|
+
# ]
|
9922
|
+
# }
|
9923
|
+
# }
|
9924
|
+
#
|
9925
|
+
data = self.safe_dict(response, 'data', {})
|
9926
|
+
responseList = self.safe_list(data, 'list', [])
|
8473
9927
|
positions = self.parse_positions(responseList, symbols, params)
|
8474
9928
|
return self.filter_by_since_limit(positions, since, limit)
|
8475
9929
|
|
@@ -8741,9 +10195,11 @@ class bitget(Exchange, ImplicitAPI):
|
|
8741
10195
|
fetch the current funding rate interval
|
8742
10196
|
|
8743
10197
|
https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
|
10198
|
+
https://www.bitget.com/api-doc/uta/public/Get-Current-Funding-Rate
|
8744
10199
|
|
8745
10200
|
:param str symbol: unified market symbol
|
8746
10201
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
10202
|
+
:param boolean [params.uta]: set to True for the unified trading account(uta), defaults to False
|
8747
10203
|
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
8748
10204
|
"""
|
8749
10205
|
self.load_markets()
|
@@ -8752,23 +10208,46 @@ class bitget(Exchange, ImplicitAPI):
|
|
8752
10208
|
productType, params = self.handle_product_type_and_params(market, params)
|
8753
10209
|
request: dict = {
|
8754
10210
|
'symbol': market['id'],
|
8755
|
-
'productType': productType,
|
8756
10211
|
}
|
8757
|
-
response =
|
8758
|
-
|
8759
|
-
|
8760
|
-
|
8761
|
-
|
8762
|
-
|
8763
|
-
|
8764
|
-
|
8765
|
-
|
8766
|
-
|
8767
|
-
|
8768
|
-
|
8769
|
-
|
8770
|
-
|
8771
|
-
|
10212
|
+
response = None
|
10213
|
+
uta = None
|
10214
|
+
uta, params = self.handle_option_and_params(params, 'fetchFundingInterval', 'uta', False)
|
10215
|
+
if uta:
|
10216
|
+
response = self.publicUtaGetV3MarketCurrentFundRate(self.extend(request, params))
|
10217
|
+
#
|
10218
|
+
# {
|
10219
|
+
# "code": "00000",
|
10220
|
+
# "msg": "success",
|
10221
|
+
# "requestTime": 1752880157959,
|
10222
|
+
# "data": [
|
10223
|
+
# {
|
10224
|
+
# "symbol": "BTCUSDT",
|
10225
|
+
# "fundingRate": "0.0001",
|
10226
|
+
# "fundingRateInterval": "8",
|
10227
|
+
# "nextUpdate": "1752883200000",
|
10228
|
+
# "minFundingRate": "-0.003",
|
10229
|
+
# "maxFundingRate": "0.003"
|
10230
|
+
# }
|
10231
|
+
# ]
|
10232
|
+
# }
|
10233
|
+
#
|
10234
|
+
else:
|
10235
|
+
request['productType'] = productType
|
10236
|
+
response = self.publicMixGetV2MixMarketFundingTime(self.extend(request, params))
|
10237
|
+
#
|
10238
|
+
# {
|
10239
|
+
# "code": "00000",
|
10240
|
+
# "msg": "success",
|
10241
|
+
# "requestTime": 1727930153888,
|
10242
|
+
# "data": [
|
10243
|
+
# {
|
10244
|
+
# "symbol": "BTCUSDT",
|
10245
|
+
# "nextFundingTime": "1727942400000",
|
10246
|
+
# "ratePeriod": "8"
|
10247
|
+
# }
|
10248
|
+
# ]
|
10249
|
+
# }
|
10250
|
+
#
|
8772
10251
|
data = self.safe_list(response, 'data', [])
|
8773
10252
|
first = self.safe_dict(data, 0, {})
|
8774
10253
|
return self.parse_funding_rate(first, market)
|
@@ -8928,7 +10407,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
8928
10407
|
if method == 'POST':
|
8929
10408
|
headers['Content-Type'] = 'application/json'
|
8930
10409
|
sandboxMode = self.safe_bool_2(self.options, 'sandboxMode', 'sandbox', False)
|
8931
|
-
if sandboxMode and (path != 'v2/public/time'):
|
10410
|
+
if sandboxMode and (path != 'v2/public/time') and (path != 'v3/market/current-fund-rate'):
|
8932
10411
|
# https://github.com/ccxt/ccxt/issues/25252#issuecomment-2662742336
|
8933
10412
|
if headers is None:
|
8934
10413
|
headers = {}
|