ccxt 4.2.38__py2.py3-none-any.whl → 4.2.40__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 (141) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/bingx.py +4 -0
  3. ccxt/abstract/coinbase.py +1 -0
  4. ccxt/abstract/coinbasepro.py +1 -0
  5. ccxt/abstract/okx.py +1 -0
  6. ccxt/ascendex.py +31 -27
  7. ccxt/async_support/__init__.py +1 -1
  8. ccxt/async_support/ascendex.py +31 -27
  9. ccxt/async_support/base/exchange.py +19 -7
  10. ccxt/async_support/bigone.py +2 -2
  11. ccxt/async_support/binance.py +478 -188
  12. ccxt/async_support/bingx.py +250 -28
  13. ccxt/async_support/bitfinex.py +3 -3
  14. ccxt/async_support/bitfinex2.py +2 -2
  15. ccxt/async_support/bitget.py +16 -7
  16. ccxt/async_support/bitmart.py +2 -2
  17. ccxt/async_support/bitmex.py +2 -2
  18. ccxt/async_support/bitrue.py +2 -2
  19. ccxt/async_support/bitso.py +19 -3
  20. ccxt/async_support/bitstamp.py +25 -3
  21. ccxt/async_support/bitvavo.py +1 -1
  22. ccxt/async_support/bl3p.py +6 -0
  23. ccxt/async_support/blockchaincom.py +21 -0
  24. ccxt/async_support/blofin.py +2 -2
  25. ccxt/async_support/btcalpha.py +9 -0
  26. ccxt/async_support/btcbox.py +9 -0
  27. ccxt/async_support/btcmarkets.py +19 -0
  28. ccxt/async_support/bybit.py +9 -7
  29. ccxt/async_support/cex.py +1 -1
  30. ccxt/async_support/coinbase.py +20 -9
  31. ccxt/async_support/coinbasepro.py +1 -0
  32. ccxt/async_support/coinex.py +4 -4
  33. ccxt/async_support/coinlist.py +11 -9
  34. ccxt/async_support/coinmetro.py +2 -1
  35. ccxt/async_support/coinone.py +1 -1
  36. ccxt/async_support/delta.py +2 -2
  37. ccxt/async_support/deribit.py +3 -3
  38. ccxt/async_support/digifinex.py +3 -3
  39. ccxt/async_support/exmo.py +2 -2
  40. ccxt/async_support/gate.py +6 -6
  41. ccxt/async_support/hitbtc.py +2 -2
  42. ccxt/async_support/hollaex.py +1 -1
  43. ccxt/async_support/htx.py +3 -3
  44. ccxt/async_support/huobijp.py +1 -1
  45. ccxt/async_support/kraken.py +2 -2
  46. ccxt/async_support/krakenfutures.py +117 -16
  47. ccxt/async_support/kucoin.py +5 -5
  48. ccxt/async_support/kucoinfutures.py +2 -2
  49. ccxt/async_support/latoken.py +1 -1
  50. ccxt/async_support/lbank.py +2 -2
  51. ccxt/async_support/luno.py +2 -2
  52. ccxt/async_support/mexc.py +5 -5
  53. ccxt/async_support/ndax.py +1 -1
  54. ccxt/async_support/novadax.py +1 -1
  55. ccxt/async_support/okcoin.py +2 -2
  56. ccxt/async_support/okx.py +18 -21
  57. ccxt/async_support/paymium.py +2 -2
  58. ccxt/async_support/phemex.py +5 -4
  59. ccxt/async_support/poloniex.py +2 -2
  60. ccxt/async_support/poloniexfutures.py +10 -6
  61. ccxt/async_support/probit.py +1 -1
  62. ccxt/async_support/timex.py +1 -1
  63. ccxt/async_support/upbit.py +1 -1
  64. ccxt/async_support/wavesexchange.py +1 -1
  65. ccxt/async_support/whitebit.py +2 -2
  66. ccxt/async_support/woo.py +4 -4
  67. ccxt/async_support/zonda.py +3 -3
  68. ccxt/base/exchange.py +37 -25
  69. ccxt/bigone.py +2 -2
  70. ccxt/binance.py +478 -188
  71. ccxt/bingx.py +250 -28
  72. ccxt/bitfinex.py +3 -3
  73. ccxt/bitfinex2.py +2 -2
  74. ccxt/bitget.py +16 -7
  75. ccxt/bitmart.py +2 -2
  76. ccxt/bitmex.py +2 -2
  77. ccxt/bitrue.py +2 -2
  78. ccxt/bitso.py +19 -3
  79. ccxt/bitstamp.py +25 -3
  80. ccxt/bitvavo.py +1 -1
  81. ccxt/bl3p.py +6 -0
  82. ccxt/blockchaincom.py +21 -0
  83. ccxt/blofin.py +2 -2
  84. ccxt/btcalpha.py +9 -0
  85. ccxt/btcbox.py +9 -0
  86. ccxt/btcmarkets.py +19 -0
  87. ccxt/bybit.py +9 -7
  88. ccxt/cex.py +1 -1
  89. ccxt/coinbase.py +20 -9
  90. ccxt/coinbasepro.py +1 -0
  91. ccxt/coinex.py +4 -4
  92. ccxt/coinlist.py +11 -9
  93. ccxt/coinmetro.py +2 -1
  94. ccxt/coinone.py +1 -1
  95. ccxt/delta.py +2 -2
  96. ccxt/deribit.py +3 -3
  97. ccxt/digifinex.py +3 -3
  98. ccxt/exmo.py +2 -2
  99. ccxt/gate.py +6 -6
  100. ccxt/hitbtc.py +2 -2
  101. ccxt/hollaex.py +1 -1
  102. ccxt/htx.py +3 -3
  103. ccxt/huobijp.py +1 -1
  104. ccxt/kraken.py +2 -2
  105. ccxt/krakenfutures.py +117 -16
  106. ccxt/kucoin.py +5 -5
  107. ccxt/kucoinfutures.py +2 -2
  108. ccxt/latoken.py +1 -1
  109. ccxt/lbank.py +2 -2
  110. ccxt/luno.py +2 -2
  111. ccxt/mexc.py +5 -5
  112. ccxt/ndax.py +1 -1
  113. ccxt/novadax.py +1 -1
  114. ccxt/okcoin.py +2 -2
  115. ccxt/okx.py +18 -21
  116. ccxt/paymium.py +2 -2
  117. ccxt/phemex.py +5 -4
  118. ccxt/poloniex.py +2 -2
  119. ccxt/poloniexfutures.py +10 -6
  120. ccxt/pro/__init__.py +1 -1
  121. ccxt/pro/bitmart.py +129 -46
  122. ccxt/pro/bitvavo.py +1 -1
  123. ccxt/pro/bybit.py +6 -6
  124. ccxt/pro/cex.py +2 -2
  125. ccxt/pro/coinbase.py +2 -2
  126. ccxt/pro/coinex.py +1 -1
  127. ccxt/pro/lbank.py +1 -1
  128. ccxt/pro/mexc.py +1 -1
  129. ccxt/probit.py +1 -1
  130. ccxt/test/test_async.py +3 -1
  131. ccxt/test/test_sync.py +3 -1
  132. ccxt/timex.py +1 -1
  133. ccxt/upbit.py +1 -1
  134. ccxt/wavesexchange.py +1 -1
  135. ccxt/whitebit.py +2 -2
  136. ccxt/woo.py +4 -4
  137. ccxt/zonda.py +3 -3
  138. {ccxt-4.2.38.dist-info → ccxt-4.2.40.dist-info}/METADATA +4 -4
  139. {ccxt-4.2.38.dist-info → ccxt-4.2.40.dist-info}/RECORD +141 -141
  140. {ccxt-4.2.38.dist-info → ccxt-4.2.40.dist-info}/WHEEL +0 -0
  141. {ccxt-4.2.38.dist-info → ccxt-4.2.40.dist-info}/top_level.txt +0 -0
