ccxt 4.3.29__py2.py3-none-any.whl → 4.3.31__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 (260) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/binance.py +2 -0
  3. ccxt/abstract/binancecoinm.py +2 -0
  4. ccxt/abstract/binanceus.py +2 -0
  5. ccxt/abstract/binanceusdm.py +2 -0
  6. ccxt/ace.py +14 -14
  7. ccxt/alpaca.py +16 -16
  8. ccxt/ascendex.py +46 -46
  9. ccxt/async_support/__init__.py +1 -1
  10. ccxt/async_support/ace.py +14 -14
  11. ccxt/async_support/alpaca.py +16 -16
  12. ccxt/async_support/ascendex.py +46 -46
  13. ccxt/async_support/base/exchange.py +23 -23
  14. ccxt/async_support/base/ws/aiohttp_client.py +1 -0
  15. ccxt/async_support/base/ws/future.py +27 -29
  16. ccxt/async_support/bigone.py +32 -32
  17. ccxt/async_support/binance.py +105 -96
  18. ccxt/async_support/bingx.py +22 -22
  19. ccxt/async_support/bit2c.py +13 -13
  20. ccxt/async_support/bitbank.py +19 -19
  21. ccxt/async_support/bitbns.py +17 -17
  22. ccxt/async_support/bitfinex.py +24 -24
  23. ccxt/async_support/bitfinex2.py +142 -109
  24. ccxt/async_support/bitflyer.py +23 -23
  25. ccxt/async_support/bitget.py +76 -76
  26. ccxt/async_support/bithumb.py +20 -20
  27. ccxt/async_support/bitmart.py +55 -55
  28. ccxt/async_support/bitmex.py +41 -41
  29. ccxt/async_support/bitopro.py +30 -30
  30. ccxt/async_support/bitrue.py +37 -37
  31. ccxt/async_support/bitso.py +30 -30
  32. ccxt/async_support/bitstamp.py +31 -31
  33. ccxt/async_support/bitteam.py +26 -26
  34. ccxt/async_support/bitvavo.py +27 -27
  35. ccxt/async_support/bl3p.py +8 -8
  36. ccxt/async_support/blockchaincom.py +24 -24
  37. ccxt/async_support/blofin.py +37 -37
  38. ccxt/async_support/btcalpha.py +19 -19
  39. ccxt/async_support/btcbox.py +11 -11
  40. ccxt/async_support/btcmarkets.py +22 -22
  41. ccxt/async_support/btcturk.py +13 -13
  42. ccxt/async_support/bybit.py +96 -96
  43. ccxt/async_support/cex.py +21 -21
  44. ccxt/async_support/coinbase.py +53 -53
  45. ccxt/async_support/coinbaseexchange.py +29 -29
  46. ccxt/async_support/coinbaseinternational.py +32 -32
  47. ccxt/async_support/coincheck.py +14 -14
  48. ccxt/async_support/coinex.py +424 -448
  49. ccxt/async_support/coinlist.py +35 -35
  50. ccxt/async_support/coinmate.py +22 -22
  51. ccxt/async_support/coinmetro.py +22 -22
  52. ccxt/async_support/coinone.py +18 -18
  53. ccxt/async_support/coinsph.py +32 -32
  54. ccxt/async_support/coinspot.py +8 -8
  55. ccxt/async_support/cryptocom.py +43 -43
  56. ccxt/async_support/currencycom.py +33 -33
  57. ccxt/async_support/delta.py +35 -35
  58. ccxt/async_support/deribit.py +54 -54
  59. ccxt/async_support/digifinex.py +56 -56
  60. ccxt/async_support/exmo.py +34 -34
  61. ccxt/async_support/gate.py +60 -60
  62. ccxt/async_support/gemini.py +24 -24
  63. ccxt/async_support/hitbtc.py +51 -51
  64. ccxt/async_support/hollaex.py +29 -29
  65. ccxt/async_support/htx.py +73 -73
  66. ccxt/async_support/huobijp.py +30 -30
  67. ccxt/async_support/hyperliquid.py +58 -58
  68. ccxt/async_support/idex.py +33 -33
  69. ccxt/async_support/independentreserve.py +12 -12
  70. ccxt/async_support/indodax.py +21 -21
  71. ccxt/async_support/kraken.py +46 -51
  72. ccxt/async_support/krakenfutures.py +29 -29
  73. ccxt/async_support/kucoin.py +51 -51
  74. ccxt/async_support/kucoinfutures.py +33 -33
  75. ccxt/async_support/kuna.py +27 -27
  76. ccxt/async_support/latoken.py +27 -27
  77. ccxt/async_support/lbank.py +35 -35
  78. ccxt/async_support/luno.py +19 -19
  79. ccxt/async_support/lykke.py +20 -20
  80. ccxt/async_support/mercado.py +17 -17
  81. ccxt/async_support/mexc.py +64 -64
  82. ccxt/async_support/ndax.py +38 -38
  83. ccxt/async_support/novadax.py +26 -26
  84. ccxt/async_support/oceanex.py +21 -21
  85. ccxt/async_support/okcoin.py +35 -35
  86. ccxt/async_support/okx.py +85 -85
  87. ccxt/async_support/onetrading.py +32 -32
  88. ccxt/async_support/p2b.py +14 -14
  89. ccxt/async_support/paymium.py +12 -12
  90. ccxt/async_support/phemex.py +50 -50
  91. ccxt/async_support/poloniex.py +35 -35
  92. ccxt/async_support/poloniexfutures.py +25 -21
  93. ccxt/async_support/probit.py +30 -30
  94. ccxt/async_support/timex.py +22 -22
  95. ccxt/async_support/tokocrypto.py +26 -26
  96. ccxt/async_support/tradeogre.py +12 -12
  97. ccxt/async_support/upbit.py +28 -28
  98. ccxt/async_support/wavesexchange.py +33 -33
  99. ccxt/async_support/wazirx.py +21 -21
  100. ccxt/async_support/whitebit.py +80 -40
  101. ccxt/async_support/woo.py +51 -51
  102. ccxt/async_support/woofipro.py +46 -46
  103. ccxt/async_support/yobit.py +20 -20
  104. ccxt/async_support/zaif.py +12 -12
  105. ccxt/async_support/zonda.py +22 -22
  106. ccxt/base/exchange.py +39 -35
  107. ccxt/base/types.py +13 -0
  108. ccxt/bigone.py +32 -32
  109. ccxt/binance.py +105 -96
  110. ccxt/bingx.py +22 -22
  111. ccxt/bit2c.py +13 -13
  112. ccxt/bitbank.py +19 -19
  113. ccxt/bitbns.py +17 -17
  114. ccxt/bitfinex.py +24 -24
  115. ccxt/bitfinex2.py +142 -109
  116. ccxt/bitflyer.py +23 -23
  117. ccxt/bitget.py +76 -76
  118. ccxt/bithumb.py +20 -20
  119. ccxt/bitmart.py +55 -55
  120. ccxt/bitmex.py +41 -41
  121. ccxt/bitopro.py +30 -30
  122. ccxt/bitrue.py +37 -37
  123. ccxt/bitso.py +30 -30
  124. ccxt/bitstamp.py +31 -31
  125. ccxt/bitteam.py +26 -26
  126. ccxt/bitvavo.py +27 -27
  127. ccxt/bl3p.py +8 -8
  128. ccxt/blockchaincom.py +24 -24
  129. ccxt/blofin.py +37 -37
  130. ccxt/btcalpha.py +19 -19
  131. ccxt/btcbox.py +11 -11
  132. ccxt/btcmarkets.py +22 -22
  133. ccxt/btcturk.py +13 -13
  134. ccxt/bybit.py +96 -96
  135. ccxt/cex.py +21 -21
  136. ccxt/coinbase.py +53 -53
  137. ccxt/coinbaseexchange.py +29 -29
  138. ccxt/coinbaseinternational.py +32 -32
  139. ccxt/coincheck.py +14 -14
  140. ccxt/coinex.py +424 -448
  141. ccxt/coinlist.py +35 -35
  142. ccxt/coinmate.py +22 -22
  143. ccxt/coinmetro.py +22 -22
  144. ccxt/coinone.py +18 -18
  145. ccxt/coinsph.py +32 -32
  146. ccxt/coinspot.py +8 -8
  147. ccxt/cryptocom.py +43 -43
  148. ccxt/currencycom.py +33 -33
  149. ccxt/delta.py +35 -35
  150. ccxt/deribit.py +54 -54
  151. ccxt/digifinex.py +56 -56
  152. ccxt/exmo.py +34 -34
  153. ccxt/gate.py +60 -60
  154. ccxt/gemini.py +24 -24
  155. ccxt/hitbtc.py +51 -51
  156. ccxt/hollaex.py +29 -29
  157. ccxt/htx.py +73 -73
  158. ccxt/huobijp.py +30 -30
  159. ccxt/hyperliquid.py +58 -58
  160. ccxt/idex.py +33 -33
  161. ccxt/independentreserve.py +12 -12
  162. ccxt/indodax.py +21 -21
  163. ccxt/kraken.py +46 -51
  164. ccxt/krakenfutures.py +29 -29
  165. ccxt/kucoin.py +51 -51
  166. ccxt/kucoinfutures.py +33 -33
  167. ccxt/kuna.py +27 -27
  168. ccxt/latoken.py +27 -27
  169. ccxt/lbank.py +35 -35
  170. ccxt/luno.py +19 -19
  171. ccxt/lykke.py +20 -20
  172. ccxt/mercado.py +17 -17
  173. ccxt/mexc.py +64 -64
  174. ccxt/ndax.py +38 -38
  175. ccxt/novadax.py +26 -26
  176. ccxt/oceanex.py +21 -21
  177. ccxt/okcoin.py +35 -35
  178. ccxt/okx.py +85 -85
  179. ccxt/onetrading.py +32 -32
  180. ccxt/p2b.py +14 -14
  181. ccxt/paymium.py +12 -12
  182. ccxt/phemex.py +50 -50
  183. ccxt/poloniex.py +35 -35
  184. ccxt/poloniexfutures.py +25 -21
  185. ccxt/pro/__init__.py +1 -1
  186. ccxt/pro/alpaca.py +8 -8
  187. ccxt/pro/ascendex.py +4 -4
  188. ccxt/pro/binance.py +56 -56
  189. ccxt/pro/bingx.py +5 -5
  190. ccxt/pro/bitfinex.py +6 -6
  191. ccxt/pro/bitfinex2.py +10 -10
  192. ccxt/pro/bitget.py +17 -17
  193. ccxt/pro/bithumb.py +6 -6
  194. ccxt/pro/bitmart.py +8 -8
  195. ccxt/pro/bitmex.py +16 -16
  196. ccxt/pro/bitopro.py +4 -4
  197. ccxt/pro/bitrue.py +8 -8
  198. ccxt/pro/bitstamp.py +5 -5
  199. ccxt/pro/bitvavo.py +14 -14
  200. ccxt/pro/blockchaincom.py +7 -7
  201. ccxt/pro/bybit.py +12 -12
  202. ccxt/pro/cex.py +19 -19
  203. ccxt/pro/coinbase.py +2 -2
  204. ccxt/pro/coinbaseexchange.py +10 -10
  205. ccxt/pro/coinbaseinternational.py +4 -4
  206. ccxt/pro/coincheck.py +2 -2
  207. ccxt/pro/coinex.py +15 -15
  208. ccxt/pro/coinone.py +4 -4
  209. ccxt/pro/cryptocom.py +11 -11
  210. ccxt/pro/currencycom.py +4 -4
  211. ccxt/pro/deribit.py +9 -9
  212. ccxt/pro/exmo.py +9 -9
  213. ccxt/pro/gate.py +12 -12
  214. ccxt/pro/gemini.py +11 -11
  215. ccxt/pro/hitbtc.py +13 -13
  216. ccxt/pro/hollaex.py +6 -6
  217. ccxt/pro/htx.py +15 -15
  218. ccxt/pro/huobijp.py +16 -16
  219. ccxt/pro/hyperliquid.py +9 -9
  220. ccxt/pro/idex.py +12 -12
  221. ccxt/pro/independentreserve.py +2 -2
  222. ccxt/pro/kraken.py +14 -14
  223. ccxt/pro/krakenfutures.py +12 -12
  224. ccxt/pro/kucoin.py +12 -12
  225. ccxt/pro/kucoinfutures.py +16 -16
  226. ccxt/pro/lbank.py +12 -12
  227. ccxt/pro/luno.py +4 -4
  228. ccxt/pro/mexc.py +14 -14
  229. ccxt/pro/ndax.py +12 -12
  230. ccxt/pro/okcoin.py +6 -6
  231. ccxt/pro/okx.py +30 -30
  232. ccxt/pro/onetrading.py +13 -13
  233. ccxt/pro/p2b.py +2 -2
  234. ccxt/pro/phemex.py +9 -9
  235. ccxt/pro/poloniex.py +9 -9
  236. ccxt/pro/poloniexfutures.py +10 -10
  237. ccxt/pro/probit.py +8 -8
  238. ccxt/pro/upbit.py +1 -1
  239. ccxt/pro/wazirx.py +10 -10
  240. ccxt/pro/whitebit.py +8 -8
  241. ccxt/pro/woo.py +14 -14
  242. ccxt/pro/woofipro.py +14 -14
  243. ccxt/probit.py +30 -30
  244. ccxt/test/base/test_shared_methods.py +1 -0
  245. ccxt/timex.py +22 -22
  246. ccxt/tokocrypto.py +26 -26
  247. ccxt/tradeogre.py +12 -12
  248. ccxt/upbit.py +28 -28
  249. ccxt/wavesexchange.py +33 -33
  250. ccxt/wazirx.py +21 -21
  251. ccxt/whitebit.py +80 -40
  252. ccxt/woo.py +51 -51
  253. ccxt/woofipro.py +46 -46
  254. ccxt/yobit.py +20 -20
  255. ccxt/zaif.py +12 -12
  256. ccxt/zonda.py +22 -22
  257. {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/METADATA +4 -4
  258. {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/RECORD +260 -260
  259. {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/WHEEL +0 -0
  260. {ccxt-4.3.29.dist-info → ccxt-4.3.31.dist-info}/top_level.txt +0 -0
ccxt/coinex.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.coinex import ImplicitAPI
8
- from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, Leverage, Leverages, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, TransferEntries
8
+ from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, TransferEntries
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import AuthenticationError
@@ -81,15 +81,15 @@ class coinex(Exchange, ImplicitAPI):
81
81
  'fetchDepositAddressByNetwork': False,
82
82
  'fetchDepositAddresses': False,
83
83
  'fetchDeposits': True,
84
- 'fetchDepositWithdrawFee': 'emulated',
85
- 'fetchDepositWithdrawFees': True,
84
+ 'fetchDepositWithdrawFee': True,
85
+ 'fetchDepositWithdrawFees': False,
86
86
  'fetchFundingHistory': True,
87
87
  'fetchFundingRate': True,
88
88
  'fetchFundingRateHistory': True,
89
89
  'fetchFundingRates': True,
90
90
  'fetchIndexOHLCV': False,
91
91
  'fetchIsolatedBorrowRate': True,
92
- 'fetchIsolatedBorrowRates': True,
92
+ 'fetchIsolatedBorrowRates': False,
93
93
  'fetchLeverage': 'emulated',
94
94
  'fetchLeverages': True,
95
95
  'fetchLeverageTiers': True,
@@ -566,7 +566,7 @@ class coinex(Exchange, ImplicitAPI):
566
566
  #
567
567
  data = self.safe_value(response, 'data', [])
568
568
  coins = list(data.keys())
569
- result = {}
569
+ result: dict = {}
570
570
  for i in range(0, len(coins)):
571
571
  coin = coins[i]
572
572
  currency = data[coin]
@@ -627,7 +627,7 @@ class coinex(Exchange, ImplicitAPI):
627
627
  if precisionString is not None:
628
628
  minPrecisionString = precisionString if (minPrecisionString is None) else Precise.string_min(precisionString, minPrecisionString)
629
629
  networks = self.safe_value(result[code], 'networks', {})
630
- network = {
630
+ network: dict = {
631
631
  'info': currency,
632
632
  'id': networkId,
633
633
  'network': networkId,
@@ -935,7 +935,7 @@ class coinex(Exchange, ImplicitAPI):
935
935
  """
936
936
  self.load_markets()
937
937
  market = self.market(symbol)
938
- request = {
938
+ request: dict = {
939
939
  'market': market['id'],
940
940
  }
941
941
  response = None
@@ -1099,7 +1099,7 @@ class coinex(Exchange, ImplicitAPI):
1099
1099
  market = self.market(symbol)
1100
1100
  if limit is None:
1101
1101
  limit = 20 # default
1102
- request = {
1102
+ request: dict = {
1103
1103
  'market': market['id'],
1104
1104
  'limit': limit,
1105
1105
  'interval': '0',
@@ -1164,7 +1164,7 @@ class coinex(Exchange, ImplicitAPI):
1164
1164
  timestamp = self.safe_integer(depth, 'updated_at')
1165
1165
  return self.parse_order_book(depth, symbol, timestamp)
1166
1166
 
1167
- def parse_trade(self, trade, market: Market = None) -> Trade:
1167
+ def parse_trade(self, trade: dict, market: Market = None) -> Trade:
1168
1168
  #
1169
1169
  # Spot and Swap fetchTrades(public)
1170
1170
  #
@@ -1236,7 +1236,7 @@ class coinex(Exchange, ImplicitAPI):
1236
1236
  """
1237
1237
  self.load_markets()
1238
1238
  market = self.market(symbol)
1239
- request = {
1239
+ request: dict = {
1240
1240
  'market': market['id'],
1241
1241
  # 'last_id': 0,
1242
1242
  }
@@ -1277,7 +1277,7 @@ class coinex(Exchange, ImplicitAPI):
1277
1277
  """
1278
1278
  self.load_markets()
1279
1279
  market = self.market(symbol)
1280
- request = {
1280
+ request: dict = {
1281
1281
  'market': market['id'],
1282
1282
  }
1283
1283
  response = None
@@ -1388,7 +1388,7 @@ class coinex(Exchange, ImplicitAPI):
1388
1388
  # }
1389
1389
  #
1390
1390
  data = self.safe_list(response, 'data', [])
1391
- result = {}
1391
+ result: dict = {}
1392
1392
  for i in range(0, len(data)):
1393
1393
  entry = data[i]
1394
1394
  marketId = self.safe_string(entry, 'market')
@@ -1397,7 +1397,7 @@ class coinex(Exchange, ImplicitAPI):
1397
1397
  result[symbol] = self.parse_trading_fee(entry, market)
1398
1398
  return result
1399
1399
 
1400
- def parse_trading_fee(self, fee, market: Market = None) -> TradingFeeInterface:
1400
+ def parse_trading_fee(self, fee: dict, market: Market = None) -> TradingFeeInterface:
1401
1401
  marketId = self.safe_value(fee, 'market')
1402
1402
  symbol = self.safe_symbol(marketId, market)
1403
1403
  return {
@@ -1445,7 +1445,7 @@ class coinex(Exchange, ImplicitAPI):
1445
1445
  """
1446
1446
  self.load_markets()
1447
1447
  market = self.market(symbol)
1448
- request = {
1448
+ request: dict = {
1449
1449
  'market': market['id'],
1450
1450
  'period': self.safe_string(self.timeframes, timeframe, timeframe),
1451
1451
  }
@@ -1513,7 +1513,7 @@ class coinex(Exchange, ImplicitAPI):
1513
1513
  # "message": "OK"
1514
1514
  # }
1515
1515
  #
1516
- result = {'info': response}
1516
+ result: dict = {'info': response}
1517
1517
  balances = self.safe_list(response, 'data', [])
1518
1518
  for i in range(0, len(balances)):
1519
1519
  entry = balances[i]
@@ -1548,7 +1548,7 @@ class coinex(Exchange, ImplicitAPI):
1548
1548
  # "message": "OK"
1549
1549
  # }
1550
1550
  #
1551
- result = {'info': response}
1551
+ result: dict = {'info': response}
1552
1552
  balances = self.safe_list(response, 'data', [])
1553
1553
  for i in range(0, len(balances)):
1554
1554
  entry = balances[i]
@@ -1579,7 +1579,7 @@ class coinex(Exchange, ImplicitAPI):
1579
1579
  # "message": "OK"
1580
1580
  # }
1581
1581
  #
1582
- result = {'info': response}
1582
+ result: dict = {'info': response}
1583
1583
  balances = self.safe_list(response, 'data', [])
1584
1584
  for i in range(0, len(balances)):
1585
1585
  entry = balances[i]
@@ -1607,7 +1607,7 @@ class coinex(Exchange, ImplicitAPI):
1607
1607
  # "message": "OK"
1608
1608
  # }
1609
1609
  #
1610
- result = {'info': response}
1610
+ result: dict = {'info': response}
1611
1611
  balances = self.safe_list(response, 'data', [])
1612
1612
  for i in range(0, len(balances)):
1613
1613
  entry = balances[i]
@@ -1645,8 +1645,8 @@ class coinex(Exchange, ImplicitAPI):
1645
1645
  else:
1646
1646
  return self.fetch_spot_balance(params)
1647
1647
 
1648
- def parse_order_status(self, status):
1649
- statuses = {
1648
+ def parse_order_status(self, status: Str):
1649
+ statuses: dict = {
1650
1650
  'rejected': 'rejected',
1651
1651
  'open': 'open',
1652
1652
  'not_deal': 'open',
@@ -1656,7 +1656,7 @@ class coinex(Exchange, ImplicitAPI):
1656
1656
  }
1657
1657
  return self.safe_string(statuses, status, status)
1658
1658
 
1659
- def parse_order(self, order, market: Market = None) -> Order:
1659
+ def parse_order(self, order: dict, market: Market = None) -> Order:
1660
1660
  #
1661
1661
  # Spot and Margin createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders
1662
1662
  #
@@ -1951,7 +1951,7 @@ class coinex(Exchange, ImplicitAPI):
1951
1951
  if reduceOnly:
1952
1952
  if not market['swap']:
1953
1953
  raise InvalidOrder(self.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap markets only')
1954
- request = {
1954
+ request: dict = {
1955
1955
  'market': market['id'],
1956
1956
  }
1957
1957
  if clientOrderId is None:
@@ -2297,7 +2297,7 @@ class coinex(Exchange, ImplicitAPI):
2297
2297
  orderRequest = self.create_order_request(marketId, type, side, amount, price, orderParams)
2298
2298
  ordersRequests.append(orderRequest)
2299
2299
  market = self.market(symbol)
2300
- request = {
2300
+ request: dict = {
2301
2301
  'market': market['id'],
2302
2302
  'orders': ordersRequests,
2303
2303
  }
@@ -2456,7 +2456,7 @@ class coinex(Exchange, ImplicitAPI):
2456
2456
  raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol argument')
2457
2457
  self.load_markets()
2458
2458
  market = self.market(symbol)
2459
- request = {
2459
+ request: dict = {
2460
2460
  'market': market['id'],
2461
2461
  }
2462
2462
  stop = self.safe_bool_2(params, 'stop', 'trigger')
@@ -2631,7 +2631,7 @@ class coinex(Exchange, ImplicitAPI):
2631
2631
  raise ArgumentsRequired(self.id + ' editOrder() requires a symbol argument')
2632
2632
  self.load_markets()
2633
2633
  market = self.market(symbol)
2634
- request = {
2634
+ request: dict = {
2635
2635
  'market': market['id'],
2636
2636
  }
2637
2637
  if amount is not None:
@@ -2767,7 +2767,7 @@ class coinex(Exchange, ImplicitAPI):
2767
2767
  market = self.market(symbol)
2768
2768
  isTriggerOrder = self.safe_bool_2(params, 'stop', 'trigger')
2769
2769
  swap = market['swap']
2770
- request = {
2770
+ request: dict = {
2771
2771
  'market': market['id'],
2772
2772
  }
2773
2773
  marginMode = None
@@ -3038,7 +3038,7 @@ class coinex(Exchange, ImplicitAPI):
3038
3038
  raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
3039
3039
  self.load_markets()
3040
3040
  market = self.market(symbol)
3041
- request = {
3041
+ request: dict = {
3042
3042
  'market': market['id'],
3043
3043
  }
3044
3044
  response = None
@@ -3074,7 +3074,7 @@ class coinex(Exchange, ImplicitAPI):
3074
3074
  raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
3075
3075
  self.load_markets()
3076
3076
  market = self.market(symbol)
3077
- request = {
3077
+ request: dict = {
3078
3078
  'market': market['id'],
3079
3079
  'order_id': self.parse_to_numeric(id),
3080
3080
  }
@@ -3160,7 +3160,7 @@ class coinex(Exchange, ImplicitAPI):
3160
3160
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
3161
3161
  """
3162
3162
  self.load_markets()
3163
- request = {}
3163
+ request: dict = {}
3164
3164
  market = None
3165
3165
  if symbol is not None:
3166
3166
  market = self.market(symbol)
@@ -3496,7 +3496,7 @@ class coinex(Exchange, ImplicitAPI):
3496
3496
  if network is None:
3497
3497
  raise ArgumentsRequired(self.id + ' createDepositAddress() requires a network parameter')
3498
3498
  params = self.omit(params, 'network')
3499
- request = {
3499
+ request: dict = {
3500
3500
  'ccy': currency['id'],
3501
3501
  'chain': self.network_code_to_id(network, currency['code']),
3502
3502
  }
@@ -3535,7 +3535,7 @@ class coinex(Exchange, ImplicitAPI):
3535
3535
  raise ArgumentsRequired(self.id + ' fetchDepositAddress() ' + code + ' requires a network parameter')
3536
3536
  if not (network in networks):
3537
3537
  raise ExchangeError(self.id + ' fetchDepositAddress() ' + network + ' network not supported for ' + code)
3538
- request = {
3538
+ request: dict = {
3539
3539
  'ccy': currency['id'],
3540
3540
  'chain': network,
3541
3541
  }
@@ -3615,7 +3615,7 @@ class coinex(Exchange, ImplicitAPI):
3615
3615
  raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol argument')
3616
3616
  self.load_markets()
3617
3617
  market = self.market(symbol)
3618
- request = {
3618
+ request: dict = {
3619
3619
  'market': market['id'],
3620
3620
  }
3621
3621
  if limit is not None:
@@ -3693,7 +3693,7 @@ class coinex(Exchange, ImplicitAPI):
3693
3693
  defaultMethod = None
3694
3694
  defaultMethod, params = self.handle_option_and_params(params, 'fetchPositions', 'method', 'v2PrivateGetFuturesPendingPosition')
3695
3695
  symbols = self.market_symbols(symbols)
3696
- request = {
3696
+ request: dict = {
3697
3697
  'market_type': 'FUTURES',
3698
3698
  }
3699
3699
  market = None
@@ -3772,7 +3772,7 @@ class coinex(Exchange, ImplicitAPI):
3772
3772
  """
3773
3773
  self.load_markets()
3774
3774
  market = self.market(symbol)
3775
- request = {
3775
+ request: dict = {
3776
3776
  'market_type': 'FUTURES',
3777
3777
  'market': market['id'],
3778
3778
  }
@@ -3823,7 +3823,7 @@ class coinex(Exchange, ImplicitAPI):
3823
3823
  data = self.safe_list(response, 'data', [])
3824
3824
  return self.parse_position(data[0], market)
3825
3825
 
3826
- def parse_position(self, position, market: Market = None):
3826
+ def parse_position(self, position: dict, market: Market = None):
3827
3827
  #
3828
3828
  # {
3829
3829
  # "position_id": 305891033,
@@ -3917,7 +3917,7 @@ class coinex(Exchange, ImplicitAPI):
3917
3917
  raise ArgumentsRequired(self.id + ' setMarginMode() requires a leverage parameter')
3918
3918
  if (leverage < 1) or (leverage > maxLeverage):
3919
3919
  raise BadRequest(self.id + ' setMarginMode() leverage should be between 1 and ' + str(maxLeverage) + ' for ' + symbol)
3920
- request = {
3920
+ request: dict = {
3921
3921
  'market': market['id'],
3922
3922
  'market_type': 'FUTURES',
3923
3923
  'margin_mode': marginMode,
@@ -3957,7 +3957,7 @@ class coinex(Exchange, ImplicitAPI):
3957
3957
  maxLeverage = self.safe_integer(market['limits']['leverage'], 'max', 100)
3958
3958
  if (leverage < minLeverage) or (leverage > maxLeverage):
3959
3959
  raise BadRequest(self.id + ' setLeverage() leverage should be between ' + str(minLeverage) + ' and ' + str(maxLeverage) + ' for ' + symbol)
3960
- request = {
3960
+ request: dict = {
3961
3961
  'market': market['id'],
3962
3962
  'market_type': 'FUTURES',
3963
3963
  'margin_mode': marginMode,
@@ -3975,7 +3975,7 @@ class coinex(Exchange, ImplicitAPI):
3975
3975
  # }
3976
3976
  #
3977
3977
 
3978
- def fetch_leverage_tiers(self, symbols: Strings = None, params={}):
3978
+ def fetch_leverage_tiers(self, symbols: Strings = None, params={}) -> LeverageTiers:
3979
3979
  """
3980
3980
  retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
3981
3981
  :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-position-level
@@ -3984,7 +3984,7 @@ class coinex(Exchange, ImplicitAPI):
3984
3984
  :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
3985
3985
  """
3986
3986
  self.load_markets()
3987
- request = {}
3987
+ request: dict = {}
3988
3988
  if symbols is not None:
3989
3989
  marketIds = self.market_ids(symbols)
3990
3990
  request['market'] = ','.join(marketIds)
@@ -4017,7 +4017,7 @@ class coinex(Exchange, ImplicitAPI):
4017
4017
  data = self.safe_list(response, 'data', [])
4018
4018
  return self.parse_leverage_tiers(data, symbols, 'market')
4019
4019
 
4020
- def parse_market_leverage_tiers(self, info, market: Market = None):
4020
+ def parse_market_leverage_tiers(self, info, market: Market = None) -> List[LeverageTier]:
4021
4021
  tiers = []
4022
4022
  brackets = self.safe_list(info, 'level', [])
4023
4023
  minNotional = 0
@@ -4045,7 +4045,7 @@ class coinex(Exchange, ImplicitAPI):
4045
4045
  requestAmount = rawAmount
4046
4046
  if addOrReduce == 'reduce':
4047
4047
  requestAmount = Precise.string_neg(rawAmount)
4048
- request = {
4048
+ request: dict = {
4049
4049
  'market': market['id'],
4050
4050
  'market_type': 'FUTURES',
4051
4051
  'amount': requestAmount,
@@ -4204,7 +4204,7 @@ class coinex(Exchange, ImplicitAPI):
4204
4204
  raise ArgumentsRequired(self.id + ' fetchFundingHistory() requires a symbol argument')
4205
4205
  self.load_markets()
4206
4206
  market = self.market(symbol)
4207
- request = {
4207
+ request: dict = {
4208
4208
  'market': market['id'],
4209
4209
  'market_type': 'FUTURES',
4210
4210
  }
@@ -4265,7 +4265,7 @@ class coinex(Exchange, ImplicitAPI):
4265
4265
  market = self.market(symbol)
4266
4266
  if not market['swap']:
4267
4267
  raise BadSymbol(self.id + ' fetchFundingRate() supports swap contracts only')
4268
- request = {
4268
+ request: dict = {
4269
4269
  'market': market['id'],
4270
4270
  }
4271
4271
  response = self.v2PublicGetFuturesFundingRate(self.extend(request, params))
@@ -4339,7 +4339,7 @@ class coinex(Exchange, ImplicitAPI):
4339
4339
  """
4340
4340
  self.load_markets()
4341
4341
  symbols = self.market_symbols(symbols)
4342
- request = {}
4342
+ request: dict = {}
4343
4343
  market = None
4344
4344
  if symbols is not None:
4345
4345
  symbol = self.safe_value(symbols, 0)
@@ -4391,7 +4391,7 @@ class coinex(Exchange, ImplicitAPI):
4391
4391
  params = self.omit(params, 'network')
4392
4392
  if tag:
4393
4393
  address = address + ':' + tag
4394
- request = {
4394
+ request: dict = {
4395
4395
  'coin_type': currency['id'],
4396
4396
  'coin_address': address, # must be authorized, inter-user transfer by a registered mobile phone number or an email address is supported
4397
4397
  'actual_amount': float(self.number_to_string(amount)), # the actual amount without fees, https://www.coinex.com/fees
@@ -4422,7 +4422,7 @@ class coinex(Exchange, ImplicitAPI):
4422
4422
  return self.parse_transaction(transaction, currency)
4423
4423
 
4424
4424
  def parse_transaction_status(self, status):
4425
- statuses = {
4425
+ statuses: dict = {
4426
4426
  'audit': 'pending',
4427
4427
  'pass': 'pending',
4428
4428
  'processing': 'pending',
@@ -4454,7 +4454,7 @@ class coinex(Exchange, ImplicitAPI):
4454
4454
  if paginate:
4455
4455
  return self.fetch_paginated_call_deterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 1000)
4456
4456
  market = self.market(symbol)
4457
- request = {
4457
+ request: dict = {
4458
4458
  'market': market['id'],
4459
4459
  }
4460
4460
  if since is not None:
@@ -4497,111 +4497,102 @@ class coinex(Exchange, ImplicitAPI):
4497
4497
  sorted = self.sort_by(rates, 'timestamp')
4498
4498
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
4499
4499
 
4500
- def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
4500
+ def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
4501
4501
  #
4502
4502
  # fetchDeposits
4503
4503
  #
4504
- # {
4505
- # "coin_deposit_id": 32555985,
4506
- # "create_time": 1673325495,
4507
- # "amount": "12.71",
4508
- # "amount_display": "12.71",
4509
- # "diff_amount": "0",
4510
- # "min_amount": "0",
4511
- # "actual_amount": "12.71",
4512
- # "actual_amount_display": "12.71",
4513
- # "confirmations": 35,
4514
- # "tx_id": "0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56",
4515
- # "tx_id_display": "0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56",
4516
- # "coin_address": "0xe7a3831c56836f466b6a6268cff4fc852cf4b738",
4517
- # "coin_address_display": "0xe7a3****f4b738",
4518
- # "add_explorer": "https://bscscan.com/address/0xe7a3831c56836f466b6a6268cff4fc852cf4b738",
4519
- # "coin_type": "USDT",
4520
- # "smart_contract_name": "BSC",
4521
- # "transfer_method": "onchain",
4522
- # "status": "finish",
4523
- # "status_display": "finish",
4524
- # "remark": "",
4525
- # "explorer": "https://bscscan.com/tx/0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56"
4526
- # }
4504
+ # {
4505
+ # "deposit_id": 5173806,
4506
+ # "created_at": 1714021652557,
4507
+ # "tx_id": "d9f47d2550397c635cb89a8963118f8fe78ef048bc8b6f0caaeaa7dc6",
4508
+ # "tx_id_display": "",
4509
+ # "ccy": "USDT",
4510
+ # "chain": "TRC20",
4511
+ # "deposit_method": "ON_CHAIN",
4512
+ # "amount": "30",
4513
+ # "actual_amount": "",
4514
+ # "to_address": "TYewD2pVWDUwfNr9A",
4515
+ # "confirmations": 20,
4516
+ # "status": "FINISHED",
4517
+ # "tx_explorer_url": "https://tronscan.org/#/transaction",
4518
+ # "to_addr_explorer_url": "https://tronscan.org/#/address",
4519
+ # "remark": ""
4520
+ # }
4527
4521
  #
4528
4522
  # fetchWithdrawals
4529
4523
  #
4530
- # {
4531
- # "coin_withdraw_id": 20076836,
4532
- # "create_time": 1673325776,
4533
- # "actual_amount": "0.029",
4534
- # "actual_amount_display": "0.029",
4535
- # "amount": "0.03",
4536
- # "amount_display": "0.03",
4537
- # "coin_address": "MBhJcc3r5b3insc7QxyvEPtf31NqUdJpAb",
4538
- # "app_coin_address_display": "MBh****pAb",
4539
- # "coin_address_display": "MBhJcc****UdJpAb",
4540
- # "add_explorer": "https://explorer.viawallet.com/ltc/address/MBhJcc3r5b3insc7QxyvEPtf31NqUdJpAb",
4541
- # "coin_type": "LTC",
4542
- # "confirmations": 7,
4543
- # "explorer": "https://explorer.viawallet.com/ltc/tx/a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9",
4544
- # "fee": "0",
4545
- # "remark": "",
4546
- # "smart_contract_name": "",
4547
- # "status": "finish",
4548
- # "status_display": "finish",
4549
- # "transfer_method": "onchain",
4550
- # "tx_fee": "0.001",
4551
- # "tx_id": "a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9"
4552
- # }
4553
- #
4554
- id = self.safe_string_2(transaction, 'coin_withdraw_id', 'coin_deposit_id')
4555
- address = self.safe_string(transaction, 'coin_address')
4556
- tag = self.safe_string(transaction, 'remark') # set but unused
4524
+ # {
4525
+ # "withdraw_id": 259364,
4526
+ # "created_at": 1701323541548,
4527
+ # "withdraw_method": "ON_CHAIN",
4528
+ # "ccy": "USDT",
4529
+ # "amount": "23.845744",
4530
+ # "actual_amount": "22.445744",
4531
+ # "chain": "TRC20",
4532
+ # "tx_fee": "1.4",
4533
+ # "fee_asset": "USDT",
4534
+ # "fee_amount": "1.4",
4535
+ # "to_address": "T8t5i2454dhdhnnnGdi49vMbihvY",
4536
+ # "memo": "",
4537
+ # "tx_id": "1237623941964de9954ed2e36640228d78765c1026",
4538
+ # "confirmations": 18,
4539
+ # "explorer_address_url": "https://tronscan.org/#/address",
4540
+ # "explorer_tx_url": "https://tronscan.org/#/transaction",
4541
+ # "remark": "",
4542
+ # "status": "finished"
4543
+ # }
4544
+ #
4545
+ address = self.safe_string(transaction, 'to_address')
4546
+ tag = self.safe_string(transaction, 'memo')
4557
4547
  if tag is not None:
4558
4548
  if len(tag) < 1:
4559
4549
  tag = None
4560
- txid = self.safe_value(transaction, 'tx_id')
4550
+ remark = self.safe_string(transaction, 'remark')
4551
+ if remark is not None:
4552
+ if len(remark) < 1:
4553
+ remark = None
4554
+ txid = self.safe_string(transaction, 'tx_id')
4561
4555
  if txid is not None:
4562
4556
  if len(txid) < 1:
4563
4557
  txid = None
4564
- currencyId = self.safe_string(transaction, 'coin_type')
4558
+ currencyId = self.safe_string(transaction, 'ccy')
4565
4559
  code = self.safe_currency_code(currencyId, currency)
4566
- timestamp = self.safe_timestamp(transaction, 'create_time')
4567
- type = 'withdrawal' if ('coin_withdraw_id' in transaction) else 'deposit'
4568
- status = self.parse_transaction_status(self.safe_string(transaction, 'status'))
4569
- networkId = self.safe_string(transaction, 'smart_contract_name')
4570
- amount = self.safe_number(transaction, 'actual_amount')
4560
+ timestamp = self.safe_integer(transaction, 'created_at')
4561
+ type = 'withdrawal' if ('withdraw_id' in transaction) else 'deposit'
4562
+ networkId = self.safe_string(transaction, 'chain')
4571
4563
  feeCost = self.safe_string(transaction, 'tx_fee')
4572
- transferMethod = self.safe_string(transaction, 'transfer_method')
4564
+ transferMethod = self.safe_string_lower_2(transaction, 'withdraw_method', 'deposit_method')
4573
4565
  internal = transferMethod == 'local'
4574
- addressTo = None
4575
- addressFrom = None
4566
+ amount = self.safe_number(transaction, 'actual_amount')
4567
+ if amount is None:
4568
+ amount = self.safe_number(transaction, 'amount')
4576
4569
  if type == 'deposit':
4577
4570
  feeCost = '0'
4578
- addressTo = address
4579
- else:
4580
- addressFrom = address
4571
+ feeCurrencyId = self.safe_string(transaction, 'fee_asset')
4581
4572
  fee = {
4582
4573
  'cost': self.parse_number(feeCost),
4583
- 'currency': code,
4574
+ 'currency': self.safe_currency_code(feeCurrencyId),
4584
4575
  }
4585
4576
  return {
4586
4577
  'info': transaction,
4587
- 'id': id,
4578
+ 'id': self.safe_string_2(transaction, 'withdraw_id', 'deposit_id'),
4588
4579
  'txid': txid,
4589
4580
  'timestamp': timestamp,
4590
4581
  'datetime': self.iso8601(timestamp),
4591
4582
  'network': self.network_id_to_code(networkId),
4592
4583
  'address': address,
4593
- 'addressTo': None,
4584
+ 'addressTo': address,
4594
4585
  'addressFrom': None,
4595
4586
  'tag': tag,
4596
- 'tagTo': addressTo,
4597
- 'tagFrom': addressFrom,
4587
+ 'tagTo': None,
4588
+ 'tagFrom': None,
4598
4589
  'type': type,
4599
- 'amount': self.parse_number(amount),
4590
+ 'amount': amount,
4600
4591
  'currency': code,
4601
- 'status': status,
4592
+ 'status': self.parse_transaction_status(self.safe_string(transaction, 'status')),
4602
4593
  'updated': None,
4603
4594
  'fee': fee,
4604
- 'comment': None,
4595
+ 'comment': remark,
4605
4596
  'internal': internal,
4606
4597
  }
4607
4598
 
@@ -4623,7 +4614,7 @@ class coinex(Exchange, ImplicitAPI):
4623
4614
  accountsByType = self.safe_dict(self.options, 'accountsById', {})
4624
4615
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
4625
4616
  toId = self.safe_string(accountsByType, toAccount, toAccount)
4626
- request = {
4617
+ request: dict = {
4627
4618
  'ccy': currency['id'],
4628
4619
  'amount': amountToPrecision,
4629
4620
  'from_account_type': fromId,
@@ -4652,7 +4643,7 @@ class coinex(Exchange, ImplicitAPI):
4652
4643
  })
4653
4644
 
4654
4645
  def parse_transfer_status(self, status):
4655
- statuses = {
4646
+ statuses: dict = {
4656
4647
  '0': 'ok',
4657
4648
  'SUCCESS': 'ok',
4658
4649
  'OK': 'ok',
@@ -4693,7 +4684,7 @@ class coinex(Exchange, ImplicitAPI):
4693
4684
  if code is None:
4694
4685
  raise ArgumentsRequired(self.id + ' fetchTransfers() requires a code argument')
4695
4686
  currency = self.currency(code)
4696
- request = {
4687
+ request: dict = {
4697
4688
  'ccy': currency['id'],
4698
4689
  }
4699
4690
  marginMode = None
@@ -4734,154 +4725,135 @@ class coinex(Exchange, ImplicitAPI):
4734
4725
  def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
4735
4726
  """
4736
4727
  fetch all withdrawals made from an account
4737
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account026_withdraw_list
4738
- :param str code: unified currency code
4728
+ :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history
4729
+ :param str [code]: unified currency code
4739
4730
  :param int [since]: the earliest time in ms to fetch withdrawals for
4740
- :param int [limit]: the maximum number of withdrawals structures to retrieve
4731
+ :param int [limit]: the maximum number of withdrawal structures to retrieve
4741
4732
  :param dict [params]: extra parameters specific to the exchange API endpoint
4742
4733
  :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
4743
4734
  """
4744
- request = {}
4735
+ self.load_markets()
4736
+ request: dict = {}
4745
4737
  currency = None
4746
4738
  if code is not None:
4747
- self.load_markets()
4748
4739
  currency = self.currency(code)
4749
- request['coin_type'] = currency['id']
4740
+ request['ccy'] = currency['id']
4750
4741
  if limit is not None:
4751
- request['Limit'] = limit
4752
- response = self.v1PrivateGetBalanceCoinWithdraw(self.extend(request, params))
4753
- #
4754
- # {
4755
- # "code": 0,
4756
- # "data": {
4757
- # "has_next": False,
4758
- # "curr_page": 1,
4759
- # "count": 1,
4760
- # "data": [
4761
- # {
4762
- # "coin_withdraw_id": 20076836,
4763
- # "create_time": 1673325776,
4764
- # "actual_amount": "0.029",
4765
- # "actual_amount_display": "0.029",
4766
- # "amount": "0.03",
4767
- # "amount_display": "0.03",
4768
- # "coin_address": "MBhJcc3r5b3insc7QxyvEPtf31NqUdJpAb",
4769
- # "app_coin_address_display": "MBh****pAb",
4770
- # "coin_address_display": "MBhJcc****UdJpAb",
4771
- # "add_explorer": "https://explorer.viawallet.com/ltc/address/MBhJcc3r5b3insc7QxyvEPtf31NqUdJpAb",
4772
- # "coin_type": "LTC",
4773
- # "confirmations": 7,
4774
- # "explorer": "https://explorer.viawallet.com/ltc/tx/a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9",
4775
- # "fee": "0",
4776
- # "remark": "",
4777
- # "smart_contract_name": "",
4778
- # "status": "finish",
4779
- # "status_display": "finish",
4780
- # "transfer_method": "onchain",
4781
- # "tx_fee": "0.001",
4782
- # "tx_id": "a0aa082132619b8a499b87e7d5bc3c508e0227104f5202ae26b695bb4cb7fbf9"
4783
- # }
4784
- # ],
4785
- # "total": 1,
4786
- # "total_page": 1
4787
- # },
4788
- # "message": "Success"
4789
- # }
4742
+ request['limit'] = limit
4743
+ response = self.v2PrivateGetAssetsWithdraw(self.extend(request, params))
4790
4744
  #
4791
- data = self.safe_value(response, 'data')
4792
- if not isinstance(data, list):
4793
- data = self.safe_value(data, 'data', [])
4745
+ # {
4746
+ # "data": [
4747
+ # {
4748
+ # "withdraw_id": 259364,
4749
+ # "created_at": 1701323541548,
4750
+ # "withdraw_method": "ON_CHAIN",
4751
+ # "ccy": "USDT",
4752
+ # "amount": "23.845744",
4753
+ # "actual_amount": "22.445744",
4754
+ # "chain": "TRC20",
4755
+ # "tx_fee": "1.4",
4756
+ # "fee_asset": "USDT",
4757
+ # "fee_amount": "1.4",
4758
+ # "to_address": "T8t5i2454dhdhnnnGdi49vMbihvY",
4759
+ # "memo": "",
4760
+ # "tx_id": "1237623941964de9954ed2e36640228d78765c1026",
4761
+ # "confirmations": 18,
4762
+ # "explorer_address_url": "https://tronscan.org/#/address",
4763
+ # "explorer_tx_url": "https://tronscan.org/#/transaction",
4764
+ # "remark": "",
4765
+ # "status": "finished"
4766
+ # },
4767
+ # ],
4768
+ # "pagination": {
4769
+ # "total": 9,
4770
+ # "has_next": True
4771
+ # },
4772
+ # "code": 0,
4773
+ # "message": "OK"
4774
+ # }
4775
+ #
4776
+ data = self.safe_list(response, 'data', [])
4794
4777
  return self.parse_transactions(data, currency, since, limit)
4795
4778
 
4796
4779
  def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
4797
4780
  """
4798
4781
  fetch all deposits made to an account
4799
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account009_deposit_list
4800
- :param str code: unified currency code
4782
+ :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history
4783
+ :param str [code]: unified currency code
4801
4784
  :param int [since]: the earliest time in ms to fetch deposits for
4802
- :param int [limit]: the maximum number of deposits structures to retrieve
4785
+ :param int [limit]: the maximum number of deposit structures to retrieve
4803
4786
  :param dict [params]: extra parameters specific to the exchange API endpoint
4804
4787
  :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
4805
4788
  """
4806
- request = {}
4789
+ self.load_markets()
4790
+ request: dict = {}
4807
4791
  currency = None
4808
4792
  if code is not None:
4809
- self.load_markets()
4810
4793
  currency = self.currency(code)
4811
- request['coin_type'] = currency['id']
4794
+ request['ccy'] = currency['id']
4812
4795
  if limit is not None:
4813
- request['Limit'] = limit
4814
- response = self.v1PrivateGetBalanceCoinDeposit(self.extend(request, params))
4815
- #
4816
- # {
4817
- # "code": 0,
4818
- # "data": {
4819
- # "has_next": False,
4820
- # "curr_page": 1,
4821
- # "count": 1,
4822
- # "data": [
4823
- # {
4824
- # "coin_deposit_id": 32555985,
4825
- # "create_time": 1673325495,
4826
- # "amount": "12.71",
4827
- # "amount_display": "12.71",
4828
- # "diff_amount": "0",
4829
- # "min_amount": "0",
4830
- # "actual_amount": "12.71",
4831
- # "actual_amount_display": "12.71",
4832
- # "confirmations": 35,
4833
- # "tx_id": "0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56",
4834
- # "tx_id_display": "0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56",
4835
- # "coin_address": "0xe7a3831c56836f466b6a6268cff4fc852cf4b738",
4836
- # "coin_address_display": "0xe7a3****f4b738",
4837
- # "add_explorer": "https://bscscan.com/address/0xe7a3831c56836f466b6a6268cff4fc852cf4b738",
4838
- # "coin_type": "USDT",
4839
- # "smart_contract_name": "BSC",
4840
- # "transfer_method": "onchain",
4841
- # "status": "finish",
4842
- # "status_display": "finish",
4843
- # "remark": "",
4844
- # "explorer": "https://bscscan.com/tx/0x57f1c92cc10b48316e2bf5faf230694fec2174e7744c1562a9a88b9c1e585f56"
4845
- # }
4846
- # ],
4847
- # "total": 1,
4848
- # "total_page": 1
4849
- # },
4850
- # "message": "Success"
4851
- # }
4796
+ request['limit'] = limit
4797
+ response = self.v2PrivateGetAssetsDepositHistory(self.extend(request, params))
4852
4798
  #
4853
- data = self.safe_value(response, 'data')
4854
- if not isinstance(data, list):
4855
- data = self.safe_value(data, 'data', [])
4799
+ # {
4800
+ # "data": [
4801
+ # {
4802
+ # "deposit_id": 5173806,
4803
+ # "created_at": 1714021652557,
4804
+ # "tx_id": "d9f47d2550397c635cb89a8963118f8fe78ef048bc8b6f0caaeaa7dc6",
4805
+ # "tx_id_display": "",
4806
+ # "ccy": "USDT",
4807
+ # "chain": "TRC20",
4808
+ # "deposit_method": "ON_CHAIN",
4809
+ # "amount": "30",
4810
+ # "actual_amount": "",
4811
+ # "to_address": "TYewD2pVWDUwfNr9A",
4812
+ # "confirmations": 20,
4813
+ # "status": "FINISHED",
4814
+ # "tx_explorer_url": "https://tronscan.org/#/transaction",
4815
+ # "to_addr_explorer_url": "https://tronscan.org/#/address",
4816
+ # "remark": ""
4817
+ # },
4818
+ # ],
4819
+ # "paginatation": {
4820
+ # "total": 8,
4821
+ # "has_next": True
4822
+ # },
4823
+ # "code": 0,
4824
+ # "message": "OK"
4825
+ # }
4826
+ #
4827
+ data = self.safe_list(response, 'data', [])
4856
4828
  return self.parse_transactions(data, currency, since, limit)
4857
4829
 
4858
4830
  def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
4859
4831
  #
4860
4832
  # {
4861
4833
  # "market": "BTCUSDT",
4834
+ # "ccy": "USDT",
4862
4835
  # "leverage": 10,
4863
- # "BTC": {
4864
- # "min_amount": "0.002",
4865
- # "max_amount": "200",
4866
- # "day_rate": "0.001"
4867
- # },
4868
- # "USDT": {
4869
- # "min_amount": "60",
4870
- # "max_amount": "5000000",
4871
- # "day_rate": "0.001"
4872
- # }
4873
- # },
4836
+ # "min_amount": "60",
4837
+ # "max_amount": "500000",
4838
+ # "daily_interest_rate": "0.001"
4839
+ # }
4874
4840
  #
4875
4841
  marketId = self.safe_string(info, 'market')
4876
4842
  market = self.safe_market(marketId, market, None, 'spot')
4877
- baseInfo = self.safe_value(info, market['baseId'])
4878
- quoteInfo = self.safe_value(info, market['quoteId'])
4843
+ currency = self.safe_string(info, 'ccy')
4844
+ rate = self.safe_number(info, 'daily_interest_rate')
4845
+ baseRate = None
4846
+ quoteRate = None
4847
+ if currency == market['baseId']:
4848
+ baseRate = rate
4849
+ elif currency == market['quoteId']:
4850
+ quoteRate = rate
4879
4851
  return {
4880
4852
  'symbol': market['symbol'],
4881
4853
  'base': market['base'],
4882
- 'baseRate': self.safe_number(baseInfo, 'day_rate'),
4854
+ 'baseRate': baseRate,
4883
4855
  'quote': market['quote'],
4884
- 'quoteRate': self.safe_number(quoteInfo, 'day_rate'),
4856
+ 'quoteRate': quoteRate,
4885
4857
  'period': 86400000,
4886
4858
  'timestamp': None,
4887
4859
  'datetime': None,
@@ -4891,153 +4863,116 @@ class coinex(Exchange, ImplicitAPI):
4891
4863
  def fetch_isolated_borrow_rate(self, symbol: str, params={}) -> IsolatedBorrowRate:
4892
4864
  """
4893
4865
  fetch the rate of interest to borrow a currency for margin trading
4894
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
4866
+ :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
4895
4867
  :param str symbol: unified symbol of the market to fetch the borrow rate for
4896
4868
  :param dict [params]: extra parameters specific to the exchange API endpoint
4869
+ :param str params['code']: unified currency code
4897
4870
  :returns dict: an `isolated borrow rate structure <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
4898
4871
  """
4899
4872
  self.load_markets()
4873
+ code = self.safe_string(params, 'code')
4874
+ if code is None:
4875
+ raise ArgumentsRequired(self.id + ' fetchIsolatedBorrowRate() requires a code parameter')
4876
+ params = self.omit(params, 'code')
4877
+ currency = self.currency(code)
4900
4878
  market = self.market(symbol)
4901
- request = {
4879
+ request: dict = {
4902
4880
  'market': market['id'],
4881
+ 'ccy': currency['id'],
4903
4882
  }
4904
- response = self.v1PrivateGetMarginConfig(self.extend(request, params))
4883
+ response = self.v2PrivateGetAssetsMarginInterestLimit(self.extend(request, params))
4905
4884
  #
4906
4885
  # {
4907
4886
  # "code": 0,
4908
4887
  # "data": {
4909
4888
  # "market": "BTCUSDT",
4889
+ # "ccy": "USDT",
4910
4890
  # "leverage": 10,
4911
- # "BTC": {
4912
- # "min_amount": "0.002",
4913
- # "max_amount": "200",
4914
- # "day_rate": "0.001"
4915
- # },
4916
- # "USDT": {
4917
- # "min_amount": "60",
4918
- # "max_amount": "5000000",
4919
- # "day_rate": "0.001"
4920
- # }
4891
+ # "min_amount": "60",
4892
+ # "max_amount": "500000",
4893
+ # "daily_interest_rate": "0.001"
4921
4894
  # },
4922
- # "message": "Success"
4895
+ # "message": "OK"
4923
4896
  # }
4924
4897
  #
4925
- data = self.safe_value(response, 'data', {})
4898
+ data = self.safe_dict(response, 'data', {})
4926
4899
  return self.parse_isolated_borrow_rate(data, market)
4927
4900
 
4928
- def fetch_isolated_borrow_rates(self, params={}) -> IsolatedBorrowRates:
4901
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4929
4902
  """
4930
- fetch the borrow interest rates of all currencies
4931
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
4903
+ fetch the interest owed by the user for borrowing currency for margin trading
4904
+ :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
4905
+ :param str [code]: unified currency code
4906
+ :param str [symbol]: unified market symbol when fetch interest in isolated markets
4907
+ :param int [since]: the earliest time in ms to fetch borrrow interest for
4908
+ :param int [limit]: the maximum number of structures to retrieve
4932
4909
  :param dict [params]: extra parameters specific to the exchange API endpoint
4933
- :returns dict: a list of `isolated borrow rate structures <https://github.com/ccxt/ccxt/wiki/Manual#isolated-borrow-rate-structure>`
4910
+ :returns dict[]: a list of `borrow interest structures <https://docs.ccxt.com/#/?id=borrow-interest-structure>`
4934
4911
  """
4935
4912
  self.load_markets()
4936
- response = self.v1PrivateGetMarginConfig(params)
4937
- #
4938
- # {
4939
- # "code": 0,
4940
- # "data": [
4941
- # {
4942
- # "market": "BTCUSDT",
4943
- # "leverage": 10,
4944
- # "BTC": {
4945
- # "min_amount": "0.002",
4946
- # "max_amount": "200",
4947
- # "day_rate": "0.001"
4948
- # },
4949
- # "USDT": {
4950
- # "min_amount": "60",
4951
- # "max_amount": "5000000",
4952
- # "day_rate": "0.001"
4953
- # }
4954
- # },
4955
- # ],
4956
- # "message": "Success"
4957
- # }
4958
- #
4959
- data = self.safe_value(response, 'data', [])
4960
- return self.parse_isolated_borrow_rates(data)
4961
-
4962
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4963
- self.load_markets()
4964
- request = {}
4913
+ request: dict = {}
4965
4914
  market = None
4966
4915
  if symbol is not None:
4967
4916
  market = self.market(symbol)
4968
4917
  request['market'] = market['id']
4969
4918
  if limit is not None:
4970
4919
  request['limit'] = limit
4971
- response = self.v1PrivateGetMarginLoanHistory(self.extend(request, params))
4920
+ response = self.v2PrivateGetAssetsMarginBorrowHistory(self.extend(request, params))
4972
4921
  #
4973
4922
  # {
4974
- # "code": 0,
4975
- # "data": {
4976
- # "page": 1,
4977
- # "limit": 10,
4978
- # "total": 1,
4979
- # "has_next": False,
4980
- # "curr_page": 1,
4981
- # "count": 1,
4982
- # "data": [
4983
- # {
4984
- # "loan_id": 2616357,
4985
- # "create_time": 1654214027,
4986
- # "market_type": "BTCUSDT",
4987
- # "coin_type": "BTC",
4988
- # "day_rate": "0.001",
4989
- # "loan_amount": "0.0144",
4990
- # "interest_amount": "0",
4991
- # "unflat_amount": "0",
4992
- # "expire_time": 1655078027,
4993
- # "is_renew": True,
4994
- # "status": "finish"
4995
- # }
4996
- # ],
4997
- # "total_page": 1
4923
+ # "data": [
4924
+ # {
4925
+ # "borrow_id": 2642934,
4926
+ # "created_at": 1654761016000,
4927
+ # "market": "BTCUSDT",
4928
+ # "ccy": "USDT",
4929
+ # "daily_interest_rate": "0.001",
4930
+ # "expired_at": 1655625016000,
4931
+ # "borrow_amount": "100",
4932
+ # "to_repaied_amount": "0",
4933
+ # "is_auto_renew": False,
4934
+ # "status": "finish"
4935
+ # },
4936
+ # ],
4937
+ # "pagination": {
4938
+ # "total": 4,
4939
+ # "has_next": True
4998
4940
  # },
4999
- # "message": "Success"
4941
+ # "code": 0,
4942
+ # "message": "OK"
5000
4943
  # }
5001
4944
  #
5002
- data = self.safe_value(response, 'data', {})
5003
- rows = self.safe_value(data, 'data', [])
4945
+ rows = self.safe_value(response, 'data', [])
5004
4946
  interest = self.parse_borrow_interests(rows, market)
5005
4947
  return self.filter_by_currency_since_limit(interest, code, since, limit)
5006
4948
 
5007
- def parse_borrow_interest(self, info, market: Market = None):
4949
+ def parse_borrow_interest(self, info: dict, market: Market = None):
5008
4950
  #
5009
4951
  # {
5010
- # "loan_id": 2616357,
5011
- # "create_time": 1654214027,
5012
- # "market_type": "BTCUSDT",
5013
- # "coin_type": "BTC",
5014
- # "day_rate": "0.001",
5015
- # "loan_amount": "0.0144",
5016
- # "interest_amount": "0",
5017
- # "unflat_amount": "0",
5018
- # "expire_time": 1655078027,
5019
- # "is_renew": True,
4952
+ # "borrow_id": 2642934,
4953
+ # "created_at": 1654761016000,
4954
+ # "market": "BTCUSDT",
4955
+ # "ccy": "USDT",
4956
+ # "daily_interest_rate": "0.001",
4957
+ # "expired_at": 1655625016000,
4958
+ # "borrow_amount": "100",
4959
+ # "to_repaied_amount": "0",
4960
+ # "is_auto_renew": False,
5020
4961
  # "status": "finish"
5021
4962
  # }
5022
4963
  #
5023
- marketId = self.safe_string(info, 'market_type')
4964
+ marketId = self.safe_string(info, 'market')
5024
4965
  market = self.safe_market(marketId, market, None, 'spot')
5025
- symbol = self.safe_string(market, 'symbol')
5026
- timestamp = self.safe_timestamp(info, 'expire_time')
5027
- unflatAmount = self.safe_string(info, 'unflat_amount')
5028
- loanAmount = self.safe_string(info, 'loan_amount')
5029
- interest = Precise.string_sub(unflatAmount, loanAmount)
5030
- if unflatAmount == '0':
5031
- interest = None
4966
+ timestamp = self.safe_integer(info, 'expired_at')
5032
4967
  return {
5033
4968
  'account': None, # deprecated
5034
- 'symbol': symbol,
4969
+ 'symbol': market['symbol'],
5035
4970
  'marginMode': 'isolated',
5036
4971
  'marginType': None, # deprecated
5037
- 'currency': self.safe_currency_code(self.safe_string(info, 'coin_type')),
5038
- 'interest': self.parse_number(interest),
5039
- 'interestRate': self.safe_number(info, 'day_rate'),
5040
- 'amountBorrowed': self.parse_number(loanAmount),
4972
+ 'currency': self.safe_currency_code(self.safe_string(info, 'ccy')),
4973
+ 'interest': self.safe_number(info, 'to_repaied_amount'),
4974
+ 'interestRate': self.safe_number(info, 'daily_interest_rate'),
4975
+ 'amountBorrowed': self.safe_number(info, 'borrow_amount'),
5041
4976
  'timestamp': timestamp, # expiry time
5042
4977
  'datetime': self.iso8601(timestamp),
5043
4978
  'info': info,
@@ -5046,32 +4981,43 @@ class coinex(Exchange, ImplicitAPI):
5046
4981
  def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
5047
4982
  """
5048
4983
  create a loan to borrow margin
5049
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account017_margin_loan
4984
+ :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-borrow
5050
4985
  :param str symbol: unified market symbol, required for coinex
5051
4986
  :param str code: unified currency code of the currency to borrow
5052
4987
  :param float amount: the amount to borrow
5053
4988
  :param dict [params]: extra parameters specific to the exchange API endpoint
4989
+ :param boolean [params.isAutoRenew]: whether to renew the margin loan automatically or not, default is False
5054
4990
  :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
5055
4991
  """
5056
4992
  self.load_markets()
5057
4993
  market = self.market(symbol)
5058
4994
  currency = self.currency(code)
5059
- request = {
4995
+ isAutoRenew = self.safe_bool_2(params, 'isAutoRenew', 'is_auto_renew', False)
4996
+ params = self.omit(params, 'isAutoRenew')
4997
+ request: dict = {
5060
4998
  'market': market['id'],
5061
- 'coin_type': currency['id'],
5062
- 'amount': self.currency_to_precision(code, amount),
4999
+ 'ccy': currency['id'],
5000
+ 'borrow_amount': self.currency_to_precision(code, amount),
5001
+ 'is_auto_renew': isAutoRenew,
5063
5002
  }
5064
- response = self.v1PrivatePostMarginLoan(self.extend(request, params))
5003
+ response = self.v2PrivatePostAssetsMarginBorrow(self.extend(request, params))
5065
5004
  #
5066
5005
  # {
5067
5006
  # "code": 0,
5068
5007
  # "data": {
5069
- # "loan_id": 1670
5008
+ # "borrow_id": 13784021,
5009
+ # "market": "BTCUSDT",
5010
+ # "ccy": "USDT",
5011
+ # "daily_interest_rate": "0.001",
5012
+ # "expired_at": 1717299948340,
5013
+ # "borrow_amount": "60",
5014
+ # "to_repaied_amount": "60.0025",
5015
+ # "status": "loan"
5070
5016
  # },
5071
- # "message": "Success"
5017
+ # "message": "OK"
5072
5018
  # }
5073
5019
  #
5074
- data = self.safe_value(response, 'data', {})
5020
+ data = self.safe_dict(response, 'data', {})
5075
5021
  transaction = self.parse_margin_loan(data, currency)
5076
5022
  return self.extend(transaction, {
5077
5023
  'amount': amount,
@@ -5081,149 +5027,179 @@ class coinex(Exchange, ImplicitAPI):
5081
5027
  def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
5082
5028
  """
5083
5029
  repay borrowed margin and interest
5084
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account018_margin_flat
5030
+ :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-repay
5085
5031
  :param str symbol: unified market symbol, required for coinex
5086
5032
  :param str code: unified currency code of the currency to repay
5087
5033
  :param float amount: the amount to repay
5088
5034
  :param dict [params]: extra parameters specific to the exchange API endpoint
5089
- :param str [params.loan_id]: extra parameter that is not required
5035
+ :param str [params.borrow_id]: extra parameter that is not required
5090
5036
  :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
5091
5037
  """
5092
5038
  self.load_markets()
5093
5039
  market = self.market(symbol)
5094
5040
  currency = self.currency(code)
5095
- request = {
5041
+ request: dict = {
5096
5042
  'market': market['id'],
5097
- 'coin_type': currency['id'],
5043
+ 'ccy': currency['id'],
5098
5044
  'amount': self.currency_to_precision(code, amount),
5099
5045
  }
5100
- response = self.v1PrivatePostMarginFlat(self.extend(request, params))
5046
+ response = self.v2PrivatePostAssetsMarginRepay(self.extend(request, params))
5101
5047
  #
5102
5048
  # {
5103
5049
  # "code": 0,
5104
- # "data": null,
5105
- # "message": "Success"
5050
+ # "data": {},
5051
+ # "message": "OK"
5106
5052
  # }
5107
5053
  #
5108
- transaction = self.parse_margin_loan(response, currency)
5054
+ data = self.safe_dict(response, 'data', {})
5055
+ transaction = self.parse_margin_loan(data, currency)
5109
5056
  return self.extend(transaction, {
5110
5057
  'amount': amount,
5111
5058
  'symbol': symbol,
5112
5059
  })
5113
5060
 
5114
5061
  def parse_margin_loan(self, info, currency: Currency = None):
5115
- #
5116
- # borrowMargin
5117
- #
5118
- # {
5119
- # "loan_id": 1670
5120
- # }
5121
- #
5122
- # repayMargin
5123
5062
  #
5124
5063
  # {
5125
- # "code": 0,
5126
- # "data": null,
5127
- # "message": "Success"
5064
+ # "borrow_id": 13784021,
5065
+ # "market": "BTCUSDT",
5066
+ # "ccy": "USDT",
5067
+ # "daily_interest_rate": "0.001",
5068
+ # "expired_at": 1717299948340,
5069
+ # "borrow_amount": "60",
5070
+ # "to_repaied_amount": "60.0025",
5071
+ # "status": "loan"
5128
5072
  # }
5129
5073
  #
5074
+ currencyId = self.safe_string(info, 'ccy')
5075
+ marketId = self.safe_string(info, 'market')
5076
+ timestamp = self.safe_integer(info, 'expired_at')
5130
5077
  return {
5131
- 'id': self.safe_integer(info, 'loan_id'),
5132
- 'currency': self.safe_currency_code(None, currency),
5133
- 'amount': None,
5134
- 'symbol': None,
5135
- 'timestamp': None,
5136
- 'datetime': None,
5078
+ 'id': self.safe_integer(info, 'borrow_id'),
5079
+ 'currency': self.safe_currency_code(currencyId, currency),
5080
+ 'amount': self.safe_string(info, 'borrow_amount'),
5081
+ 'symbol': self.safe_symbol(marketId, None, None, 'spot'),
5082
+ 'timestamp': timestamp,
5083
+ 'datetime': self.iso8601(timestamp),
5137
5084
  'info': info,
5138
5085
  }
5139
5086
 
5140
- def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
5087
+ def fetch_deposit_withdraw_fee(self, code: str, params={}):
5141
5088
  """
5142
- fetch deposit and withdraw fees
5143
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot001_market010_asset_config
5144
- :param str[]|None codes: list of unified currency codes
5089
+ fetch the fee for deposits and withdrawals
5090
+ :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-withdrawal-config
5091
+ :param str code: unified currency code
5145
5092
  :param dict [params]: extra parameters specific to the exchange API endpoint
5146
- :returns dict[]: a list of `fees structures <https://docs.ccxt.com/#/?id=fee-structure>`
5093
+ :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
5147
5094
  """
5148
5095
  self.load_markets()
5149
- request = {}
5150
- if codes is not None:
5151
- codesLength = len(codes)
5152
- if codesLength == 1:
5153
- request['coin_type'] = self.safe_value(codes, 0)
5154
- response = self.v1PublicGetCommonAssetConfig(self.extend(request, params))
5155
- #
5156
- # {
5157
- # "code": 0,
5158
- # "data": {
5159
- # "CET-CSC": {
5160
- # "asset": "CET",
5161
- # "chain": "CSC",
5162
- # "can_deposit": True,
5163
- # "can_withdraw ": False,
5164
- # "deposit_least_amount": "1",
5165
- # "withdraw_least_amount": "1",
5166
- # "withdraw_tx_fee": "0.1"
5167
- # },
5168
- # "CET-ERC20": {
5169
- # "asset": "CET",
5170
- # "chain": "ERC20",
5171
- # "can_deposit": True,
5172
- # "can_withdraw": False,
5173
- # "deposit_least_amount": "14",
5174
- # "withdraw_least_amount": "14",
5175
- # "withdraw_tx_fee": "14"
5176
- # }
5177
- # },
5178
- # "message": "Success"
5179
- # }
5180
- #
5181
- return self.parse_deposit_withdraw_fees(response, codes)
5096
+ currency = self.currency(code)
5097
+ request: dict = {
5098
+ 'ccy': currency['id'],
5099
+ }
5100
+ response = self.v2PrivateGetAssetsDepositWithdrawConfig(self.extend(request, params))
5101
+ #
5102
+ # {
5103
+ # "code": 0,
5104
+ # "data": {
5105
+ # "asset": {
5106
+ # "ccy": "USDT",
5107
+ # "deposit_enabled": True,
5108
+ # "withdraw_enabled": True,
5109
+ # "inter_transfer_enabled": True,
5110
+ # "is_st": False
5111
+ # },
5112
+ # "chains": [
5113
+ # {
5114
+ # "chain": "TRC20",
5115
+ # "min_deposit_amount": "2.4",
5116
+ # "min_withdraw_amount": "2.4",
5117
+ # "deposit_enabled": True,
5118
+ # "withdraw_enabled": True,
5119
+ # "deposit_delay_minutes": 0,
5120
+ # "safe_confirmations": 10,
5121
+ # "irreversible_confirmations": 20,
5122
+ # "deflation_rate": "0",
5123
+ # "withdrawal_fee": "2.4",
5124
+ # "withdrawal_precision": 6,
5125
+ # "memo": "",
5126
+ # "is_memo_required_for_deposit": False,
5127
+ # "explorer_asset_url": "https://tronscan.org/#/token20/TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
5128
+ # },
5129
+ # ]
5130
+ # },
5131
+ # "message": "OK"
5132
+ # }
5133
+ #
5134
+ data = self.safe_dict(response, 'data', {})
5135
+ return self.parse_deposit_withdraw_fee(data, currency)
5182
5136
 
5183
- def parse_deposit_withdraw_fees(self, response, codes=None, currencyIdKey=None):
5184
- depositWithdrawFees = {}
5185
- codes = self.market_codes(codes)
5186
- data = self.safe_value(response, 'data')
5187
- currencyIds = list(data.keys())
5188
- for i in range(0, len(currencyIds)):
5189
- entry = currencyIds[i]
5190
- splitEntry = entry.split('-')
5191
- feeInfo = data[currencyIds[i]]
5192
- currencyId = self.safe_string(feeInfo, 'asset')
5193
- currency = self.safe_currency(currencyId)
5194
- code = self.safe_string(currency, 'code')
5195
- if (codes is None) or (self.in_array(code, codes)):
5196
- depositWithdrawFee = self.safe_value(depositWithdrawFees, code)
5197
- if depositWithdrawFee is None:
5198
- depositWithdrawFees[code] = self.deposit_withdraw_fee({})
5199
- depositWithdrawFees[code]['info'][entry] = feeInfo
5200
- networkId = self.safe_string(splitEntry, 1)
5201
- withdrawFee = self.safe_value(feeInfo, 'withdraw_tx_fee')
5202
- withdrawResult = {
5203
- 'fee': withdrawFee,
5204
- 'percentage': False if (withdrawFee is not None) else None,
5205
- }
5206
- depositResult = {
5207
- 'fee': None,
5208
- 'percentage': None,
5209
- }
5210
- if networkId is not None:
5211
- networkCode = self.network_id_to_code(networkId)
5212
- depositWithdrawFees[code]['networks'][networkCode] = {
5213
- 'withdraw': withdrawResult,
5214
- 'deposit': depositResult,
5137
+ def parse_deposit_withdraw_fee(self, fee, currency: Currency = None):
5138
+ #
5139
+ # {
5140
+ # "asset": {
5141
+ # "ccy": "USDT",
5142
+ # "deposit_enabled": True,
5143
+ # "withdraw_enabled": True,
5144
+ # "inter_transfer_enabled": True,
5145
+ # "is_st": False
5146
+ # },
5147
+ # "chains": [
5148
+ # {
5149
+ # "chain": "TRC20",
5150
+ # "min_deposit_amount": "2.4",
5151
+ # "min_withdraw_amount": "2.4",
5152
+ # "deposit_enabled": True,
5153
+ # "withdraw_enabled": True,
5154
+ # "deposit_delay_minutes": 0,
5155
+ # "safe_confirmations": 10,
5156
+ # "irreversible_confirmations": 20,
5157
+ # "deflation_rate": "0",
5158
+ # "withdrawal_fee": "2.4",
5159
+ # "withdrawal_precision": 6,
5160
+ # "memo": "",
5161
+ # "is_memo_required_for_deposit": False,
5162
+ # "explorer_asset_url": "https://tronscan.org/#/token20/TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"
5163
+ # },
5164
+ # ]
5165
+ # }
5166
+ #
5167
+ result: dict = {
5168
+ 'info': fee,
5169
+ 'withdraw': {
5170
+ 'fee': None,
5171
+ 'percentage': None,
5172
+ },
5173
+ 'deposit': {
5174
+ 'fee': None,
5175
+ 'percentage': None,
5176
+ },
5177
+ 'networks': {},
5178
+ }
5179
+ chains = self.safe_list(fee, 'chains', [])
5180
+ asset = self.safe_dict(fee, 'asset', {})
5181
+ for i in range(0, len(chains)):
5182
+ entry = chains[i]
5183
+ isWithdrawEnabled = self.safe_bool(entry, 'withdraw_enabled')
5184
+ if isWithdrawEnabled:
5185
+ result['withdraw']['fee'] = self.safe_number(entry, 'withdrawal_fee')
5186
+ result['withdraw']['percentage'] = False
5187
+ networkId = self.safe_string(entry, 'chain')
5188
+ if networkId:
5189
+ networkCode = self.network_id_to_code(networkId, self.safe_string(asset, 'ccy'))
5190
+ result['networks'][networkCode] = {
5191
+ 'withdraw': {
5192
+ 'fee': self.safe_number(entry, 'withdrawal_fee'),
5193
+ 'percentage': False,
5194
+ },
5195
+ 'deposit': {
5196
+ 'fee': None,
5197
+ 'percentage': None,
5198
+ },
5215
5199
  }
5216
- else:
5217
- depositWithdrawFees[code]['withdraw'] = withdrawResult
5218
- depositWithdrawFees[code]['deposit'] = depositResult
5219
- depositWithdrawCodes = list(depositWithdrawFees.keys())
5220
- for i in range(0, len(depositWithdrawCodes)):
5221
- code = depositWithdrawCodes[i]
5222
- currency = self.currency(code)
5223
- depositWithdrawFees[code] = self.assign_default_deposit_withdraw_fees(depositWithdrawFees[code], currency)
5224
- return depositWithdrawFees
5200
+ return result
5225
5201
 
5226
- def fetch_leverages(self, symbols: List[str] = None, params={}) -> Leverages:
5202
+ def fetch_leverages(self, symbols: Strings = None, params={}) -> Leverages:
5227
5203
  """
5228
5204
  fetch the set leverage for all contract and margin markets
5229
5205
  :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
@@ -5291,7 +5267,7 @@ class coinex(Exchange, ImplicitAPI):
5291
5267
  """
5292
5268
  self.load_markets()
5293
5269
  market = self.market(symbol)
5294
- request = {
5270
+ request: dict = {
5295
5271
  'market_type': 'FUTURES',
5296
5272
  'market': market['id'],
5297
5273
  }
@@ -5494,7 +5470,7 @@ class coinex(Exchange, ImplicitAPI):
5494
5470
  if positionId is None:
5495
5471
  raise ArgumentsRequired(self.id + ' fetchMarginAdjustmentHistory() requires a positionId parameter')
5496
5472
  market = self.market(symbol)
5497
- request = {
5473
+ request: dict = {
5498
5474
  'market': market['id'],
5499
5475
  'market_type': 'FUTURES',
5500
5476
  'position_id': positionId,