ccxt 4.3.57__py2.py3-none-any.whl → 4.3.59__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. ccxt/__init__.py +5 -5
  2. ccxt/abstract/bitmart.py +1 -0
  3. ccxt/abstract/btcbox.py +1 -0
  4. ccxt/abstract/kucoin.py +1 -0
  5. ccxt/abstract/kucoinfutures.py +1 -0
  6. ccxt/abstract/upbit.py +3 -0
  7. ccxt/abstract/xt.py +1 -0
  8. ccxt/alpaca.py +5 -1
  9. ccxt/async_support/__init__.py +5 -5
  10. ccxt/async_support/alpaca.py +5 -1
  11. ccxt/async_support/base/exchange.py +1 -1
  12. ccxt/async_support/base/ws/client.py +1 -0
  13. ccxt/async_support/bigone.py +19 -1
  14. ccxt/async_support/binance.py +1 -1
  15. ccxt/async_support/bingx.py +116 -26
  16. ccxt/async_support/bitget.py +1 -1
  17. ccxt/async_support/bitmart.py +1 -0
  18. ccxt/async_support/btcbox.py +145 -8
  19. ccxt/async_support/bybit.py +2 -2
  20. ccxt/async_support/cex.py +1 -1
  21. ccxt/async_support/coinmate.py +28 -32
  22. ccxt/async_support/coinone.py +1 -1
  23. ccxt/async_support/coinsph.py +1 -1
  24. ccxt/async_support/deribit.py +15 -1
  25. ccxt/async_support/digifinex.py +30 -7
  26. ccxt/async_support/gate.py +22 -18
  27. ccxt/async_support/htx.py +10 -8
  28. ccxt/async_support/hyperliquid.py +106 -2
  29. ccxt/async_support/kraken.py +1 -1
  30. ccxt/async_support/kucoin.py +3 -0
  31. ccxt/async_support/latoken.py +5 -1
  32. ccxt/async_support/mexc.py +11 -11
  33. ccxt/async_support/novadax.py +1 -1
  34. ccxt/async_support/okcoin.py +1 -1
  35. ccxt/async_support/okx.py +3 -1
  36. ccxt/async_support/phemex.py +1 -1
  37. ccxt/async_support/probit.py +1 -1
  38. ccxt/async_support/tokocrypto.py +1 -1
  39. ccxt/async_support/upbit.py +139 -45
  40. ccxt/async_support/woo.py +2 -1
  41. ccxt/async_support/xt.py +70 -7
  42. ccxt/base/errors.py +23 -23
  43. ccxt/base/exchange.py +9 -9
  44. ccxt/bigone.py +19 -1
  45. ccxt/binance.py +1 -1
  46. ccxt/bingx.py +116 -26
  47. ccxt/bitget.py +1 -1
  48. ccxt/bitmart.py +1 -0
  49. ccxt/btcbox.py +145 -8
  50. ccxt/bybit.py +2 -2
  51. ccxt/cex.py +1 -1
  52. ccxt/coinmate.py +28 -32
  53. ccxt/coinone.py +1 -1
  54. ccxt/coinsph.py +1 -1
  55. ccxt/deribit.py +15 -1
  56. ccxt/digifinex.py +30 -7
  57. ccxt/gate.py +22 -18
  58. ccxt/htx.py +10 -8
  59. ccxt/hyperliquid.py +106 -2
  60. ccxt/kraken.py +1 -1
  61. ccxt/kucoin.py +3 -0
  62. ccxt/latoken.py +5 -1
  63. ccxt/mexc.py +11 -11
  64. ccxt/novadax.py +1 -1
  65. ccxt/okcoin.py +1 -1
  66. ccxt/okx.py +3 -1
  67. ccxt/phemex.py +1 -1
  68. ccxt/pro/__init__.py +3 -1
  69. ccxt/pro/binance.py +11 -13
  70. ccxt/pro/bingx.py +11 -8
  71. ccxt/pro/bitmart.py +2 -2
  72. ccxt/pro/bitopro.py +1 -1
  73. ccxt/pro/coincheck.py +1 -1
  74. ccxt/pro/coinone.py +1 -1
  75. ccxt/pro/htx.py +1 -1
  76. ccxt/pro/hyperliquid.py +1 -1
  77. ccxt/pro/okx.py +3 -3
  78. ccxt/pro/xt.py +1043 -0
  79. ccxt/probit.py +1 -1
  80. ccxt/test/tests_async.py +2 -2
  81. ccxt/test/tests_helpers.py +1 -1
  82. ccxt/test/tests_sync.py +2 -2
  83. ccxt/tokocrypto.py +1 -1
  84. ccxt/upbit.py +139 -45
  85. ccxt/woo.py +2 -1
  86. ccxt/xt.py +70 -7
  87. {ccxt-4.3.57.dist-info → ccxt-4.3.59.dist-info}/METADATA +5 -5
  88. {ccxt-4.3.57.dist-info → ccxt-4.3.59.dist-info}/RECORD +91 -90
  89. {ccxt-4.3.57.dist-info → ccxt-4.3.59.dist-info}/LICENSE.txt +0 -0
  90. {ccxt-4.3.57.dist-info → ccxt-4.3.59.dist-info}/WHEEL +0 -0
  91. {ccxt-4.3.57.dist-info → ccxt-4.3.59.dist-info}/top_level.txt +0 -0
