ccxt-ir 4.3.46.0.3__py2.py3-none-any.whl → 4.5.0__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 (529) hide show
  1. ccxt/__init__.py +39 -35
  2. ccxt/abantether.py +8 -8
  3. ccxt/abstract/alpaca.py +4 -0
  4. ccxt/abstract/apex.py +31 -0
  5. ccxt/abstract/bigone.py +1 -1
  6. ccxt/abstract/binance.py +106 -48
  7. ccxt/abstract/binancecoinm.py +106 -48
  8. ccxt/abstract/binanceus.py +141 -83
  9. ccxt/abstract/binanceusdm.py +106 -48
  10. ccxt/abstract/bingx.py +50 -1
  11. ccxt/abstract/bitbank.py +5 -0
  12. ccxt/abstract/bitfinex.py +136 -65
  13. ccxt/abstract/bitflyer.py +1 -0
  14. ccxt/abstract/bitget.py +67 -0
  15. ccxt/abstract/bitmart.py +19 -1
  16. ccxt/abstract/bitopro.py +1 -0
  17. ccxt/abstract/bitrue.py +68 -68
  18. ccxt/abstract/bitstamp.py +1 -0
  19. ccxt/abstract/blofin.py +30 -0
  20. ccxt/abstract/btcbox.py +2 -0
  21. ccxt/abstract/bybit.py +28 -13
  22. ccxt/abstract/cex.py +28 -29
  23. ccxt/abstract/coinbaseexchange.py +1 -0
  24. ccxt/abstract/coinbaseinternational.py +1 -1
  25. ccxt/abstract/cryptocom.py +16 -0
  26. ccxt/abstract/cryptomus.py +20 -0
  27. ccxt/abstract/defx.py +69 -0
  28. ccxt/abstract/deribit.py +1 -0
  29. ccxt/abstract/derive.py +117 -0
  30. ccxt/abstract/digifinex.py +1 -0
  31. ccxt/abstract/ellipx.py +25 -0
  32. ccxt/abstract/foxbit.py +26 -0
  33. ccxt/abstract/gate.py +19 -0
  34. ccxt/abstract/gateio.py +19 -0
  35. ccxt/abstract/gemini.py +1 -0
  36. ccxt/abstract/hibachi.py +26 -0
  37. ccxt/abstract/hyperliquid.py +1 -1
  38. ccxt/abstract/independentreserve.py +6 -0
  39. ccxt/abstract/kraken.py +1 -0
  40. ccxt/abstract/krakenfutures.py +4 -0
  41. ccxt/abstract/kucoin.py +10 -0
  42. ccxt/abstract/kucoinfutures.py +18 -0
  43. ccxt/abstract/lbank.py +2 -1
  44. ccxt/abstract/luno.py +1 -0
  45. ccxt/abstract/mexc.py +2 -0
  46. ccxt/abstract/modetrade.py +119 -0
  47. ccxt/abstract/myokx.py +349 -0
  48. ccxt/abstract/oceanex.py +5 -0
  49. ccxt/abstract/okx.py +25 -0
  50. ccxt/abstract/okxus.py +349 -0
  51. ccxt/abstract/onetrading.py +0 -12
  52. ccxt/abstract/paradex.py +23 -0
  53. ccxt/abstract/phemex.py +2 -0
  54. ccxt/abstract/poloniex.py +36 -0
  55. ccxt/abstract/tradeogre.py +3 -1
  56. ccxt/abstract/upbit.py +51 -34
  57. ccxt/abstract/whitebit.py +16 -0
  58. ccxt/abstract/woo.py +64 -6
  59. ccxt/abstract/xt.py +10 -5
  60. ccxt/afratether.py +7 -7
  61. ccxt/alpaca.py +828 -51
  62. ccxt/apex.py +1875 -0
  63. ccxt/arzinja.py +7 -7
  64. ccxt/arzplus.py +9 -9
  65. ccxt/ascendex.py +501 -306
  66. ccxt/async_support/__init__.py +39 -35
  67. ccxt/async_support/abantether.py +8 -8
  68. ccxt/async_support/afratether.py +9 -9
  69. ccxt/async_support/alpaca.py +828 -51
  70. ccxt/async_support/apex.py +1875 -0
  71. ccxt/async_support/arzinja.py +10 -10
  72. ccxt/async_support/arzplus.py +12 -12
  73. ccxt/async_support/ascendex.py +502 -306
  74. ccxt/async_support/base/exchange.py +303 -89
  75. ccxt/async_support/base/ws/cache.py +9 -3
  76. ccxt/async_support/base/ws/client.py +173 -38
  77. ccxt/async_support/base/ws/future.py +25 -37
  78. ccxt/async_support/bequant.py +5 -3
  79. ccxt/async_support/bigone.py +279 -144
  80. ccxt/async_support/binance.py +2347 -1158
  81. ccxt/async_support/binancecoinm.py +9 -3
  82. ccxt/async_support/binanceus.py +17 -3
  83. ccxt/async_support/binanceusdm.py +9 -4
  84. ccxt/async_support/bingx.py +2962 -920
  85. ccxt/async_support/bit2c.py +147 -27
  86. ccxt/async_support/bitbank.py +151 -23
  87. ccxt/async_support/bitbns.py +104 -30
  88. ccxt/async_support/bitfinex.py +3291 -1113
  89. ccxt/async_support/bitflyer.py +202 -27
  90. ccxt/async_support/bitget.py +3683 -1538
  91. ccxt/async_support/bithumb.py +195 -38
  92. ccxt/async_support/bitimen.py +12 -12
  93. ccxt/async_support/bitir.py +38 -38
  94. ccxt/async_support/bitmart.py +1288 -350
  95. ccxt/async_support/bitmex.py +260 -75
  96. ccxt/async_support/bitopro.py +262 -62
  97. ccxt/async_support/bitpin.py +17 -16
  98. ccxt/async_support/bitrue.py +459 -290
  99. ccxt/async_support/bitso.py +199 -54
  100. ccxt/async_support/bitstamp.py +230 -96
  101. ccxt/async_support/bitteam.py +167 -25
  102. ccxt/async_support/{huobijp.py → bittrade.py} +158 -30
  103. ccxt/async_support/bitvavo.py +213 -49
  104. ccxt/async_support/blockchaincom.py +160 -46
  105. ccxt/async_support/blofin.py +502 -120
  106. ccxt/async_support/btcalpha.py +169 -31
  107. ccxt/async_support/btcbox.py +292 -23
  108. ccxt/async_support/btcmarkets.py +211 -58
  109. ccxt/async_support/btcturk.py +161 -38
  110. ccxt/async_support/bybit.py +1775 -1030
  111. ccxt/async_support/cex.py +1440 -1303
  112. ccxt/async_support/coinbase.py +724 -212
  113. ccxt/async_support/coinbaseadvanced.py +2 -1
  114. ccxt/async_support/coinbaseexchange.py +388 -89
  115. ccxt/async_support/coinbaseinternational.py +412 -57
  116. ccxt/async_support/coincatch.py +177 -78
  117. ccxt/async_support/coincheck.py +135 -19
  118. ccxt/async_support/coinex.py +606 -232
  119. ccxt/async_support/coinmate.py +189 -63
  120. ccxt/async_support/coinmetro.py +195 -54
  121. ccxt/async_support/coinone.py +158 -51
  122. ccxt/async_support/coinsph.py +336 -61
  123. ccxt/async_support/coinspot.py +151 -52
  124. ccxt/async_support/cryptocom.py +661 -111
  125. ccxt/async_support/cryptomus.py +1137 -0
  126. ccxt/async_support/defx.py +2071 -0
  127. ccxt/async_support/delta.py +299 -99
  128. ccxt/async_support/deribit.py +348 -126
  129. ccxt/async_support/derive.py +2572 -0
  130. ccxt/async_support/digifinex.py +430 -214
  131. ccxt/async_support/ellipx.py +2029 -0
  132. ccxt/async_support/eterex.py +10 -10
  133. ccxt/async_support/excoino.py +31 -31
  134. ccxt/async_support/exir.py +14 -14
  135. ccxt/async_support/exmo.py +344 -131
  136. ccxt/async_support/exnovin.py +10 -10
  137. ccxt/async_support/farhadexchange.py +12 -12
  138. ccxt/async_support/fmfwio.py +2 -1
  139. ccxt/async_support/foxbit.py +1935 -0
  140. ccxt/async_support/gate.py +1351 -529
  141. ccxt/async_support/gateio.py +2 -1
  142. ccxt/async_support/gemini.py +144 -39
  143. ccxt/async_support/hashkey.py +152 -109
  144. ccxt/async_support/hibachi.py +2080 -0
  145. ccxt/async_support/hitbtc.py +395 -167
  146. ccxt/async_support/hitobit.py +12 -12
  147. ccxt/async_support/hollaex.py +307 -119
  148. ccxt/async_support/htx.py +851 -383
  149. ccxt/async_support/huobi.py +2 -1
  150. ccxt/async_support/hyperliquid.py +1848 -536
  151. ccxt/async_support/independentreserve.py +288 -15
  152. ccxt/async_support/indodax.py +190 -33
  153. ccxt/async_support/jibitex.py +12 -12
  154. ccxt/async_support/kraken.py +795 -351
  155. ccxt/async_support/krakenfutures.py +214 -62
  156. ccxt/async_support/kucoin.py +715 -396
  157. ccxt/async_support/kucoinfutures.py +652 -89
  158. ccxt/async_support/latoken.py +217 -113
  159. ccxt/async_support/lbank.py +425 -97
  160. ccxt/async_support/luno.py +382 -35
  161. ccxt/async_support/mercado.py +113 -6
  162. ccxt/async_support/mexc.py +874 -437
  163. ccxt/async_support/modetrade.py +2818 -0
  164. ccxt/async_support/myokx.py +54 -0
  165. ccxt/async_support/ndax.py +221 -64
  166. ccxt/async_support/nobitex.py +31 -37
  167. ccxt/async_support/novadax.py +190 -34
  168. ccxt/async_support/oceanex.py +217 -28
  169. ccxt/async_support/okcoin.py +253 -145
  170. ccxt/async_support/okexchange.py +11 -11
  171. ccxt/async_support/okx.py +1088 -351
  172. ccxt/async_support/okxus.py +54 -0
  173. ccxt/async_support/ompfinex.py +25 -24
  174. ccxt/async_support/onetrading.py +213 -392
  175. ccxt/async_support/oxfun.py +245 -166
  176. ccxt/async_support/p2b.py +151 -29
  177. ccxt/async_support/paradex.py +562 -49
  178. ccxt/async_support/paymium.py +82 -19
  179. ccxt/async_support/phemex.py +713 -172
  180. ccxt/async_support/poloniex.py +1602 -283
  181. ccxt/async_support/probit.py +224 -95
  182. ccxt/async_support/ramzinex.py +30 -27
  183. ccxt/async_support/sarmayex.py +9 -9
  184. ccxt/async_support/sarrafex.py +13 -13
  185. ccxt/async_support/tabdeal.py +14 -13
  186. ccxt/async_support/tetherland.py +9 -9
  187. ccxt/async_support/timex.py +210 -51
  188. ccxt/async_support/tokocrypto.py +167 -47
  189. ccxt/async_support/tradeogre.py +266 -31
  190. ccxt/async_support/twox.py +9 -9
  191. ccxt/async_support/ubitex.py +12 -12
  192. ccxt/async_support/upbit.py +568 -165
  193. ccxt/async_support/vertex.py +160 -32
  194. ccxt/async_support/wallex.py +12 -12
  195. ccxt/async_support/wavesexchange.py +165 -30
  196. ccxt/async_support/whitebit.py +975 -127
  197. ccxt/async_support/woo.py +1918 -1016
  198. ccxt/async_support/woofipro.py +433 -141
  199. ccxt/async_support/xt.py +649 -193
  200. ccxt/async_support/yobit.py +195 -70
  201. ccxt/async_support/zaif.py +91 -15
  202. ccxt/async_support/zonda.py +151 -36
  203. ccxt/base/decimal_to_precision.py +14 -10
  204. ccxt/base/errors.py +49 -18
  205. ccxt/base/exchange.py +1556 -450
  206. ccxt/base/precise.py +10 -0
  207. ccxt/base/types.py +114 -6
  208. ccxt/bequant.py +5 -3
  209. ccxt/bigone.py +279 -144
  210. ccxt/binance.py +2347 -1158
  211. ccxt/binancecoinm.py +9 -3
  212. ccxt/binanceus.py +17 -3
  213. ccxt/binanceusdm.py +9 -4
  214. ccxt/bingx.py +2962 -920
  215. ccxt/bit2c.py +147 -27
  216. ccxt/bitbank.py +151 -23
  217. ccxt/bitbns.py +104 -30
  218. ccxt/bitfinex.py +3290 -1113
  219. ccxt/bitflyer.py +202 -27
  220. ccxt/bitget.py +3683 -1538
  221. ccxt/bithumb.py +194 -38
  222. ccxt/bitimen.py +9 -9
  223. ccxt/bitir.py +35 -35
  224. ccxt/bitmart.py +1288 -350
  225. ccxt/bitmex.py +260 -75
  226. ccxt/bitopro.py +262 -62
  227. ccxt/bitpin.py +15 -14
  228. ccxt/bitrue.py +459 -290
  229. ccxt/bitso.py +199 -54
  230. ccxt/bitstamp.py +230 -96
  231. ccxt/bitteam.py +167 -25
  232. ccxt/{huobijp.py → bittrade.py} +158 -30
  233. ccxt/bitvavo.py +213 -49
  234. ccxt/blockchaincom.py +160 -46
  235. ccxt/blofin.py +502 -120
  236. ccxt/btcalpha.py +169 -31
  237. ccxt/btcbox.py +291 -23
  238. ccxt/btcmarkets.py +211 -58
  239. ccxt/btcturk.py +161 -38
  240. ccxt/bybit.py +1775 -1030
  241. ccxt/cex.py +1439 -1303
  242. ccxt/coinbase.py +724 -212
  243. ccxt/coinbaseadvanced.py +2 -1
  244. ccxt/coinbaseexchange.py +388 -89
  245. ccxt/coinbaseinternational.py +412 -57
  246. ccxt/coincatch.py +177 -78
  247. ccxt/coincheck.py +135 -19
  248. ccxt/coinex.py +606 -232
  249. ccxt/coinmate.py +189 -63
  250. ccxt/coinmetro.py +194 -54
  251. ccxt/coinone.py +158 -51
  252. ccxt/coinsph.py +336 -61
  253. ccxt/coinspot.py +151 -52
  254. ccxt/cryptocom.py +661 -111
  255. ccxt/cryptomus.py +1137 -0
  256. ccxt/defx.py +2070 -0
  257. ccxt/delta.py +299 -99
  258. ccxt/deribit.py +348 -126
  259. ccxt/derive.py +2571 -0
  260. ccxt/digifinex.py +430 -214
  261. ccxt/ellipx.py +2029 -0
  262. ccxt/eterex.py +7 -7
  263. ccxt/excoino.py +29 -29
  264. ccxt/exir.py +11 -11
  265. ccxt/exmo.py +343 -131
  266. ccxt/exnovin.py +8 -8
  267. ccxt/farhadexchange.py +10 -10
  268. ccxt/fmfwio.py +2 -1
  269. ccxt/foxbit.py +1935 -0
  270. ccxt/gate.py +1351 -529
  271. ccxt/gateio.py +2 -1
  272. ccxt/gemini.py +144 -39
  273. ccxt/hashkey.py +152 -109
  274. ccxt/hibachi.py +2079 -0
  275. ccxt/hitbtc.py +395 -167
  276. ccxt/hitobit.py +9 -9
  277. ccxt/hollaex.py +307 -119
  278. ccxt/htx.py +851 -383
  279. ccxt/huobi.py +2 -1
  280. ccxt/hyperliquid.py +1848 -536
  281. ccxt/independentreserve.py +287 -15
  282. ccxt/indodax.py +190 -33
  283. ccxt/jibitex.py +9 -9
  284. ccxt/kraken.py +794 -351
  285. ccxt/krakenfutures.py +214 -62
  286. ccxt/kucoin.py +715 -396
  287. ccxt/kucoinfutures.py +652 -89
  288. ccxt/latoken.py +217 -113
  289. ccxt/lbank.py +425 -97
  290. ccxt/luno.py +382 -35
  291. ccxt/mercado.py +113 -6
  292. ccxt/mexc.py +873 -437
  293. ccxt/modetrade.py +2818 -0
  294. ccxt/myokx.py +54 -0
  295. ccxt/ndax.py +221 -64
  296. ccxt/nobitex.py +29 -35
  297. ccxt/novadax.py +190 -34
  298. ccxt/oceanex.py +217 -28
  299. ccxt/okcoin.py +253 -145
  300. ccxt/okexchange.py +9 -9
  301. ccxt/okx.py +1088 -351
  302. ccxt/okxus.py +54 -0
  303. ccxt/ompfinex.py +22 -21
  304. ccxt/onetrading.py +213 -392
  305. ccxt/oxfun.py +245 -166
  306. ccxt/p2b.py +151 -29
  307. ccxt/paradex.py +562 -49
  308. ccxt/paymium.py +82 -19
  309. ccxt/phemex.py +712 -172
  310. ccxt/poloniex.py +1601 -283
  311. ccxt/pro/__init__.py +76 -17
  312. ccxt/pro/alpaca.py +21 -6
  313. ccxt/pro/apex.py +984 -0
  314. ccxt/pro/ascendex.py +58 -10
  315. ccxt/pro/bequant.py +6 -1
  316. ccxt/pro/binance.py +728 -156
  317. ccxt/pro/binancecoinm.py +6 -2
  318. ccxt/pro/binanceus.py +8 -4
  319. ccxt/pro/binanceusdm.py +7 -2
  320. ccxt/pro/bingx.py +333 -142
  321. ccxt/pro/bitfinex.py +727 -262
  322. ccxt/pro/bitget.py +570 -79
  323. ccxt/pro/bithumb.py +20 -6
  324. ccxt/pro/bitmart.py +216 -87
  325. ccxt/pro/bitmex.py +47 -9
  326. ccxt/pro/bitopro.py +26 -14
  327. ccxt/pro/bitrue.py +22 -22
  328. ccxt/pro/bitstamp.py +54 -21
  329. ccxt/pro/{huobijp.py → bittrade.py} +7 -6
  330. ccxt/pro/bitvavo.py +191 -67
  331. ccxt/pro/blockchaincom.py +21 -8
  332. ccxt/pro/blofin.py +9 -1
  333. ccxt/pro/bybit.py +632 -245
  334. ccxt/pro/cex.py +59 -24
  335. ccxt/pro/coinbase.py +102 -73
  336. ccxt/pro/coinbaseadvanced.py +2 -1
  337. ccxt/pro/coinbaseexchange.py +8 -8
  338. ccxt/pro/coinbaseinternational.py +181 -25
  339. ccxt/pro/coincatch.py +6 -7
  340. ccxt/pro/coincheck.py +11 -6
  341. ccxt/pro/coinex.py +967 -665
  342. ccxt/pro/coinone.py +16 -9
  343. ccxt/pro/cryptocom.py +448 -45
  344. ccxt/pro/defx.py +831 -0
  345. ccxt/pro/deribit.py +150 -14
  346. ccxt/pro/derive.py +704 -0
  347. ccxt/pro/exmo.py +239 -6
  348. ccxt/pro/gate.py +623 -65
  349. ccxt/pro/gateio.py +2 -1
  350. ccxt/pro/gemini.py +27 -11
  351. ccxt/pro/hashkey.py +2 -2
  352. ccxt/pro/hitbtc.py +196 -91
  353. ccxt/pro/hollaex.py +23 -7
  354. ccxt/pro/htx.py +51 -14
  355. ccxt/pro/huobi.py +2 -1
  356. ccxt/pro/hyperliquid.py +591 -27
  357. ccxt/pro/independentreserve.py +9 -6
  358. ccxt/pro/kraken.py +640 -320
  359. ccxt/pro/krakenfutures.py +62 -35
  360. ccxt/pro/kucoin.py +267 -46
  361. ccxt/pro/kucoinfutures.py +165 -21
  362. ccxt/pro/lbank.py +102 -21
  363. ccxt/pro/luno.py +12 -8
  364. ccxt/pro/mexc.py +877 -111
  365. ccxt/pro/modetrade.py +1271 -0
  366. ccxt/pro/myokx.py +38 -0
  367. ccxt/pro/ndax.py +15 -2
  368. ccxt/pro/okcoin.py +23 -4
  369. ccxt/pro/okx.py +573 -98
  370. ccxt/pro/okxus.py +38 -0
  371. ccxt/pro/onetrading.py +30 -13
  372. ccxt/pro/oxfun.py +131 -27
  373. ccxt/pro/p2b.py +88 -22
  374. ccxt/pro/paradex.py +3 -3
  375. ccxt/pro/phemex.py +75 -21
  376. ccxt/pro/poloniex.py +124 -41
  377. ccxt/pro/probit.py +87 -80
  378. ccxt/pro/tradeogre.py +272 -0
  379. ccxt/pro/upbit.py +152 -12
  380. ccxt/pro/vertex.py +8 -3
  381. ccxt/pro/whitebit.py +58 -5
  382. ccxt/pro/woo.py +228 -37
  383. ccxt/pro/woofipro.py +106 -18
  384. ccxt/pro/xt.py +111 -5
  385. ccxt/probit.py +224 -95
  386. ccxt/protobuf/__init__.py +0 -0
  387. ccxt/protobuf/mexc/PrivateAccountV3Api_pb2.py +37 -0
  388. ccxt/protobuf/mexc/PrivateDealsV3Api_pb2.py +37 -0
  389. ccxt/protobuf/mexc/PrivateOrdersV3Api_pb2.py +37 -0
  390. ccxt/protobuf/mexc/PublicAggreBookTickerV3Api_pb2.py +37 -0
  391. ccxt/protobuf/mexc/PublicAggreDealsV3Api_pb2.py +39 -0
  392. ccxt/protobuf/mexc/PublicAggreDepthsV3Api_pb2.py +39 -0
  393. ccxt/protobuf/mexc/PublicBookTickerBatchV3Api_pb2.py +38 -0
  394. ccxt/protobuf/mexc/PublicBookTickerV3Api_pb2.py +37 -0
  395. ccxt/protobuf/mexc/PublicDealsV3Api_pb2.py +39 -0
  396. ccxt/protobuf/mexc/PublicIncreaseDepthsBatchV3Api_pb2.py +38 -0
  397. ccxt/protobuf/mexc/PublicIncreaseDepthsV3Api_pb2.py +39 -0
  398. ccxt/protobuf/mexc/PublicLimitDepthsV3Api_pb2.py +39 -0
  399. ccxt/protobuf/mexc/PublicMiniTickerV3Api_pb2.py +37 -0
  400. ccxt/protobuf/mexc/PublicMiniTickersV3Api_pb2.py +38 -0
  401. ccxt/protobuf/mexc/PublicSpotKlineV3Api_pb2.py +37 -0
  402. ccxt/protobuf/mexc/PushDataV3ApiWrapper_pb2.py +52 -0
  403. ccxt/protobuf/mexc/__init__.py +0 -0
  404. ccxt/ramzinex.py +28 -25
  405. ccxt/sarmayex.py +7 -7
  406. ccxt/sarrafex.py +10 -10
  407. ccxt/static_dependencies/__init__.py +1 -1
  408. ccxt/static_dependencies/lark/py.typed +0 -0
  409. ccxt/static_dependencies/marshmallow/py.typed +0 -0
  410. ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
  411. ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
  412. ccxt/tabdeal.py +12 -11
  413. ccxt/test/tests_async.py +261 -57
  414. ccxt/test/tests_helpers.py +1 -3
  415. ccxt/test/tests_init.py +4 -3
  416. ccxt/test/tests_sync.py +261 -57
  417. ccxt/tetherland.py +7 -7
  418. ccxt/timex.py +210 -51
  419. ccxt/tokocrypto.py +167 -47
  420. ccxt/tradeogre.py +266 -31
  421. ccxt/twox.py +7 -7
  422. ccxt/ubitex.py +9 -9
  423. ccxt/upbit.py +568 -165
  424. ccxt/vertex.py +160 -32
  425. ccxt/wallex.py +9 -9
  426. ccxt/wavesexchange.py +165 -30
  427. ccxt/whitebit.py +975 -127
  428. ccxt/woo.py +1917 -1016
  429. ccxt/woofipro.py +432 -141
  430. ccxt/xt.py +649 -193
  431. ccxt/yobit.py +194 -70
  432. ccxt/zaif.py +91 -15
  433. ccxt/zonda.py +151 -36
  434. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/METADATA +225 -73
  435. ccxt_ir-4.5.0.dist-info/RECORD +743 -0
  436. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/WHEEL +1 -1
  437. ccxt/__test__.py +0 -7
  438. ccxt/abstract/ace.py +0 -15
  439. ccxt/abstract/bitbay.py +0 -53
  440. ccxt/abstract/bitcoincom.py +0 -115
  441. ccxt/abstract/bitfinex2.py +0 -139
  442. ccxt/abstract/bitpanda.py +0 -35
  443. ccxt/abstract/bl3p.py +0 -19
  444. ccxt/abstract/coinlist.py +0 -54
  445. ccxt/abstract/currencycom.py +0 -68
  446. ccxt/abstract/hitbtc3.py +0 -115
  447. ccxt/abstract/idex.py +0 -26
  448. ccxt/abstract/kuna.py +0 -182
  449. ccxt/abstract/lykke.py +0 -29
  450. ccxt/abstract/poloniexfutures.py +0 -48
  451. ccxt/abstract/wazirx.py +0 -30
  452. ccxt/ace.py +0 -1012
  453. ccxt/async_support/ace.py +0 -1012
  454. ccxt/async_support/base/ws/aiohttp_client.py +0 -125
  455. ccxt/async_support/base/ws/fast_client.py +0 -96
  456. ccxt/async_support/bitbay.py +0 -17
  457. ccxt/async_support/bitcoincom.py +0 -17
  458. ccxt/async_support/bitfinex2.py +0 -3552
  459. ccxt/async_support/bitpanda.py +0 -16
  460. ccxt/async_support/bl3p.py +0 -485
  461. ccxt/async_support/coinlist.py +0 -2243
  462. ccxt/async_support/currencycom.py +0 -1950
  463. ccxt/async_support/hitbtc3.py +0 -16
  464. ccxt/async_support/idex.py +0 -1766
  465. ccxt/async_support/kuna.py +0 -1841
  466. ccxt/async_support/lykke.py +0 -1270
  467. ccxt/async_support/poloniexfutures.py +0 -1717
  468. ccxt/async_support/wazirx.py +0 -1224
  469. ccxt/bitbay.py +0 -17
  470. ccxt/bitcoincom.py +0 -17
  471. ccxt/bitfinex2.py +0 -3552
  472. ccxt/bitpanda.py +0 -16
  473. ccxt/bl3p.py +0 -485
  474. ccxt/coinlist.py +0 -2243
  475. ccxt/currencycom.py +0 -1950
  476. ccxt/hitbtc3.py +0 -16
  477. ccxt/idex.py +0 -1766
  478. ccxt/kuna.py +0 -1841
  479. ccxt/lykke.py +0 -1270
  480. ccxt/poloniexfutures.py +0 -1717
  481. ccxt/pro/bitcoincom.py +0 -34
  482. ccxt/pro/bitfinex2.py +0 -1083
  483. ccxt/pro/bitpanda.py +0 -15
  484. ccxt/pro/currencycom.py +0 -536
  485. ccxt/pro/idex.py +0 -672
  486. ccxt/pro/poloniexfutures.py +0 -990
  487. ccxt/pro/wazirx.py +0 -749
  488. ccxt/test/base/__init__.py +0 -29
  489. ccxt/test/base/test_account.py +0 -26
  490. ccxt/test/base/test_balance.py +0 -56
  491. ccxt/test/base/test_borrow_interest.py +0 -35
  492. ccxt/test/base/test_borrow_rate.py +0 -32
  493. ccxt/test/base/test_calculate_fee.py +0 -51
  494. ccxt/test/base/test_crypto.py +0 -127
  495. ccxt/test/base/test_currency.py +0 -76
  496. ccxt/test/base/test_datetime.py +0 -109
  497. ccxt/test/base/test_decimal_to_precision.py +0 -392
  498. ccxt/test/base/test_deep_extend.py +0 -68
  499. ccxt/test/base/test_deposit_withdrawal.py +0 -50
  500. ccxt/test/base/test_exchange_datetime_functions.py +0 -76
  501. ccxt/test/base/test_funding_rate_history.py +0 -29
  502. ccxt/test/base/test_last_price.py +0 -31
  503. ccxt/test/base/test_ledger_entry.py +0 -45
  504. ccxt/test/base/test_ledger_item.py +0 -48
  505. ccxt/test/base/test_leverage_tier.py +0 -33
  506. ccxt/test/base/test_liquidation.py +0 -50
  507. ccxt/test/base/test_margin_mode.py +0 -24
  508. ccxt/test/base/test_margin_modification.py +0 -35
  509. ccxt/test/base/test_market.py +0 -193
  510. ccxt/test/base/test_number.py +0 -411
  511. ccxt/test/base/test_ohlcv.py +0 -33
  512. ccxt/test/base/test_open_interest.py +0 -32
  513. ccxt/test/base/test_order.py +0 -64
  514. ccxt/test/base/test_order_book.py +0 -69
  515. ccxt/test/base/test_position.py +0 -60
  516. ccxt/test/base/test_shared_methods.py +0 -353
  517. ccxt/test/base/test_status.py +0 -24
  518. ccxt/test/base/test_throttle.py +0 -126
  519. ccxt/test/base/test_ticker.py +0 -92
  520. ccxt/test/base/test_trade.py +0 -47
  521. ccxt/test/base/test_trading_fee.py +0 -26
  522. ccxt/test/base/test_transaction.py +0 -39
  523. ccxt/test/test_async.py +0 -1649
  524. ccxt/test/test_sync.py +0 -1648
  525. ccxt/wazirx.py +0 -1224
  526. ccxt_ir-4.3.46.0.3.dist-info/RECORD +0 -773
  527. /ccxt/abstract/{huobijp.py → bittrade.py} +0 -0
  528. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info/licenses}/LICENSE.txt +0 -0
  529. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,7 @@
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.coinex import ImplicitAPI
8
8
  import asyncio