@@ -2075,7 +2075,7 @@ class hitbtc(Exchange, ImplicitAPI):
2075
2075
  raise NotSupported(self.id + ' cancelOrder() not support self market type')
2076
2076
  return self.parse_order(response, market)
2077
2077
 
2078
- async def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
2078
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
2079
2079
  await self.load_markets()
2080
2080
  market = None
2081
2081
  request = {
@@ -2400,7 +2400,7 @@ class hitbtc(Exchange, ImplicitAPI):
2400
2400
  filteredMargin = self.filter_by_symbol(marginModes, symbol)
2401
2401
  return self.safe_value(filteredMargin, 0)
2402
2402
 
2403
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
2403
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2404
2404
  """
2405
2405
  transfer currency internally between wallets on the same account
2406
2406
  :see: https://api.hitbtc.com/#transfer-between-wallet-and-exchange
@@ -1277,7 +1277,7 @@ class hollaex(Exchange, ImplicitAPI):
1277
1277
  'info': depositAddress,
1278
1278
  }
1279
1279
 
1280
- async def fetch_deposit_addresses(self, codes=None, params={}):
1280
+ async def fetch_deposit_addresses(self, codes: List[str] = None, params={}):
1281
1281
  """
1282
1282
  fetch deposit addresses for multiple currencies and chain types
1283
1283
  :param str[]|None codes: list of unified currency codes, default is None
ccxt/async_support/htx.py CHANGED
@@ -4753,7 +4753,7 @@ class htx(Exchange, ImplicitAPI):
4753
4753
  'trades': trades,
4754
4754
  }, market)
4755
4755
 
4756
- async def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
4756
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
4757
4757
  """
4758
4758
  create a market buy order by providing the symbol and cost
4759
4759
  :see: https://www.htx.com/en-us/opend/newApiPages/?id=7ec4ee16-7773-11ed-9966-0242ac110003
@@ -6023,7 +6023,7 @@ class htx(Exchange, ImplicitAPI):
6023
6023
  'status': None,
6024
6024
  }
6025
6025
 
6026
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
6026
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
6027
6027
  """