ccxt/async_support/xt.py CHANGED
@@ -40,7 +40,7 @@ class xt(Exchange, ImplicitAPI):
40
40
  'rateLimit': 100,
41
41
  'version': 'v4',
42
42
  'certified': False,
43
- 'pro': False,
43
+ 'pro': True,
44
44
  'has': {
45
45
  'CORS': False,
46
46
  'spot': True,
@@ -235,6 +235,7 @@ class xt(Exchange, ImplicitAPI):
235
235
  'withdraw': 1,
236
236
  'balance/transfer': 1,
237
237
  'balance/account/transfer': 1,
238
+ 'ws-token': 1,
238
239
  },
239
240
  'delete': {
240
241
  'batch-order': 1,
@@ -1436,8 +1437,12 @@ class xt(Exchange, ImplicitAPI):
1436
1437
  orderBook = self.safe_value(response, 'result', {})
1437
1438
  timestamp = self.safe_integer_2(orderBook, 'timestamp', 't')
1438
1439
  if market['spot']:
1439
- return self.parse_order_book(orderBook, symbol, timestamp)
1440
- return self.parse_order_book(orderBook, symbol, timestamp, 'b', 'a')
1440
+ ob = self.parse_order_book(orderBook, symbol, timestamp)
1441
+ ob['nonce'] = self.safe_integer(orderBook, 'lastUpdateId')
1442
+ return ob
1443
+ swapOb = self.parse_order_book(orderBook, symbol, timestamp, 'b', 'a')
1444
+ swapOb['nonce'] = self.safe_integer_2(orderBook, 'u', 'lastUpdateId')
1445
+ return swapOb
1441
1446
 
1442
1447
  async def fetch_ticker(self, symbol: str, params={}):
1443
1448
  """
@@ -1680,8 +1685,9 @@ class xt(Exchange, ImplicitAPI):
1680
1685
  #
1681
1686
  marketId = self.safe_string(ticker, 's')
1682
1687
  marketType = market['type'] if (market is not None) else None
1688
+ hasSpotKeys = ('cv' in ticker) or ('aq' in ticker)
1683
1689
  if marketType is None:
1684
- marketType = ('cv' in ticker) or 'spot' if ('aq' in ticker) else 'contract'
1690
+ marketType = 'spot' if hasSpotKeys else 'contract'
1685
1691
  market = self.safe_market(marketId, market, '_', marketType)
1686
1692
  symbol = market['symbol']
1687
1693
  timestamp = self.safe_integer(ticker, 't')
@@ -1889,6 +1895,29 @@ class xt(Exchange, ImplicitAPI):
1889
1895
  # "b": True
1890
1896
  # }
1891
1897
  #
1898
+ # spot: watchMyTrades
1899
+ #
1900
+ # {
1901
+ # "s": "btc_usdt", # symbol
1902
+ # "t": 1656043204763, # time
1903
+ # "i": "6316559590087251233", # tradeId
1904
+ # "oi": "6216559590087220004", # orderId
1905
+ # "p": "30000", # trade price
1906
+ # "q": "3", # qty quantity
1907
+ # "v": "90000" # volume trade amount
1908
+ # }
1909
+ #
1910
+ # spot: watchTrades
1911
+ #
1912
+ # {
1913
+ # s: 'btc_usdt',
1914
+ # i: '228825383103928709',
1915
+ # t: 1684258222702,
1916
+ # p: '27003.65',
1917
+ # q: '0.000796',
1918
+ # b: True
1919
+ # }
1920
+ #
1892
1921
  # swap and future: fetchTrades
1893
1922
  #
1894
1923
  # {
@@ -1933,19 +1962,53 @@ class xt(Exchange, ImplicitAPI):
1933
1962
  # "takerMaker": "TAKER"
1934
1963
  # }
1935
1964
  #
1965
+ # contract watchMyTrades
1966
+ #
1967
+ # {
1968
+ # "symbol": 'btc_usdt',
1969
+ # "orderSide": 'SELL',
1970
+ # "positionSide": 'LONG',
1971
+ # "orderId": '231485367663419328',
1972
+ # "price": '27152.7',
1973
+ # "quantity": '33',
1974
+ # "marginUnfrozen": '2.85318000',
1975
+ # "timestamp": 1684892412565
1976
+ # }
1977
+ #
1978
+ # watchMyTrades(ws, swap)
1979
+ #
1980
+ # {
1981
+ # 'fee': '0.04080840',
1982
+ # 'isMaker': False,
1983
+ # 'marginUnfrozen': '0.75711984',
1984
+ # 'orderId': '376172779053188416',
1985
+ # 'orderSide': 'BUY',
1986
+ # 'positionSide': 'LONG',
1987
+ # 'price': '3400.70',
1988
+ # 'quantity': '2',
1989
+ # 'symbol': 'eth_usdt',
1990
+ # 'timestamp': 1719388579622
1991
+ # }
1992
+ #
1936
1993
  marketId = self.safe_string_2(trade, 's', 'symbol')
1937
1994
  marketType = market['type'] if (market is not None) else None
1995
+ hasSpotKeys = ('b' in trade) or ('bizType' in trade) or ('oi' in trade)
1938
1996
  if marketType is None:
1939
- marketType = ('b' in trade) or 'spot' if ('bizType' in trade) else 'contract'
1997
+ marketType = 'spot' if hasSpotKeys else 'contract'
1940
1998
  market = self.safe_market(marketId, market, '_', marketType)
1941
1999
  bidOrAsk = self.safe_string(trade, 'm')
1942
2000
  side = self.safe_string_lower(trade, 'orderSide')
1943
2001
  if bidOrAsk is not None:
1944
2002
  side = 'buy' if (bidOrAsk == 'BID') else 'sell'
1945
2003
  buyerMaker = self.safe_value(trade, 'b')
2004
+ if buyerMaker is not None:
2005
+ side = 'buy'
1946
2006
  takerOrMaker = self.safe_string_lower(trade, 'takerMaker')
1947
2007
  if buyerMaker is not None:
1948
2008
  takerOrMaker = 'maker' if buyerMaker else 'taker'
2009
+ isMaker = self.safe_bool(trade, 'isMaker')
2010
+ if isMaker is not None:
2011
+ takerOrMaker = 'maker' if isMaker else 'taker'
1949
2012
  timestamp = self.safe_integer_n(trade, ['t', 'time', 'timestamp'])
1950
2013
  quantity = self.safe_string_2(trade, 'q', 'quantity')
1951
2014
  amount = None
@@ -1962,7 +2025,7 @@ class xt(Exchange, ImplicitAPI):
1962
2025
  'timestamp': timestamp,
1963
2026
  'datetime': self.iso8601(timestamp),
1964
2027
  'symbol': market['symbol'],
1965
- 'order': self.safe_string(trade, 'orderId'),
2028
+ 'order': self.safe_string_2(trade, 'orderId', 'oi'),
1966
2029
  'type': self.safe_string_lower(trade, 'orderType'),
1967
2030
  'side': side,
1968
2031
  'takerOrMaker': takerOrMaker,
@@ -4419,7 +4482,7 @@ class xt(Exchange, ImplicitAPI):
4419
4482
  body['clientMedia'] = id
4420
4483
  else:
4421
4484
  body['media'] = id
4422
- isUndefinedBody = ((method == 'GET') or (path == 'order/{orderId}'))
4485
+ isUndefinedBody = ((method == 'GET') or (path == 'order/{orderId}') or (path == 'ws-token'))
4423
4486
  body = None if isUndefinedBody else self.json(body)
4424
4487
  payloadString = None
4425
4488
  if (endpoint == 'spot') or (endpoint == 'user'):
ccxt/base/errors.py CHANGED
@@ -17,9 +17,6 @@ error_hierarchy = {
17
17
  },
18
18
  'MarketClosed': {},
19
19
  },
20
- 'BadResponse': {
21
- 'NullResponse': {},
22
- },
23
20
  'InsufficientFunds': {},
24
21
  'InvalidAddress': {
25
22
  'AddressPending': {},
@@ -27,14 +24,13 @@ error_hierarchy = {
27
24
  'InvalidOrder': {
28
25
  'OrderNotFound': {},
29
26
  'OrderNotCached': {},
30
- 'CancelPending': {},
31
27
  'OrderImmediatelyFillable': {},
32
28
  'OrderNotFillable': {},
33
29
  'DuplicateOrderId': {},
34
30
  'ContractUnavailable': {},
35
31
  },
36
32
  'NotSupported': {},
37
- 'ProxyError': {},
33
+ 'InvalidProxySettings': {},
38
34
  'ExchangeClosedByUser': {},
39
35
  },
40
36
  'OperationFailed': {
@@ -47,6 +43,10 @@ error_hierarchy = {
47
43
  'InvalidNonce': {},
48
44
  'RequestTimeout': {},
49
45
  },
46
+ 'BadResponse': {
47
+ 'NullResponse': {},
48
+ },
49
+ 'CancelPending': {},
50
50
  },
51
51
  },
52
52
  }
@@ -104,14 +104,6 @@ class MarketClosed(OperationRejected):
104
104
  pass
105
105
 
106
106
 
107
- class BadResponse(ExchangeError):
108
- pass
109
-
110
-
111
- class NullResponse(BadResponse):
112
- pass
113
-
114
-
115
107
  class InsufficientFunds(ExchangeError):
116
108
  pass
117
109
 
@@ -136,10 +128,6 @@ class OrderNotCached(InvalidOrder):
136
128
  pass
137
129
 
138
130
 
139
- class CancelPending(InvalidOrder):
140
- pass
141
-
142
-
143
131
  class OrderImmediatelyFillable(InvalidOrder):
144
132
  pass
145
133
 
@@ -160,7 +148,7 @@ class NotSupported(ExchangeError):
160
148
  pass
161
149
 
162
150
 
163
- class ProxyError(ExchangeError):
151
+ class InvalidProxySettings(ExchangeError):
164
152
  pass
165
153
 
166
154
 
@@ -200,6 +188,18 @@ class RequestTimeout(NetworkError):
200
188
  pass
201
189
 
202
190
 
191
+ class BadResponse(OperationFailed):
192
+ pass
193
+
194
+
195
+ class NullResponse(BadResponse):
196
+ pass
197
+
198
+
199
+ class CancelPending(OperationFailed):
200
+ pass
201
+
202
+
203
203
  __all__ = [
204
204
  'error_hierarchy',
205
205
  'BaseError',
@@ -215,21 +215,18 @@ __all__ = [
215
215
  'NoChange',
216
216
  'MarginModeAlreadySet',
217
217
  'MarketClosed',
218
- 'BadResponse',
219
- 'NullResponse',
220
218
  'InsufficientFunds',
221
219
  'InvalidAddress',
222
220
  'AddressPending',
223
221
  'InvalidOrder',
224
222
  'OrderNotFound',
225
223
  'OrderNotCached',
226
- 'CancelPending',
227
224
  'OrderImmediatelyFillable',
228
225
  'OrderNotFillable',
229
226
  'DuplicateOrderId',
230
227
  'ContractUnavailable',
231
228
  'NotSupported',
232
- 'ProxyError',
229
+ 'InvalidProxySettings',
233
230
  'ExchangeClosedByUser',
234
231
  'OperationFailed',
235
232
  'NetworkError',
@@ -238,5 +235,8 @@ __all__ = [
238
235
  'ExchangeNotAvailable',
239
236
  'OnMaintenance',
240
237
  'InvalidNonce',
241
- 'RequestTimeout'
238
+ 'RequestTimeout',
239
+ 'BadResponse',
240
+ 'NullResponse',
241
+ 'CancelPending'
242
242
  ]
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.3.57'
7
+ __version__ = '4.3.59'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -23,7 +23,7 @@ from ccxt.base.errors import NullResponse
23
23
  from ccxt.base.errors import RateLimitExceeded
24
24
  from ccxt.base.errors import BadRequest
25
25
  from ccxt.base.errors import BadResponse
26
- from ccxt.base.errors import ProxyError
26
+ from ccxt.base.errors import InvalidProxySettings
27
27
 
28
28
  # -----------------------------------------------------------------------------
29
29
 
@@ -1943,7 +1943,7 @@ class Exchange(object):
1943
1943
  length = len(usedProxies)
1944
1944
  if length > 1:
1945
1945
  joinedProxyNames = ','.join(usedProxies)
1946
- raise ProxyError(self.id + ' you have multiple conflicting proxy settings(' + joinedProxyNames + '), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback')
1946
+ raise InvalidProxySettings(self.id + ' you have multiple conflicting proxy settings(' + joinedProxyNames + '), please use only one from : proxyUrl, proxy_url, proxyUrlCallback, proxy_url_callback')
1947
1947
  return proxyUrl
1948
1948
 
1949
1949
  def check_proxy_settings(self, url: Str = None, method: Str = None, headers=None, body=None):
@@ -1994,7 +1994,7 @@ class Exchange(object):
1994
1994
  length = len(usedProxies)
1995
1995
  if length > 1:
1996
1996
  joinedProxyNames = ','.join(usedProxies)
1997
- raise ProxyError(self.id + ' you have multiple conflicting proxy settings(' + joinedProxyNames + '), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback')
1997
+ raise InvalidProxySettings(self.id + ' you have multiple conflicting proxy settings(' + joinedProxyNames + '), please use only one from: httpProxy, httpsProxy, httpProxyCallback, httpsProxyCallback, socksProxy, socksProxyCallback')
1998
1998
  return [httpProxy, httpsProxy, socksProxy]
1999
1999
 
2000
2000
  def check_ws_proxy_settings(self):
@@ -2027,12 +2027,12 @@ class Exchange(object):
2027
2027
  length = len(usedProxies)
2028
2028
  if length > 1:
2029
2029
  joinedProxyNames = ','.join(usedProxies)
2030
- raise ProxyError(self.id + ' you have multiple conflicting proxy settings(' + joinedProxyNames + '), please use only one from: wsProxy, wssProxy, wsSocksProxy')
2030
+ raise InvalidProxySettings(self.id + ' you have multiple conflicting proxy settings(' + joinedProxyNames + '), please use only one from: wsProxy, wssProxy, wsSocksProxy')
2031
2031
  return [wsProxy, wssProxy, wsSocksProxy]
2032
2032
 
2033
2033
  def check_conflicting_proxies(self, proxyAgentSet, proxyUrlSet):
2034
2034
  if proxyAgentSet and proxyUrlSet:
2035
- raise ProxyError(self.id + ' you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy')
2035
+ raise InvalidProxySettings(self.id + ' you have multiple conflicting proxy settings, please use only one from : proxyUrl, httpProxy, httpsProxy, socksProxy')
2036
2036
 
2037
2037
  def find_message_hashes(self, client, element: str):
2038
2038
  result = []
@@ -2258,13 +2258,13 @@ class Exchange(object):
2258
2258
  def parse_isolated_borrow_rate(self, info: dict, market: Market = None):
2259
2259
  raise NotSupported(self.id + ' parseIsolatedBorrowRate() is not supported yet')
2260
2260
 
2261
- def parse_ws_trade(self, trade, market: Market = None):
2261
+ def parse_ws_trade(self, trade: dict, market: Market = None):
2262
2262
  raise NotSupported(self.id + ' parseWsTrade() is not supported yet')
2263
2263
 
2264
- def parse_ws_order(self, order, market: Market = None):
2264
+ def parse_ws_order(self, order: dict, market: Market = None):
2265
2265
  raise NotSupported(self.id + ' parseWsOrder() is not supported yet')
2266
2266
 
2267
- def parse_ws_order_trade(self, trade, market: Market = None):
2267
+ def parse_ws_order_trade(self, trade: dict, market: Market = None):
2268
2268
  raise NotSupported(self.id + ' parseWsOrderTrade() is not supported yet')
2269
2269
 
2270
2270
  def parse_ws_ohlcv(self, ohlcv, market: Market = None):
ccxt/bigone.py CHANGED
@@ -1539,7 +1539,25 @@ class bigone(Exchange, ImplicitAPI):
1539
1539
  # }
1540
1540
  # }
1541
1541
  #
1542
- return response
1542
+ data = self.safe_dict(response, 'data', {})
1543
+ cancelled = self.safe_list(data, 'cancelled', [])
1544
+ failed = self.safe_list(data, 'failed', [])
1545
+ result = []
1546
+ for i in range(0, len(cancelled)):
1547
+ orderId = cancelled[i]
1548
+ result.append(self.safe_order({
1549
+ 'info': orderId,
1550
+ 'id': orderId,
1551
+ 'status': 'canceled',
1552
+ }))
1553
+ for i in range(0, len(failed)):
1554
+ orderId = failed[i]
1555
+ result.append(self.safe_order({
1556
+ 'info': orderId,
1557
+ 'id': orderId,
1558
+ 'status': 'failed',
1559
+ }))
1560
+ return result
1543
1561
 
1544
1562
  def fetch_order(self, id: str, symbol: Str = None, params={}):
1545
1563
  """
ccxt/binance.py CHANGED
@@ -19,7 +19,6 @@ from ccxt.base.errors import BadSymbol
19
19
  from ccxt.base.errors import OperationRejected
20
20
  from ccxt.base.errors import MarginModeAlreadySet
21
21
  from ccxt.base.errors import MarketClosed
22
- from ccxt.base.errors import BadResponse
23
22
  from ccxt.base.errors import InsufficientFunds
24
23
  from ccxt.base.errors import InvalidOrder
25
24
  from ccxt.base.errors import OrderNotFound
@@ -32,6 +31,7 @@ from ccxt.base.errors import RateLimitExceeded
32
31
  from ccxt.base.errors import OnMaintenance
33
32
  from ccxt.base.errors import InvalidNonce
34
33
  from ccxt.base.errors import RequestTimeout
34
+ from ccxt.base.errors import BadResponse
35
35
  from ccxt.base.decimal_to_precision import TRUNCATE
36
36
  from ccxt.base.decimal_to_precision import TICK_SIZE
37
37
  from ccxt.base.precise import Precise
ccxt/bingx.py CHANGED
@@ -815,13 +815,14 @@ class bingx(Exchange, ImplicitAPI):
815
815
  :see: https://bingx-api.github.io/docs/#/spot/market-api.html#Candlestick%20chart%20data
816
816
  :see: https://bingx-api.github.io/docs/#/swapV2/market-api.html#%20K-Line%20Data
817
817
  :see: https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#K-Line%20Data%20-%20Mark%20Price
818
+ :see: https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get%20K-line%20Data
818
819
  :param str symbol: unified symbol of the market to fetch OHLCV data for
819
820
  :param str timeframe: the length of time each candle represents
820
821
  :param int [since]: timestamp in ms of the earliest candle to fetch
821
822
  :param int [limit]: the maximum amount of candles to fetch
822
823
  :param dict [params]: extra parameters specific to the exchange API endpoint
823
824
  :param int [params.until]: timestamp in ms of the latest candle to fetch
824
- :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)
825
+ :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)
825
826
  :returns int[][]: A list of candles ordered, open, high, low, close, volume