9
- from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, TransferEntries
9
+ from ccxt.base.types import Any, Balances, BorrowInterest, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -19,6 +19,7 @@ from ccxt.base.errors import InsufficientFunds
19
19
  from ccxt.base.errors import InvalidOrder
20
20
  from ccxt.base.errors import OrderNotFound
21
21
  from ccxt.base.errors import NotSupported
22
+ from ccxt.base.errors import OperationFailed
22
23
  from ccxt.base.errors import RateLimitExceeded
23
24
  from ccxt.base.errors import ExchangeNotAvailable
24
25
  from ccxt.base.errors import RequestTimeout
@@ -28,7 +29,7 @@ from ccxt.base.precise import Precise
28
29
 
29
30
  class coinex(Exchange, ImplicitAPI):
30
31
 
31
- def describe(self):
32
+ def describe(self) -> Any:
32
33
  return self.deep_extend(super(coinex, self).describe(), {
33
34
  'id': 'coinex',
34
35
  'name': 'CoinEx',
@@ -59,6 +60,8 @@ class coinex(Exchange, ImplicitAPI):
59
60
  'cancelAllOrders': True,
60
61
  'cancelOrder': True,
61
62
  'cancelOrders': True,
63
+ 'closeAllPositions': False,
64
+ 'closePosition': True,
62
65
  'createDepositAddress': True,
63
66
  'createMarketBuyOrderWithCost': True,
64
67
  'createMarketOrderWithCost': False,
@@ -67,6 +70,7 @@ class coinex(Exchange, ImplicitAPI):
67
70
  'createOrders': True,
68
71
  'createReduceOnlyOrder': True,
69
72
  'createStopLossOrder': True,
73
+ 'createStopOrder': True,
70
74
  'createTakeProfitOrder': True,
71
75
  'createTriggerOrder': True,
72
76
  'editOrder': True,
@@ -79,12 +83,14 @@ class coinex(Exchange, ImplicitAPI):
79
83
  'fetchCrossBorrowRates': False,
80
84
  'fetchCurrencies': True,
81
85
  'fetchDepositAddress': True,
82
- 'fetchDepositAddressByNetwork': False,
83
86
  'fetchDepositAddresses': False,
87
+ 'fetchDepositAddressesByNetwork': False,
84
88
  'fetchDeposits': True,
85
89
  'fetchDepositWithdrawFee': True,
86
- 'fetchDepositWithdrawFees': False,
90
+ 'fetchDepositWithdrawFees': True,
87
91
  'fetchFundingHistory': True,
92
+ 'fetchFundingInterval': True,
93
+ 'fetchFundingIntervals': False,
88
94
  'fetchFundingRate': True,
89
95
  'fetchFundingRateHistory': True,
90
96
  'fetchFundingRates': True,
@@ -470,9 +476,133 @@ class coinex(Exchange, ImplicitAPI):
470
476
  'FUTURES': 'swap',
471
477
  },
472
478
  'networks': {
479
+ 'BTC': 'BTC',
473
480
  'BEP20': 'BSC',
474
- 'TRX': 'TRC20',
475
- 'ETH': 'ERC20',
481
+ 'TRC20': 'TRC20',
482
+ 'ERC20': 'ERC20',
483
+ 'BRC20': 'BRC20',
484
+ 'SOL': 'SOL',
485
+ 'TON': 'TON',
486
+ 'BSV': 'BSV',
487
+ 'AVAXC': 'AVA_C',
488
+ 'AVAXX': 'AVA',
489
+ 'SUI': 'SUI',
490
+ 'ACA': 'ACA',
491
+ 'CHZ': 'CHILIZ',
492
+ 'ADA': 'ADA',
493
+ 'ARB': 'ARBITRUM',
494
+ 'ARBNOVA': 'ARBITRUM_NOVA',
495
+ 'OP': 'OPTIMISM',
496
+ 'APT': 'APTOS',
497
+ 'ATOM': 'ATOM',
498
+ 'FTM': 'FTM',
499
+ 'BCH': 'BCH',
500
+ 'ASTR': 'ASTR',
501
+ 'LTC': 'LTC',
502
+ 'MATIC': 'MATIC',
503
+ 'CRONOS': 'CRONOS',
504
+ 'DASH': 'DASH',
505
+ 'DOT': 'DOT',
506
+ 'ETC': 'ETC',
507
+ 'ETHW': 'ETHPOW',
508
+ 'FIL': 'FIL',
509
+ 'ZIL': 'ZIL',
510
+ 'DOGE': 'DOGE',
511
+ 'TIA': 'CELESTIA',
512
+ 'SEI': 'SEI',
513
+ 'XRP': 'XRP',
514
+ 'XMR': 'XMR',
515
+ # CSC, AE, BASE, AIPG, AKASH, POLKADOTASSETHUB ?, ALEO, STX, ALGO, ALPH, BLAST, AR, ARCH, ARDR, ARK, ARRR, MANTA, NTRN, LUNA, AURORA, AVAIL, ASC20, AVA, AYA, AZERO, BAN, BAND, BB, RUNES, BEAM, BELLSCOIN, BITCI, NEAR, AGORIC, BLOCX, BNC, BOBA, BRISE, KRC20, CANTO, CAPS, CCD, CELO, CFX, CHI, CKB, CLORE, CLV, CORE, CSPR, CTXC, DAG, DCR, DERO, DESO, DEFI, DGB, DNX, DOCK, DOGECHAIN, DYDX, DYMENSION, EGLD, ELA, ELF, ENJIN, EOSIO, ERG, ETN_SC, EVMOS, EWC, SGB, FACT, FB, FET, FIO, FIRO, NEO3, FLOW, FLARE, FLUX, LINEA, FREN, FSN, FB_BRC20, GLMR, GRIN, GRS, HACASH, HBAR, HERB, HIVE, MAPO, HMND, HNS, ZKSYNC, HTR, HUAHUA, MERLIN, ICP, ICX, INJ, IOST, IOTA, IOTX, IRIS, IRON, ONE, JOYSTREAM, KAI, KAR, KAS, KAVA, KCN, KDA, KLAY, KLY, KMD, KSM, KUB, KUJIRA, LAT, LBC, LUNC, LUKSO, MARS, METIS, MINA, MANTLE, MOB, MODE, MONA, MOVR, MTL, NEOX, NEXA, NIBI, NIMIQ, NMC, ONOMY, NRG, WAVES, NULS, OAS, OCTA, OLT, ONT, OORT, ORAI, OSMO, P3D, COMPOSABLE, PIVX, RON, POKT, POLYMESH, PRE_MARKET, PYI, QKC, QTUM, QUBIC, RSK, ROSE, ROUTE, RTM, THORCHAIN, RVN, RADIANT, SAGA, SALVIUM, SATOX, SC, SCP, _NULL, SCRT, SDN, RGBPP, SELF, SMH, SPACE, STARGAZE, STC, STEEM, STRATISEVM, STRD, STARKNET, SXP, SYS, TAIKO, TAO, TARA, TENET, THETA, TT, VENOM, VECHAIN, TOMO, VITE, VLX, VSYS, VTC, WAN, WAXP, WEMIX, XCH, XDC, XEC, XELIS, NEM, XHV, XLM, XNA, NANO, XPLA, XPR, XPRT, XRD, XTZ, XVG, XYM, ZANO, ZEC, ZEN, ZEPH, ZETA
516
+ },
517
+ },
518
+ 'features': {
519
+ 'spot': {
520
+ 'sandbox': False,
521
+ 'createOrder': {
522
+ 'marginMode': True,
523
+ 'triggerPrice': True,
524
+ 'triggerPriceType': None,
525
+ 'triggerDirection': False,
526
+ 'stopLossPrice': False, # todo
527
+ 'takeProfitPrice': False, # todo
528
+ 'attachedStopLossTakeProfit': None,
529
+ 'timeInForce': {
530
+ 'IOC': True,
531
+ 'FOK': True,
532
+ 'PO': True,
533
+ 'GTD': False,
534
+ },
535
+ 'hedged': False,
536
+ 'trailing': False,
537
+ 'leverage': False,
538
+ 'marketBuyByCost': True,
539
+ 'marketBuyRequiresPrice': True,
540
+ 'selfTradePrevention': True, # todo: implement
541
+ 'iceberg': True, # todo implement
542
+ },
543
+ 'createOrders': {
544
+ 'max': 5,
545
+ },
546
+ 'fetchMyTrades': {
547
+ 'marginMode': True,
548
+ 'limit': 1000,
549
+ 'daysBack': None,
550
+ 'untilDays': 100000,
551
+ 'symbolRequired': True,
552
+ },
553
+ 'fetchOrder': {
554
+ 'marginMode': False,
555
+ 'trigger': False,
556
+ 'trailing': False,
557
+ 'symbolRequired': True,
558
+ },
559
+ 'fetchOpenOrders': {
560
+ 'marginMode': True,
561
+ 'limit': 1000,
562
+ 'trigger': True,
563
+ 'trailing': False,
564
+ 'symbolRequired': False,
565
+ },
566
+ 'fetchOrders': None,
567
+ 'fetchClosedOrders': {
568
+ 'marginMode': True,
569
+ 'limit': 1000,
570
+ 'daysBack': None,
571
+ 'daysBackCanceled': None,
572
+ 'untilDays': None,
573
+ 'trigger': True,
574
+ 'trailing': False,
575
+ 'symbolRequired': False,
576
+ },
577
+ 'fetchOHLCV': {
578
+ 'limit': 1000,
579
+ },
580
+ },
581
+ 'forDerivatives': {
582
+ 'extends': 'spot',
583
+ 'createOrder': {
584
+ 'marginMode': True,
585
+ 'stopLossPrice': True,
586
+ 'takeProfitPrice': True,
587
+ },
588
+ 'fetchOpenOrders': {
589
+ 'marginMode': False,
590
+ },
591
+ 'fetchClosedOrders': {
592
+ 'marginMode': False,
593
+ },
594
+ },
595
+ 'swap': {
596
+ 'linear': {
597
+ 'extends': 'forDerivatives',
598
+ },
599
+ 'inverse': {
600
+ 'extends': 'forDerivatives',
601
+ },
602
+ },
603
+ 'future': {
604
+ 'linear': None,
605
+ 'inverse': None,
476
606
  },
477
607
  },