6028
6028
  transfer currency internally between wallets on the same account
6029
6029
  :see: https://huobiapi.github.io/docs/dm/v1/en/#transfer-margin-between-spot-account-and-future-account
@@ -8357,7 +8357,7 @@ class htx(Exchange, ImplicitAPI):
8357
8357
  'datetime': self.iso8601(timestamp),
8358
8358
  })
8359
8359
 
8360
- async def set_position_mode(self, hedged, symbol: Str = None, params={}):
8360
+ async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
8361
8361
  """
8362
8362
  set hedged to True or False
8363
8363
  :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-position-mode
@@ -1305,7 +1305,7 @@ class huobijp(Exchange, ImplicitAPI):
1305
1305
  'trades': None,
1306
1306
  }, market)
1307
1307
 
1308
- async def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
1308
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1309
1309
  """
1310
1310
  create a market buy order by providing the symbol and cost
1311
1311
  :param str symbol: unified symbol of the market to create an order in
@@ -1669,7 +1669,7 @@ class kraken(Exchange, ImplicitAPI):
1669
1669
  params = self.omit(params, ['timeInForce', 'reduceOnly', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingLimitAmount', 'offset'])
1670
1670
  return [request, params]
1671
1671
 
1672
- async def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
1672
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
1673
1673
  """
1674
1674
  edit a trade order
1675
1675
  :see: https://docs.kraken.com/rest/#tag/Trading/operation/editOrder
@@ -2597,7 +2597,7 @@ class kraken(Exchange, ImplicitAPI):
2597
2597
  """
2598
2598
  return await self.transfer(code, amount, 'spot', 'swap', params)
2599
2599
 
2600
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
2600
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2601
2601
  """
2602
2602
  :see: https://docs.kraken.com/rest/#tag/User-Funding/operation/walletTransfer
2603
2603
  transfers currencies between sub-accounts(only spot->swap direction is supported)
@@ -54,7 +54,8 @@ class krakenfutures(Exchange, ImplicitAPI):
54
54
  'fetchBalance': True,
55
55
  'fetchBorrowRateHistories': False,
56
56
  'fetchBorrowRateHistory': False,
57
- 'fetchClosedOrders': None, # https://support.kraken.com/hc/en-us/articles/360058243651-Historical-orders
57
+ 'fetchCanceledOrders': True,
58
+ 'fetchClosedOrders': True, # https://support.kraken.com/hc/en-us/articles/360058243651-Historical-orders
58
59
  'fetchCrossBorrowRate': False,
59
60
  'fetchCrossBorrowRates': False,
60
61
  'fetchDepositAddress': False,
@@ -784,32 +785,27 @@ class krakenfutures(Exchange, ImplicitAPI):
784
785
  if id is None:
785
786
  id = self.safe_string(trade, 'executionId')
786
787
  order = self.safe_string(trade, 'order_id')
787
- symbolId = self.safe_string(trade, 'symbol')
788
+ marketId = self.safe_string(trade, 'symbol')
788
789
  side = self.safe_string(trade, 'side')
789
790
  type = None
790
791
  priorEdit = self.safe_value(trade, 'orderPriorEdit')
791
792
  priorExecution = self.safe_value(trade, 'orderPriorExecution')
792
793
  if priorExecution is not None:
793
794
  order = self.safe_string(priorExecution, 'orderId')
794
- symbolId = self.safe_string(priorExecution, 'symbol')
795
+ marketId = self.safe_string(priorExecution, 'symbol')
795
796
  side = self.safe_string(priorExecution, 'side')
796
797
  type = self.safe_string(priorExecution, 'type')
797
798
  elif priorEdit is not None:
798
799
  order = self.safe_string(priorEdit, 'orderId')
799
- symbolId = self.safe_string(priorEdit, 'symbol')
800
+ marketId = self.safe_string(priorEdit, 'symbol')
800
801
  side = self.safe_string(priorEdit, 'type')
801
802
  type = self.safe_string(priorEdit, 'type')
802
803
  if type is not None:
803
804
  type = self.parse_order_type(type)
804
- symbol = None
805
- if symbolId is not None:
806
- market = self.safe_value(self.markets_by_id, symbolId)
807
- if market is None:
808
- symbol = symbolId
809
- symbol = self.safe_string(market, 'symbol', symbol)
805
+ market = self.safe_market(marketId, market)
810
806
  cost = None
807
+ linear = self.safe_bool(market, 'linear')
811
808
  if (amount is not None) and (price is not None) and (market is not None):
812
- linear = self.safe_value(market, 'linear')
813
809
  if linear:
814
810
  cost = Precise.string_mul(amount, price) # in quote
815
811
  else:
@@ -826,15 +822,15 @@ class krakenfutures(Exchange, ImplicitAPI):
826
822
  return self.safe_trade({
827
823
  'info': trade,
828
824
  'id': id,
825
+ 'symbol': self.safe_string(market, 'symbol'),
829
826
  'timestamp': timestamp,
830
827
  'datetime': self.iso8601(timestamp),
831
- 'symbol': symbol,
832
828
  'order': order,
833
829
  'type': type,
834
830
  'side': side,
835
831
  'takerOrMaker': takerOrMaker,
836
832
  'price': price,
837
- 'amount': amount,
833
+ 'amount': amount if linear else None,
838
834
  'cost': cost,
839
835
  'fee': None,
840
836
  })
@@ -994,7 +990,7 @@ class krakenfutures(Exchange, ImplicitAPI):
994
990
  data = self.safe_value(response, 'batchStatus', [])
995
991
  return self.parse_orders(data)
996
992
 
997
- async def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
993
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
998
994
  """
999
995
  :see: https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-edit-order
1000
996
  Edit an open order on the exchange
@@ -1130,6 +1126,84 @@ class krakenfutures(Exchange, ImplicitAPI):
1130
1126
  orders = self.safe_value(response, 'openOrders', [])
1131
1127
  return self.parse_orders(orders, market, since, limit)
1132
1128
 
1129
+ async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1130
+ """
1131
+ :see: https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
1132
+ Gets all closed orders, including trigger orders, for an account from the exchange api
1133
+ :param str symbol: Unified market symbol
1134
+ :param int [since]: Timestamp(ms) of earliest order.
1135
+ :param int [limit]: How many orders to return.
1136
+ :param dict [params]: Exchange specific parameters
1137
+ :returns: An array of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1138
+ """
1139
+ await self.load_markets()
1140
+ market = None
1141
+ if symbol is not None:
1142
+ market = self.market(symbol)
1143
+ request = {}
1144
+ if limit is not None:
1145
+ request['count'] = limit
1146
+ if since is not None:
1147
+ request['from'] = since
1148
+ response = await self.historyGetOrders(self.extend(request, params))
1149
+ allOrders = self.safe_list(response, 'elements', [])
1150
+ closedOrders = []
1151
+ for i in range(0, len(allOrders)):
1152
+ order = allOrders[i]
1153
+ event = self.safe_dict(order, 'event', {})
1154
+ orderPlaced = self.safe_dict(event, 'OrderPlaced')
1155
+ if orderPlaced is not None:
1156
+ innerOrder = self.safe_dict(orderPlaced, 'order', {})
1157
+ filled = self.safe_string(innerOrder, 'filled')
1158
+ if filled != '0':
1159
+ innerOrder['status'] = 'closed' # status not available in the response
1160
+ closedOrders.append(innerOrder)
1161
+ return self.parse_orders(closedOrders, market, since, limit)
1162
+
1163
+ async def fetch_canceled_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1164
+ """
1165
+ :see: https://docs.futures.kraken.com/#http-api-history-account-history-get-order-events
1166
+ Gets all canceled orders, including trigger orders, for an account from the exchange api
1167
+ :param str symbol: Unified market symbol
1168
+ :param int [since]: Timestamp(ms) of earliest order.
1169
+ :param int [limit]: How many orders to return.
1170
+ :param dict [params]: Exchange specific parameters
1171
+ :returns: An array of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1172
+ """
1173
+ await self.load_markets()
1174
+ market = None
1175
+ if symbol is not None:
1176
+ market = self.market(symbol)
1177
+ request = {}
1178
+ if limit is not None:
1179
+ request['count'] = limit
1180
+ if since is not None:
1181
+ request['from'] = since
1182
+ response = await self.historyGetOrders(self.extend(request, params))
1183
+ allOrders = self.safe_list(response, 'elements', [])
1184
+ canceledAndRejected = []
1185
+ for i in range(0, len(allOrders)):
1186
+ order = allOrders[i]
1187
+ event = self.safe_dict(order, 'event', {})
1188
+ orderPlaced = self.safe_dict(event, 'OrderPlaced')
1189
+ if orderPlaced is not None:
1190
+ innerOrder = self.safe_dict(orderPlaced, 'order', {})
1191
+ filled = self.safe_string(innerOrder, 'filled')
1192
+ if filled == '0':
1193
+ innerOrder['status'] = 'canceled' # status not available in the response
1194
+ canceledAndRejected.append(innerOrder)
1195
+ orderCanceled = self.safe_dict(event, 'OrderCancelled')
1196
+ if orderCanceled is not None:
1197
+ innerOrder = self.safe_dict(orderCanceled, 'order', {})
1198
+ innerOrder['status'] = 'canceled' # status not available in the response
1199
+ canceledAndRejected.append(innerOrder)
1200
+ orderRejected = self.safe_dict(event, 'OrderRejected')
1201
+ if orderRejected is not None:
1202
+ innerOrder = self.safe_dict(orderRejected, 'order', {})
1203
+ innerOrder['status'] = 'rejected' # status not available in the response
1204
+ canceledAndRejected.append(innerOrder)
1205
+ return self.parse_orders(canceledAndRejected, market, since, limit)
1206
+
1133
1207
  def parse_order_type(self, orderType):
1134
1208
  map = {
1135
1209
  'lmt': 'limit',
@@ -1372,6 +1446,32 @@ class krakenfutures(Exchange, ImplicitAPI):
1372
1446
  # "status": "requiredArgumentMissing",
1373
1447
  # "orderEvents": []
1374
1448
  # }
1449
+ # closed orders
1450
+ # {
1451
+ # uid: '2f00cd63-e61d-44f8-8569-adabde885941',
1452
+ # timestamp: '1707258274849',
1453
+ # event: {
1454
+ # OrderPlaced: {
1455
+ # order: {
1456
+ # uid: '85805e01-9eed-4395-8360-ed1a228237c9',
1457
+ # accountUid: '406142dd-7c5c-4a8b-acbc-5f16eca30009',
1458
+ # tradeable: 'PF_LTCUSD',
1459
+ # direction: 'Buy',
1460
+ # quantity: '0',
1461
+ # filled: '0.1',
1462
+ # timestamp: '1707258274849',
1463
+ # limitPrice: '69.2200000000',
1464
+ # orderType: 'IoC',
1465
+ # clientId: '',
1466
+ # reduceOnly: False,
1467
+ # lastUpdateTimestamp: '1707258274849'
1468
+ # },
1469
+ # reason: 'new_user_order',
1470
+ # reducedQuantity: '',
1471
+ # algoId: ''
1472
+ # }
1473
+ # }
1474
+ # }
1375
1475
  #
1376
1476
  orderEvents = self.safe_value(order, 'orderEvents', [])
1377
1477
  errorStatus = self.safe_string(order, 'status')
@@ -1424,7 +1524,8 @@ class krakenfutures(Exchange, ImplicitAPI):
1424
1524
  remaining = self.safe_string(details, 'unfilledSize')
1425
1525
  average = None
1426
1526
  filled2 = '0.0'
1427
- if len(trades):
1527
+ tradesLength = len(trades)
1528
+ if tradesLength > 0:
1428
1529
  vwapSum = '0.0'
1429
1530
  for i in range(0, len(trades)):
1430
1531
  trade = trades[i]
@@ -2137,7 +2238,7 @@ class krakenfutures(Exchange, ImplicitAPI):
2137
2238
  """
2138
2239
  return await self.transfer(code, amount, 'future', 'spot', params)
2139
2240
 
2140
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
2241
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2141
2242
  """
2142
2243
  :see: https://docs.futures.kraken.com/#http-api-trading-v3-api-transfers-initiate-wallet-transfer
2143
2244
  :see: https://docs.futures.kraken.com/#http-api-trading-v3-api-transfers-initiate-withdrawal-to-spot-wallet
@@ -1903,7 +1903,7 @@ class kucoin(Exchange, ImplicitAPI):
1903
1903
  data = self.safe_value(response, 'data', {})
1904
1904
  return self.parse_order(data, market)
1905
1905
 
1906
- async def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost, params={}):
1906
+ async def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
1907
1907
  """
1908
1908
  create a market order by providing the symbol, side and cost
1909
1909
  :see: https://www.kucoin.com/docs/rest/spot-trading/orders/place-order
@@ -1917,7 +1917,7 @@ class kucoin(Exchange, ImplicitAPI):
1917
1917
  params['cost'] = cost
1918
1918
  return await self.create_order(symbol, 'market', side, cost, None, params)
1919
1919
 
1920
- async def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
1920
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1921
1921
  """
1922
1922
  create a market buy order by providing the symbol and cost
1923
1923
  :see: https://www.kucoin.com/docs/rest/spot-trading/orders/place-order
@@ -1929,7 +1929,7 @@ class kucoin(Exchange, ImplicitAPI):
1929
1929
  await self.load_markets()
1930
1930
  return await self.create_market_order_with_cost(symbol, 'buy', cost, params)
1931
1931
 
1932
- async def create_market_sell_order_with_cost(self, symbol: str, cost, params={}):
1932
+ async def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
1933
1933
  """
1934
1934
  create a market sell order by providing the symbol and cost
1935
1935
  :see: https://www.kucoin.com/docs/rest/spot-trading/orders/place-order
@@ -2074,7 +2074,7 @@ class kucoin(Exchange, ImplicitAPI):
2074
2074
  request['postOnly'] = True
2075
2075
  return self.extend(request, params)
2076
2076
 
2077
- async def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
2077
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
2078
2078
  """
2079
2079
  edit an order, kucoin currently only supports the modification of HF orders
2080
2080
  :see: https://docs.kucoin.com/spot-hf/#modify-order
@@ -3373,7 +3373,7 @@ class kucoin(Exchange, ImplicitAPI):
3373
3373
  returnType = result if isolated else self.safe_balance(result)
3374
3374
  return returnType
3375
3375
 
3376
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
3376
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
3377
3377
  """
3378
3378
  transfer currency internally between wallets on the same account
3379
3379
  :see: https://docs.kucoin.com/#inner-transfer
@@ -1544,7 +1544,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
1544
1544
  return await self.fetch_paginated_call_dynamic('fetchClosedOrders', symbol, since, limit, params)
1545
1545
  return await self.fetch_orders_by_status('done', symbol, since, limit, params)
1546
1546
 
1547
- async def fetch_order(self, id=None, symbol: Str = None, params={}):
1547
+ async def fetch_order(self, id: str = None, symbol: Str = None, params={}):
1548
1548
  """
1549
1549
  fetches information on an order made by the user
1550
1550
  :see: https://docs.kucoin.com/futures/#get-details-of-a-single-order
@@ -1842,7 +1842,7 @@ class kucoinfutures(kucoin, ImplicitAPI):
1842
1842
  #
1843
1843
  return self.parse_balance(response)
1844
1844
 
1845
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
1845
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
1846
1846
  """
1847
1847
  transfer currency internally between wallets on the same account
1848
1848
  :param str code: unified currency code
@@ -1493,7 +1493,7 @@ class latoken(Exchange, ImplicitAPI):
1493
1493
  transfers = self.safe_value(response, 'content', [])
1494
1494
  return self.parse_transfers(transfers, currency, since, limit)
1495
1495
 
1496
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
1496
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
1497
1497
  """
1498
1498
  transfer currency internally between wallets on the same account
1499
1499
  :param str code: unified currency code
@@ -1228,7 +1228,7 @@ class lbank(Exchange, ImplicitAPI):
1228
1228
  result[symbol] = fee
1229
1229
  return result
1230
1230
 
1231
- async def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
1231
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1232
1232
  """
1233
1233
  create a market buy order by providing the symbol and cost
1234
1234
  :see: https://www.lbank.com/en-US/docs/index.html#place-order
@@ -2164,7 +2164,7 @@ class lbank(Exchange, ImplicitAPI):
2164
2164
  withdraws = self.safe_value(data, 'withdraws', [])
2165
2165
  return self.parse_transactions(withdraws, currency, since, limit)
2166
2166
 
2167
- async def fetch_transaction_fees(self, codes=None, params={}):
2167
+ async def fetch_transaction_fees(self, codes: List[str] = None, params={}):
2168
2168
  """
2169
2169
  * @deprecated
2170
2170
  please use fetchDepositWithdrawFees instead
@@ -694,7 +694,7 @@ class luno(Exchange, ImplicitAPI):
694
694
  trades = self.safe_value(response, 'trades', [])
695
695
  return self.parse_trades(trades, market, since, limit)
696
696
 
697
- async def fetch_ohlcv(self, symbol, timeframe='1m', since=None, limit=None, params={}):
697
+ async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
698
698
  """
699
699
  :see: https://www.luno.com/en/developers/api#tag/Market/operation/GetCandles
700
700
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
@@ -712,7 +712,7 @@ class luno(Exchange, ImplicitAPI):
712
712
  'pair': market['id'],
713
713
  }
714
714
  if since is not None:
715
- request['since'] = int(since)
715
+ request['since'] = self.parse_to_int(since)
716
716
  else:
717
717
  duration = 1000 * 1000 * self.parse_timeframe(timeframe)
718
718
  request['since'] = self.milliseconds() - duration
@@ -1043,7 +1043,7 @@ class mexc(Exchange, ImplicitAPI):
1043
1043
 
1044
1044
  async def fetch_markets(self, params={}):
1045
1045
  """
1046
- retrieves data on all markets for mexc3
1046
+ retrieves data on all markets for mexc
1047
1047
  :param dict [params]: extra parameters specific to the exchange API endpoint
1048
1048
  :returns dict[]: an array of objects representing market data
1049
1049
  """
@@ -2002,7 +2002,7 @@ class mexc(Exchange, ImplicitAPI):
2002
2002
  tickers = [tickers]
2003
2003
  return self.parse_tickers(tickers, symbols)
2004
2004
 
2005
- async def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
2005
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
2006
2006
  """
2007
2007
  create a market buy order by providing the symbol and cost
2008
2008
  :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
@@ -4583,7 +4583,7 @@ class mexc(Exchange, ImplicitAPI):
4583
4583
  #
4584
4584
  return self.parse_transfers(resultList, currency, since, limit)
4585
4585
 
4586
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
4586
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
4587
4587
  """
4588
4588
  transfer currency internally between wallets on the same account
4589
4589
  :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#user-universal-transfer
@@ -4744,7 +4744,7 @@ class mexc(Exchange, ImplicitAPI):
4744
4744
  #
4745
4745
  return self.parse_transaction(response, currency)
4746
4746
 
4747
- async def set_position_mode(self, hedged, symbol: Str = None, params={}):
4747
+ async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
4748
4748
  request = {
4749
4749
  'positionMode': 1 if hedged else 2, # 1 Hedge, 2 One-way, before changing position mode make sure that there are no active orders, planned orders, or open positions, the risk limit level will be reset to 1
4750
4750
  }
@@ -4772,7 +4772,7 @@ class mexc(Exchange, ImplicitAPI):
4772
4772
  'hedged': (positionMode == 1),
4773
4773
  }
4774
4774
 
4775
- async def fetch_transaction_fees(self, codes=None, params={}):
4775
+ async def fetch_transaction_fees(self, codes: List[str] = None, params={}):
4776
4776
  """
4777
4777
  fetch deposit and withdrawal fees
4778
4778
  :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
@@ -1337,7 +1337,7 @@ class ndax(Exchange, ImplicitAPI):
1337
1337
  #
1338
1338
  return self.parse_order(response, market)
1339
1339
 
1340
- async def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
1340
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
1341
1341
  omsId = self.safe_integer(self.options, 'omsId', 1)
1342
1342
  await self.load_markets()
1343
1343
  await self.load_accounts()
@@ -1083,7 +1083,7 @@ class novadax(Exchange, ImplicitAPI):
1083
1083
  'trades': None,
1084
1084
  }, market)