826
827
  """
827
828
  self.load_markets()
@@ -846,12 +847,15 @@ class bingx(Exchange, ImplicitAPI):
846
847
  if market['spot']:
847
848
  response = self.spotV1PublicGetMarketKline(self.extend(request, params))
848
849
  else:
849
- price = self.safe_string(params, 'price')
850
- params = self.omit(params, 'price')
851
- if price == 'mark':
852
- response = self.swapV1PrivateGetMarketMarkPriceKlines(self.extend(request, params))
850
+ if market['inverse']:
851
+ response = self.cswapV1PublicGetMarketKlines(self.extend(request, params))
853
852
  else:
854
- response = self.swapV3PublicGetQuoteKlines(self.extend(request, params))
853
+ price = self.safe_string(params, 'price')
854
+ params = self.omit(params, 'price')
855
+ if price == 'mark':
856
+ response = self.swapV1PrivateGetMarketMarkPriceKlines(self.extend(request, params))
857
+ else:
858
+ response = self.swapV3PublicGetQuoteKlines(self.extend(request, params))
855
859
  #
856
860
  # {
857
861
  # "code": 0,
@@ -1144,6 +1148,7 @@ class bingx(Exchange, ImplicitAPI):
1144
1148
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1145
1149
  :see: https://bingx-api.github.io/docs/#/spot/market-api.html#Query%20depth%20information
1146
1150
  :see: https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Market%20Depth
1151
+ :see: https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Query%20Depth%20Data
1147
1152
  :param str symbol: unified symbol of the market to fetch the order book for
1148
1153
  :param int [limit]: the maximum amount of order book entries to return
1149
1154
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1162,7 +1167,10 @@ class bingx(Exchange, ImplicitAPI):
1162
1167
  if marketType == 'spot':
1163
1168
  response = self.spotV1PublicGetMarketDepth(self.extend(request, params))
1164
1169
  else:
1165
- response = self.swapV2PublicGetQuoteDepth(self.extend(request, params))
1170
+ if market['inverse']:
1171
+ response = self.cswapV1PublicGetMarketDepth(self.extend(request, params))
1172
+ else:
1173
+ response = self.swapV2PublicGetQuoteDepth(self.extend(request, params))
1166
1174
  #
1167
1175
  # spot
1168
1176
  #
@@ -1228,6 +1236,7 @@ class bingx(Exchange, ImplicitAPI):
1228
1236
  """