478
608
  'commonCurrencies': {
@@ -498,6 +628,7 @@ class coinex(Exchange, ImplicitAPI):
498
628
  '3008': RequestTimeout, # Service busy, please try again later.
499
629
  '3109': InsufficientFunds, # {"code":3109,"data":{},"message":"balance not enough"}
500
630
  '3127': InvalidOrder, # The order quantity is below the minimum requirement. Please adjust the order quantity.
631
+ '3600': OrderNotFound, # {"code":3600,"data":{},"message":"Order not found"}
501
632
  '3606': InvalidOrder, # The price difference between the order price and the latest price is too large. Please adjust the order amount accordingly.
502
633
  '3610': ExchangeError, # Order cancellation prohibited during the Call Auction period.
503
634
  '3612': InvalidOrder, # The est. ask price is lower than the current bottom ask price. Please reduce the amount.
@@ -541,6 +672,7 @@ class coinex(Exchange, ImplicitAPI):
541
672
  'broad': {
542
673
  'ip not allow visit': PermissionDenied,
543
674
  'service too busy': ExchangeNotAvailable,
675
+ 'Service is not available during funding fee settlement': OperationFailed,
544
676
  },
545
677
  },
546
678
  })
@@ -548,7 +680,9 @@ class coinex(Exchange, ImplicitAPI):
548
680
  async def fetch_currencies(self, params={}) -> Currencies:
549
681
  """
550
682
  fetches all available currencies on an exchange
551
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-all-deposit-withdrawal-config
683
+
684
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-all-deposit-withdrawal-config
685
+
552
686
  :param dict [params]: extra parameters specific to the exchange API endpoint
553
687
  :returns dict: an associative dictionary of currencies
554
688
  """
@@ -602,35 +736,13 @@ class coinex(Exchange, ImplicitAPI):
602
736
  canWithdraw = self.safe_bool(asset, 'withdraw_enabled')
603
737
  firstChain = self.safe_dict(chains, 0, {})
604
738
  firstPrecisionString = self.parse_precision(self.safe_string(firstChain, 'withdrawal_precision'))
605
- result[code] = {
606
- 'id': currencyId,
607
- 'code': code,
608
- 'name': None,
609
- 'active': canDeposit and canWithdraw,
610
- 'deposit': canDeposit,
611
- 'withdraw': canWithdraw,
612
- 'fee': None,
613
- 'precision': self.parse_number(firstPrecisionString),
614
- 'limits': {
615
- 'amount': {
616
- 'min': None,
617
- 'max': None,
618
- },
619
- 'deposit': {
620
- 'min': None,
621
- 'max': None,
622
- },
623
- 'withdraw': {
624
- 'min': None,
625
- 'max': None,
626
- },
627
- },
628
- 'networks': {},
629
- 'info': coin,
630
- }
739
+ networks: dict = {}
631
740
  for j in range(0, len(chains)):
632
741
  chain = chains[j]
633
742
  networkId = self.safe_string(chain, 'chain')
743
+ networkCode = self.network_id_to_code(networkId, code)
744
+ if networkId is None:
745
+ continue
634
746
  precisionString = self.parse_precision(self.safe_string(chain, 'withdrawal_precision'))
635
747
  feeString = self.safe_string(chain, 'withdrawal_fee')
636
748
  minNetworkDepositString = self.safe_string(chain, 'min_deposit_amount')
@@ -639,7 +751,7 @@ class coinex(Exchange, ImplicitAPI):
639
751
  canWithdrawChain = self.safe_bool(chain, 'withdraw_enabled')
640
752
  network: dict = {
641
753
  'id': networkId,
642
- 'network': networkId,
754
+ 'network': networkCode,
643
755
  'name': None,
644
756
  'active': canDepositChain and canWithdrawChain,
645
757
  'deposit': canDepositChain,
@@ -662,16 +774,43 @@ class coinex(Exchange, ImplicitAPI):
662
774
  },
663
775
  'info': chain,
664
776
  }
665
- networks = self.safe_dict(result[code], 'networks', {})
666
- networks[networkId] = network
667
- result[code]['networks'] = networks
777
+ networks[networkCode] = network
778
+ result[code] = self.safe_currency_structure({
779
+ 'id': currencyId,
780
+ 'code': code,
781
+ 'name': None,
782
+ 'active': canDeposit and canWithdraw,
783
+ 'deposit': canDeposit,
784
+ 'withdraw': canWithdraw,
785
+ 'fee': None,
786
+ 'precision': self.parse_number(firstPrecisionString),
787
+ 'limits': {
788
+ 'amount': {
789
+ 'min': None,
790
+ 'max': None,
791
+ },
792
+ 'deposit': {
793
+ 'min': None,
794
+ 'max': None,
795
+ },
796
+ 'withdraw': {
797
+ 'min': None,
798
+ 'max': None,
799
+ },
800
+ },
801
+ 'networks': networks,
802
+ 'type': 'crypto',
803
+ 'info': coin,
804
+ })
668
805
  return result
669
806
 
670
807
  async def fetch_markets(self, params={}) -> List[Market]:
671
808
  """
672
809
  retrieves data on all markets for coinex
673
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market
674
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market
810
+
811
+ https://docs.coinex.com/api/v2/spot/market/http/list-market
812
+ https://docs.coinex.com/api/v2/futures/market/http/list-market
813
+
675
814
  :param dict [params]: extra parameters specific to the exchange API endpoint
676
815
  :returns dict[]: an array of objects representing market data
677
816
  """
@@ -684,24 +823,26 @@ class coinex(Exchange, ImplicitAPI):
684
823
  swapMarkets = promises[1]
685
824
  return self.array_concat(spotMarkets, swapMarkets)
686
825
 
687
- async def fetch_spot_markets(self, params):
826
+ async def fetch_spot_markets(self, params) -> List[Market]:
688
827
  response = await self.v2PublicGetSpotMarket(params)
689
828
  #
690
829
  # {
691
830
  # "code": 0,
692
831
  # "data": [
693
832
  # {
694
- # "base_ccy": "SORA",
833
+ # "market": "BTCUSDT",
834
+ # "taker_fee_rate": "0.002",
835
+ # "maker_fee_rate": "0.002",
836
+ # "min_amount": "0.0005",
837
+ # "base_ccy": "BTC",
838
+ # "quote_ccy": "USDT",
695
839
  # "base_ccy_precision": 8,
840
+ # "quote_ccy_precision": 2,
696
841
  # "is_amm_available": True,
697
- # "is_margin_available": False,
698
- # "maker_fee_rate": "0.003",
699
- # "market": "SORAUSDT",
700
- # "min_amount": "500",
701
- # "quote_ccy": "USDT",
702
- # "quote_ccy_precision": 6,
703
- # "taker_fee_rate": "0.003"
704
- # },
842
+ # "is_margin_available": True,
843
+ # "is_pre_trading_available": True,
844
+ # "is_api_trading_available": True
845
+ # }
705
846
  # ],
706
847
  # "message": "OK"
707
848
  # }
@@ -727,11 +868,11 @@ class coinex(Exchange, ImplicitAPI):
727
868
  'settleId': None,
728
869
  'type': 'spot',
729
870
  'spot': True,
730
- 'margin': None,
871
+ 'margin': self.safe_bool(market, 'is_margin_available'),
731
872
  'swap': False,
732
873
  'future': False,
733
874
  'option': False,
734
- 'active': None,
875
+ 'active': self.safe_bool(market, 'is_api_trading_available'),
735
876
  'contract': False,
736
877
  'linear': None,
737
878
  'inverse': None,
@@ -922,14 +1063,18 @@ class coinex(Exchange, ImplicitAPI):
922
1063
  'average': None,
923
1064
  'baseVolume': self.safe_string(ticker, 'volume'),
924
1065
  'quoteVolume': None,
1066
+ 'markPrice': self.safe_string(ticker, 'mark_price'),
1067
+ 'indexPrice': self.safe_string(ticker, 'index_price'),
925
1068
  'info': ticker,
926
1069
  }, market)
927
1070
 
928
1071
  async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
929
1072
  """
930
1073
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
931
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
932
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
1074
+
1075
+ https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
1076
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
1077
+
933
1078
  :param str symbol: unified symbol of the market to fetch the ticker for
934
1079
  :param dict [params]: extra parameters specific to the exchange API endpoint
935
1080
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -998,8 +1143,10 @@ class coinex(Exchange, ImplicitAPI):
998
1143
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
999
1144
  """
1000
1145
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1001
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
1002
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
1146
+
1147
+ https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
1148
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
1149
+
1003
1150
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1004
1151
  :param dict [params]: extra parameters specific to the exchange API endpoint
1005
1152
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1066,10 +1213,12 @@ class coinex(Exchange, ImplicitAPI):
1066
1213
  data = self.safe_list(response, 'data', [])
1067
1214
  return self.parse_tickers(data, symbols)
1068
1215
 
1069
- async def fetch_time(self, params={}):
1216
+ async def fetch_time(self, params={}) -> Int:
1070
1217
  """
1071
1218
  fetches the current integer timestamp in milliseconds from the exchange server
1072
- :see: https://docs.coinex.com/api/v2/common/http/time
1219
+
1220
+ https://docs.coinex.com/api/v2/common/http/time
1221
+
1073
1222
  :param dict [params]: extra parameters specific to the exchange API endpoint
1074
1223
  :returns int: the current integer timestamp in milliseconds from the exchange server
1075
1224
  """
@@ -1089,8 +1238,10 @@ class coinex(Exchange, ImplicitAPI):
1089
1238
  async def fetch_order_book(self, symbol: str, limit: Int = 20, params={}):
1090
1239
  """
1091
1240
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1092
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-depth
1093
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-depth
1241
+
1242
+ https://docs.coinex.com/api/v2/spot/market/http/list-market-depth
1243
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-depth
1244
+
1094
1245
  :param str symbol: unified symbol of the market to fetch the order book for
1095
1246
  :param int [limit]: the maximum amount of order book entries to return
1096
1247
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1199,7 +1350,10 @@ class coinex(Exchange, ImplicitAPI):
1199
1350
  # "side": "buy",
1200
1351
  # "order_id": 136915589622,
1201
1352
  # "price": "64376",
1202
- # "amount": "0.0001"
1353
+ # "amount": "0.0001",
1354
+ # "role": "taker",
1355
+ # "fee": "0.0299",
1356
+ # "fee_ccy": "USDT"
1203
1357
  # }
1204
1358
  #
1205
1359
  timestamp = self.safe_integer(trade, 'created_at')
@@ -1208,6 +1362,15 @@ class coinex(Exchange, ImplicitAPI):
1208
1362
  defaultType = market['type']
1209
1363
  marketId = self.safe_string(trade, 'market')
1210
1364
  market = self.safe_market(marketId, market, None, defaultType)
1365
+ feeCostString = self.safe_string(trade, 'fee')
1366
+ fee = None
1367
+ if feeCostString is not None:
1368
+ feeCurrencyId = self.safe_string(trade, 'fee_ccy')
1369
+ feeCurrencyCode = self.safe_currency_code(feeCurrencyId)
1370
+ fee = {
1371
+ 'cost': feeCostString,
1372
+ 'currency': feeCurrencyCode,
1373
+ }
1211
1374
  return self.safe_trade({
1212
1375
  'info': trade,
1213
1376
  'timestamp': timestamp,
@@ -1217,18 +1380,20 @@ class coinex(Exchange, ImplicitAPI):
1217
1380
  'order': self.safe_string(trade, 'order_id'),
1218
1381
  'type': None,
1219
1382
  'side': self.safe_string(trade, 'side'),
1220
- 'takerOrMaker': None,
1383
+ 'takerOrMaker': self.safe_string(trade, 'role'),
1221
1384
  'price': self.safe_string(trade, 'price'),
1222
1385
  'amount': self.safe_string(trade, 'amount'),
1223
1386
  'cost': self.safe_string(trade, 'deal_money'),
1224
- 'fee': None,
1387
+ 'fee': fee,
1225
1388
  }, market)
1226
1389
 
1227
1390
  async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1228
1391
  """