1085
1085
 
1086
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
1086
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
1087
1087
  """
1088
1088
  transfer currency internally between wallets on the same account
1089
1089
  :see: https://doc.novadax.com/en-US/#get-sub-account-transfer
@@ -1244,7 +1244,7 @@ class okcoin(Exchange, ImplicitAPI):
1244
1244
  result[code] = account
1245
1245
  return self.safe_balance(result)
1246
1246
 
1247
- async def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
1247
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1248
1248
  """
1249
1249
  create a market buy order by providing the symbol and cost
1250
1250
  :see: https://www.okcoin.com/docs-v5/en/#rest-api-trade-place-order
@@ -2143,7 +2143,7 @@ class okcoin(Exchange, ImplicitAPI):
2143
2143
  parsed = self.parse_deposit_addresses(filtered, [currency['code']], False)
2144
2144
  return self.index_by(parsed, 'network')
2145
2145
 
2146
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
2146
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2147
2147
  """
2148
2148
  :see: https://www.okcoin.com/docs-v5/en/#rest-api-funding-funds-transfer
2149
2149
  transfer currency internally between wallets on the same account
ccxt/async_support/okx.py CHANGED
@@ -304,6 +304,7 @@ class okx(Exchange, ImplicitAPI):
304
304
  'trade/easy-convert-history': 20,
305
305
  'trade/one-click-repay-currency-list': 20,
306
306
  'trade/one-click-repay-history': 20,
307
+ 'trade/account-rate-limit': 1,
307
308
  # asset
308
309
  'asset/currencies': 5 / 3,
309
310
  'asset/balances': 5 / 3,
@@ -1123,7 +1124,7 @@ class okx(Exchange, ImplicitAPI):
1123
1124
  reconstructedDate = '20' + year + '-' + month + '-' + day + 'T00:00:00Z'
1124
1125
  return reconstructedDate
1125
1126
 
1126
- def create_expired_option_market(self, symbol):
1127
+ def create_expired_option_market(self, symbol: str):
1127
1128
  # support expired option contracts
1128
1129
  quote = 'USD'
1129
1130
  optionParts = symbol.split('-')
@@ -1617,7 +1618,7 @@ class okx(Exchange, ImplicitAPI):
1617
1618
  if (networkId is not None) and (networkId.find('-') >= 0):
1618
1619
  parts = networkId.split('-')
1619
1620
  chainPart = self.safe_string(parts, 1, networkId)
1620
- networkCode = self.safe_network(chainPart)
1621
+ networkCode = self.network_id_to_code(chainPart, currency['code'])
1621
1622
  precision = self.parse_precision(self.safe_string(chain, 'wdTickSz'))
1622
1623
  if maxPrecision is None:
1623
1624
  maxPrecision = precision
@@ -2446,7 +2447,7 @@ class okx(Exchange, ImplicitAPI):
2446
2447
  #
2447
2448
  return self.parse_balance_by_type(marketType, response)
2448
2449
 
2449
- async def create_market_buy_order_with_cost(self, symbol: str, cost, params={}):
2450
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
2450
2451
  """