1229
1237
  fetch the current funding rate
1230
1238
  :see: https://bingx-api.github.io/docs/#/swapV2/market-api.html#Current%20Funding%20Rate
1239
+ :see: https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Price%20&%20Current%20Funding%20Rate
1231
1240
  :param str symbol: unified market symbol
1232
1241
  :param dict [params]: extra parameters specific to the exchange API endpoint
1233
1242
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -1237,7 +1246,11 @@ class bingx(Exchange, ImplicitAPI):
1237
1246
  request: dict = {
1238
1247
  'symbol': market['id'],
1239
1248
  }
1240
- response = self.swapV2PublicGetQuotePremiumIndex(self.extend(request, params))
1249
+ response = None
1250
+ if market['inverse']:
1251
+ response = self.cswapV1PublicGetMarketPremiumIndex(self.extend(request, params))
1252
+ else:
1253
+ response = self.swapV2PublicGetQuotePremiumIndex(self.extend(request, params))
1241
1254
  #
1242
1255
  # {
1243
1256
  # "code":0,
@@ -1375,9 +1388,10 @@ class bingx(Exchange, ImplicitAPI):
1375
1388
 
1376
1389
  def fetch_open_interest(self, symbol: str, params={}):
1377
1390
  """
1378
- Retrieves the open interest of a currency
1391
+ retrieves the open interest of a trading pair
1379
1392
  :see: https://bingx-api.github.io/docs/#/swapV2/market-api.html#Get%20Swap%20Open%20Positions
1380
- :param str symbol: Unified CCXT market symbol
1393
+ :see: https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Get%20Swap%20Open%20Positions
1394
+ :param str symbol: unified CCXT market symbol
1381
1395
  :param dict [params]: exchange specific parameters
1382
1396
  :returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
1383
1397
  """
