ccxt 4.1.54__py2.py3-none-any.whl → 4.1.56__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.

Potentially problematic release.


This version of ccxt might be problematic. Click here for more details.

Files changed (251) hide show
  1. ccxt/__init__.py +2 -2
  2. ccxt/abstract/binance.py +1 -0
  3. ccxt/abstract/binancecoinm.py +1 -0
  4. ccxt/abstract/binanceus.py +1 -0
  5. ccxt/abstract/binanceusdm.py +1 -0
  6. ccxt/abstract/bitbank.py +1 -0
  7. ccxt/abstract/coinbase.py +2 -0
  8. ccxt/abstract/htx.py +3 -0
  9. ccxt/abstract/huobi.py +3 -0
  10. ccxt/abstract/huobipro.py +3 -0
  11. ccxt/abstract/okex.py +3 -1
  12. ccxt/abstract/okex5.py +3 -1
  13. ccxt/abstract/okx.py +3 -1
  14. ccxt/ace.py +23 -23
  15. ccxt/alpaca.py +8 -8
  16. ccxt/ascendex.py +26 -26
  17. ccxt/async_support/__init__.py +2 -2
  18. ccxt/async_support/ace.py +23 -23
  19. ccxt/async_support/alpaca.py +8 -8
  20. ccxt/async_support/ascendex.py +26 -26
  21. ccxt/async_support/base/exchange.py +4 -2216
  22. ccxt/async_support/bigone.py +21 -24
  23. ccxt/async_support/binance.py +61 -54
  24. ccxt/async_support/bingx.py +28 -28
  25. ccxt/async_support/bit2c.py +9 -9
  26. ccxt/async_support/bitbank.py +11 -10
  27. ccxt/async_support/bitbns.py +11 -11
  28. ccxt/async_support/bitfinex.py +15 -15
  29. ccxt/async_support/bitfinex2.py +22 -22
  30. ccxt/async_support/bitflyer.py +13 -13
  31. ccxt/async_support/bitforex.py +10 -10
  32. ccxt/async_support/bitget.py +44 -44
  33. ccxt/async_support/bithumb.py +9 -9
  34. ccxt/async_support/bitmart.py +85 -104
  35. ccxt/async_support/bitmex.py +27 -27
  36. ccxt/async_support/bitopro.py +18 -18
  37. ccxt/async_support/bitpanda.py +18 -18
  38. ccxt/async_support/bitrue.py +14 -14
  39. ccxt/async_support/bitso.py +17 -17
  40. ccxt/async_support/bitstamp.py +17 -17
  41. ccxt/async_support/bittrex.py +22 -24
  42. ccxt/async_support/bitvavo.py +15 -15
  43. ccxt/async_support/bl3p.py +4 -4
  44. ccxt/async_support/blockchaincom.py +17 -17
  45. ccxt/async_support/btcalpha.py +14 -14
  46. ccxt/async_support/btcbox.py +9 -9
  47. ccxt/async_support/btcmarkets.py +17 -17
  48. ccxt/async_support/btcturk.py +9 -9
  49. ccxt/async_support/bybit.py +46 -46
  50. ccxt/async_support/cex.py +10 -10
  51. ccxt/async_support/coinbase.py +69 -25
  52. ccxt/async_support/coinbasepro.py +19 -19
  53. ccxt/async_support/coincheck.py +10 -10
  54. ccxt/async_support/coinex.py +57 -66
  55. ccxt/async_support/coinlist.py +22 -22
  56. ccxt/async_support/coinmate.py +10 -10
  57. ccxt/async_support/coinone.py +10 -10
  58. ccxt/async_support/coinsph.py +17 -17
  59. ccxt/async_support/coinspot.py +5 -5
  60. ccxt/async_support/cryptocom.py +27 -27
  61. ccxt/async_support/currencycom.py +18 -18
  62. ccxt/async_support/delta.py +21 -21
  63. ccxt/async_support/deribit.py +24 -24
  64. ccxt/async_support/digifinex.py +35 -35
  65. ccxt/async_support/exmo.py +19 -19
  66. ccxt/async_support/gate.py +38 -38
  67. ccxt/async_support/gemini.py +11 -11
  68. ccxt/async_support/hitbtc.py +27 -27
  69. ccxt/async_support/hollaex.py +19 -19
  70. ccxt/async_support/htx.py +47 -44
  71. ccxt/async_support/huobijp.py +22 -22
  72. ccxt/async_support/idex.py +20 -20
  73. ccxt/async_support/independentreserve.py +9 -9
  74. ccxt/async_support/indodax.py +10 -10
  75. ccxt/async_support/kraken.py +25 -25
  76. ccxt/async_support/krakenfutures.py +17 -17
  77. ccxt/async_support/kucoin.py +27 -27
  78. ccxt/async_support/kucoinfutures.py +20 -20
  79. ccxt/async_support/kuna.py +19 -19
  80. ccxt/async_support/latoken.py +14 -14
  81. ccxt/async_support/lbank.py +18 -18
  82. ccxt/async_support/luno.py +14 -14
  83. ccxt/async_support/lykke.py +12 -12
  84. ccxt/async_support/mercado.py +11 -11
  85. ccxt/async_support/mexc.py +36 -36
  86. ccxt/async_support/ndax.py +18 -18
  87. ccxt/async_support/novadax.py +17 -17
  88. ccxt/async_support/oceanex.py +12 -12
  89. ccxt/async_support/okcoin.py +19 -19
  90. ccxt/async_support/okx.py +48 -45
  91. ccxt/async_support/p2b.py +6 -6
  92. ccxt/async_support/paymium.py +6 -6
  93. ccxt/async_support/phemex.py +57 -57
  94. ccxt/async_support/poloniex.py +31 -30
  95. ccxt/async_support/poloniexfutures.py +16 -16
  96. ccxt/async_support/probit.py +22 -22
  97. ccxt/async_support/tidex.py +15 -15
  98. ccxt/async_support/timex.py +20 -20
  99. ccxt/async_support/tokocrypto.py +16 -16
  100. ccxt/async_support/upbit.py +15 -15
  101. ccxt/async_support/wavesexchange.py +12 -12
  102. ccxt/async_support/wazirx.py +13 -13
  103. ccxt/async_support/whitebit.py +26 -26
  104. ccxt/async_support/woo.py +47 -47
  105. ccxt/async_support/yobit.py +8 -8
  106. ccxt/async_support/zaif.py +10 -10
  107. ccxt/async_support/zonda.py +16 -16
  108. ccxt/base/errors.py +17 -16
  109. ccxt/base/exchange.py +57 -97
  110. ccxt/base/types.py +138 -139
  111. ccxt/bigone.py +21 -24
  112. ccxt/binance.py +61 -54
  113. ccxt/bingx.py +28 -28
  114. ccxt/bit2c.py +9 -9
  115. ccxt/bitbank.py +11 -10
  116. ccxt/bitbns.py +11 -11
  117. ccxt/bitfinex.py +15 -15
  118. ccxt/bitfinex2.py +22 -22
  119. ccxt/bitflyer.py +13 -13
  120. ccxt/bitforex.py +10 -10
  121. ccxt/bitget.py +44 -44
  122. ccxt/bithumb.py +9 -9
  123. ccxt/bitmart.py +85 -104
  124. ccxt/bitmex.py +27 -27
  125. ccxt/bitopro.py +18 -18
  126. ccxt/bitpanda.py +18 -18
  127. ccxt/bitrue.py +14 -14
  128. ccxt/bitso.py +17 -17
  129. ccxt/bitstamp.py +17 -17
  130. ccxt/bittrex.py +22 -24
  131. ccxt/bitvavo.py +15 -15
  132. ccxt/bl3p.py +4 -4
  133. ccxt/blockchaincom.py +17 -17
  134. ccxt/btcalpha.py +14 -14
  135. ccxt/btcbox.py +9 -9
  136. ccxt/btcmarkets.py +17 -17
  137. ccxt/btcturk.py +9 -9
  138. ccxt/bybit.py +46 -46
  139. ccxt/cex.py +10 -10
  140. ccxt/coinbase.py +69 -25
  141. ccxt/coinbasepro.py +19 -19
  142. ccxt/coincheck.py +10 -10
  143. ccxt/coinex.py +57 -66
  144. ccxt/coinlist.py +22 -22
  145. ccxt/coinmate.py +10 -10
  146. ccxt/coinone.py +10 -10
  147. ccxt/coinsph.py +17 -17
  148. ccxt/coinspot.py +5 -5
  149. ccxt/cryptocom.py +27 -27
  150. ccxt/currencycom.py +18 -18
  151. ccxt/delta.py +21 -21
  152. ccxt/deribit.py +24 -24
  153. ccxt/digifinex.py +35 -35
  154. ccxt/exmo.py +19 -19
  155. ccxt/gate.py +38 -38
  156. ccxt/gemini.py +11 -11
  157. ccxt/hitbtc.py +27 -27
  158. ccxt/hollaex.py +19 -19
  159. ccxt/htx.py +47 -44
  160. ccxt/huobijp.py +22 -22
  161. ccxt/idex.py +20 -20
  162. ccxt/independentreserve.py +9 -9
  163. ccxt/indodax.py +10 -10
  164. ccxt/kraken.py +25 -25
  165. ccxt/krakenfutures.py +17 -17
  166. ccxt/kucoin.py +27 -27
  167. ccxt/kucoinfutures.py +20 -20
  168. ccxt/kuna.py +19 -19
  169. ccxt/latoken.py +14 -14
  170. ccxt/lbank.py +18 -18
  171. ccxt/luno.py +14 -14
  172. ccxt/lykke.py +12 -12
  173. ccxt/mercado.py +11 -11
  174. ccxt/mexc.py +36 -36
  175. ccxt/ndax.py +18 -18
  176. ccxt/novadax.py +17 -17
  177. ccxt/oceanex.py +12 -12
  178. ccxt/okcoin.py +19 -19
  179. ccxt/okx.py +48 -45
  180. ccxt/p2b.py +6 -6
  181. ccxt/paymium.py +6 -6
  182. ccxt/phemex.py +57 -57
  183. ccxt/poloniex.py +31 -30
  184. ccxt/poloniexfutures.py +16 -16
  185. ccxt/pro/__init__.py +1 -1
  186. ccxt/pro/alpaca.py +3 -3
  187. ccxt/pro/ascendex.py +2 -2
  188. ccxt/pro/binance.py +9 -9
  189. ccxt/pro/bingx.py +3 -3
  190. ccxt/pro/bitfinex.py +3 -3
  191. ccxt/pro/bitfinex2.py +3 -3
  192. ccxt/pro/bitget.py +3 -3
  193. ccxt/pro/bitmart.py +2 -2
  194. ccxt/pro/bitmex.py +3 -3
  195. ccxt/pro/bitpanda.py +3 -3
  196. ccxt/pro/bitrue.py +2 -2
  197. ccxt/pro/bitstamp.py +2 -2
  198. ccxt/pro/bittrex.py +3 -3
  199. ccxt/pro/bitvavo.py +3 -3
  200. ccxt/pro/blockchaincom.py +2 -2
  201. ccxt/pro/bybit.py +4 -4
  202. ccxt/pro/cex.py +3 -3
  203. ccxt/pro/coinbasepro.py +3 -3
  204. ccxt/pro/coinex.py +2 -2
  205. ccxt/pro/cryptocom.py +5 -5
  206. ccxt/pro/deribit.py +3 -3
  207. ccxt/pro/exmo.py +2 -2
  208. ccxt/pro/gate.py +3 -3
  209. ccxt/pro/gemini.py +2 -2
  210. ccxt/pro/hitbtc.py +4 -4
  211. ccxt/pro/hollaex.py +3 -3
  212. ccxt/pro/htx.py +3 -3
  213. ccxt/pro/idex.py +3 -3
  214. ccxt/pro/kraken.py +7 -7
  215. ccxt/pro/krakenfutures.py +4 -4
  216. ccxt/pro/kucoin.py +3 -3
  217. ccxt/pro/kucoinfutures.py +3 -3
  218. ccxt/pro/mexc.py +3 -3
  219. ccxt/pro/okcoin.py +2 -2
  220. ccxt/pro/okx.py +6 -6
  221. ccxt/pro/phemex.py +3 -3
  222. ccxt/pro/poloniex.py +3 -3
  223. ccxt/pro/poloniexfutures.py +3 -3
  224. ccxt/pro/probit.py +3 -3
  225. ccxt/pro/wazirx.py +3 -3
  226. ccxt/pro/whitebit.py +3 -3
  227. ccxt/pro/woo.py +2 -2
  228. ccxt/probit.py +22 -22
  229. ccxt/test/base/test_shared_methods.py +3 -3
  230. ccxt/test/test_async.py +543 -535
  231. ccxt/test/test_sync.py +542 -534
  232. ccxt/tidex.py +15 -15
  233. ccxt/timex.py +20 -20
  234. ccxt/tokocrypto.py +16 -16
  235. ccxt/upbit.py +15 -15
  236. ccxt/wavesexchange.py +12 -12
  237. ccxt/wazirx.py +13 -13
  238. ccxt/whitebit.py +26 -26
  239. ccxt/woo.py +47 -47
  240. ccxt/yobit.py +8 -8
  241. ccxt/zaif.py +10 -10
  242. ccxt/zonda.py +16 -16
  243. {ccxt-4.1.54.dist-info → ccxt-4.1.56.dist-info}/METADATA +10 -8
  244. ccxt-4.1.56.dist-info/RECORD +449 -0
  245. ccxt/async_support/bitstamp1.py +0 -402
  246. ccxt/async_support/lbank2.py +0 -2620
  247. ccxt/bitstamp1.py +0 -402
  248. ccxt/lbank2.py +0 -2619
  249. ccxt-4.1.54.dist-info/RECORD +0 -453
  250. {ccxt-4.1.54.dist-info → ccxt-4.1.56.dist-info}/WHEEL +0 -0
  251. {ccxt-4.1.54.dist-info → ccxt-4.1.56.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.bitmart import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Balances, Int, Order, OrderBook, OrderSide, OrderType, String, Strings, Ticker, Tickers, Trade, Transaction
9
+ from ccxt.base.types import Balances, Currency, Int, Market, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import PermissionDenied
@@ -979,7 +979,7 @@ class bitmart(Exchange, ImplicitAPI):
979
979
  'deposit': {},
980
980
  }