2451
2452
  :see: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
2452
2453
  create a market buy order by providing the symbol and cost
@@ -2463,7 +2464,7 @@ class okx(Exchange, ImplicitAPI):
2463
2464
  params['tgtCcy'] = 'quote_ccy'
2464
2465
  return await self.create_order(symbol, 'market', 'buy', cost, None, params)
2465
2466
 
2466
- async def create_market_sell_order_with_cost(self, symbol: str, cost, params={}):
2467
+ async def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
2467
2468
  """
2468
2469
  :see: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
2469
2470
  create a market buy order by providing the symbol and cost
@@ -2859,7 +2860,7 @@ class okx(Exchange, ImplicitAPI):
2859
2860
  params = self.omit(params, ['clOrdId', 'clientOrderId', 'takeProfitPrice', 'stopLossPrice', 'stopLoss', 'takeProfit'])
2860
2861
  return self.extend(request, params)
2861
2862
 
2862
- async def edit_order(self, id: str, symbol, type, side, amount=None, price=None, params={}):
2863
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: float = None, price: float = None, params={}):
2863
2864
  """
2864
2865
  edit a trade order
2865
2866
  :see: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-amend-order
@@ -3422,7 +3423,6 @@ class okx(Exchange, ImplicitAPI):
3422
3423
  :param int [since]: the earliest time in ms to fetch open orders for