@@ -1386,7 +1400,13 @@ class bingx(Exchange, ImplicitAPI):
1386
1400
  request: dict = {
1387
1401
  'symbol': market['id'],
1388
1402
  }
1389
- response = self.swapV2PublicGetQuoteOpenInterest(self.extend(request, params))
1403
+ response = None
1404
+ if market['inverse']:
1405
+ response = self.cswapV1PublicGetMarketOpenInterest(self.extend(request, params))
1406
+ else:
1407
+ response = self.swapV2PublicGetQuoteOpenInterest(self.extend(request, params))
1408
+ #
1409
+ # linear swap
1390
1410
  #
1391
1411
  # {
1392
1412
  # "code": 0,
@@ -1398,18 +1418,48 @@ class bingx(Exchange, ImplicitAPI):
1398
1418
  # }
1399
1419
  # }
1400
1420
  #
1401
- data = self.safe_dict(response, 'data', {})
1402
- return self.parse_open_interest(data, market)
1421
+ # inverse swap
1422
+ #
1423
+ # {
1424
+ # "code": 0,
1425
+ # "msg": "",
1426
+ # "timestamp": 1720328247986,
1427
+ # "data": [
1428
+ # {
1429
+ # "symbol": "BTC-USD",
1430
+ # "openInterest": "749.1160",
1431
+ # "timestamp": 1720310400000
1432
+ # }
1433
+ # ]
1434
+ # }
1435
+ #
1436
+ result: dict = {}
1437
+ if market['inverse']:
1438
+ data = self.safe_list(response, 'data', [])
1439
+ result = self.safe_dict(data, 0, {})
1440
+ else:
1441
+ result = self.safe_dict(response, 'data', {})
1442
+ return self.parse_open_interest(result, market)
1403
1443
 