1229
1392
  get the list of the most recent trades for a particular symbol
1230
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-deals
1231
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-deals
1393
+
1394
+ https://docs.coinex.com/api/v2/spot/market/http/list-market-deals
1395
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-deals
1396
+
1232
1397
  :param str symbol: unified symbol of the market to fetch trades for
1233
1398
  :param int [since]: timestamp in ms of the earliest trade to fetch
1234
1399
  :param int [limit]: the maximum amount of trades to fetch
@@ -1270,8 +1435,10 @@ class coinex(Exchange, ImplicitAPI):
1270
1435
  async def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
1271
1436
  """
1272
1437
  fetch the trading fees for a market
1273
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market
1274
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market
1438
+
1439
+ https://docs.coinex.com/api/v2/spot/market/http/list-market
1440
+ https://docs.coinex.com/api/v2/futures/market/http/list-market
1441
+
1275
1442
  :param str symbol: unified market symbol
1276
1443
  :param dict [params]: extra parameters specific to the exchange API endpoint
1277
1444
  :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -1334,8 +1501,10 @@ class coinex(Exchange, ImplicitAPI):
1334
1501
  async def fetch_trading_fees(self, params={}) -> TradingFees:
1335
1502
  """
1336
1503
  fetch the trading fees for multiple markets
1337
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market
1338
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market
1504
+
1505
+ https://docs.coinex.com/api/v2/spot/market/http/list-market
1506
+ https://docs.coinex.com/api/v2/futures/market/http/list-market
1507
+
1339
1508
  :param dict [params]: extra parameters specific to the exchange API endpoint
1340
1509
  :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
1341
1510
  """
@@ -1435,8 +1604,10 @@ class coinex(Exchange, ImplicitAPI):
1435
1604
  async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1436
1605
  """
1437
1606
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1438
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-kline
1439
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-kline
1607
+
1608
+ https://docs.coinex.com/api/v2/spot/market/http/list-market-kline
1609
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-kline
1610
+
1440
1611
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1441
1612
  :param str timeframe: the length of time each candle represents
1442
1613
  :param int [since]: timestamp in ms of the earliest candle to fetch
@@ -1623,10 +1794,12 @@ class coinex(Exchange, ImplicitAPI):
1623
1794
  async def fetch_balance(self, params={}) -> Balances:
1624
1795
  """
1625
1796
  query for balance and get the amount of funds available for trading or funds locked in orders
1626
- :see: https://docs.coinex.com/api/v2/assets/balance/http/get-spot-balance # spot
1627
- :see: https://docs.coinex.com/api/v2/assets/balance/http/get-futures-balance # swap
1628
- :see: https://docs.coinex.com/api/v2/assets/balance/http/get-marigin-balance # margin
1629
- :see: https://docs.coinex.com/api/v2/assets/balance/http/get-financial-balance # financial
1797
+
1798
+ https://docs.coinex.com/api/v2/assets/balance/http/get-spot-balance # spot
1799
+ https://docs.coinex.com/api/v2/assets/balance/http/get-futures-balance # swap
1800
+ https://docs.coinex.com/api/v2/assets/balance/http/get-marigin-balance # margin
1801
+ https://docs.coinex.com/api/v2/assets/balance/http/get-financial-balance # financial
1802
+
1630
1803
  :param dict [params]: extra parameters specific to the exchange API endpoint
1631
1804
  :param str [params.type]: 'margin', 'swap', 'financial', or 'spot'
1632
1805
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
@@ -1714,7 +1887,7 @@ class coinex(Exchange, ImplicitAPI):
1714
1887
  # "stop_id": 117180138153
1715
1888
  # }
1716
1889
  #
1717
- # Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders, fetchClosedOrders
1890
+ # Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders, fetchClosedOrders, closePosition
1718
1891
  #
1719
1892
  # {
1720
1893
  # "amount": "0.0001",
@@ -1902,7 +2075,6 @@ class coinex(Exchange, ImplicitAPI):
1902
2075
  'reduceOnly': None,
1903
2076
  'side': side,
1904
2077
  'price': self.safe_string(order, 'price'),
1905
- 'stopPrice': self.safe_string(order, 'trigger_price'),
1906
2078
  'triggerPrice': self.safe_string(order, 'trigger_price'),
1907
2079
  'takeProfitPrice': self.safe_number(order, 'take_profit_price'),
1908
2080
  'stopLossPrice': self.safe_number(order, 'stop_loss_price'),
@@ -1922,8 +2094,10 @@ class coinex(Exchange, ImplicitAPI):
1922
2094
  async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1923
2095
  """
1924
2096
  create a market buy order by providing the symbol and cost
1925
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
1926
- :see: https://docs.coinex.com/api/v2/spot/order/http/put-order
2097
+
2098
+ https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
2099
+ https://docs.coinex.com/api/v2/spot/order/http/put-order
2100
+
1927
2101
  :param str symbol: unified symbol of the market to create an order in
1928
2102
  :param float cost: how much you want to trade in units of the quote currency
1929
2103
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1940,7 +2114,7 @@ class coinex(Exchange, ImplicitAPI):
1940
2114
  market = self.market(symbol)
1941
2115
  swap = market['swap']
1942
2116
  clientOrderId = self.safe_string_2(params, 'client_id', 'clientOrderId')
1943
- stopPrice = self.safe_string_2(params, 'stopPrice', 'triggerPrice')
2117
+ triggerPrice = self.safe_string_2(params, 'stopPrice', 'triggerPrice')
1944
2118
  stopLossPrice = self.safe_string(params, 'stopLossPrice')
1945
2119
  takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
1946
2120
  option = self.safe_string(params, 'option')
@@ -1985,8 +2159,8 @@ class coinex(Exchange, ImplicitAPI):
1985
2159
  request['take_profit_type'] = self.safe_string(params, 'stop_type', 'latest_price')
1986
2160
  else:
1987
2161
  request['amount'] = self.amount_to_precision(symbol, amount)
1988
- if stopPrice is not None:
1989
- request['trigger_price'] = self.price_to_precision(symbol, stopPrice)
2162
+ if triggerPrice is not None:
2163
+ request['trigger_price'] = self.price_to_precision(symbol, triggerPrice)
1990
2164
  request['trigger_price_type'] = self.safe_string(params, 'stop_type', 'latest_price')
1991
2165
  else:
1992
2166
  marginMode = None
@@ -2013,26 +2187,28 @@ class coinex(Exchange, ImplicitAPI):
2013
2187
  request['amount'] = self.cost_to_precision(symbol, amount)
2014
2188
  else:
2015
2189
  request['amount'] = self.amount_to_precision(symbol, amount)