3423
3424
  :param int [limit]: the maximum number of open orders structures to retrieve
3424
3425
  :param dict [params]: extra parameters specific to the exchange API endpoint
3425
- :param int [params.till]: Timestamp in ms of the latest time to retrieve orders for
3426
3426
  :param bool [params.stop]: True if fetching trigger or conditional orders
3427
3427
  :param str [params.ordType]: "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
3428
3428
  :param str [params.algoId]: Algo ID "'433845797218942976'"
@@ -3462,10 +3462,8 @@ class okx(Exchange, ImplicitAPI):
3462
3462
  method = 'privateGetTradeOrdersAlgoPending'
3463
3463
  if trailing:
3464
3464
  request['ordType'] = 'move_order_stop'
3465
- elif stop or (ordType in algoOrderTypes):
3466
- if stop:
3467
- if ordType is None:
3468
- raise ArgumentsRequired(self.id + ' fetchOpenOrders() requires an "ordType" string parameter, "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"')
3465
+ elif stop and (ordType is None):
3466
+ request['ordType'] = 'trigger'
3469
3467
  query = self.omit(params, ['method', 'stop', 'trigger', 'trailing'])
3470
3468
  response = None
3471
3469
  if method == 'privateGetTradeOrdersAlgoPending':
@@ -3753,7 +3751,7 @@ class okx(Exchange, ImplicitAPI):
3753
3751
  :param int [since]: the earliest time in ms to fetch orders for