1404
1444
  def parse_open_interest(self, interest, market: Market = None):
1405
1445
  #
1406
- # {
1407
- # "openInterest": "3289641547.10",
1408
- # "symbol": "BTC-USDT",
1409
- # "time": 1672026617364
1410
- # }
1446
+ # linear swap
1447
+ #
1448
+ # {
1449
+ # "openInterest": "3289641547.10",
1450
+ # "symbol": "BTC-USDT",
1451
+ # "time": 1672026617364
1452
+ # }
1453
+ #
1454
+ # inverse swap
1455
+ #
1456
+ # {
1457
+ # "symbol": "BTC-USD",
1458
+ # "openInterest": "749.1160",
1459
+ # "timestamp": 1720310400000
1460
+ # }
1411
1461
  #
1412
- timestamp = self.safe_integer(interest, 'time')
1462
+ timestamp = self.safe_integer_2(interest, 'time', 'timestamp')
1413
1463
  id = self.safe_string(interest, 'symbol')
1414
1464
  symbol = self.safe_symbol(id, market, '-', 'swap')
1415
1465
  openInterest = self.safe_number(interest, 'openInterest')
@@ -1869,7 +1919,7 @@ class bingx(Exchange, ImplicitAPI):
1869
1919
  elif timeInForce == 'GTC':