981
981
 
982
- def parse_deposit_withdraw_fee(self, fee, currency=None):
982
+ def parse_deposit_withdraw_fee(self, fee, currency: Currency = None):
983
983
  #
984
984
  # {
985
985
  # "today_available_withdraw_BTC": "100.0000",
@@ -1030,7 +1030,7 @@ class bitmart(Exchange, ImplicitAPI):
1030
1030
  data = response['data']
1031
1031
  return self.parse_deposit_withdraw_fee(data)
1032
1032
 
1033
- def parse_ticker(self, ticker, market=None) -> Ticker:
1033
+ def parse_ticker(self, ticker, market: Market = None) -> Ticker:
1034
1034
  #
1035
1035
  # spot
1036
1036
  #
@@ -1294,7 +1294,7 @@ class bitmart(Exchange, ImplicitAPI):
1294
1294
  timestamp = self.safe_integer_2(data, 'ts', 'timestamp')
1295
1295
  return self.parse_order_book(data, market['symbol'], timestamp)
1296
1296
 
1297
- def parse_trade(self, trade, market=None) -> Trade:
1297
+ def parse_trade(self, trade, market: Market = None) -> Trade:
1298
1298
  #
1299
1299
  # public fetchTrades spot( amount = count * price )
1300
1300
  #