3754
3752
  :param int [limit]: the maximum number of order structures to retrieve
3755
3753
  :param dict [params]: extra parameters specific to the exchange API endpoint
3756
- :param bool [params.stop]: True if fetching trigger or conditional orders
3754
+ :param bool [params.trigger]: True if fetching trigger or conditional orders
3757
3755
  :param str [params.ordType]: "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
3758
3756
  :param str [params.algoId]: Algo ID "'433845797218942976'"
3759
3757
  :param int [params.until]: timestamp in ms to fetch orders for
@@ -3788,22 +3786,21 @@ class okx(Exchange, ImplicitAPI):
3788
3786
  request['instType'] = self.convert_to_instrument_type(type)
3789
3787
  if limit is not None:
3790
3788
  request['limit'] = limit # default 100, max 100
3791
- options = self.safe_value(self.options, 'fetchClosedOrders', {})
3792
- algoOrderTypes = self.safe_value(self.options, 'algoOrderTypes', {})
3789
+ options = self.safe_dict(self.options, 'fetchClosedOrders', {})
3790
+ algoOrderTypes = self.safe_dict(self.options, 'algoOrderTypes', {})
3793
3791
  defaultMethod = self.safe_string(options, 'method', 'privateGetTradeOrdersHistory')
3794
3792
  method = self.safe_string(params, 'method', defaultMethod)