1870
1920
  request['timeInForce'] = 'GTC'
1871
1921
  if isSpot:
1872
- cost = self.safe_number_2(params, 'cost', 'quoteOrderQty')
1922
+ cost = self.safe_string_2(params, 'cost', 'quoteOrderQty')
1873
1923
  params = self.omit(params, 'cost')
1874
1924
  if cost is not None:
1875
1925
  request['quoteOrderQty'] = self.parse_to_numeric(self.cost_to_precision(symbol, cost))
@@ -1979,7 +2029,7 @@ class bingx(Exchange, ImplicitAPI):
1979
2029
  else:
1980
2030
  positionSide = 'LONG' if (side == 'buy') else 'SHORT'
1981
2031
  request['positionSide'] = positionSide
1982
- request['quantity'] = self.parse_to_numeric(self.amount_to_precision(symbol, amount))
2032
+ request['quantity'] = amount if (market['inverse']) else self.parse_to_numeric(self.amount_to_precision(symbol, amount)) # precision not available for inverse contracts
1983
2033
  params = self.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'trailingType', 'takeProfit', 'stopLoss', 'clientOrderId'])
1984
2034
  return self.extend(request, params)
1985
2035
 
@@ -1988,6 +2038,7 @@ class bingx(Exchange, ImplicitAPI):
1988
2038
  create a trade order
1989
2039
  :see: https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
1990
2040
  :see: https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
2041
+ :see: https://bingx-api.github.io/docs/#/en-us/cswap/trade-api.html#Trade%20order
1991
2042
  :param str symbol: unified symbol of the market to create an order in