@@ -1426,7 +1426,7 @@ class bitmart(Exchange, ImplicitAPI):
1426
1426
  trades = self.safe_value(data, 'trades', [])
1427
1427
  return self.parse_trades(trades, market, since, limit)
1428
1428
 
1429
- def parse_ohlcv(self, ohlcv, market=None) -> list:
1429
+ def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
1430
1430
  #
1431
1431
  # spot
1432
1432
  #
@@ -1573,7 +1573,7 @@ class bitmart(Exchange, ImplicitAPI):
1573
1573
  ohlcv = self.safe_value(response, 'data', [])
1574
1574
  return self.parse_ohlcvs(ohlcv, market, timeframe, since, limit)
1575
1575
 
1576
- async def fetch_my_trades(self, symbol: String = None, since: Int = None, limit: Int = None, params={}):
1576
+ async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1577
1577
  """
1578
1578
  :see: https://developer-pro.bitmart.com/en/spot/#account-trade-list-v4-signed
1579
1579
  :see: https://developer-pro.bitmart.com/en/futures/#get-order-trade-keyed
@@ -1675,7 +1675,7 @@ class bitmart(Exchange, ImplicitAPI):
1675
1675
  data = self.safe_value(response, 'data', [])
1676
1676
  return self.parse_trades(data, market, since, limit)
1677
1677
 
1678
- async def fetch_order_trades(self, id: str, symbol: String = None, since: Int = None, limit: Int = None, params={}):
1678
+ async def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1679
1679
  """