3795
3793
  ordType = self.safe_string(params, 'ordType')
3796
- stop = self.safe_value_2(params, 'stop', 'trigger')
3794
+ stop = self.safe_bool_2(params, 'stop', 'trigger')
3797
3795
  trailing = self.safe_bool(params, 'trailing', False)
3798
3796
  if trailing or stop or (ordType in algoOrderTypes):
3799
3797
  method = 'privateGetTradeOrdersAlgoHistory'
3800
3798
  request['state'] = 'effective'
3801
3799
  if trailing:
3802
3800
  request['ordType'] = 'move_order_stop'
3803
- elif stop or (ordType in algoOrderTypes):
3804
- if stop:
3805
- if ordType is None:
3806
- raise ArgumentsRequired(self.id + ' fetchClosedOrders() requires an "ordType" string parameter, "conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"')
3801
+ elif stop:
3802
+ if ordType is None:
3803
+ request['ordType'] = 'trigger'
3807
3804
  else:
3808
3805
  if since is not None:
3809
3806
  request['begin'] = since
@@ -5118,7 +5115,7 @@ class okx(Exchange, ImplicitAPI):
5118
5115
  'takeProfitPrice': None,
5119
5116
  })
5120
5117
 
5121
- async def transfer(self, code: str, amount: float, fromAccount, toAccount, params={}) -> TransferEntry:
5118
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
5122
5119
  """
5123
5120
  transfer currency internally between wallets on the same account
5124
5121
  :see: https://www.okx.com/docs-v5/en/#rest-api-funding-funds-transfer
@@ -5676,7 +5673,7 @@ class okx(Exchange, ImplicitAPI):
5676
5673
  #
5677
5674
  return response
5678
5675
 
5679
- async def set_position_mode(self, hedged, symbol: Str = None, params={}):
5676
+ async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
5680
5677
  """
5681
5678
  set hedged to True or False for a market
5682
5679
  :see: https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-position-mode
@@ -5707,7 +5704,7 @@ class okx(Exchange, ImplicitAPI):
5707
5704
  #
5708
5705
  return response
5709
5706
 
5710
- async def set_margin_mode(self, marginMode, symbol: Str = None, params={}):
5707
+ async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
5711
5708
  """
5712
5709
  set margin mode to 'cross' or 'isolated'
5713
5710
  :see: https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-leverage