1992
2043
  :param str type: 'market' or 'limit'
1993
2044
  :param str side: 'buy' or 'sell'
@@ -2020,6 +2071,8 @@ class bingx(Exchange, ImplicitAPI):
2020
2071
  if market['swap']:
2021
2072
  if test:
2022
2073
  response = self.swapV2PrivatePostTradeOrderTest(request)
2074
+ elif market['inverse']:
2075
+ response = self.cswapV1PrivatePostTradeOrder(request)
2023
2076
  else:
2024
2077
  response = self.swapV2PrivatePostTradeOrder(request)
2025
2078
  else:
@@ -2044,7 +2097,7 @@ class bingx(Exchange, ImplicitAPI):
2044
2097
  # }
2045
2098
  # }
2046
2099
  #
2047
- # swap
2100
+ # linear swap
2048
2101
  #
2049
2102
  # {
2050
2103
  # "code": 0,
@@ -2062,15 +2115,37 @@ class bingx(Exchange, ImplicitAPI):
2062
2115
  # }
2063
2116
  # }
2064
2117
  #
2118
+ # inverse swap
2119
+ #
2120
+ # {
2121
+ # "orderId": 1809841379603398656,
2122
+ # "symbol": "SOL-USD",
2123
+ # "positionSide": "LONG",
2124
+ # "side": "BUY",
2125
+ # "type": "LIMIT",
2126
+ # "price": 100,
2127
+ # "quantity": 1,
2128
+ # "stopPrice": 0,
2129
+ # "workingType": "",
2130
+ # "timeInForce": ""
2131
+ # }
2132
+ #
2065
2133
  if isinstance(response, str):
2066
2134
  # broken api engine : order-ids are too long numbers(i.e. 1742930526912864656)
2067
2135
  # and json.loadscan not handle them in JS, so we have to use .parseJson
2068
2136
  # however, when order has an attached SL/TP, their value types need extra parsing
2069
2137
  response = self.fix_stringified_json_members(response)
2070
2138
  response = self.parse_json(response)
2071
- data = self.safe_value(response, 'data', {})
2072
- order = self.safe_dict(data, 'order', data)
2073
- return self.parse_order(order, market)
2139
+ data = self.safe_dict(response, 'data', {})
2140
+ result: dict = {}
2141
+ if market['swap']:
2142
+ if market['inverse']:
2143
+ result = response
2144
+ else:
2145
+ result = self.safe_dict(data, 'order', {})
2146
+ else:
2147
+ result = data
2148
+ return self.parse_order(result, market)
2074
2149
 
2075
2150
  def create_orders(self, orders: List[OrderRequest], params={}):
2076
2151
  """
@@ -2236,7 +2311,7 @@ class bingx(Exchange, ImplicitAPI):
2236
2311
  # }
2237
2312
  #
2238
2313
  #
2239
- # swap
2314
+ # linear swap
2240
2315
  # createOrder, createOrders
2241
2316
  #
2242
2317
  # {
@@ -2247,6 +2322,21 @@ class bingx(Exchange, ImplicitAPI):
2247
2322
  # "type": "LIMIT"
2248
2323
  # }
2249
2324
  #
2325
+ # inverse swap createOrder
2326
+ #
2327
+ # {
2328
+ # "orderId": 1809841379603398656,
2329
+ # "symbol": "SOL-USD",
2330
+ # "positionSide": "LONG",
2331
+ # "side": "BUY",
2332
+ # "type": "LIMIT",
2333
+ # "price": 100,
2334
+ # "quantity": 1,
2335
+ # "stopPrice": 0,
2336
+ # "workingType": "",
2337
+ # "timeInForce": ""
2338
+ # }
2339
+ #
2250
2340
  # fetchOrder, fetchOpenOrders, fetchClosedOrders
2251
2341
  #
2252
2342
  # {
ccxt/bitget.py CHANGED
@@ -20,7 +20,6 @@ from ccxt.base.errors import InsufficientFunds
20
20
  from ccxt.base.errors import InvalidAddress
21
21
  from ccxt.base.errors import InvalidOrder
22
22
  from ccxt.base.errors import OrderNotFound
23
- from ccxt.base.errors import CancelPending
24
23
  from ccxt.base.errors import NotSupported
25
24
  from ccxt.base.errors import DDoSProtection
26
25
  from ccxt.base.errors import RateLimitExceeded
@@ -28,6 +27,7 @@ from ccxt.base.errors import ExchangeNotAvailable
28
27
  from ccxt.base.errors import OnMaintenance
29
28
  from ccxt.base.errors import InvalidNonce
30
29
  from ccxt.base.errors import RequestTimeout
30
+ from ccxt.base.errors import CancelPending
31
31
  from ccxt.base.decimal_to_precision import TICK_SIZE
32
32
  from ccxt.base.precise import Precise
33
33