2016
- if stopPrice is not None:
2017
- request['trigger_price'] = self.price_to_precision(symbol, stopPrice)
2190
+ if triggerPrice is not None:
2191
+ request['trigger_price'] = self.price_to_precision(symbol, triggerPrice)
2018
2192
  params = self.omit(params, ['reduceOnly', 'timeInForce', 'postOnly', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice'])
2019
2193
  return self.extend(request, params)
2020
2194
 
2021
2195
  async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
2022
2196
  """
2023
2197
  create a trade order
2024
- :see: https://docs.coinex.com/api/v2/spot/order/http/put-order
2025
- :see: https://docs.coinex.com/api/v2/spot/order/http/put-stop-order
2026
- :see: https://docs.coinex.com/api/v2/futures/order/http/put-order
2027
- :see: https://docs.coinex.com/api/v2/futures/order/http/put-stop-order
2028
- :see: https://docs.coinex.com/api/v2/futures/position/http/close-position
2029
- :see: https://docs.coinex.com/api/v2/futures/position/http/set-position-stop-loss
2030
- :see: https://docs.coinex.com/api/v2/futures/position/http/set-position-take-profit
2198
+
2199
+ https://docs.coinex.com/api/v2/spot/order/http/put-order
2200
+ https://docs.coinex.com/api/v2/spot/order/http/put-stop-order
2201
+ https://docs.coinex.com/api/v2/futures/order/http/put-order
2202
+ https://docs.coinex.com/api/v2/futures/order/http/put-stop-order
2203
+ https://docs.coinex.com/api/v2/futures/position/http/close-position
2204
+ https://docs.coinex.com/api/v2/futures/position/http/set-position-stop-loss
2205
+ https://docs.coinex.com/api/v2/futures/position/http/set-position-take-profit
2206
+
2031
2207
  :param str symbol: unified symbol of the market to create an order in
2032
2208
  :param str type: 'market' or 'limit'
2033
2209
  :param str side: 'buy' or 'sell'
2034
2210
  :param float amount: how much you want to trade in units of the base currency
2035
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2211
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2036
2212
  :param dict [params]: extra parameters specific to the exchange API endpoint
2037
2213
  :param float [params.triggerPrice]: price to trigger stop orders
2038
2214
  :param float [params.stopLossPrice]: price to trigger stop loss orders
@@ -2257,10 +2433,12 @@ class coinex(Exchange, ImplicitAPI):
2257
2433
  async def create_orders(self, orders: List[OrderRequest], params={}) -> List[Order]:
2258
2434
  """
2259
2435
  create a list of trade orders(all orders should be of the same symbol)
2260
- :see: https://docs.coinex.com/api/v2/spot/order/http/put-multi-order
2261
- :see: https://docs.coinex.com/api/v2/spot/order/http/put-multi-stop-order
2262
- :see: https://docs.coinex.com/api/v2/futures/order/http/put-multi-order
2263
- :see: https://docs.coinex.com/api/v2/futures/order/http/put-multi-stop-order
2436
+
2437
+ https://docs.coinex.com/api/v2/spot/order/http/put-multi-order
2438
+ https://docs.coinex.com/api/v2/spot/order/http/put-multi-stop-order
2439
+ https://docs.coinex.com/api/v2/futures/order/http/put-multi-order
2440
+ https://docs.coinex.com/api/v2/futures/order/http/put-multi-stop-order
2441
+
2264
2442
  :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
2265
2443
  :param dict [params]: extra parameters specific to the api endpoint
2266
2444
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -2442,10 +2620,12 @@ class coinex(Exchange, ImplicitAPI):
2442
2620
  async def cancel_orders(self, ids, symbol: Str = None, params={}):
2443
2621
  """
2444
2622
  cancel multiple orders
2445
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-order
2446
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-stop-order
2447
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-order
2448
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-stop-order
2623
+
2624
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-order
2625
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-stop-order
2626
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-order
2627
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-stop-order
2628
+
2449
2629
  :param str[] ids: order ids
2450
2630
  :param str symbol: unified market symbol
2451
2631
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2459,15 +2639,18 @@ class coinex(Exchange, ImplicitAPI):
2459
2639
  request: dict = {
2460
2640
  'market': market['id'],
2461
2641
  }
2462
- stop = self.safe_bool_2(params, 'stop', 'trigger')
2642
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
2463
2643
  params = self.omit(params, ['stop', 'trigger'])
2464
2644
  response = None
2465
- if stop:
2466
- request['stop_ids'] = ids
2645
+ requestIds = []
2646
+ for i in range(0, len(ids)):
2647
+ requestIds.append(int(ids[i]))
2648
+ if trigger:
2649
+ request['stop_ids'] = requestIds
2467
2650
  else:
2468
- request['order_ids'] = ids
2651
+ request['order_ids'] = requestIds
2469
2652
  if market['spot']:
2470
- if stop:
2653
+ if trigger:
2471
2654
  response = await self.v2PrivatePostSpotCancelBatchStopOrder(self.extend(request, params))
2472
2655
  #
2473
2656
  # {
@@ -2536,7 +2719,7 @@ class coinex(Exchange, ImplicitAPI):
2536
2719
  #
2537
2720
  else:
2538
2721
  request['market_type'] = 'FUTURES'
2539
- if stop:
2722
+ if trigger:
2540
2723
  response = await self.v2PrivatePostFuturesCancelBatchStopOrder(self.extend(request, params))
2541
2724
  #
2542
2725
  # {
@@ -2613,16 +2796,18 @@ class coinex(Exchange, ImplicitAPI):
2613
2796
  async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
2614
2797
  """
2615
2798
  edit a trade order
2616
- :see: https://docs.coinex.com/api/v2/spot/order/http/edit-order
2617
- :see: https://docs.coinex.com/api/v2/spot/order/http/edit-stop-order
2618
- :see: https://docs.coinex.com/api/v2/futures/order/http/edit-order
2619
- :see: https://docs.coinex.com/api/v2/futures/order/http/edit-stop-order
2799
+
2800
+ https://docs.coinex.com/api/v2/spot/order/http/edit-order
2801
+ https://docs.coinex.com/api/v2/spot/order/http/edit-stop-order
2802
+ https://docs.coinex.com/api/v2/futures/order/http/edit-order
2803
+ https://docs.coinex.com/api/v2/futures/order/http/edit-stop-order
2804
+
2620
2805
  :param str id: order id
2621
2806
  :param str symbol: unified symbol of the market to create an order in
2622
2807
  :param str type: 'market' or 'limit'
2623
2808
  :param str side: 'buy' or 'sell'
2624
2809
  :param float amount: how much of the currency you want to trade in units of the base currency
2625
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2810
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2626
2811
  :param dict [params]: extra parameters specific to the exchange API endpoint
2627
2812
  :param float [params.triggerPrice]: the price to trigger stop orders
2628
2813
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -2746,14 +2931,16 @@ class coinex(Exchange, ImplicitAPI):
2746
2931
  async def cancel_order(self, id: str, symbol: Str = None, params={}):
2747
2932
  """
2748
2933
  cancels an open order
2749
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-order
2750
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order
2751
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-order-by-client-id
2752
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order-by-client-id
2753
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-order
2754
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order
2755
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-order-by-client-id
2756
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order-by-client-id
2934
+
2935
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-order
2936
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order
2937
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-order-by-client-id
2938
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order-by-client-id
2939
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-order
2940
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order
2941
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-order-by-client-id
2942
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order-by-client-id
2943
+
2757
2944
  :param str id: order id
2758
2945
  :param str symbol: unified symbol of the market the order was made in
2759
2946
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3027,8 +3214,10 @@ class coinex(Exchange, ImplicitAPI):
3027
3214
  async def cancel_all_orders(self, symbol: Str = None, params={}):
3028
3215
  """
3029
3216
  cancel all open orders in a market
3030
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-all-order
3031
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-all-order
3217
+
3218
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-all-order
3219
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-all-order
3220
+
3032
3221
  :param str symbol: unified market symbol of the market to cancel orders in
3033
3222
  :param dict [params]: extra parameters specific to the exchange API endpoint
3034
3223
  :param str [params.marginMode]: 'cross' or 'isolated' for canceling spot margin orders
@@ -3068,8 +3257,11 @@ class coinex(Exchange, ImplicitAPI):
3068
3257
  async def fetch_order(self, id: str, symbol: Str = None, params={}):
3069
3258
  """
3070
3259
  fetches information on an order made by the user
3071
- :see: https://docs.coinex.com/api/v2/spot/order/http/get-order-status
3072
- :see: https://docs.coinex.com/api/v2/futures/order/http/get-order-status
3260
+
3261
+ https://docs.coinex.com/api/v2/spot/order/http/get-order-status
3262
+ https://docs.coinex.com/api/v2/futures/order/http/get-order-status
3263
+
3264
+ :param str id: order id
3073
3265
  :param str symbol: unified symbol of the market the order was made in
3074
3266
  :param dict [params]: extra parameters specific to the exchange API endpoint
3075
3267
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -3152,13 +3344,17 @@ class coinex(Exchange, ImplicitAPI):
3152
3344
  async def fetch_orders_by_status(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3153
3345
  """
3154
3346
  fetch a list of orders
3155
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
3156
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
3157
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
3158
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
3347
+
3348
+ https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
3349
+ https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
3350
+ https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
3351
+ https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
3352
+
3353
+ :param str status: order status to fetch for
3159
3354
  :param str symbol: unified market symbol of the market orders were made in
3160
3355
  :param int [since]: the earliest time in ms to fetch orders for
3161
3356
  :param int [limit]: the maximum number of order structures to retrieve
3357
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3162
3358
  :param boolean [params.trigger]: set to True for fetching trigger orders
3163
3359
  :param str [params.marginMode]: 'cross' or 'isolated' for fetching spot margin orders
3164
3360
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
@@ -3171,7 +3367,7 @@ class coinex(Exchange, ImplicitAPI):
3171
3367
  request['market'] = market['id']
3172
3368
  if limit is not None:
3173
3369
  request['limit'] = limit
3174
- stop = self.safe_bool_2(params, 'stop', 'trigger')
3370
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
3175
3371
  params = self.omit(params, ['stop', 'trigger'])
3176
3372
  marketType = None
3177
3373
  marketType, params = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
@@ -3181,7 +3377,7 @@ class coinex(Exchange, ImplicitAPI):
3181
3377
  if marketType == 'swap':
3182
3378
  request['market_type'] = 'FUTURES'
3183
3379
  if isClosed:
3184
- if stop:
3380
+ if trigger:
3185
3381
  response = await self.v2PrivateGetFuturesFinishedStopOrder(self.extend(request, params))
3186
3382
  #
3187
3383
  # {
@@ -3242,7 +3438,7 @@ class coinex(Exchange, ImplicitAPI):
3242
3438
  # }
3243
3439
  #
3244
3440
  elif isOpen:
3245
- if stop:
3441
+ if trigger:
3246
3442
  response = await self.v2PrivateGetFuturesPendingStopOrder(self.extend(request, params))
3247
3443
  #
3248
3444
  # {
@@ -3315,7 +3511,7 @@ class coinex(Exchange, ImplicitAPI):
3315
3511
  else:
3316
3512
  request['market_type'] = 'SPOT'
3317
3513
  if isClosed:
3318
- if stop:
3514
+ if trigger:
3319
3515
  response = await self.v2PrivateGetSpotFinishedStopOrder(self.extend(request, params))
3320
3516
  #
3321
3517
  # {
@@ -3379,7 +3575,7 @@ class coinex(Exchange, ImplicitAPI):
3379
3575
  # }
3380
3576
  #
3381
3577
  elif status == 'pending':
3382
- if stop:
3578
+ if trigger:
3383
3579
  response = await self.v2PrivateGetSpotPendingStopOrder(self.extend(request, params))
3384
3580
  #
3385
3581
  # {
@@ -3452,10 +3648,12 @@ class coinex(Exchange, ImplicitAPI):
3452
3648
  async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
3453
3649
  """
3454
3650
  fetch all unfilled currently open orders
3455
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-pending-order
3456
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-pending-stop-order
3457
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-pending-order
3458
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-pending-stop-order
3651
+
3652
+ https://docs.coinex.com/api/v2/spot/order/http/list-pending-order
3653
+ https://docs.coinex.com/api/v2/spot/order/http/list-pending-stop-order
3654
+ https://docs.coinex.com/api/v2/futures/order/http/list-pending-order
3655
+ https://docs.coinex.com/api/v2/futures/order/http/list-pending-stop-order
3656
+
3459
3657
  :param str symbol: unified market symbol
3460
3658
  :param int [since]: the earliest time in ms to fetch open orders for
3461
3659
  :param int [limit]: the maximum number of open order structures to retrieve
@@ -3472,23 +3670,28 @@ class coinex(Exchange, ImplicitAPI):
3472
3670
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
3473
3671
  """
3474
3672
  fetches information on multiple closed orders made by the user
3475
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
3476
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
3477
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
3478
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
3673
+
3674
+ https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
3675
+ https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
3676
+ https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
3677
+ https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
3678
+
3479
3679
  :param str symbol: unified market symbol of the market orders were made in
3480
3680
  :param int [since]: the earliest time in ms to fetch orders for
3481
3681
  :param int [limit]: the maximum number of order structures to retrieve
3682
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3482
3683
  :param boolean [params.trigger]: set to True for fetching trigger orders
3483
3684
  :param str [params.marginMode]: 'cross' or 'isolated' for fetching spot margin orders
3484
3685
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
3485
3686
  """
3486
3687
  return await self.fetch_orders_by_status('finished', symbol, since, limit, params)
3487
3688
 
3488
- async def create_deposit_address(self, code: str, params={}):
3689
+ async def create_deposit_address(self, code: str, params={}) -> DepositAddress:
3489
3690
  """
3490
3691
  create a currency deposit address
3491
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/update-deposit-address
3692
+
3693
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/update-deposit-address
3694
+
3492
3695
  :param str code: unified currency code of the currency for the deposit address
3493
3696
  :param dict [params]: extra parameters specific to the exchange API endpoint
3494
3697
  :param str [params.network]: the blockchain network to create a deposit address on
@@ -3518,10 +3721,12 @@ class coinex(Exchange, ImplicitAPI):
3518
3721
  data = self.safe_dict(response, 'data', {})
3519
3722
  return self.parse_deposit_address(data, currency)
3520
3723
 
3521
- async def fetch_deposit_address(self, code: str, params={}):
3724
+ async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
3522
3725
  """
3523
3726
  fetch the deposit address for a currency associated with self account
3524
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-address
3727
+
3728
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-address
3729
+
3525
3730
  :param str code: unified currency code
3526
3731
  :param dict [params]: extra parameters specific to the exchange API endpoint
3527
3732
  :param str [params.network]: the blockchain network to create a deposit address on
@@ -3529,20 +3734,14 @@ class coinex(Exchange, ImplicitAPI):
3529
3734
  """
3530
3735
  await self.load_markets()
3531
3736
  currency = self.currency(code)
3532
- networks = self.safe_dict(currency, 'networks', {})
3533
- network = self.safe_string_2(params, 'network', 'chain')
3534
- params = self.omit(params, 'network')
3535
- networksKeys = list(networks.keys())
3536
- numOfNetworks = len(networksKeys)
3537
- if networks is not None and numOfNetworks > 1:
3538
- if network is None:
3539
- raise ArgumentsRequired(self.id + ' fetchDepositAddress() ' + code + ' requires a network parameter')
3540
- if not (network in networks):
3541
- raise ExchangeError(self.id + ' fetchDepositAddress() ' + network + ' network not supported for ' + code)
3542
3737
  request: dict = {
3543
3738
  'ccy': currency['id'],
3544
- 'chain': network,
3545
3739
  }
3740
+ networkCode = None
3741
+ networkCode, params = self.handle_network_code_and_params(params)
3742
+ if networkCode is None:
3743
+ raise ArgumentsRequired(self.id + ' fetchDepositAddress() requires a "network" parameter')
3744
+ request['chain'] = self.network_code_to_id(networkCode) # required for on-chain, not required for inter-user transfer
3546
3745
  response = await self.v2PrivateGetAssetsDepositAddress(self.extend(request, params))
3547
3746
  #
3548
3747
  # {
@@ -3555,29 +3754,9 @@ class coinex(Exchange, ImplicitAPI):
3555
3754
  # }
3556
3755
  #
3557
3756
  data = self.safe_dict(response, 'data', {})
3558
- depositAddress = self.parse_deposit_address(data, currency)
3559
- options = self.safe_dict(self.options, 'fetchDepositAddress', {})
3560
- fillResponseFromRequest = self.safe_bool(options, 'fillResponseFromRequest', True)
3561
- if fillResponseFromRequest:
3562
- depositAddress['network'] = self.safe_network_code(network, currency)
3563
- return depositAddress
3564
-
3565
- def safe_network(self, networkId, currency: Currency = None):
3566
- networks = self.safe_value(currency, 'networks', {})
3567
- networksCodes = list(networks.keys())
3568
- networksCodesLength = len(networksCodes)
3569
- if networkId is None and networksCodesLength == 1:
3570
- return networks[networksCodes[0]]
3571
- return {
3572
- 'id': networkId,
3573
- 'network': None if (networkId is None) else networkId.upper(),
3574
- }
3575
-
3576
- def safe_network_code(self, networkId, currency: Currency = None):
3577
- network = self.safe_network(networkId, currency)
3578
- return network['network']
3757
+ return self.parse_deposit_address(data, currency)
3579
3758
 
3580
- def parse_deposit_address(self, depositAddress, currency: Currency = None):
3759
+ def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
3581
3760
  #
3582
3761
  # {
3583
3762
  # "address": "1P1JqozxioQwaqPwgMAQdNDYNyaVSqgARq",
@@ -3597,16 +3776,18 @@ class coinex(Exchange, ImplicitAPI):
3597
3776
  return {
3598
3777
  'info': depositAddress,
3599
3778
  'currency': self.safe_currency_code(None, currency),
3600
- 'address': address,
3601
- 'tag': tag,
3602
3779
  'network': None,
3780
+ 'address': address,
3781
+ 'tag': self.safe_string(depositAddress, 'memo', tag),
3603
3782
  }
3604
3783
 
3605
3784
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3606
3785
  """
3607
3786
  fetch all trades made by the user
3608
- :see: https://docs.coinex.com/api/v2/spot/deal/http/list-user-deals
3609
- :see: https://docs.coinex.com/api/v2/futures/deal/http/list-user-deals
3787
+
3788
+ https://docs.coinex.com/api/v2/spot/deal/http/list-user-deals
3789
+ https://docs.coinex.com/api/v2/futures/deal/http/list-user-deals
3790
+
3610
3791
  :param str symbol: unified market symbol
3611
3792
  :param int [since]: the earliest time in ms to fetch trades for
3612
3793
  :param int [limit]: the maximum number of trade structures to retrieve
@@ -3683,11 +3864,13 @@ class coinex(Exchange, ImplicitAPI):
3683
3864
  data = self.safe_list(response, 'data', [])
3684
3865
  return self.parse_trades(data, market, since, limit)
3685
3866
 
3686
- async def fetch_positions(self, symbols: Strings = None, params={}):
3867
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
3687
3868
  """
3688
3869
  fetch all open positions
3689
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-pending-position
3690
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-finished-position
3870
+
3871
+ https://docs.coinex.com/api/v2/futures/position/http/list-pending-position
3872
+ https://docs.coinex.com/api/v2/futures/position/http/list-finished-position
3873
+
3691
3874
  :param str[] [symbols]: list of unified market symbols
3692
3875
  :param dict [params]: extra parameters specific to the exchange API endpoint
3693
3876
  :param str [params.method]: the method to use 'v2PrivateGetFuturesPendingPosition' or 'v2PrivateGetFuturesFinishedPosition' default is 'v2PrivateGetFuturesPendingPosition'
@@ -3769,7 +3952,9 @@ class coinex(Exchange, ImplicitAPI):
3769
3952
  async def fetch_position(self, symbol: str, params={}):
3770
3953
  """
3771
3954
  fetch data on a single open contract trade position
3772
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-pending-position
3955
+
3956
+ https://docs.coinex.com/api/v2/futures/position/http/list-pending-position
3957
+
3773
3958
  :param str symbol: unified market symbol of the market the position is held in
3774
3959
  :param dict [params]: extra parameters specific to the exchange API endpoint
3775
3960
  :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -3899,7 +4084,9 @@ class coinex(Exchange, ImplicitAPI):
3899
4084
  async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
3900
4085
  """
3901
4086
  set margin mode to 'cross' or 'isolated'
3902
- :see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage
4087
+
4088
+ https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage
4089
+
3903
4090
  :param str marginMode: 'cross' or 'isolated'
3904
4091
  :param str symbol: unified market symbol
3905
4092
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3939,9 +4126,11 @@ class coinex(Exchange, ImplicitAPI):
3939
4126
  # }
3940
4127
  #
3941
4128
 
3942
- async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
4129
+ async def set_leverage(self, leverage: int, symbol: Str = None, params={}):
3943
4130
  """
3944
- :see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage
4131
+
4132
+ https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage
4133
+
3945
4134
  set the level of leverage for a market
3946
4135
  :param float leverage: the rate of leverage
3947
4136
  :param str symbol: unified market symbol
@@ -3982,7 +4171,9 @@ class coinex(Exchange, ImplicitAPI):
3982
4171
  async def fetch_leverage_tiers(self, symbols: Strings = None, params={}) -> LeverageTiers:
3983
4172
  """
3984
4173
  retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
3985
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-position-level
4174
+
4175
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-position-level
4176
+
3986
4177
  :param str[]|None symbols: list of unified market symbols
3987
4178
  :param dict [params]: extra parameters specific to the exchange API endpoint
3988
4179
  :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
@@ -4032,6 +4223,7 @@ class coinex(Exchange, ImplicitAPI):
4032
4223
  maxNotional = self.safe_number(tier, 'amount')
4033
4224
  tiers.append({
4034
4225
  'tier': self.sum(i, 1),
4226
+ 'symbol': self.safe_symbol(marketId, market, None, 'swap'),
4035
4227
  'currency': market['base'] if market['linear'] else market['quote'],
4036
4228
  'minNotional': minNotional,
4037
4229
  'maxNotional': maxNotional,
@@ -4175,7 +4367,9 @@ class coinex(Exchange, ImplicitAPI):
4175
4367
  async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
4176
4368
  """
4177
4369
  add margin
4178
- :see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4370
+
4371
+ https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4372
+
4179
4373
  :param str symbol: unified market symbol
4180
4374
  :param float amount: amount of margin to add
4181
4375
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -4186,7 +4380,9 @@ class coinex(Exchange, ImplicitAPI):
4186
4380
  async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
4187
4381
  """
4188
4382
  remove margin from a position
4189
- :see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4383
+
4384
+ https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4385
+
4190
4386
  :param str symbol: unified market symbol
4191
4387
  :param float amount: the amount of margin to remove
4192
4388
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -4197,7 +4393,9 @@ class coinex(Exchange, ImplicitAPI):
4197
4393
  async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4198
4394
  """
4199
4395
  fetch the history of funding fee payments paid and received on self account
4200
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-position-funding-history
4396
+
4397
+ https://docs.coinex.com/api/v2/futures/position/http/list-position-funding-history
4398
+
4201
4399
  :param str symbol: unified market symbol
4202
4400
  :param int [since]: the earliest time in ms to fetch funding history for
4203
4401
  :param int [limit]: the maximum number of funding history structures to retrieve
@@ -4257,10 +4455,12 @@ class coinex(Exchange, ImplicitAPI):
4257
4455
  })
4258
4456
  return result
4259
4457
 
4260
- async def fetch_funding_rate(self, symbol: str, params={}):
4458
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
4261
4459
  """
4262
4460
  fetch the current funding rate
4263
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4461
+
4462
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4463
+
4264
4464
  :param str symbol: unified market symbol
4265
4465
  :param dict [params]: extra parameters specific to the exchange API endpoint
4266
4466
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -4295,9 +4495,21 @@ class coinex(Exchange, ImplicitAPI):
4295
4495
  first = self.safe_dict(data, 0, {})
4296
4496
  return self.parse_funding_rate(first, market)
4297
4497
 
4298
- def parse_funding_rate(self, contract, market: Market = None):
4498
+ async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
4499
+ """
4500
+ fetch the current funding rate interval
4501
+
4502
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4503
+
4504
+ :param str symbol: unified market symbol
4505
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4506
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
4507
+ """
4508
+ return await self.fetch_funding_rate(symbol, params)
4509
+
4510
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
4299
4511
  #
4300
- # fetchFundingRate, fetchFundingRates
4512
+ # fetchFundingRate, fetchFundingRates, fetchFundingInterval
4301
4513
  #
4302
4514
  # {
4303
4515
  # "latest_funding_rate": "0",
@@ -4312,6 +4524,9 @@ class coinex(Exchange, ImplicitAPI):
4312
4524
  #
4313
4525
  currentFundingTimestamp = self.safe_integer(contract, 'latest_funding_time')
4314
4526
  futureFundingTimestamp = self.safe_integer(contract, 'next_funding_time')
4527
+ fundingTimeString = self.safe_string(contract, 'latest_funding_time')
4528
+ nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
4529
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
4315
4530
  marketId = self.safe_string(contract, 'market')
4316
4531
  return {
4317
4532
  'info': contract,
@@ -4331,12 +4546,25 @@ class coinex(Exchange, ImplicitAPI):
4331
4546
  'previousFundingRate': None,
4332
4547
  'previousFundingTimestamp': None,
4333
4548
  'previousFundingDatetime': None,
4549
+ 'interval': self.parse_funding_interval(millisecondsInterval),
4334
4550
  }
4335
4551
 
4336
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
4552
+ def parse_funding_interval(self, interval):
4553
+ intervals: dict = {
4554
+ '3600000': '1h',
4555
+ '14400000': '4h',
4556
+ '28800000': '8h',
4557
+ '57600000': '16h',
4558
+ '86400000': '24h',
4559
+ }
4560
+ return self.safe_string(intervals, interval, interval)
4561
+
4562
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
4337
4563
  """
4338
- fetch the current funding rates
4339
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4564
+ fetch the current funding rates for multiple markets
4565
+
4566
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4567
+
4340
4568
  :param str[] symbols: unified market symbols
4341
4569
  :param dict [params]: extra parameters specific to the exchange API endpoint
4342
4570
  :returns dict[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -4372,17 +4600,18 @@ class coinex(Exchange, ImplicitAPI):
4372
4600
  # }
4373
4601
  #
4374
4602
  data = self.safe_list(response, 'data', [])
4375
- result = self.parse_funding_rates(data, market)
4376
- return self.filter_by_array(result, 'symbol', symbols)
4603
+ return self.parse_funding_rates(data, symbols)
4377
4604
 
4378
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
4605
+ async def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
4379
4606
  """
4380
4607
  make a withdrawal
4381
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/withdrawal
4608
+
4609
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/withdrawal
4610
+
4382
4611
  :param str code: unified currency code
4383
4612
  :param float amount: the amount to withdraw
4384
4613
  :param str address: the address to withdraw to
4385
- :param str tag:
4614
+ :param str [tag]: memo
4386
4615
  :param dict [params]: extra parameters specific to the exchange API endpoint
4387
4616
  :param str [params.network]: unified network code
4388
4617
  :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
@@ -4391,15 +4620,15 @@ class coinex(Exchange, ImplicitAPI):
4391
4620
  self.check_address(address)
4392
4621
  await self.load_markets()
4393
4622
  currency = self.currency(code)
4394
- networkCode = self.safe_string_upper_2(params, 'network', 'chain')
4395
- params = self.omit(params, 'network')
4396
- if tag:
4397
- address = address + ':' + tag
4398
4623
  request: dict = {
4399
4624
  'ccy': currency['id'],
4400
4625
  'to_address': address, # must be authorized, inter-user transfer by a registered mobile phone number or an email address is supported
4401
- 'amount': self.number_to_string(amount), # the actual amount without fees, https://www.coinex.com/fees
4626
+ 'amount': self.currency_to_precision(code, amount), # the actual amount without fees, https://www.coinex.com/fees
4402
4627
  }
4628
+ if tag is not None:
4629
+ request['memo'] = tag
4630
+ networkCode = None
4631
+ networkCode, params = self.handle_network_code_and_params(params)
4403
4632
  if networkCode is not None:
4404
4633
  request['chain'] = self.network_code_to_id(networkCode) # required for on-chain, not required for inter-user transfer
4405
4634
  response = await self.v2PrivatePostAssetsWithdraw(self.extend(request, params))
@@ -4436,11 +4665,13 @@ class coinex(Exchange, ImplicitAPI):
4436
4665
  statuses: dict = {
4437
4666
  'audit': 'pending',
4438
4667
  'pass': 'pending',
4668
+ 'audit_required': 'pending',
4439
4669
  'processing': 'pending',
4440
4670
  'confirming': 'pending',
4441
4671
  'not_pass': 'failed',
4442
4672
  'cancel': 'canceled',
4443
4673
  'finish': 'ok',
4674
+ 'finished': 'ok',
4444
4675
  'fail': 'failed',
4445
4676
  }
4446
4677
  return self.safe_string(statuses, status, status)
@@ -4448,7 +4679,9 @@ class coinex(Exchange, ImplicitAPI):
4448
4679
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4449
4680
  """
4450
4681
  fetches historical funding rate prices
4451
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate-history
4682
+
4683
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate-history
4684
+
4452
4685
  :param str symbol: unified symbol of the market to fetch the funding rate history for
4453
4686
  :param int [since]: timestamp in ms of the earliest funding rate to fetch
4454
4687
  :param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
@@ -4610,7 +4843,9 @@ class coinex(Exchange, ImplicitAPI):
4610
4843
  async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
4611
4844
  """
4612
4845
  transfer currency internally between wallets on the same account
4613
- :see: https://docs.coinex.com/api/v2/assets/transfer/http/transfer
4846
+
4847
+ https://docs.coinex.com/api/v2/assets/transfer/http/transfer
4848
+
4614
4849
  :param str code: unified currency code
4615
4850
  :param float amount: amount to transfer
4616
4851
  :param str fromAccount: account to transfer from
@@ -4622,7 +4857,7 @@ class coinex(Exchange, ImplicitAPI):
4622
4857
  await self.load_markets()
4623
4858
  currency = self.currency(code)
4624
4859
  amountToPrecision = self.currency_to_precision(code, amount)
4625
- accountsByType = self.safe_dict(self.options, 'accountsById', {})
4860
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
4626
4861
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
4627
4862
  toId = self.safe_string(accountsByType, toAccount, toAccount)
4628
4863
  request: dict = {
@@ -4680,10 +4915,12 @@ class coinex(Exchange, ImplicitAPI):
4680
4915
  'status': self.parse_transfer_status(self.safe_string_2(transfer, 'code', 'status')),
4681
4916
  }
4682
4917
 
4683
- async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> TransferEntries:
4918
+ async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
4684
4919
  """
4685
4920
  fetch a history of internal transfers made on an account
4686
- :see: https://docs.coinex.com/api/v2/assets/transfer/http/list-transfer-history
4921
+
4922
+ https://docs.coinex.com/api/v2/assets/transfer/http/list-transfer-history
4923
+
4687
4924
  :param str code: unified currency code of the currency transferred
4688
4925
  :param int [since]: the earliest time in ms to fetch transfers for
4689
4926
  :param int [limit]: the maximum number of transfer structures to retrieve
@@ -4736,7 +4973,9 @@ class coinex(Exchange, ImplicitAPI):
4736
4973
  async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
4737
4974
  """
4738
4975
  fetch all withdrawals made from an account
4739
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history
4976
+
4977
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history
4978
+
4740
4979
  :param str [code]: unified currency code
4741
4980
  :param int [since]: the earliest time in ms to fetch withdrawals for
4742
4981
  :param int [limit]: the maximum number of withdrawal structures to retrieve
@@ -4790,7 +5029,9 @@ class coinex(Exchange, ImplicitAPI):
4790
5029
  async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
4791
5030
  """
4792
5031
  fetch all deposits made to an account
4793
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history
5032
+
5033
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history
5034
+
4794
5035
  :param str [code]: unified currency code
4795
5036
  :param int [since]: the earliest time in ms to fetch deposits for
4796
5037
  :param int [limit]: the maximum number of deposit structures to retrieve
@@ -4838,7 +5079,7 @@ class coinex(Exchange, ImplicitAPI):
4838
5079
  data = self.safe_list(response, 'data', [])
4839
5080
  return self.parse_transactions(data, currency, since, limit)
4840
5081
 
4841
- def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
5082
+ def parse_isolated_borrow_rate(self, info: dict, market: Market = None) -> IsolatedBorrowRate:
4842
5083
  #
4843
5084
  # {
4844
5085
  # "market": "BTCUSDT",
@@ -4874,7 +5115,9 @@ class coinex(Exchange, ImplicitAPI):
4874
5115
  async def fetch_isolated_borrow_rate(self, symbol: str, params={}) -> IsolatedBorrowRate:
4875
5116
  """
4876
5117
  fetch the rate of interest to borrow a currency for margin trading
4877
- :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
5118
+
5119
+ https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
5120
+
4878
5121
  :param str symbol: unified symbol of the market to fetch the borrow rate for
4879
5122
  :param dict [params]: extra parameters specific to the exchange API endpoint
4880
5123
  :param str params['code']: unified currency code
@@ -4909,10 +5152,12 @@ class coinex(Exchange, ImplicitAPI):
4909
5152
  data = self.safe_dict(response, 'data', {})
4910
5153
  return self.parse_isolated_borrow_rate(data, market)
4911
5154
 
4912
- async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
5155
+ async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
4913
5156
  """
4914
5157
  fetch the interest owed by the user for borrowing currency for margin trading
4915
- :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
5158
+
5159
+ https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
5160
+
4916
5161
  :param str [code]: unified currency code
4917
5162
  :param str [symbol]: unified market symbol when fetch interest in isolated markets
4918
5163
  :param int [since]: the earliest time in ms to fetch borrrow interest for
@@ -4957,7 +5202,7 @@ class coinex(Exchange, ImplicitAPI):
4957
5202
  interest = self.parse_borrow_interests(rows, market)
4958
5203
  return self.filter_by_currency_since_limit(interest, code, since, limit)
4959
5204
 
4960
- def parse_borrow_interest(self, info: dict, market: Market = None):
5205
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
4961
5206
  #
4962
5207
  # {
4963
5208
  # "borrow_id": 2642934,
@@ -4976,23 +5221,23 @@ class coinex(Exchange, ImplicitAPI):
4976
5221
  market = self.safe_market(marketId, market, None, 'spot')
4977
5222
  timestamp = self.safe_integer(info, 'expired_at')
4978
5223
  return {
4979
- 'account': None, # deprecated
5224
+ 'info': info,
4980
5225
  'symbol': market['symbol'],
4981
- 'marginMode': 'isolated',
4982
- 'marginType': None, # deprecated
4983
5226
  'currency': self.safe_currency_code(self.safe_string(info, 'ccy')),
4984
5227
  'interest': self.safe_number(info, 'to_repaied_amount'),
4985
5228
  'interestRate': self.safe_number(info, 'daily_interest_rate'),
4986
5229
  'amountBorrowed': self.safe_number(info, 'borrow_amount'),
5230
+ 'marginMode': 'isolated',
4987
5231
  'timestamp': timestamp, # expiry time
4988
5232
  'datetime': self.iso8601(timestamp),
4989
- 'info': info,
4990
5233
  }
4991
5234
 
4992
5235
  async def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
4993
5236
  """
4994
5237
  create a loan to borrow margin
4995
- :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-borrow
5238
+
5239
+ https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-borrow
5240
+
4996
5241
  :param str symbol: unified market symbol, required for coinex
4997
5242
  :param str code: unified currency code of the currency to borrow
4998
5243
  :param float amount: the amount to borrow
@@ -5038,7 +5283,9 @@ class coinex(Exchange, ImplicitAPI):
5038
5283
  async def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
5039
5284
  """
5040
5285
  repay borrowed margin and interest
5041
- :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-repay
5286
+
5287
+ https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-repay
5288
+
5042
5289
  :param str symbol: unified market symbol, required for coinex
5043
5290
  :param str code: unified currency code of the currency to repay
5044
5291
  :param float amount: the amount to repay
@@ -5098,7 +5345,9 @@ class coinex(Exchange, ImplicitAPI):
5098
5345
  async def fetch_deposit_withdraw_fee(self, code: str, params={}):
5099
5346
  """
5100
5347
  fetch the fee for deposits and withdrawals
5101
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-withdrawal-config
5348
+
5349
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-withdrawal-config
5350
+
5102
5351
  :param str code: unified currency code
5103
5352
  :param dict [params]: extra parameters specific to the exchange API endpoint
5104
5353
  :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -5145,6 +5394,66 @@ class coinex(Exchange, ImplicitAPI):
5145
5394
  data = self.safe_dict(response, 'data', {})
5146
5395
  return self.parse_deposit_withdraw_fee(data, currency)
5147
5396
 
5397
+ async def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
5398
+ """
5399
+ fetch the fees for deposits and withdrawals
5400
+
5401
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-all-deposit-withdrawal-config
5402
+
5403
+ @param codes
5404
+ :param dict [params]: extra parameters specific to the exchange API endpoint
5405
+ :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
5406
+ """
5407
+ await self.load_markets()
5408
+ response = await self.v2PublicGetAssetsAllDepositWithdrawConfig(params)
5409
+ #
5410
+ # {
5411
+ # "code": 0,
5412
+ # "data": [
5413
+ # {
5414
+ # "asset": {
5415
+ # "ccy": "CET",
5416
+ # "deposit_enabled": True,
5417
+ # "withdraw_enabled": True,
5418
+ # "inter_transfer_enabled": True,
5419
+ # "is_st": False
5420
+ # },
5421
+ # "chains": [
5422
+ # {
5423
+ # "chain": "CSC",
5424
+ # "min_deposit_amount": "0.8",
5425
+ # "min_withdraw_amount": "8",
5426
+ # "deposit_enabled": True,
5427
+ # "withdraw_enabled": True,
5428
+ # "deposit_delay_minutes": 0,
5429
+ # "safe_confirmations": 10,
5430
+ # "irreversible_confirmations": 20,
5431
+ # "deflation_rate": "0",
5432
+ # "withdrawal_fee": "0.026",
5433
+ # "withdrawal_precision": 8,
5434
+ # "memo": "",
5435
+ # "is_memo_required_for_deposit": False,
5436
+ # "explorer_asset_url": ""
5437
+ # },
5438
+ # ]
5439
+ # }
5440
+ # ],
5441
+ # "message": "OK"
5442
+ # }
5443
+ #
5444
+ data = self.safe_list(response, 'data', [])
5445
+ result: dict = {}
5446
+ for i in range(0, len(data)):
5447
+ item = data[i]
5448
+ asset = self.safe_dict(item, 'asset', {})
5449
+ currencyId = self.safe_string(asset, 'ccy')
5450
+ if currencyId is None:
5451
+ continue
5452
+ code = self.safe_currency_code(currencyId)
5453
+ if codes is None or self.in_array(code, codes):
5454
+ result[code] = self.parse_deposit_withdraw_fee(item)
5455
+ return result
5456
+
5148
5457
  def parse_deposit_withdraw_fee(self, fee, currency: Currency = None):
5149
5458
  #
5150
5459
  # {
@@ -5213,7 +5522,9 @@ class coinex(Exchange, ImplicitAPI):
5213
5522
  async def fetch_leverage(self, symbol: str, params={}) -> Leverage:
5214
5523
  """
5215
5524
  fetch the set leverage for a market
5216
- :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
5525
+
5526
+ https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
5527
+
5217
5528
  :param str symbol: unified market symbol
5218
5529
  :param dict [params]: extra parameters specific to the exchange API endpoint
5219
5530
  :param str params['code']: unified currency code
@@ -5269,10 +5580,12 @@ class coinex(Exchange, ImplicitAPI):
5269
5580
  'shortLeverage': leverageValue,
5270
5581
  }
5271
5582
 
5272
- async def fetch_position_history(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> Position:
5583
+ async def fetch_position_history(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Position]:
5273
5584
  """
5274
5585
  fetches historical positions
5275
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-finished-position
5586
+
5587
+ https://docs.coinex.com/api/v2/futures/position/http/list-finished-position
5588
+
5276
5589
  :param str symbol: unified contract symbol
5277
5590
  :param int [since]: the earliest time in ms to fetch positions for
5278
5591
  :param int [limit]: the maximum amount of records to fetch, default is 10
@@ -5339,9 +5652,68 @@ class coinex(Exchange, ImplicitAPI):
5339
5652
  positions = self.parse_positions(records)
5340
5653
  return self.filter_by_symbol_since_limit(positions, symbol, since, limit)
5341
5654
 
5655
+ async def close_position(self, symbol: str, side: OrderSide = None, params={}) -> Order:
5656
+ """
5657
+ closes an open position for a market
5658
+
5659
+ https://docs.coinex.com/api/v2/futures/position/http/close-position
5660
+
5661
+ :param str symbol: unified CCXT market symbol
5662
+ :param str [side]: buy or sell, not used by coinex
5663
+ :param dict [params]: extra parameters specific to the exchange API endpoint
5664
+ :param str params['type']: required by coinex, one of: limit, market, maker_only, ioc or fok, default is *market*
5665
+ :param str [params.price]: the price to fulfill the order, ignored in market orders
5666
+ :param str [params.amount]: the amount to trade in units of the base currency
5667
+ :param str [params.clientOrderId]: the client id of the order
5668
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
5669
+ """
5670
+ await self.load_markets()
5671
+ market = self.market(symbol)
5672
+ type = self.safe_string(params, 'type', 'market')
5673
+ request: dict = {
5674
+ 'market': market['id'],
5675
+ 'market_type': 'FUTURES',
5676
+ 'type': type,
5677
+ }
5678
+ clientOrderId = self.safe_string_2(params, 'client_id', 'clientOrderId')
5679
+ if clientOrderId is not None:
5680
+ request['client_id'] = clientOrderId
5681
+ params = self.omit(params, 'clientOrderId')
5682
+ response = await self.v2PrivatePostFuturesClosePosition(self.extend(request, params))
5683
+ #
5684
+ # {
5685
+ # "code": 0,
5686
+ # "data": {
5687
+ # "amount": "0.0001",
5688
+ # "client_id": "",
5689
+ # "created_at": 1729666043969,
5690
+ # "fee": "0.00335858",
5691
+ # "fee_ccy": "USDT",
5692
+ # "filled_amount": "0.0001",
5693
+ # "filled_value": "6.717179",
5694
+ # "last_filled_amount": "0.0001",
5695
+ # "last_filled_price": "67171.79",
5696
+ # "maker_fee_rate": "0",
5697
+ # "market": "BTCUSDT",
5698
+ # "market_type": "FUTURES",
5699
+ # "order_id": 155477479761,
5700
+ # "price": "0",
5701
+ # "realized_pnl": "-0.001823",
5702
+ # "side": "sell",
5703
+ # "taker_fee_rate": "0.0005",
5704
+ # "type": "market",
5705
+ # "unfilled_amount": "0",
5706
+ # "updated_at": 1729666043969
5707
+ # },
5708
+ # "message": "OK"
5709
+ # }
5710
+ #
5711
+ data = self.safe_dict(response, 'data', {})
5712
+ return self.parse_order(data, market)
5713
+
5342
5714
  def handle_margin_mode_and_params(self, methodName, params={}, defaultValue=None):
5343
5715
  """
5344
- * @ignore
5716
+ @ignore
5345
5717
  marginMode specified by params["marginMode"], self.options["marginMode"], self.options["defaultMarginMode"], params["margin"] = True or self.options["defaultType"] = 'margin'
5346
5718
  :param dict params: extra parameters specific to the exchange api endpoint
5347
5719
  :returns Array: the marginMode in lowercase
@@ -5467,7 +5839,9 @@ class coinex(Exchange, ImplicitAPI):
5467
5839
  async def fetch_margin_adjustment_history(self, symbol: Str = None, type: Str = None, since: Num = None, limit: Num = None, params={}) -> List[MarginModification]:
5468
5840
  """
5469
5841
  fetches the history of margin added or reduced from contract isolated positions
5470
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-position-margin-history
5842
+
5843
+ https://docs.coinex.com/api/v2/futures/position/http/list-position-margin-history
5844
+
5471
5845
  :param str symbol: unified market symbol
5472
5846
  :param str [type]: not used by coinex fetchMarginAdjustmentHistory
5473
5847
  :param int [since]: timestamp in ms of the earliest change to fetch