1680
1680
  :see: https://developer-pro.bitmart.com/en/spot/#order-trade-list-v4-signed
1681
1681
  fetch all the trades made from a single order
@@ -1862,7 +1862,7 @@ class bitmart(Exchange, ImplicitAPI):
1862
1862
  #
1863
1863
  return self.custom_parse_balance(response, marketType)
1864
1864
 
1865
- def parse_trading_fee(self, fee, market=None):
1865
+ def parse_trading_fee(self, fee, market: Market = None):
1866
1866
  #
1867
1867
  # {
1868
1868
  # "symbol": "ETH_USDT",
@@ -1909,7 +1909,7 @@ class bitmart(Exchange, ImplicitAPI):
1909
1909
  data = self.safe_value(response, 'data')
1910
1910
  return self.parse_trading_fee(data)
1911
1911
 
1912
- def parse_order(self, order, market=None) -> Order:
1912
+ def parse_order(self, order, market: Market = None) -> Order:
1913
1913
  #
1914
1914
  # createOrder
1915
1915
  #
@@ -2042,17 +2042,17 @@ class bitmart(Exchange, ImplicitAPI):
2042
2042
  def parse_order_status_by_type(self, type, status):
2043
2043
  statusesByType = {
2044
2044
  'spot': {
2045
- '1': 'failed', # Order failure
2045
+ '1': 'rejected', # Order failure
2046
2046
  '2': 'open', # Placing order
2047
- '3': 'failed', # Order failure, Freeze failure
2047
+ '3': 'rejected', # Order failure, Freeze failure
2048
2048
  '4': 'open', # Order success, Pending for fulfilment
2049
2049
  '5': 'open', # Partially filled
2050
2050
  '6': 'closed', # Fully filled
2051
- '7': 'canceling', # Canceling
2051
+ '7': 'canceled', # Canceling
2052
2052
  '8': 'canceled', # Canceled
2053
2053
  'new': 'open',
2054
2054
  'partially_filled': 'open',
2055
- 'filled': 'filled',
2055
+ 'filled': 'closed',
2056
2056
  'partially_canceled': 'canceled',
2057
2057
  },
2058
2058
  'swap': {
@@ -2243,7 +2243,7 @@ class bitmart(Exchange, ImplicitAPI):
2243
2243
  request['type'] = 'ioc'
2244
2244
  return self.extend(request, params)
2245
2245
 
2246
- async def cancel_order(self, id: str, symbol: String = None, params={}):
2246
+ async def cancel_order(self, id: str, symbol: Str = None, params={}):
2247
2247
  """
2248
2248
  :see: https://developer-pro.bitmart.com/en/futures/#cancel-order-signed
2249
2249
  :see: https://developer-pro.bitmart.com/en/spot/#cancel-order-v3-signed
@@ -2318,7 +2318,7 @@ class bitmart(Exchange, ImplicitAPI):
2318
2318
  order = self.parse_order(id, market)
2319
2319
  return self.extend(order, {'id': id})
2320
2320
 
2321
- async def cancel_all_orders(self, symbol: String = None, params={}):
2321
+ async def cancel_all_orders(self, symbol: Str = None, params={}):
2322
2322
  """
2323
2323
  cancel all open orders in a market
2324
2324
  :see: https://developer-pro.bitmart.com/en/spot/#cancel-all-orders
@@ -2362,7 +2362,7 @@ class bitmart(Exchange, ImplicitAPI):
2362
2362
  #
2363
2363
  return response
2364
2364
 
2365
- async def fetch_orders_by_status(self, status, symbol: String = None, since: Int = None, limit: Int = None, params={}):
2365
+ async def fetch_orders_by_status(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2366
2366
  self.check_required_symbol('fetchOrdersByStatus', symbol)
2367
2367
  await self.load_markets()
2368
2368
  market = self.market(symbol)
@@ -2414,7 +2414,7 @@ class bitmart(Exchange, ImplicitAPI):
2414
2414
  orders = self.safe_value(data, 'orders', [])
2415
2415
  return self.parse_orders(orders, market, since, limit)
2416
2416
 
2417
- async def fetch_open_orders(self, symbol: String = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2417
+ async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2418
2418
  """
2419
2419
  :see: https://developer-pro.bitmart.com/en/spot/#current-open-orders-v4-signed
2420
2420
  :see: https://developer-pro.bitmart.com/en/futures/#get-all-open-orders-keyed
@@ -2513,14 +2513,17 @@ class bitmart(Exchange, ImplicitAPI):
2513
2513
  data = self.safe_value(response, 'data', [])
2514
2514
  return self.parse_orders(data, market, since, limit)
2515
2515
 
2516
- async def fetch_closed_orders(self, symbol: String = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2516
+ async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2517
2517
  """
2518
2518
  :see: https://developer-pro.bitmart.com/en/spot/#account-orders-v4-signed
2519
+ :see: https://developer-pro.bitmart.com/en/futures/#get-order-history-keyed
2519
2520
  fetches information on multiple closed orders made by the user
2520
2521
  :param str symbol: unified market symbol of the market orders were made in
2521
2522
  :param int [since]: the earliest time in ms to fetch orders for
2522
2523
  :param int [limit]: the maximum number of orde structures to retrieve
2523
2524
  :param dict [params]: extra parameters specific to the bitmart api endpoint
2525
+ :param int [params.until]: timestamp in ms of the latest entry
2526
+ :param str [params.marginMode]: *spot only* 'cross' or 'isolated', for margin trading
2524
2527
  :returns Order[]: a list of `order structures <https://github.com/ccxt/ccxt/wiki/Manual#order-structure>`
2525
2528
  """
2526
2529
  await self.load_markets()
@@ -2532,20 +2535,28 @@ class bitmart(Exchange, ImplicitAPI):
2532
2535
  type = None
2533
2536
  type, params = self.handle_market_type_and_params('fetchClosedOrders', market, params)
2534
2537
  if type != 'spot':
2535
- raise NotSupported(self.id + ' fetchClosedOrders() does not support ' + type + ' orders, only spot orders are accepted')
2538
+ self.check_required_symbol('fetchClosedOrders', symbol)
2536
2539
  marginMode = None
2537
2540
  marginMode, params = self.handle_margin_mode_and_params('fetchClosedOrders', params)
2538
2541
  if marginMode == 'isolated':
2539
2542
  request['orderMode'] = 'iso_margin'
2540
- until = self.safe_integer_2(params, 'until', 'endTime')
2543
+ startTimeKey = 'startTime' if (type == 'spot') else 'start_time'
2544
+ if since is not None:
2545
+ request[startTimeKey] = since
2546
+ endTimeKey = 'endTime' if (type == 'spot') else 'end_time'
2547
+ until = self.safe_integer_2(params, 'until', endTimeKey)
2541
2548
  if until is not None:
2542
- params = self.omit(params, ['endTime'])
2543
- request['endTime'] = until
2544
- response = await self.privatePostSpotV4QueryHistoryOrders(self.extend(request, params))
2545
- data = self.safe_value(response, 'data')
2549
+ params = self.omit(params, ['until'])
2550
+ request[endTimeKey] = until
2551
+ response = None
2552
+ if type == 'spot':
2553
+ response = await self.privatePostSpotV4QueryHistoryOrders(self.extend(request, params))
2554
+ else:
2555
+ response = await self.privateGetContractPrivateOrderHistory(self.extend(request, params))
2556
+ data = self.safe_value(response, 'data', [])
2546
2557
  return self.parse_orders(data, market, since, limit)
2547
2558
 
2548
- async def fetch_canceled_orders(self, symbol: String = None, since: Int = None, limit: Int = None, params={}):
2559
+ async def fetch_canceled_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2549
2560
  """
2550
2561
  fetches information on multiple canceled orders made by the user
2551
2562
  :param str symbol: unified market symbol of the market orders were made in
@@ -2556,7 +2567,7 @@ class bitmart(Exchange, ImplicitAPI):
2556
2567
  """
2557
2568
  return await self.fetch_orders_by_status('canceled', symbol, since, limit, params)
2558
2569
 
2559
- async def fetch_order(self, id: str, symbol: String = None, params={}):
2570
+ async def fetch_order(self, id: str, symbol: Str = None, params={}):
2560
2571
  """
2561
2572
  fetches information on an order made by the user
2562
2573
  :see: https://developer-pro.bitmart.com/en/spot/#query-order-by-id-v4-signed
@@ -2749,7 +2760,7 @@ class bitmart(Exchange, ImplicitAPI):
2749
2760
  'tag': tag,
2750
2761
  })
2751
2762
 
2752
- async def fetch_transactions_by_type(self, type, code: String = None, since: Int = None, limit: Int = None, params={}):
2763
+ async def fetch_transactions_by_type(self, type, code: Str = None, since: Int = None, limit: Int = None, params={}):
2753
2764
  await self.load_markets()
2754
2765
  if limit is None:
2755
2766
  limit = 50 # max 50
@@ -2801,7 +2812,7 @@ class bitmart(Exchange, ImplicitAPI):
2801
2812
  records = self.safe_value(data, 'records', [])
2802
2813
  return self.parse_transactions(records, currency, since, limit)
2803
2814
 
2804
- async def fetch_deposit(self, id: str, code: String = None, params={}):
2815
+ async def fetch_deposit(self, id: str, code: Str = None, params={}):
2805
2816
  """
2806
2817
  fetch information on a deposit
2807
2818
  :param str id: deposit id
@@ -2840,7 +2851,7 @@ class bitmart(Exchange, ImplicitAPI):
2840
2851
  record = self.safe_value(data, 'record', {})
2841
2852
  return self.parse_transaction(record)
2842
2853
 
2843
- async def fetch_deposits(self, code: String = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
2854
+ async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
2844
2855
  """
2845
2856
  fetch all deposits made to an account
2846
2857
  :param str code: unified currency code
@@ -2851,7 +2862,7 @@ class bitmart(Exchange, ImplicitAPI):
2851
2862
  """
2852
2863
  return await self.fetch_transactions_by_type('deposit', code, since, limit, params)
2853
2864
 
2854
- async def fetch_withdrawal(self, id: str, code: String = None, params={}):
2865
+ async def fetch_withdrawal(self, id: str, code: Str = None, params={}):
2855
2866
  """
2856
2867
  fetch data on a currency withdrawal via the withdrawal id
2857
2868
  :param str id: withdrawal id
@@ -2890,7 +2901,7 @@ class bitmart(Exchange, ImplicitAPI):
2890
2901
  record = self.safe_value(data, 'record', {})
2891
2902
  return self.parse_transaction(record)
2892
2903
 
2893
- async def fetch_withdrawals(self, code: String = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
2904
+ async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
2894
2905
  """
2895
2906
  fetch all withdrawals made from an account
2896
2907
  :param str code: unified currency code
@@ -2912,7 +2923,7 @@ class bitmart(Exchange, ImplicitAPI):
2912
2923
  }
2913
2924
  return self.safe_string(statuses, status, status)
2914
2925
 
2915
- def parse_transaction(self, transaction, currency=None) -> Transaction:
2926
+ def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
2916
2927
  #
2917
2928
  # withdraw
2918
2929
  #
@@ -2984,7 +2995,7 @@ class bitmart(Exchange, ImplicitAPI):
2984
2995
  'fee': fee,
2985
2996
  }
2986
2997
 
2987
- async def repay_margin(self, code: str, amount, symbol: String = None, params={}):
2998
+ async def repay_margin(self, code: str, amount, symbol: Str = None, params={}):
2988
2999
  """
2989
3000
  repay borrowed margin and interest
2990
3001
  :see: https://developer-pro.bitmart.com/en/spot/#margin-repay-isolated
@@ -3023,7 +3034,7 @@ class bitmart(Exchange, ImplicitAPI):
3023
3034
  'symbol': symbol,
3024
3035
  })
3025
3036
 
3026
- async def borrow_margin(self, code: str, amount, symbol: String = None, params={}):
3037
+ async def borrow_margin(self, code: str, amount, symbol: Str = None, params={}):
3027
3038
  """
3028
3039
  create a loan to borrow margin
3029
3040
  :see: https://developer-pro.bitmart.com/en/spot/#margin-borrow-isolated
@@ -3062,7 +3073,7 @@ class bitmart(Exchange, ImplicitAPI):
3062
3073
  'symbol': symbol,
3063
3074
  })
3064
3075
 
3065
- def parse_margin_loan(self, info, currency=None):
3076
+ def parse_margin_loan(self, info, currency: Currency = None):
3066
3077
  #
3067
3078
  # borrowMargin
3068
3079
  #
@@ -3087,7 +3098,7 @@ class bitmart(Exchange, ImplicitAPI):
3087
3098
  'info': info,
3088
3099
  }
3089
3100
 
3090
- async def fetch_borrow_rate(self, code: str, params={}):
3101
+ async def fetch_isolated_borrow_rate(self, symbol: str, params={}):
3091
3102
  """
3092
3103
  fetch the rate of interest to borrow a currency for margin trading
3093
3104
  :see: https://developer-pro.bitmart.com/en/spot/#get-trading-pair-borrowing-rate-and-amount
@@ -3097,14 +3108,8 @@ class bitmart(Exchange, ImplicitAPI):
3097
3108
  """
3098
3109
  await self.load_markets()
3099
3110
  market = None
3100
- if code in self.markets:
3101
- market = self.market(code)
3102
- else:
3103
- defaultSettle = self.safe_string(self.options, 'defaultSettle', 'USDT')
3104
- if code == 'USDT':
3105
- market = self.market('BTC' + '/' + defaultSettle)
3106
- else:
3107
- market = self.market(code + '/' + defaultSettle)
3111
+ if symbol is not None:
3112
+ market = self.market(symbol)
3108
3113
  request = {
3109
3114
  'symbol': market['id'],
3110
3115
  }
@@ -3143,10 +3148,10 @@ class bitmart(Exchange, ImplicitAPI):
3143
3148
  #
3144
3149
  data = self.safe_value(response, 'data', {})
3145
3150
  symbols = self.safe_value(data, 'symbols', [])
3146
- currency = market['quote'] if (code == 'USDT') else market['base']
3147
- return self.parse_borrow_rate(symbols, currency)
3151
+ borrowRate = self.safe_value(symbols, 0)
3152
+ return self.parse_isolated_borrow_rate(borrowRate, market)
3148
3153
 
3149
- def parse_borrow_rate(self, info, currency=None):
3154
+ def parse_isolated_borrow_rate(self, info, market: Market = None):
3150
3155
  #
3151
3156
  # {
3152
3157
  # "symbol": "BTC_USDT",
@@ -3170,18 +3175,29 @@ class bitmart(Exchange, ImplicitAPI):
3170
3175
  # }
3171
3176
  # }
3172
3177
  #
3173
- timestamp = self.milliseconds()
3174
- currencyData = self.safe_value(info[0], 'quote', {}) if (currency == 'USDT') else self.safe_value(info[0], 'base', {})
3178
+ marketId = self.safe_string(info, 'symbol')
3179
+ symbol = self.safe_symbol(marketId, market)
3180
+ baseData = self.safe_value(info, 'base')
3181
+ quoteData = self.safe_value(info, 'quote')
3182
+ baseId = self.safe_string(baseData, 'currency')
3183
+ quoteId = self.safe_string(quoteData, 'currency')
3184
+ base = self.safe_currency_code(baseId)
3185
+ quote = self.safe_currency_code(quoteId)
3186
+ baseRate = self.safe_number(baseData, 'hourly_interest')
3187
+ quoteRate = self.safe_number(quoteData, 'hourly_interest')
3175
3188
  return {
3176
- 'currency': self.safe_currency_code(currency),
3177
- 'rate': self.safe_number(currencyData, 'hourly_interest'),
3189
+ 'symbol': symbol,
3190
+ 'base': base,
3191
+ 'baseRate': baseRate,
3192
+ 'quote': quote,
3193
+ 'quoteRate': quoteRate,
3178
3194
  'period': 3600000, # 1-Hour
3179
- 'timestamp': timestamp,
3180
- 'datetime': self.iso8601(timestamp),
3195
+ 'timestamp': None,
3196
+ 'datetime': None,
3181
3197
  'info': info,
3182
3198
  }
3183
3199
 
3184
- async def fetch_borrow_rates(self, params={}):
3200
+ async def fetch_isolated_borrow_rates(self, params={}):
3185
3201
  """
3186
3202
  fetch the borrow interest rates of all currencies, currently only works for isolated margin
3187
3203
  :see: https://developer-pro.bitmart.com/en/spot/#get-trading-pair-borrowing-rate-and-amount
@@ -3224,46 +3240,11 @@ class bitmart(Exchange, ImplicitAPI):
3224
3240
  #
3225
3241
  data = self.safe_value(response, 'data', {})
3226
3242
  symbols = self.safe_value(data, 'symbols', [])
3227
- return self.parse_borrow_rates(symbols, None)
3228
-
3229
- def parse_borrow_rates(self, info, codeKey):
3230
- #
3231
- # {
3232
- # "symbol": "BTC_USDT",
3233
- # "max_leverage": "5",
3234
- # "symbol_enabled": True,
3235
- # "base": {
3236
- # "currency": "BTC",
3237
- # "daily_interest": "0.00055000",
3238
- # "hourly_interest": "0.00002291",
3239
- # "max_borrow_amount": "2.00000000",
3240
- # "min_borrow_amount": "0.00000001",
3241
- # "borrowable_amount": "0.00670810"
3242
- # },
3243
- # "quote": {
3244
- # "currency": "USDT",
3245
- # "daily_interest": "0.00055000",
3246
- # "hourly_interest": "0.00002291",
3247
- # "max_borrow_amount": "50000.00000000",
3248
- # "min_borrow_amount": "0.00000001",
3249
- # "borrowable_amount": "135.12575038"
3250
- # }
3251
- # }
3252
- #
3253
- timestamp = self.milliseconds()
3254
- rates = []
3255
- for i in range(0, len(info)):
3256
- entry = info[i]
3257
- base = self.safe_value(entry, 'base', {})
3258
- rates.append({
3259
- 'currency': self.safe_currency_code(self.safe_string(base, 'currency')),
3260
- 'rate': self.safe_number(base, 'hourly_interest'),
3261
- 'period': 3600000, # 1-Hour
3262
- 'timestamp': timestamp,
3263
- 'datetime': self.iso8601(timestamp),
3264
- 'info': entry,
3265
- })
3266
- return rates
3243
+ result = []
3244
+ for i in range(0, len(symbols)):
3245
+ symbol = self.safe_value(symbols, i)
3246
+ result.append(self.parse_isolated_borrow_rate(symbol))
3247
+ return result
3267
3248
 
3268
3249
  async def transfer(self, code: str, amount, fromAccount, toAccount, params={}):
3269
3250
  """
@@ -3356,7 +3337,7 @@ class bitmart(Exchange, ImplicitAPI):
3356
3337
  }
3357
3338
  return self.safe_string(types, type, type)
3358
3339
 
3359
- def parse_transfer(self, transfer, currency=None):
3340
+ def parse_transfer(self, transfer, currency: Currency = None):
3360
3341
  #
3361
3342
  # margin
3362
3343
  #
@@ -3395,7 +3376,7 @@ class bitmart(Exchange, ImplicitAPI):
3395
3376
  'status': self.parse_transfer_status(self.safe_string(transfer, 'state')),
3396
3377
  }
3397
3378
 
3398
- async def fetch_transfers(self, code: String = None, since: Int = None, limit: Int = None, params={}):
3379
+ async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
3399
3380
  """
3400
3381
  fetch a history of internal transfers made on an account, only transfers between spot and swap are supported
3401
3382
  :see: https://developer-pro.bitmart.com/en/futures/#get-transfer-list-signed
@@ -3451,7 +3432,7 @@ class bitmart(Exchange, ImplicitAPI):
3451
3432
  records = self.safe_value(data, 'records', [])
3452
3433
  return self.parse_transfers(records, currency, since, limit)
3453
3434
 
3454
- async def fetch_borrow_interest(self, code: String = None, symbol: String = None, since: Int = None, limit: Int = None, params={}):
3435
+ async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3455
3436
  """
3456
3437
  fetch the interest owed by the user for borrowing currency for margin trading
3457
3438
  :see: https://developer-pro.bitmart.com/en/spot/#get-borrow-record-isolated
@@ -3499,7 +3480,7 @@ class bitmart(Exchange, ImplicitAPI):
3499
3480
  interest = self.parse_borrow_interests(rows, market)
3500
3481
  return self.filter_by_currency_since_limit(interest, code, since, limit)
3501
3482
 
3502
- def parse_borrow_interest(self, info, market=None):
3483
+ def parse_borrow_interest(self, info, market: Market = None):
3503
3484
  #
3504
3485
  # {
3505
3486
  # "borrow_id": "1657664327844Lk5eJJugXmdHHZoe",
@@ -3559,7 +3540,7 @@ class bitmart(Exchange, ImplicitAPI):
3559
3540
  data = self.safe_value(response, 'data', {})
3560
3541
  return self.parse_open_interest(data, market)
3561
3542
 
3562
- def parse_open_interest(self, interest, market=None):
3543
+ def parse_open_interest(self, interest, market: Market = None):
3563
3544
  #
3564
3545
  # {
3565
3546
  # "timestamp": 1694657502415,
@@ -3579,7 +3560,7 @@ class bitmart(Exchange, ImplicitAPI):
3579
3560
  'info': interest,
3580
3561
  }, market)
3581
3562
 
3582
- async def set_leverage(self, leverage, symbol: String = None, params={}):
3563
+ async def set_leverage(self, leverage, symbol: Str = None, params={}):
3583
3564
  """
3584
3565
  set the level of leverage for a market
3585
3566
  :see: https://developer-pro.bitmart.com/en/futures/#submit-leverage-signed
@@ -3636,7 +3617,7 @@ class bitmart(Exchange, ImplicitAPI):
3636
3617
  data = self.safe_value(response, 'data', {})
3637
3618
  return self.parse_funding_rate(data, market)
3638
3619
 
3639
- def parse_funding_rate(self, contract, market=None):
3620
+ def parse_funding_rate(self, contract, market: Market = None):
3640
3621
  #
3641
3622
  # {
3642
3623
  # "timestamp": 1695184410697,
@@ -3770,7 +3751,7 @@ class bitmart(Exchange, ImplicitAPI):
3770
3751
  symbols = self.market_symbols(symbols)
3771
3752
  return self.filter_by_array_positions(result, 'symbol', symbols, False)
3772
3753
 
3773
- def parse_position(self, position, market=None):
3754
+ def parse_position(self, position, market: Market = None):
3774
3755
  #
3775
3756
  # {
3776
3757
  # "symbol": "BTCUSDT",
@@ -3834,7 +3815,7 @@ class bitmart(Exchange, ImplicitAPI):
3834
3815
  'takeProfitPrice': None,
3835
3816
  })
3836
3817
 
3837
- async def fetch_my_liquidations(self, symbol: String = None, since: Int = None, limit: Int = None, params={}):
3818
+ async def fetch_my_liquidations(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3838
3819
  """
3839
3820
  retrieves the users liquidated positions
3840
3821
  :see: https://developer-pro.bitmart.com/en/futures/#get-order-history-keyed
@@ -3891,7 +3872,7 @@ class bitmart(Exchange, ImplicitAPI):
3891
3872
  result.append(entry)
3892
3873
  return self.parse_liquidations(result, market, since, limit)
3893
3874
 
3894
- def parse_liquidation(self, liquidation, market=None):
3875
+ def parse_liquidation(self, liquidation, market: Market = None):
3895
3876
  #
3896
3877
  # {
3897
3878
  # "order_id": "231007865458273",