ccxt-ir 4.3.46.0.2__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 (528) hide show
  1. ccxt/__init__.py +39 -35
  2. ccxt/abantether.py +9 -9
  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 +10 -10
  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.2.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.2.dist-info → ccxt_ir-4.5.0.dist-info}/WHEEL +1 -1
  437. ccxt/abstract/ace.py +0 -15
  438. ccxt/abstract/bitbay.py +0 -53
  439. ccxt/abstract/bitcoincom.py +0 -115
  440. ccxt/abstract/bitfinex2.py +0 -139
  441. ccxt/abstract/bitpanda.py +0 -35
  442. ccxt/abstract/bl3p.py +0 -19
  443. ccxt/abstract/coinlist.py +0 -54
  444. ccxt/abstract/currencycom.py +0 -68
  445. ccxt/abstract/hitbtc3.py +0 -115
  446. ccxt/abstract/idex.py +0 -26
  447. ccxt/abstract/kuna.py +0 -182
  448. ccxt/abstract/lykke.py +0 -29
  449. ccxt/abstract/poloniexfutures.py +0 -48
  450. ccxt/abstract/wazirx.py +0 -30
  451. ccxt/ace.py +0 -1012
  452. ccxt/async_support/ace.py +0 -1012
  453. ccxt/async_support/base/ws/aiohttp_client.py +0 -125
  454. ccxt/async_support/base/ws/fast_client.py +0 -96
  455. ccxt/async_support/bitbay.py +0 -17
  456. ccxt/async_support/bitcoincom.py +0 -17
  457. ccxt/async_support/bitfinex2.py +0 -3552
  458. ccxt/async_support/bitpanda.py +0 -16
  459. ccxt/async_support/bl3p.py +0 -485
  460. ccxt/async_support/coinlist.py +0 -2243
  461. ccxt/async_support/currencycom.py +0 -1950
  462. ccxt/async_support/hitbtc3.py +0 -16
  463. ccxt/async_support/idex.py +0 -1766
  464. ccxt/async_support/kuna.py +0 -1841
  465. ccxt/async_support/lykke.py +0 -1270
  466. ccxt/async_support/poloniexfutures.py +0 -1717
  467. ccxt/async_support/wazirx.py +0 -1224
  468. ccxt/bitbay.py +0 -17
  469. ccxt/bitcoincom.py +0 -17
  470. ccxt/bitfinex2.py +0 -3552
  471. ccxt/bitpanda.py +0 -16
  472. ccxt/bl3p.py +0 -485
  473. ccxt/coinlist.py +0 -2243
  474. ccxt/currencycom.py +0 -1950
  475. ccxt/hitbtc3.py +0 -16
  476. ccxt/idex.py +0 -1766
  477. ccxt/kuna.py +0 -1841
  478. ccxt/lykke.py +0 -1270
  479. ccxt/poloniexfutures.py +0 -1717
  480. ccxt/pro/bitcoincom.py +0 -34
  481. ccxt/pro/bitfinex2.py +0 -1083
  482. ccxt/pro/bitpanda.py +0 -15
  483. ccxt/pro/currencycom.py +0 -536
  484. ccxt/pro/idex.py +0 -672
  485. ccxt/pro/poloniexfutures.py +0 -990
  486. ccxt/pro/wazirx.py +0 -749
  487. ccxt/test/base/__init__.py +0 -29
  488. ccxt/test/base/test_account.py +0 -26
  489. ccxt/test/base/test_balance.py +0 -56
  490. ccxt/test/base/test_borrow_interest.py +0 -35
  491. ccxt/test/base/test_borrow_rate.py +0 -32
  492. ccxt/test/base/test_calculate_fee.py +0 -51
  493. ccxt/test/base/test_crypto.py +0 -127
  494. ccxt/test/base/test_currency.py +0 -76
  495. ccxt/test/base/test_datetime.py +0 -109
  496. ccxt/test/base/test_decimal_to_precision.py +0 -392
  497. ccxt/test/base/test_deep_extend.py +0 -68
  498. ccxt/test/base/test_deposit_withdrawal.py +0 -50
  499. ccxt/test/base/test_exchange_datetime_functions.py +0 -76
  500. ccxt/test/base/test_funding_rate_history.py +0 -29
  501. ccxt/test/base/test_last_price.py +0 -31
  502. ccxt/test/base/test_ledger_entry.py +0 -45
  503. ccxt/test/base/test_ledger_item.py +0 -48
  504. ccxt/test/base/test_leverage_tier.py +0 -33
  505. ccxt/test/base/test_liquidation.py +0 -50
  506. ccxt/test/base/test_margin_mode.py +0 -24
  507. ccxt/test/base/test_margin_modification.py +0 -35
  508. ccxt/test/base/test_market.py +0 -193
  509. ccxt/test/base/test_number.py +0 -411
  510. ccxt/test/base/test_ohlcv.py +0 -33
  511. ccxt/test/base/test_open_interest.py +0 -32
  512. ccxt/test/base/test_order.py +0 -64
  513. ccxt/test/base/test_order_book.py +0 -69
  514. ccxt/test/base/test_position.py +0 -60
  515. ccxt/test/base/test_shared_methods.py +0 -353
  516. ccxt/test/base/test_status.py +0 -24
  517. ccxt/test/base/test_throttle.py +0 -126
  518. ccxt/test/base/test_ticker.py +0 -92
  519. ccxt/test/base/test_trade.py +0 -47
  520. ccxt/test/base/test_trading_fee.py +0 -26
  521. ccxt/test/base/test_transaction.py +0 -39
  522. ccxt/test/test_async.py +0 -1649
  523. ccxt/test/test_sync.py +0 -1648
  524. ccxt/wazirx.py +0 -1224
  525. ccxt_ir-4.3.46.0.2.dist-info/RECORD +0 -772
  526. /ccxt/abstract/{huobijp.py → bittrade.py} +0 -0
  527. {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info/licenses}/LICENSE.txt +0 -0
  528. {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info}/top_level.txt +0 -0
ccxt/coinex.py CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.coinex import ImplicitAPI
8
- from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, TransferEntries
8
+ 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
9
9
  from typing import List
10
10
  from ccxt.base.errors import ExchangeError
11
11
  from ccxt.base.errors import AuthenticationError
@@ -18,6 +18,7 @@ from ccxt.base.errors import InsufficientFunds
18
18
  from ccxt.base.errors import InvalidOrder
19
19
  from ccxt.base.errors import OrderNotFound
20
20
  from ccxt.base.errors import NotSupported
21
+ from ccxt.base.errors import OperationFailed
21
22
  from ccxt.base.errors import RateLimitExceeded
22
23
  from ccxt.base.errors import ExchangeNotAvailable
23
24
  from ccxt.base.errors import RequestTimeout
@@ -27,7 +28,7 @@ from ccxt.base.precise import Precise
27
28
 
28
29
  class coinex(Exchange, ImplicitAPI):
29
30
 
30
- def describe(self):
31
+ def describe(self) -> Any:
31
32
  return self.deep_extend(super(coinex, self).describe(), {
32
33
  'id': 'coinex',
33
34
  'name': 'CoinEx',
@@ -58,6 +59,8 @@ class coinex(Exchange, ImplicitAPI):
58
59
  'cancelAllOrders': True,
59
60
  'cancelOrder': True,
60
61
  'cancelOrders': True,
62
+ 'closeAllPositions': False,
63
+ 'closePosition': True,
61
64
  'createDepositAddress': True,
62
65
  'createMarketBuyOrderWithCost': True,
63
66
  'createMarketOrderWithCost': False,
@@ -66,6 +69,7 @@ class coinex(Exchange, ImplicitAPI):
66
69
  'createOrders': True,
67
70
  'createReduceOnlyOrder': True,
68
71
  'createStopLossOrder': True,
72
+ 'createStopOrder': True,
69
73
  'createTakeProfitOrder': True,
70
74
  'createTriggerOrder': True,
71
75
  'editOrder': True,
@@ -78,12 +82,14 @@ class coinex(Exchange, ImplicitAPI):
78
82
  'fetchCrossBorrowRates': False,
79
83
  'fetchCurrencies': True,
80
84
  'fetchDepositAddress': True,
81
- 'fetchDepositAddressByNetwork': False,
82
85
  'fetchDepositAddresses': False,
86
+ 'fetchDepositAddressesByNetwork': False,
83
87
  'fetchDeposits': True,
84
88
  'fetchDepositWithdrawFee': True,
85
- 'fetchDepositWithdrawFees': False,
89
+ 'fetchDepositWithdrawFees': True,
86
90
  'fetchFundingHistory': True,
91
+ 'fetchFundingInterval': True,
92
+ 'fetchFundingIntervals': False,
87
93
  'fetchFundingRate': True,
88
94
  'fetchFundingRateHistory': True,
89
95
  'fetchFundingRates': True,
@@ -469,9 +475,133 @@ class coinex(Exchange, ImplicitAPI):
469
475
  'FUTURES': 'swap',
470
476
  },
471
477
  'networks': {
478
+ 'BTC': 'BTC',
472
479
  'BEP20': 'BSC',
473
- 'TRX': 'TRC20',
474
- 'ETH': 'ERC20',
480
+ 'TRC20': 'TRC20',
481
+ 'ERC20': 'ERC20',
482
+ 'BRC20': 'BRC20',
483
+ 'SOL': 'SOL',
484
+ 'TON': 'TON',
485
+ 'BSV': 'BSV',
486
+ 'AVAXC': 'AVA_C',
487
+ 'AVAXX': 'AVA',
488
+ 'SUI': 'SUI',
489
+ 'ACA': 'ACA',
490
+ 'CHZ': 'CHILIZ',
491
+ 'ADA': 'ADA',
492
+ 'ARB': 'ARBITRUM',
493
+ 'ARBNOVA': 'ARBITRUM_NOVA',
494
+ 'OP': 'OPTIMISM',
495
+ 'APT': 'APTOS',
496
+ 'ATOM': 'ATOM',
497
+ 'FTM': 'FTM',
498
+ 'BCH': 'BCH',
499
+ 'ASTR': 'ASTR',
500
+ 'LTC': 'LTC',
501
+ 'MATIC': 'MATIC',
502
+ 'CRONOS': 'CRONOS',
503
+ 'DASH': 'DASH',
504
+ 'DOT': 'DOT',
505
+ 'ETC': 'ETC',
506
+ 'ETHW': 'ETHPOW',
507
+ 'FIL': 'FIL',
508
+ 'ZIL': 'ZIL',
509
+ 'DOGE': 'DOGE',
510
+ 'TIA': 'CELESTIA',
511
+ 'SEI': 'SEI',
512
+ 'XRP': 'XRP',
513
+ 'XMR': 'XMR',
514
+ # 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
515
+ },
516
+ },
517
+ 'features': {
518
+ 'spot': {
519
+ 'sandbox': False,
520
+ 'createOrder': {
521
+ 'marginMode': True,
522
+ 'triggerPrice': True,
523
+ 'triggerPriceType': None,
524
+ 'triggerDirection': False,
525
+ 'stopLossPrice': False, # todo
526
+ 'takeProfitPrice': False, # todo
527
+ 'attachedStopLossTakeProfit': None,
528
+ 'timeInForce': {
529
+ 'IOC': True,
530
+ 'FOK': True,
531
+ 'PO': True,
532
+ 'GTD': False,
533
+ },
534
+ 'hedged': False,
535
+ 'trailing': False,
536
+ 'leverage': False,
537
+ 'marketBuyByCost': True,
538
+ 'marketBuyRequiresPrice': True,
539
+ 'selfTradePrevention': True, # todo: implement
540
+ 'iceberg': True, # todo implement
541
+ },
542
+ 'createOrders': {
543
+ 'max': 5,
544
+ },
545
+ 'fetchMyTrades': {
546
+ 'marginMode': True,
547
+ 'limit': 1000,
548
+ 'daysBack': None,
549
+ 'untilDays': 100000,
550
+ 'symbolRequired': True,
551
+ },
552
+ 'fetchOrder': {
553
+ 'marginMode': False,
554
+ 'trigger': False,
555
+ 'trailing': False,
556
+ 'symbolRequired': True,
557
+ },
558
+ 'fetchOpenOrders': {
559
+ 'marginMode': True,
560
+ 'limit': 1000,
561
+ 'trigger': True,
562
+ 'trailing': False,
563
+ 'symbolRequired': False,
564
+ },
565
+ 'fetchOrders': None,
566
+ 'fetchClosedOrders': {
567
+ 'marginMode': True,
568
+ 'limit': 1000,
569
+ 'daysBack': None,
570
+ 'daysBackCanceled': None,
571
+ 'untilDays': None,
572
+ 'trigger': True,
573
+ 'trailing': False,
574
+ 'symbolRequired': False,
575
+ },
576
+ 'fetchOHLCV': {
577
+ 'limit': 1000,
578
+ },
579
+ },
580
+ 'forDerivatives': {
581
+ 'extends': 'spot',
582
+ 'createOrder': {
583
+ 'marginMode': True,
584
+ 'stopLossPrice': True,
585
+ 'takeProfitPrice': True,
586
+ },
587
+ 'fetchOpenOrders': {
588
+ 'marginMode': False,
589
+ },
590
+ 'fetchClosedOrders': {
591
+ 'marginMode': False,
592
+ },
593
+ },
594
+ 'swap': {
595
+ 'linear': {
596
+ 'extends': 'forDerivatives',
597
+ },
598
+ 'inverse': {
599
+ 'extends': 'forDerivatives',
600
+ },
601
+ },
602
+ 'future': {
603
+ 'linear': None,
604
+ 'inverse': None,
475
605
  },
476
606
  },
477
607
  'commonCurrencies': {
@@ -497,6 +627,7 @@ class coinex(Exchange, ImplicitAPI):
497
627
  '3008': RequestTimeout, # Service busy, please try again later.
498
628
  '3109': InsufficientFunds, # {"code":3109,"data":{},"message":"balance not enough"}
499
629
  '3127': InvalidOrder, # The order quantity is below the minimum requirement. Please adjust the order quantity.
630
+ '3600': OrderNotFound, # {"code":3600,"data":{},"message":"Order not found"}
500
631
  '3606': InvalidOrder, # The price difference between the order price and the latest price is too large. Please adjust the order amount accordingly.
501
632
  '3610': ExchangeError, # Order cancellation prohibited during the Call Auction period.
502
633
  '3612': InvalidOrder, # The est. ask price is lower than the current bottom ask price. Please reduce the amount.
@@ -540,6 +671,7 @@ class coinex(Exchange, ImplicitAPI):
540
671
  'broad': {
541
672
  'ip not allow visit': PermissionDenied,
542
673
  'service too busy': ExchangeNotAvailable,
674
+ 'Service is not available during funding fee settlement': OperationFailed,
543
675
  },
544
676
  },
545
677
  })
@@ -547,7 +679,9 @@ class coinex(Exchange, ImplicitAPI):
547
679
  def fetch_currencies(self, params={}) -> Currencies:
548
680
  """
549
681
  fetches all available currencies on an exchange
550
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-all-deposit-withdrawal-config
682
+
683
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-all-deposit-withdrawal-config
684
+
551
685
  :param dict [params]: extra parameters specific to the exchange API endpoint
552
686
  :returns dict: an associative dictionary of currencies
553
687
  """
@@ -601,35 +735,13 @@ class coinex(Exchange, ImplicitAPI):
601
735
  canWithdraw = self.safe_bool(asset, 'withdraw_enabled')
602
736
  firstChain = self.safe_dict(chains, 0, {})
603
737
  firstPrecisionString = self.parse_precision(self.safe_string(firstChain, 'withdrawal_precision'))
604
- result[code] = {
605
- 'id': currencyId,
606
- 'code': code,
607
- 'name': None,
608
- 'active': canDeposit and canWithdraw,
609
- 'deposit': canDeposit,
610
- 'withdraw': canWithdraw,
611
- 'fee': None,
612
- 'precision': self.parse_number(firstPrecisionString),
613
- 'limits': {
614
- 'amount': {
615
- 'min': None,
616
- 'max': None,
617
- },
618
- 'deposit': {
619
- 'min': None,
620
- 'max': None,
621
- },
622
- 'withdraw': {
623
- 'min': None,
624
- 'max': None,
625
- },
626
- },
627
- 'networks': {},
628
- 'info': coin,
629
- }
738
+ networks: dict = {}
630
739
  for j in range(0, len(chains)):
631
740
  chain = chains[j]
632
741
  networkId = self.safe_string(chain, 'chain')
742
+ networkCode = self.network_id_to_code(networkId, code)
743
+ if networkId is None:
744
+ continue
633
745
  precisionString = self.parse_precision(self.safe_string(chain, 'withdrawal_precision'))
634
746
  feeString = self.safe_string(chain, 'withdrawal_fee')
635
747
  minNetworkDepositString = self.safe_string(chain, 'min_deposit_amount')
@@ -638,7 +750,7 @@ class coinex(Exchange, ImplicitAPI):
638
750
  canWithdrawChain = self.safe_bool(chain, 'withdraw_enabled')
639
751
  network: dict = {
640
752
  'id': networkId,
641
- 'network': networkId,
753
+ 'network': networkCode,
642
754
  'name': None,
643
755
  'active': canDepositChain and canWithdrawChain,
644
756
  'deposit': canDepositChain,
@@ -661,16 +773,43 @@ class coinex(Exchange, ImplicitAPI):
661
773
  },
662
774
  'info': chain,
663
775
  }
664
- networks = self.safe_dict(result[code], 'networks', {})
665
- networks[networkId] = network
666
- result[code]['networks'] = networks
776
+ networks[networkCode] = network
777
+ result[code] = self.safe_currency_structure({
778
+ 'id': currencyId,
779
+ 'code': code,
780
+ 'name': None,
781
+ 'active': canDeposit and canWithdraw,
782
+ 'deposit': canDeposit,
783
+ 'withdraw': canWithdraw,
784
+ 'fee': None,
785
+ 'precision': self.parse_number(firstPrecisionString),
786
+ 'limits': {
787
+ 'amount': {
788
+ 'min': None,
789
+ 'max': None,
790
+ },
791
+ 'deposit': {
792
+ 'min': None,
793
+ 'max': None,
794
+ },
795
+ 'withdraw': {
796
+ 'min': None,
797
+ 'max': None,
798
+ },
799
+ },
800
+ 'networks': networks,
801
+ 'type': 'crypto',
802
+ 'info': coin,
803
+ })
667
804
  return result
668
805
 
669
806
  def fetch_markets(self, params={}) -> List[Market]:
670
807
  """
671
808
  retrieves data on all markets for coinex
672
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market
673
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market
809
+
810
+ https://docs.coinex.com/api/v2/spot/market/http/list-market
811
+ https://docs.coinex.com/api/v2/futures/market/http/list-market
812
+
674
813
  :param dict [params]: extra parameters specific to the exchange API endpoint
675
814
  :returns dict[]: an array of objects representing market data
676
815
  """
@@ -683,24 +822,26 @@ class coinex(Exchange, ImplicitAPI):
683
822
  swapMarkets = promises[1]
684
823
  return self.array_concat(spotMarkets, swapMarkets)
685
824
 
686
- def fetch_spot_markets(self, params):
825
+ def fetch_spot_markets(self, params) -> List[Market]:
687
826
  response = self.v2PublicGetSpotMarket(params)
688
827
  #
689
828
  # {
690
829
  # "code": 0,
691
830
  # "data": [
692
831
  # {
693
- # "base_ccy": "SORA",
832
+ # "market": "BTCUSDT",
833
+ # "taker_fee_rate": "0.002",
834
+ # "maker_fee_rate": "0.002",
835
+ # "min_amount": "0.0005",
836
+ # "base_ccy": "BTC",
837
+ # "quote_ccy": "USDT",
694
838
  # "base_ccy_precision": 8,
839
+ # "quote_ccy_precision": 2,
695
840
  # "is_amm_available": True,
696
- # "is_margin_available": False,
697
- # "maker_fee_rate": "0.003",
698
- # "market": "SORAUSDT",
699
- # "min_amount": "500",
700
- # "quote_ccy": "USDT",
701
- # "quote_ccy_precision": 6,
702
- # "taker_fee_rate": "0.003"
703
- # },
841
+ # "is_margin_available": True,
842
+ # "is_pre_trading_available": True,
843
+ # "is_api_trading_available": True
844
+ # }
704
845
  # ],
705
846
  # "message": "OK"
706
847
  # }
@@ -726,11 +867,11 @@ class coinex(Exchange, ImplicitAPI):
726
867
  'settleId': None,
727
868
  'type': 'spot',
728
869
  'spot': True,
729
- 'margin': None,
870
+ 'margin': self.safe_bool(market, 'is_margin_available'),
730
871
  'swap': False,
731
872
  'future': False,
732
873
  'option': False,
733
- 'active': None,
874
+ 'active': self.safe_bool(market, 'is_api_trading_available'),
734
875
  'contract': False,
735
876
  'linear': None,
736
877
  'inverse': None,
@@ -921,14 +1062,18 @@ class coinex(Exchange, ImplicitAPI):
921
1062
  'average': None,
922
1063
  'baseVolume': self.safe_string(ticker, 'volume'),
923
1064
  'quoteVolume': None,
1065
+ 'markPrice': self.safe_string(ticker, 'mark_price'),
1066
+ 'indexPrice': self.safe_string(ticker, 'index_price'),
924
1067
  'info': ticker,
925
1068
  }, market)
926
1069
 
927
1070
  def fetch_ticker(self, symbol: str, params={}) -> Ticker:
928
1071
  """
929
1072
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
930
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
931
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
1073
+
1074
+ https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
1075
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
1076
+
932
1077
  :param str symbol: unified symbol of the market to fetch the ticker for
933
1078
  :param dict [params]: extra parameters specific to the exchange API endpoint
934
1079
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -997,8 +1142,10 @@ class coinex(Exchange, ImplicitAPI):
997
1142
  def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
998
1143
  """
999
1144
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1000
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
1001
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
1145
+
1146
+ https://docs.coinex.com/api/v2/spot/market/http/list-market-ticker
1147
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-ticker
1148
+
1002
1149
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1003
1150
  :param dict [params]: extra parameters specific to the exchange API endpoint
1004
1151
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1065,10 +1212,12 @@ class coinex(Exchange, ImplicitAPI):
1065
1212
  data = self.safe_list(response, 'data', [])
1066
1213
  return self.parse_tickers(data, symbols)
1067
1214
 
1068
- def fetch_time(self, params={}):
1215
+ def fetch_time(self, params={}) -> Int:
1069
1216
  """
1070
1217
  fetches the current integer timestamp in milliseconds from the exchange server
1071
- :see: https://docs.coinex.com/api/v2/common/http/time
1218
+
1219
+ https://docs.coinex.com/api/v2/common/http/time
1220
+
1072
1221
  :param dict [params]: extra parameters specific to the exchange API endpoint
1073
1222
  :returns int: the current integer timestamp in milliseconds from the exchange server
1074
1223
  """
@@ -1088,8 +1237,10 @@ class coinex(Exchange, ImplicitAPI):
1088
1237
  def fetch_order_book(self, symbol: str, limit: Int = 20, params={}):
1089
1238
  """
1090
1239
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1091
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-depth
1092
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-depth
1240
+
1241
+ https://docs.coinex.com/api/v2/spot/market/http/list-market-depth
1242
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-depth
1243
+
1093
1244
  :param str symbol: unified symbol of the market to fetch the order book for
1094
1245
  :param int [limit]: the maximum amount of order book entries to return
1095
1246
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1198,7 +1349,10 @@ class coinex(Exchange, ImplicitAPI):
1198
1349
  # "side": "buy",
1199
1350
  # "order_id": 136915589622,
1200
1351
  # "price": "64376",
1201
- # "amount": "0.0001"
1352
+ # "amount": "0.0001",
1353
+ # "role": "taker",
1354
+ # "fee": "0.0299",
1355
+ # "fee_ccy": "USDT"
1202
1356
  # }
1203
1357
  #
1204
1358
  timestamp = self.safe_integer(trade, 'created_at')
@@ -1207,6 +1361,15 @@ class coinex(Exchange, ImplicitAPI):
1207
1361
  defaultType = market['type']
1208
1362
  marketId = self.safe_string(trade, 'market')
1209
1363
  market = self.safe_market(marketId, market, None, defaultType)
1364
+ feeCostString = self.safe_string(trade, 'fee')
1365
+ fee = None
1366
+ if feeCostString is not None:
1367
+ feeCurrencyId = self.safe_string(trade, 'fee_ccy')
1368
+ feeCurrencyCode = self.safe_currency_code(feeCurrencyId)
1369
+ fee = {
1370
+ 'cost': feeCostString,
1371
+ 'currency': feeCurrencyCode,
1372
+ }
1210
1373
  return self.safe_trade({
1211
1374
  'info': trade,
1212
1375
  'timestamp': timestamp,
@@ -1216,18 +1379,20 @@ class coinex(Exchange, ImplicitAPI):
1216
1379
  'order': self.safe_string(trade, 'order_id'),
1217
1380
  'type': None,
1218
1381
  'side': self.safe_string(trade, 'side'),
1219
- 'takerOrMaker': None,
1382
+ 'takerOrMaker': self.safe_string(trade, 'role'),
1220
1383
  'price': self.safe_string(trade, 'price'),
1221
1384
  'amount': self.safe_string(trade, 'amount'),
1222
1385
  'cost': self.safe_string(trade, 'deal_money'),
1223
- 'fee': None,
1386
+ 'fee': fee,
1224
1387
  }, market)
1225
1388
 
1226
1389
  def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1227
1390
  """
1228
1391
  get the list of the most recent trades for a particular symbol
1229
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-deals
1230
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-deals
1392
+
1393
+ https://docs.coinex.com/api/v2/spot/market/http/list-market-deals
1394
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-deals
1395
+
1231
1396
  :param str symbol: unified symbol of the market to fetch trades for
1232
1397
  :param int [since]: timestamp in ms of the earliest trade to fetch
1233
1398
  :param int [limit]: the maximum amount of trades to fetch
@@ -1269,8 +1434,10 @@ class coinex(Exchange, ImplicitAPI):
1269
1434
  def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
1270
1435
  """
1271
1436
  fetch the trading fees for a market
1272
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market
1273
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market
1437
+
1438
+ https://docs.coinex.com/api/v2/spot/market/http/list-market
1439
+ https://docs.coinex.com/api/v2/futures/market/http/list-market
1440
+
1274
1441
  :param str symbol: unified market symbol
1275
1442
  :param dict [params]: extra parameters specific to the exchange API endpoint
1276
1443
  :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -1333,8 +1500,10 @@ class coinex(Exchange, ImplicitAPI):
1333
1500
  def fetch_trading_fees(self, params={}) -> TradingFees:
1334
1501
  """
1335
1502
  fetch the trading fees for multiple markets
1336
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market
1337
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market
1503
+
1504
+ https://docs.coinex.com/api/v2/spot/market/http/list-market
1505
+ https://docs.coinex.com/api/v2/futures/market/http/list-market
1506
+
1338
1507
  :param dict [params]: extra parameters specific to the exchange API endpoint
1339
1508
  :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
1340
1509
  """
@@ -1434,8 +1603,10 @@ class coinex(Exchange, ImplicitAPI):
1434
1603
  def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1435
1604
  """
1436
1605
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1437
- :see: https://docs.coinex.com/api/v2/spot/market/http/list-market-kline
1438
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-kline
1606
+
1607
+ https://docs.coinex.com/api/v2/spot/market/http/list-market-kline
1608
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-kline
1609
+
1439
1610
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1440
1611
  :param str timeframe: the length of time each candle represents
1441
1612
  :param int [since]: timestamp in ms of the earliest candle to fetch
@@ -1622,10 +1793,12 @@ class coinex(Exchange, ImplicitAPI):
1622
1793
  def fetch_balance(self, params={}) -> Balances:
1623
1794
  """
1624
1795
  query for balance and get the amount of funds available for trading or funds locked in orders
1625
- :see: https://docs.coinex.com/api/v2/assets/balance/http/get-spot-balance # spot
1626
- :see: https://docs.coinex.com/api/v2/assets/balance/http/get-futures-balance # swap
1627
- :see: https://docs.coinex.com/api/v2/assets/balance/http/get-marigin-balance # margin
1628
- :see: https://docs.coinex.com/api/v2/assets/balance/http/get-financial-balance # financial
1796
+
1797
+ https://docs.coinex.com/api/v2/assets/balance/http/get-spot-balance # spot
1798
+ https://docs.coinex.com/api/v2/assets/balance/http/get-futures-balance # swap
1799
+ https://docs.coinex.com/api/v2/assets/balance/http/get-marigin-balance # margin
1800
+ https://docs.coinex.com/api/v2/assets/balance/http/get-financial-balance # financial
1801
+
1629
1802
  :param dict [params]: extra parameters specific to the exchange API endpoint
1630
1803
  :param str [params.type]: 'margin', 'swap', 'financial', or 'spot'
1631
1804
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
@@ -1713,7 +1886,7 @@ class coinex(Exchange, ImplicitAPI):
1713
1886
  # "stop_id": 117180138153
1714
1887
  # }
1715
1888
  #
1716
- # Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders, fetchClosedOrders
1889
+ # Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders, fetchClosedOrders, closePosition
1717
1890
  #
1718
1891
  # {
1719
1892
  # "amount": "0.0001",
@@ -1901,7 +2074,6 @@ class coinex(Exchange, ImplicitAPI):
1901
2074
  'reduceOnly': None,
1902
2075
  'side': side,
1903
2076
  'price': self.safe_string(order, 'price'),
1904
- 'stopPrice': self.safe_string(order, 'trigger_price'),
1905
2077
  'triggerPrice': self.safe_string(order, 'trigger_price'),
1906
2078
  'takeProfitPrice': self.safe_number(order, 'take_profit_price'),
1907
2079
  'stopLossPrice': self.safe_number(order, 'stop_loss_price'),
@@ -1921,8 +2093,10 @@ class coinex(Exchange, ImplicitAPI):
1921
2093
  def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1922
2094
  """
1923
2095
  create a market buy order by providing the symbol and cost
1924
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
1925
- :see: https://docs.coinex.com/api/v2/spot/order/http/put-order
2096
+
2097
+ https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
2098
+ https://docs.coinex.com/api/v2/spot/order/http/put-order
2099
+
1926
2100
  :param str symbol: unified symbol of the market to create an order in
1927
2101
  :param float cost: how much you want to trade in units of the quote currency
1928
2102
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -1939,7 +2113,7 @@ class coinex(Exchange, ImplicitAPI):
1939
2113
  market = self.market(symbol)
1940
2114
  swap = market['swap']
1941
2115
  clientOrderId = self.safe_string_2(params, 'client_id', 'clientOrderId')
1942
- stopPrice = self.safe_string_2(params, 'stopPrice', 'triggerPrice')
2116
+ triggerPrice = self.safe_string_2(params, 'stopPrice', 'triggerPrice')
1943
2117
  stopLossPrice = self.safe_string(params, 'stopLossPrice')
1944
2118
  takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
1945
2119
  option = self.safe_string(params, 'option')
@@ -1984,8 +2158,8 @@ class coinex(Exchange, ImplicitAPI):
1984
2158
  request['take_profit_type'] = self.safe_string(params, 'stop_type', 'latest_price')
1985
2159
  else:
1986
2160
  request['amount'] = self.amount_to_precision(symbol, amount)
1987
- if stopPrice is not None:
1988
- request['trigger_price'] = self.price_to_precision(symbol, stopPrice)
2161
+ if triggerPrice is not None:
2162
+ request['trigger_price'] = self.price_to_precision(symbol, triggerPrice)
1989
2163
  request['trigger_price_type'] = self.safe_string(params, 'stop_type', 'latest_price')
1990
2164
  else:
1991
2165
  marginMode = None
@@ -2012,26 +2186,28 @@ class coinex(Exchange, ImplicitAPI):
2012
2186
  request['amount'] = self.cost_to_precision(symbol, amount)
2013
2187
  else:
2014
2188
  request['amount'] = self.amount_to_precision(symbol, amount)
2015
- if stopPrice is not None:
2016
- request['trigger_price'] = self.price_to_precision(symbol, stopPrice)
2189
+ if triggerPrice is not None:
2190
+ request['trigger_price'] = self.price_to_precision(symbol, triggerPrice)
2017
2191
  params = self.omit(params, ['reduceOnly', 'timeInForce', 'postOnly', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice'])
2018
2192
  return self.extend(request, params)
2019
2193
 
2020
2194
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
2021
2195
  """
2022
2196
  create a trade order
2023
- :see: https://docs.coinex.com/api/v2/spot/order/http/put-order
2024
- :see: https://docs.coinex.com/api/v2/spot/order/http/put-stop-order
2025
- :see: https://docs.coinex.com/api/v2/futures/order/http/put-order
2026
- :see: https://docs.coinex.com/api/v2/futures/order/http/put-stop-order
2027
- :see: https://docs.coinex.com/api/v2/futures/position/http/close-position
2028
- :see: https://docs.coinex.com/api/v2/futures/position/http/set-position-stop-loss
2029
- :see: https://docs.coinex.com/api/v2/futures/position/http/set-position-take-profit
2197
+
2198
+ https://docs.coinex.com/api/v2/spot/order/http/put-order
2199
+ https://docs.coinex.com/api/v2/spot/order/http/put-stop-order
2200
+ https://docs.coinex.com/api/v2/futures/order/http/put-order
2201
+ https://docs.coinex.com/api/v2/futures/order/http/put-stop-order
2202
+ https://docs.coinex.com/api/v2/futures/position/http/close-position
2203
+ https://docs.coinex.com/api/v2/futures/position/http/set-position-stop-loss
2204
+ https://docs.coinex.com/api/v2/futures/position/http/set-position-take-profit
2205
+
2030
2206
  :param str symbol: unified symbol of the market to create an order in
2031
2207
  :param str type: 'market' or 'limit'
2032
2208
  :param str side: 'buy' or 'sell'
2033
2209
  :param float amount: how much you want to trade in units of the base currency
2034
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2210
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2035
2211
  :param dict [params]: extra parameters specific to the exchange API endpoint
2036
2212
  :param float [params.triggerPrice]: price to trigger stop orders
2037
2213
  :param float [params.stopLossPrice]: price to trigger stop loss orders
@@ -2256,10 +2432,12 @@ class coinex(Exchange, ImplicitAPI):
2256
2432
  def create_orders(self, orders: List[OrderRequest], params={}) -> List[Order]:
2257
2433
  """
2258
2434
  create a list of trade orders(all orders should be of the same symbol)
2259
- :see: https://docs.coinex.com/api/v2/spot/order/http/put-multi-order
2260
- :see: https://docs.coinex.com/api/v2/spot/order/http/put-multi-stop-order
2261
- :see: https://docs.coinex.com/api/v2/futures/order/http/put-multi-order
2262
- :see: https://docs.coinex.com/api/v2/futures/order/http/put-multi-stop-order
2435
+
2436
+ https://docs.coinex.com/api/v2/spot/order/http/put-multi-order
2437
+ https://docs.coinex.com/api/v2/spot/order/http/put-multi-stop-order
2438
+ https://docs.coinex.com/api/v2/futures/order/http/put-multi-order
2439
+ https://docs.coinex.com/api/v2/futures/order/http/put-multi-stop-order
2440
+
2263
2441
  :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
2264
2442
  :param dict [params]: extra parameters specific to the api endpoint
2265
2443
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -2441,10 +2619,12 @@ class coinex(Exchange, ImplicitAPI):
2441
2619
  def cancel_orders(self, ids, symbol: Str = None, params={}):
2442
2620
  """
2443
2621
  cancel multiple orders
2444
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-order
2445
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-stop-order
2446
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-order
2447
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-stop-order
2622
+
2623
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-order
2624
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-stop-order
2625
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-order
2626
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-stop-order
2627
+
2448
2628
  :param str[] ids: order ids
2449
2629
  :param str symbol: unified market symbol
2450
2630
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2458,15 +2638,18 @@ class coinex(Exchange, ImplicitAPI):
2458
2638
  request: dict = {
2459
2639
  'market': market['id'],
2460
2640
  }
2461
- stop = self.safe_bool_2(params, 'stop', 'trigger')
2641
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
2462
2642
  params = self.omit(params, ['stop', 'trigger'])
2463
2643
  response = None
2464
- if stop:
2465
- request['stop_ids'] = ids
2644
+ requestIds = []
2645
+ for i in range(0, len(ids)):
2646
+ requestIds.append(int(ids[i]))
2647
+ if trigger:
2648
+ request['stop_ids'] = requestIds
2466
2649
  else:
2467
- request['order_ids'] = ids
2650
+ request['order_ids'] = requestIds
2468
2651
  if market['spot']:
2469
- if stop:
2652
+ if trigger:
2470
2653
  response = self.v2PrivatePostSpotCancelBatchStopOrder(self.extend(request, params))
2471
2654
  #
2472
2655
  # {
@@ -2535,7 +2718,7 @@ class coinex(Exchange, ImplicitAPI):
2535
2718
  #
2536
2719
  else:
2537
2720
  request['market_type'] = 'FUTURES'
2538
- if stop:
2721
+ if trigger:
2539
2722
  response = self.v2PrivatePostFuturesCancelBatchStopOrder(self.extend(request, params))
2540
2723
  #
2541
2724
  # {
@@ -2612,16 +2795,18 @@ class coinex(Exchange, ImplicitAPI):
2612
2795
  def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
2613
2796
  """
2614
2797
  edit a trade order
2615
- :see: https://docs.coinex.com/api/v2/spot/order/http/edit-order
2616
- :see: https://docs.coinex.com/api/v2/spot/order/http/edit-stop-order
2617
- :see: https://docs.coinex.com/api/v2/futures/order/http/edit-order
2618
- :see: https://docs.coinex.com/api/v2/futures/order/http/edit-stop-order
2798
+
2799
+ https://docs.coinex.com/api/v2/spot/order/http/edit-order
2800
+ https://docs.coinex.com/api/v2/spot/order/http/edit-stop-order
2801
+ https://docs.coinex.com/api/v2/futures/order/http/edit-order
2802
+ https://docs.coinex.com/api/v2/futures/order/http/edit-stop-order
2803
+
2619
2804
  :param str id: order id
2620
2805
  :param str symbol: unified symbol of the market to create an order in
2621
2806
  :param str type: 'market' or 'limit'
2622
2807
  :param str side: 'buy' or 'sell'
2623
2808
  :param float amount: how much of the currency you want to trade in units of the base currency
2624
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2809
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2625
2810
  :param dict [params]: extra parameters specific to the exchange API endpoint
2626
2811
  :param float [params.triggerPrice]: the price to trigger stop orders
2627
2812
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -2745,14 +2930,16 @@ class coinex(Exchange, ImplicitAPI):
2745
2930
  def cancel_order(self, id: str, symbol: Str = None, params={}):
2746
2931
  """
2747
2932
  cancels an open order
2748
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-order
2749
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order
2750
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-order-by-client-id
2751
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order-by-client-id
2752
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-order
2753
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order
2754
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-order-by-client-id
2755
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order-by-client-id
2933
+
2934
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-order
2935
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order
2936
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-order-by-client-id
2937
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order-by-client-id
2938
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-order
2939
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order
2940
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-order-by-client-id
2941
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order-by-client-id
2942
+
2756
2943
  :param str id: order id
2757
2944
  :param str symbol: unified symbol of the market the order was made in
2758
2945
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3026,8 +3213,10 @@ class coinex(Exchange, ImplicitAPI):
3026
3213
  def cancel_all_orders(self, symbol: Str = None, params={}):
3027
3214
  """
3028
3215
  cancel all open orders in a market
3029
- :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-all-order
3030
- :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-all-order
3216
+
3217
+ https://docs.coinex.com/api/v2/spot/order/http/cancel-all-order
3218
+ https://docs.coinex.com/api/v2/futures/order/http/cancel-all-order
3219
+
3031
3220
  :param str symbol: unified market symbol of the market to cancel orders in
3032
3221
  :param dict [params]: extra parameters specific to the exchange API endpoint
3033
3222
  :param str [params.marginMode]: 'cross' or 'isolated' for canceling spot margin orders
@@ -3067,8 +3256,11 @@ class coinex(Exchange, ImplicitAPI):
3067
3256
  def fetch_order(self, id: str, symbol: Str = None, params={}):
3068
3257
  """
3069
3258
  fetches information on an order made by the user
3070
- :see: https://docs.coinex.com/api/v2/spot/order/http/get-order-status
3071
- :see: https://docs.coinex.com/api/v2/futures/order/http/get-order-status
3259
+
3260
+ https://docs.coinex.com/api/v2/spot/order/http/get-order-status
3261
+ https://docs.coinex.com/api/v2/futures/order/http/get-order-status
3262
+
3263
+ :param str id: order id
3072
3264
  :param str symbol: unified symbol of the market the order was made in
3073
3265
  :param dict [params]: extra parameters specific to the exchange API endpoint
3074
3266
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -3151,13 +3343,17 @@ class coinex(Exchange, ImplicitAPI):
3151
3343
  def fetch_orders_by_status(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3152
3344
  """
3153
3345
  fetch a list of orders
3154
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
3155
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
3156
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
3157
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
3346
+
3347
+ https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
3348
+ https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
3349
+ https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
3350
+ https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
3351
+
3352
+ :param str status: order status to fetch for
3158
3353
  :param str symbol: unified market symbol of the market orders were made in
3159
3354
  :param int [since]: the earliest time in ms to fetch orders for
3160
3355
  :param int [limit]: the maximum number of order structures to retrieve
3356
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3161
3357
  :param boolean [params.trigger]: set to True for fetching trigger orders
3162
3358
  :param str [params.marginMode]: 'cross' or 'isolated' for fetching spot margin orders
3163
3359
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
@@ -3170,7 +3366,7 @@ class coinex(Exchange, ImplicitAPI):
3170
3366
  request['market'] = market['id']
3171
3367
  if limit is not None:
3172
3368
  request['limit'] = limit
3173
- stop = self.safe_bool_2(params, 'stop', 'trigger')
3369
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
3174
3370
  params = self.omit(params, ['stop', 'trigger'])
3175
3371
  marketType = None
3176
3372
  marketType, params = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
@@ -3180,7 +3376,7 @@ class coinex(Exchange, ImplicitAPI):
3180
3376
  if marketType == 'swap':
3181
3377
  request['market_type'] = 'FUTURES'
3182
3378
  if isClosed:
3183
- if stop:
3379
+ if trigger:
3184
3380
  response = self.v2PrivateGetFuturesFinishedStopOrder(self.extend(request, params))
3185
3381
  #
3186
3382
  # {
@@ -3241,7 +3437,7 @@ class coinex(Exchange, ImplicitAPI):
3241
3437
  # }
3242
3438
  #
3243
3439
  elif isOpen:
3244
- if stop:
3440
+ if trigger:
3245
3441
  response = self.v2PrivateGetFuturesPendingStopOrder(self.extend(request, params))
3246
3442
  #
3247
3443
  # {
@@ -3314,7 +3510,7 @@ class coinex(Exchange, ImplicitAPI):
3314
3510
  else:
3315
3511
  request['market_type'] = 'SPOT'
3316
3512
  if isClosed:
3317
- if stop:
3513
+ if trigger:
3318
3514
  response = self.v2PrivateGetSpotFinishedStopOrder(self.extend(request, params))
3319
3515
  #
3320
3516
  # {
@@ -3378,7 +3574,7 @@ class coinex(Exchange, ImplicitAPI):
3378
3574
  # }
3379
3575
  #
3380
3576
  elif status == 'pending':
3381
- if stop:
3577
+ if trigger:
3382
3578
  response = self.v2PrivateGetSpotPendingStopOrder(self.extend(request, params))
3383
3579
  #
3384
3580
  # {
@@ -3451,10 +3647,12 @@ class coinex(Exchange, ImplicitAPI):
3451
3647
  def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
3452
3648
  """
3453
3649
  fetch all unfilled currently open orders
3454
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-pending-order
3455
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-pending-stop-order
3456
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-pending-order
3457
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-pending-stop-order
3650
+
3651
+ https://docs.coinex.com/api/v2/spot/order/http/list-pending-order
3652
+ https://docs.coinex.com/api/v2/spot/order/http/list-pending-stop-order
3653
+ https://docs.coinex.com/api/v2/futures/order/http/list-pending-order
3654
+ https://docs.coinex.com/api/v2/futures/order/http/list-pending-stop-order
3655
+
3458
3656
  :param str symbol: unified market symbol
3459
3657
  :param int [since]: the earliest time in ms to fetch open orders for
3460
3658
  :param int [limit]: the maximum number of open order structures to retrieve
@@ -3471,23 +3669,28 @@ class coinex(Exchange, ImplicitAPI):
3471
3669
  def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
3472
3670
  """
3473
3671
  fetches information on multiple closed orders made by the user
3474
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
3475
- :see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
3476
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
3477
- :see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
3672
+
3673
+ https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
3674
+ https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
3675
+ https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
3676
+ https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
3677
+
3478
3678
  :param str symbol: unified market symbol of the market orders were made in
3479
3679
  :param int [since]: the earliest time in ms to fetch orders for
3480
3680
  :param int [limit]: the maximum number of order structures to retrieve
3681
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3481
3682
  :param boolean [params.trigger]: set to True for fetching trigger orders
3482
3683
  :param str [params.marginMode]: 'cross' or 'isolated' for fetching spot margin orders
3483
3684
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
3484
3685
  """
3485
3686
  return self.fetch_orders_by_status('finished', symbol, since, limit, params)
3486
3687
 
3487
- def create_deposit_address(self, code: str, params={}):
3688
+ def create_deposit_address(self, code: str, params={}) -> DepositAddress:
3488
3689
  """
3489
3690
  create a currency deposit address
3490
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/update-deposit-address
3691
+
3692
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/update-deposit-address
3693
+
3491
3694
  :param str code: unified currency code of the currency for the deposit address
3492
3695
  :param dict [params]: extra parameters specific to the exchange API endpoint
3493
3696
  :param str [params.network]: the blockchain network to create a deposit address on
@@ -3517,10 +3720,12 @@ class coinex(Exchange, ImplicitAPI):
3517
3720
  data = self.safe_dict(response, 'data', {})
3518
3721
  return self.parse_deposit_address(data, currency)
3519
3722
 
3520
- def fetch_deposit_address(self, code: str, params={}):
3723
+ def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
3521
3724
  """
3522
3725
  fetch the deposit address for a currency associated with self account
3523
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-address
3726
+
3727
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-address
3728
+
3524
3729
  :param str code: unified currency code
3525
3730
  :param dict [params]: extra parameters specific to the exchange API endpoint
3526
3731
  :param str [params.network]: the blockchain network to create a deposit address on
@@ -3528,20 +3733,14 @@ class coinex(Exchange, ImplicitAPI):
3528
3733
  """
3529
3734
  self.load_markets()
3530
3735
  currency = self.currency(code)
3531
- networks = self.safe_dict(currency, 'networks', {})
3532
- network = self.safe_string_2(params, 'network', 'chain')
3533
- params = self.omit(params, 'network')
3534
- networksKeys = list(networks.keys())
3535
- numOfNetworks = len(networksKeys)
3536
- if networks is not None and numOfNetworks > 1:
3537
- if network is None:
3538
- raise ArgumentsRequired(self.id + ' fetchDepositAddress() ' + code + ' requires a network parameter')
3539
- if not (network in networks):
3540
- raise ExchangeError(self.id + ' fetchDepositAddress() ' + network + ' network not supported for ' + code)
3541
3736
  request: dict = {
3542
3737
  'ccy': currency['id'],
3543
- 'chain': network,
3544
3738
  }
3739
+ networkCode = None
3740
+ networkCode, params = self.handle_network_code_and_params(params)
3741
+ if networkCode is None:
3742
+ raise ArgumentsRequired(self.id + ' fetchDepositAddress() requires a "network" parameter')
3743
+ request['chain'] = self.network_code_to_id(networkCode) # required for on-chain, not required for inter-user transfer
3545
3744
  response = self.v2PrivateGetAssetsDepositAddress(self.extend(request, params))
3546
3745
  #
3547
3746
  # {
@@ -3554,29 +3753,9 @@ class coinex(Exchange, ImplicitAPI):
3554
3753
  # }
3555
3754
  #
3556
3755
  data = self.safe_dict(response, 'data', {})
3557
- depositAddress = self.parse_deposit_address(data, currency)
3558
- options = self.safe_dict(self.options, 'fetchDepositAddress', {})
3559
- fillResponseFromRequest = self.safe_bool(options, 'fillResponseFromRequest', True)
3560
- if fillResponseFromRequest:
3561
- depositAddress['network'] = self.safe_network_code(network, currency)
3562
- return depositAddress
3563
-
3564
- def safe_network(self, networkId, currency: Currency = None):
3565
- networks = self.safe_value(currency, 'networks', {})
3566
- networksCodes = list(networks.keys())
3567
- networksCodesLength = len(networksCodes)
3568
- if networkId is None and networksCodesLength == 1:
3569
- return networks[networksCodes[0]]
3570
- return {
3571
- 'id': networkId,
3572
- 'network': None if (networkId is None) else networkId.upper(),
3573
- }
3574
-
3575
- def safe_network_code(self, networkId, currency: Currency = None):
3576
- network = self.safe_network(networkId, currency)
3577
- return network['network']
3756
+ return self.parse_deposit_address(data, currency)
3578
3757
 
3579
- def parse_deposit_address(self, depositAddress, currency: Currency = None):
3758
+ def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
3580
3759
  #
3581
3760
  # {
3582
3761
  # "address": "1P1JqozxioQwaqPwgMAQdNDYNyaVSqgARq",
@@ -3596,16 +3775,18 @@ class coinex(Exchange, ImplicitAPI):
3596
3775
  return {
3597
3776
  'info': depositAddress,
3598
3777
  'currency': self.safe_currency_code(None, currency),
3599
- 'address': address,
3600
- 'tag': tag,
3601
3778
  'network': None,
3779
+ 'address': address,
3780
+ 'tag': self.safe_string(depositAddress, 'memo', tag),
3602
3781
  }
3603
3782
 
3604
3783
  def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3605
3784
  """
3606
3785
  fetch all trades made by the user
3607
- :see: https://docs.coinex.com/api/v2/spot/deal/http/list-user-deals
3608
- :see: https://docs.coinex.com/api/v2/futures/deal/http/list-user-deals
3786
+
3787
+ https://docs.coinex.com/api/v2/spot/deal/http/list-user-deals
3788
+ https://docs.coinex.com/api/v2/futures/deal/http/list-user-deals
3789
+
3609
3790
  :param str symbol: unified market symbol
3610
3791
  :param int [since]: the earliest time in ms to fetch trades for
3611
3792
  :param int [limit]: the maximum number of trade structures to retrieve
@@ -3682,11 +3863,13 @@ class coinex(Exchange, ImplicitAPI):
3682
3863
  data = self.safe_list(response, 'data', [])
3683
3864
  return self.parse_trades(data, market, since, limit)
3684
3865
 
3685
- def fetch_positions(self, symbols: Strings = None, params={}):
3866
+ def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
3686
3867
  """
3687
3868
  fetch all open positions
3688
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-pending-position
3689
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-finished-position
3869
+
3870
+ https://docs.coinex.com/api/v2/futures/position/http/list-pending-position
3871
+ https://docs.coinex.com/api/v2/futures/position/http/list-finished-position
3872
+
3690
3873
  :param str[] [symbols]: list of unified market symbols
3691
3874
  :param dict [params]: extra parameters specific to the exchange API endpoint
3692
3875
  :param str [params.method]: the method to use 'v2PrivateGetFuturesPendingPosition' or 'v2PrivateGetFuturesFinishedPosition' default is 'v2PrivateGetFuturesPendingPosition'
@@ -3768,7 +3951,9 @@ class coinex(Exchange, ImplicitAPI):
3768
3951
  def fetch_position(self, symbol: str, params={}):
3769
3952
  """
3770
3953
  fetch data on a single open contract trade position
3771
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-pending-position
3954
+
3955
+ https://docs.coinex.com/api/v2/futures/position/http/list-pending-position
3956
+
3772
3957
  :param str symbol: unified market symbol of the market the position is held in
3773
3958
  :param dict [params]: extra parameters specific to the exchange API endpoint
3774
3959
  :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -3898,7 +4083,9 @@ class coinex(Exchange, ImplicitAPI):
3898
4083
  def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
3899
4084
  """
3900
4085
  set margin mode to 'cross' or 'isolated'
3901
- :see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage
4086
+
4087
+ https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage
4088
+
3902
4089
  :param str marginMode: 'cross' or 'isolated'
3903
4090
  :param str symbol: unified market symbol
3904
4091
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3938,9 +4125,11 @@ class coinex(Exchange, ImplicitAPI):
3938
4125
  # }
3939
4126
  #
3940
4127
 
3941
- def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
4128
+ def set_leverage(self, leverage: int, symbol: Str = None, params={}):
3942
4129
  """
3943
- :see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage
4130
+
4131
+ https://docs.coinex.com/api/v2/futures/position/http/adjust-position-leverage
4132
+
3944
4133
  set the level of leverage for a market
3945
4134
  :param float leverage: the rate of leverage
3946
4135
  :param str symbol: unified market symbol
@@ -3981,7 +4170,9 @@ class coinex(Exchange, ImplicitAPI):
3981
4170
  def fetch_leverage_tiers(self, symbols: Strings = None, params={}) -> LeverageTiers:
3982
4171
  """
3983
4172
  retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
3984
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-position-level
4173
+
4174
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-position-level
4175
+
3985
4176
  :param str[]|None symbols: list of unified market symbols
3986
4177
  :param dict [params]: extra parameters specific to the exchange API endpoint
3987
4178
  :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
@@ -4031,6 +4222,7 @@ class coinex(Exchange, ImplicitAPI):
4031
4222
  maxNotional = self.safe_number(tier, 'amount')
4032
4223
  tiers.append({
4033
4224
  'tier': self.sum(i, 1),
4225
+ 'symbol': self.safe_symbol(marketId, market, None, 'swap'),
4034
4226
  'currency': market['base'] if market['linear'] else market['quote'],
4035
4227
  'minNotional': minNotional,
4036
4228
  'maxNotional': maxNotional,
@@ -4174,7 +4366,9 @@ class coinex(Exchange, ImplicitAPI):
4174
4366
  def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
4175
4367
  """
4176
4368
  add margin
4177
- :see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4369
+
4370
+ https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4371
+
4178
4372
  :param str symbol: unified market symbol
4179
4373
  :param float amount: amount of margin to add
4180
4374
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -4185,7 +4379,9 @@ class coinex(Exchange, ImplicitAPI):
4185
4379
  def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
4186
4380
  """
4187
4381
  remove margin from a position
4188
- :see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4382
+
4383
+ https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
4384
+
4189
4385
  :param str symbol: unified market symbol
4190
4386
  :param float amount: the amount of margin to remove
4191
4387
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -4196,7 +4392,9 @@ class coinex(Exchange, ImplicitAPI):
4196
4392
  def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4197
4393
  """
4198
4394
  fetch the history of funding fee payments paid and received on self account
4199
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-position-funding-history
4395
+
4396
+ https://docs.coinex.com/api/v2/futures/position/http/list-position-funding-history
4397
+
4200
4398
  :param str symbol: unified market symbol
4201
4399
  :param int [since]: the earliest time in ms to fetch funding history for
4202
4400
  :param int [limit]: the maximum number of funding history structures to retrieve
@@ -4256,10 +4454,12 @@ class coinex(Exchange, ImplicitAPI):
4256
4454
  })
4257
4455
  return result
4258
4456
 
4259
- def fetch_funding_rate(self, symbol: str, params={}):
4457
+ def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
4260
4458
  """
4261
4459
  fetch the current funding rate
4262
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4460
+
4461
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4462
+
4263
4463
  :param str symbol: unified market symbol
4264
4464
  :param dict [params]: extra parameters specific to the exchange API endpoint
4265
4465
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -4294,9 +4494,21 @@ class coinex(Exchange, ImplicitAPI):
4294
4494
  first = self.safe_dict(data, 0, {})
4295
4495
  return self.parse_funding_rate(first, market)
4296
4496
 
4297
- def parse_funding_rate(self, contract, market: Market = None):
4497
+ def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
4498
+ """
4499
+ fetch the current funding rate interval
4500
+
4501
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4502
+
4503
+ :param str symbol: unified market symbol
4504
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4505
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
4506
+ """
4507
+ return self.fetch_funding_rate(symbol, params)
4508
+
4509
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
4298
4510
  #
4299
- # fetchFundingRate, fetchFundingRates
4511
+ # fetchFundingRate, fetchFundingRates, fetchFundingInterval
4300
4512
  #
4301
4513
  # {
4302
4514
  # "latest_funding_rate": "0",
@@ -4311,6 +4523,9 @@ class coinex(Exchange, ImplicitAPI):
4311
4523
  #
4312
4524
  currentFundingTimestamp = self.safe_integer(contract, 'latest_funding_time')
4313
4525
  futureFundingTimestamp = self.safe_integer(contract, 'next_funding_time')
4526
+ fundingTimeString = self.safe_string(contract, 'latest_funding_time')
4527
+ nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
4528
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
4314
4529
  marketId = self.safe_string(contract, 'market')
4315
4530
  return {
4316
4531
  'info': contract,
@@ -4330,12 +4545,25 @@ class coinex(Exchange, ImplicitAPI):
4330
4545
  'previousFundingRate': None,
4331
4546
  'previousFundingTimestamp': None,
4332
4547
  'previousFundingDatetime': None,
4548
+ 'interval': self.parse_funding_interval(millisecondsInterval),
4333
4549
  }
4334
4550
 
4335
- def fetch_funding_rates(self, symbols: Strings = None, params={}):
4551
+ def parse_funding_interval(self, interval):
4552
+ intervals: dict = {
4553
+ '3600000': '1h',
4554
+ '14400000': '4h',
4555
+ '28800000': '8h',
4556
+ '57600000': '16h',
4557
+ '86400000': '24h',
4558
+ }
4559
+ return self.safe_string(intervals, interval, interval)
4560
+
4561
+ def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
4336
4562
  """
4337
- fetch the current funding rates
4338
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4563
+ fetch the current funding rates for multiple markets
4564
+
4565
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
4566
+
4339
4567
  :param str[] symbols: unified market symbols
4340
4568
  :param dict [params]: extra parameters specific to the exchange API endpoint
4341
4569
  :returns dict[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -4371,17 +4599,18 @@ class coinex(Exchange, ImplicitAPI):
4371
4599
  # }
4372
4600
  #
4373
4601
  data = self.safe_list(response, 'data', [])
4374
- result = self.parse_funding_rates(data, market)
4375
- return self.filter_by_array(result, 'symbol', symbols)
4602
+ return self.parse_funding_rates(data, symbols)
4376
4603
 
4377
- def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
4604
+ def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
4378
4605
  """
4379
4606
  make a withdrawal
4380
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/withdrawal
4607
+
4608
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/withdrawal
4609
+
4381
4610
  :param str code: unified currency code
4382
4611
  :param float amount: the amount to withdraw
4383
4612
  :param str address: the address to withdraw to
4384
- :param str tag:
4613
+ :param str [tag]: memo
4385
4614
  :param dict [params]: extra parameters specific to the exchange API endpoint
4386
4615
  :param str [params.network]: unified network code
4387
4616
  :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
@@ -4390,15 +4619,15 @@ class coinex(Exchange, ImplicitAPI):
4390
4619
  self.check_address(address)
4391
4620
  self.load_markets()
4392
4621
  currency = self.currency(code)
4393
- networkCode = self.safe_string_upper_2(params, 'network', 'chain')
4394
- params = self.omit(params, 'network')
4395
- if tag:
4396
- address = address + ':' + tag
4397
4622
  request: dict = {
4398
4623
  'ccy': currency['id'],
4399
4624
  'to_address': address, # must be authorized, inter-user transfer by a registered mobile phone number or an email address is supported
4400
- 'amount': self.number_to_string(amount), # the actual amount without fees, https://www.coinex.com/fees
4625
+ 'amount': self.currency_to_precision(code, amount), # the actual amount without fees, https://www.coinex.com/fees
4401
4626
  }
4627
+ if tag is not None:
4628
+ request['memo'] = tag
4629
+ networkCode = None
4630
+ networkCode, params = self.handle_network_code_and_params(params)
4402
4631
  if networkCode is not None:
4403
4632
  request['chain'] = self.network_code_to_id(networkCode) # required for on-chain, not required for inter-user transfer
4404
4633
  response = self.v2PrivatePostAssetsWithdraw(self.extend(request, params))
@@ -4435,11 +4664,13 @@ class coinex(Exchange, ImplicitAPI):
4435
4664
  statuses: dict = {
4436
4665
  'audit': 'pending',
4437
4666
  'pass': 'pending',
4667
+ 'audit_required': 'pending',
4438
4668
  'processing': 'pending',
4439
4669
  'confirming': 'pending',
4440
4670
  'not_pass': 'failed',
4441
4671
  'cancel': 'canceled',
4442
4672
  'finish': 'ok',
4673
+ 'finished': 'ok',
4443
4674
  'fail': 'failed',
4444
4675
  }
4445
4676
  return self.safe_string(statuses, status, status)
@@ -4447,7 +4678,9 @@ class coinex(Exchange, ImplicitAPI):
4447
4678
  def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4448
4679
  """
4449
4680
  fetches historical funding rate prices
4450
- :see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate-history
4681
+
4682
+ https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate-history
4683
+
4451
4684
  :param str symbol: unified symbol of the market to fetch the funding rate history for
4452
4685
  :param int [since]: timestamp in ms of the earliest funding rate to fetch
4453
4686
  :param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
@@ -4609,7 +4842,9 @@ class coinex(Exchange, ImplicitAPI):
4609
4842
  def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
4610
4843
  """
4611
4844
  transfer currency internally between wallets on the same account
4612
- :see: https://docs.coinex.com/api/v2/assets/transfer/http/transfer
4845
+
4846
+ https://docs.coinex.com/api/v2/assets/transfer/http/transfer
4847
+
4613
4848
  :param str code: unified currency code
4614
4849
  :param float amount: amount to transfer
4615
4850
  :param str fromAccount: account to transfer from
@@ -4621,7 +4856,7 @@ class coinex(Exchange, ImplicitAPI):
4621
4856
  self.load_markets()
4622
4857
  currency = self.currency(code)
4623
4858
  amountToPrecision = self.currency_to_precision(code, amount)
4624
- accountsByType = self.safe_dict(self.options, 'accountsById', {})
4859
+ accountsByType = self.safe_dict(self.options, 'accountsByType', {})
4625
4860
  fromId = self.safe_string(accountsByType, fromAccount, fromAccount)
4626
4861
  toId = self.safe_string(accountsByType, toAccount, toAccount)
4627
4862
  request: dict = {
@@ -4679,10 +4914,12 @@ class coinex(Exchange, ImplicitAPI):
4679
4914
  'status': self.parse_transfer_status(self.safe_string_2(transfer, 'code', 'status')),
4680
4915
  }
4681
4916
 
4682
- def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> TransferEntries:
4917
+ def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
4683
4918
  """
4684
4919
  fetch a history of internal transfers made on an account
4685
- :see: https://docs.coinex.com/api/v2/assets/transfer/http/list-transfer-history
4920
+
4921
+ https://docs.coinex.com/api/v2/assets/transfer/http/list-transfer-history
4922
+
4686
4923
  :param str code: unified currency code of the currency transferred
4687
4924
  :param int [since]: the earliest time in ms to fetch transfers for
4688
4925
  :param int [limit]: the maximum number of transfer structures to retrieve
@@ -4735,7 +4972,9 @@ class coinex(Exchange, ImplicitAPI):
4735
4972
  def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
4736
4973
  """
4737
4974
  fetch all withdrawals made from an account
4738
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history
4975
+
4976
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-withdrawal-history
4977
+
4739
4978
  :param str [code]: unified currency code
4740
4979
  :param int [since]: the earliest time in ms to fetch withdrawals for
4741
4980
  :param int [limit]: the maximum number of withdrawal structures to retrieve
@@ -4789,7 +5028,9 @@ class coinex(Exchange, ImplicitAPI):
4789
5028
  def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
4790
5029
  """
4791
5030
  fetch all deposits made to an account
4792
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history
5031
+
5032
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-deposit-history
5033
+
4793
5034
  :param str [code]: unified currency code
4794
5035
  :param int [since]: the earliest time in ms to fetch deposits for
4795
5036
  :param int [limit]: the maximum number of deposit structures to retrieve
@@ -4837,7 +5078,7 @@ class coinex(Exchange, ImplicitAPI):
4837
5078
  data = self.safe_list(response, 'data', [])
4838
5079
  return self.parse_transactions(data, currency, since, limit)
4839
5080
 
4840
- def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
5081
+ def parse_isolated_borrow_rate(self, info: dict, market: Market = None) -> IsolatedBorrowRate:
4841
5082
  #
4842
5083
  # {
4843
5084
  # "market": "BTCUSDT",
@@ -4873,7 +5114,9 @@ class coinex(Exchange, ImplicitAPI):
4873
5114
  def fetch_isolated_borrow_rate(self, symbol: str, params={}) -> IsolatedBorrowRate:
4874
5115
  """
4875
5116
  fetch the rate of interest to borrow a currency for margin trading
4876
- :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
5117
+
5118
+ https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
5119
+
4877
5120
  :param str symbol: unified symbol of the market to fetch the borrow rate for
4878
5121
  :param dict [params]: extra parameters specific to the exchange API endpoint
4879
5122
  :param str params['code']: unified currency code
@@ -4908,10 +5151,12 @@ class coinex(Exchange, ImplicitAPI):
4908
5151
  data = self.safe_dict(response, 'data', {})
4909
5152
  return self.parse_isolated_borrow_rate(data, market)
4910
5153
 
4911
- def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
5154
+ def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
4912
5155
  """
4913
5156
  fetch the interest owed by the user for borrowing currency for margin trading
4914
- :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
5157
+
5158
+ https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-borrow-history
5159
+
4915
5160
  :param str [code]: unified currency code
4916
5161
  :param str [symbol]: unified market symbol when fetch interest in isolated markets
4917
5162
  :param int [since]: the earliest time in ms to fetch borrrow interest for
@@ -4956,7 +5201,7 @@ class coinex(Exchange, ImplicitAPI):
4956
5201
  interest = self.parse_borrow_interests(rows, market)
4957
5202
  return self.filter_by_currency_since_limit(interest, code, since, limit)
4958
5203
 
4959
- def parse_borrow_interest(self, info: dict, market: Market = None):
5204
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
4960
5205
  #
4961
5206
  # {
4962
5207
  # "borrow_id": 2642934,
@@ -4975,23 +5220,23 @@ class coinex(Exchange, ImplicitAPI):
4975
5220
  market = self.safe_market(marketId, market, None, 'spot')
4976
5221
  timestamp = self.safe_integer(info, 'expired_at')
4977
5222
  return {
4978
- 'account': None, # deprecated
5223
+ 'info': info,
4979
5224
  'symbol': market['symbol'],
4980
- 'marginMode': 'isolated',
4981
- 'marginType': None, # deprecated
4982
5225
  'currency': self.safe_currency_code(self.safe_string(info, 'ccy')),
4983
5226
  'interest': self.safe_number(info, 'to_repaied_amount'),
4984
5227
  'interestRate': self.safe_number(info, 'daily_interest_rate'),
4985
5228
  'amountBorrowed': self.safe_number(info, 'borrow_amount'),
5229
+ 'marginMode': 'isolated',
4986
5230
  'timestamp': timestamp, # expiry time
4987
5231
  'datetime': self.iso8601(timestamp),
4988
- 'info': info,
4989
5232
  }
4990
5233
 
4991
5234
  def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
4992
5235
  """
4993
5236
  create a loan to borrow margin
4994
- :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-borrow
5237
+
5238
+ https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-borrow
5239
+
4995
5240
  :param str symbol: unified market symbol, required for coinex
4996
5241
  :param str code: unified currency code of the currency to borrow
4997
5242
  :param float amount: the amount to borrow
@@ -5037,7 +5282,9 @@ class coinex(Exchange, ImplicitAPI):
5037
5282
  def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
5038
5283
  """
5039
5284
  repay borrowed margin and interest
5040
- :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-repay
5285
+
5286
+ https://docs.coinex.com/api/v2/assets/loan-flat/http/margin-repay
5287
+
5041
5288
  :param str symbol: unified market symbol, required for coinex
5042
5289
  :param str code: unified currency code of the currency to repay
5043
5290
  :param float amount: the amount to repay
@@ -5097,7 +5344,9 @@ class coinex(Exchange, ImplicitAPI):
5097
5344
  def fetch_deposit_withdraw_fee(self, code: str, params={}):
5098
5345
  """
5099
5346
  fetch the fee for deposits and withdrawals
5100
- :see: https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-withdrawal-config
5347
+
5348
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/get-deposit-withdrawal-config
5349
+
5101
5350
  :param str code: unified currency code
5102
5351
  :param dict [params]: extra parameters specific to the exchange API endpoint
5103
5352
  :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -5144,6 +5393,66 @@ class coinex(Exchange, ImplicitAPI):
5144
5393
  data = self.safe_dict(response, 'data', {})
5145
5394
  return self.parse_deposit_withdraw_fee(data, currency)
5146
5395
 
5396
+ def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
5397
+ """
5398
+ fetch the fees for deposits and withdrawals
5399
+
5400
+ https://docs.coinex.com/api/v2/assets/deposit-withdrawal/http/list-all-deposit-withdrawal-config
5401
+
5402
+ @param codes
5403
+ :param dict [params]: extra parameters specific to the exchange API endpoint
5404
+ :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
5405
+ """
5406
+ self.load_markets()
5407
+ response = self.v2PublicGetAssetsAllDepositWithdrawConfig(params)
5408
+ #
5409
+ # {
5410
+ # "code": 0,
5411
+ # "data": [
5412
+ # {
5413
+ # "asset": {
5414
+ # "ccy": "CET",
5415
+ # "deposit_enabled": True,
5416
+ # "withdraw_enabled": True,
5417
+ # "inter_transfer_enabled": True,
5418
+ # "is_st": False
5419
+ # },
5420
+ # "chains": [
5421
+ # {
5422
+ # "chain": "CSC",
5423
+ # "min_deposit_amount": "0.8",
5424
+ # "min_withdraw_amount": "8",
5425
+ # "deposit_enabled": True,
5426
+ # "withdraw_enabled": True,
5427
+ # "deposit_delay_minutes": 0,
5428
+ # "safe_confirmations": 10,
5429
+ # "irreversible_confirmations": 20,
5430
+ # "deflation_rate": "0",
5431
+ # "withdrawal_fee": "0.026",
5432
+ # "withdrawal_precision": 8,
5433
+ # "memo": "",
5434
+ # "is_memo_required_for_deposit": False,
5435
+ # "explorer_asset_url": ""
5436
+ # },
5437
+ # ]
5438
+ # }
5439
+ # ],
5440
+ # "message": "OK"
5441
+ # }
5442
+ #
5443
+ data = self.safe_list(response, 'data', [])
5444
+ result: dict = {}
5445
+ for i in range(0, len(data)):
5446
+ item = data[i]
5447
+ asset = self.safe_dict(item, 'asset', {})
5448
+ currencyId = self.safe_string(asset, 'ccy')
5449
+ if currencyId is None:
5450
+ continue
5451
+ code = self.safe_currency_code(currencyId)
5452
+ if codes is None or self.in_array(code, codes):
5453
+ result[code] = self.parse_deposit_withdraw_fee(item)
5454
+ return result
5455
+
5147
5456
  def parse_deposit_withdraw_fee(self, fee, currency: Currency = None):
5148
5457
  #
5149
5458
  # {
@@ -5212,7 +5521,9 @@ class coinex(Exchange, ImplicitAPI):
5212
5521
  def fetch_leverage(self, symbol: str, params={}) -> Leverage:
5213
5522
  """
5214
5523
  fetch the set leverage for a market
5215
- :see: https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
5524
+
5525
+ https://docs.coinex.com/api/v2/assets/loan-flat/http/list-margin-interest-limit
5526
+
5216
5527
  :param str symbol: unified market symbol
5217
5528
  :param dict [params]: extra parameters specific to the exchange API endpoint
5218
5529
  :param str params['code']: unified currency code
@@ -5268,10 +5579,12 @@ class coinex(Exchange, ImplicitAPI):
5268
5579
  'shortLeverage': leverageValue,
5269
5580
  }
5270
5581
 
5271
- def fetch_position_history(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> Position:
5582
+ def fetch_position_history(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Position]:
5272
5583
  """
5273
5584
  fetches historical positions
5274
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-finished-position
5585
+
5586
+ https://docs.coinex.com/api/v2/futures/position/http/list-finished-position
5587
+
5275
5588
  :param str symbol: unified contract symbol
5276
5589
  :param int [since]: the earliest time in ms to fetch positions for
5277
5590
  :param int [limit]: the maximum amount of records to fetch, default is 10
@@ -5338,9 +5651,68 @@ class coinex(Exchange, ImplicitAPI):
5338
5651
  positions = self.parse_positions(records)
5339
5652
  return self.filter_by_symbol_since_limit(positions, symbol, since, limit)
5340
5653
 
5654
+ def close_position(self, symbol: str, side: OrderSide = None, params={}) -> Order:
5655
+ """
5656
+ closes an open position for a market
5657
+
5658
+ https://docs.coinex.com/api/v2/futures/position/http/close-position
5659
+
5660
+ :param str symbol: unified CCXT market symbol
5661
+ :param str [side]: buy or sell, not used by coinex
5662
+ :param dict [params]: extra parameters specific to the exchange API endpoint
5663
+ :param str params['type']: required by coinex, one of: limit, market, maker_only, ioc or fok, default is *market*
5664
+ :param str [params.price]: the price to fulfill the order, ignored in market orders
5665
+ :param str [params.amount]: the amount to trade in units of the base currency
5666
+ :param str [params.clientOrderId]: the client id of the order
5667
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
5668
+ """
5669
+ self.load_markets()
5670
+ market = self.market(symbol)
5671
+ type = self.safe_string(params, 'type', 'market')
5672
+ request: dict = {
5673
+ 'market': market['id'],
5674
+ 'market_type': 'FUTURES',
5675
+ 'type': type,
5676
+ }
5677
+ clientOrderId = self.safe_string_2(params, 'client_id', 'clientOrderId')
5678
+ if clientOrderId is not None:
5679
+ request['client_id'] = clientOrderId
5680
+ params = self.omit(params, 'clientOrderId')
5681
+ response = self.v2PrivatePostFuturesClosePosition(self.extend(request, params))
5682
+ #
5683
+ # {
5684
+ # "code": 0,
5685
+ # "data": {
5686
+ # "amount": "0.0001",
5687
+ # "client_id": "",
5688
+ # "created_at": 1729666043969,
5689
+ # "fee": "0.00335858",
5690
+ # "fee_ccy": "USDT",
5691
+ # "filled_amount": "0.0001",
5692
+ # "filled_value": "6.717179",
5693
+ # "last_filled_amount": "0.0001",
5694
+ # "last_filled_price": "67171.79",
5695
+ # "maker_fee_rate": "0",
5696
+ # "market": "BTCUSDT",
5697
+ # "market_type": "FUTURES",
5698
+ # "order_id": 155477479761,
5699
+ # "price": "0",
5700
+ # "realized_pnl": "-0.001823",
5701
+ # "side": "sell",
5702
+ # "taker_fee_rate": "0.0005",
5703
+ # "type": "market",
5704
+ # "unfilled_amount": "0",
5705
+ # "updated_at": 1729666043969
5706
+ # },
5707
+ # "message": "OK"
5708
+ # }
5709
+ #
5710
+ data = self.safe_dict(response, 'data', {})
5711
+ return self.parse_order(data, market)
5712
+
5341
5713
  def handle_margin_mode_and_params(self, methodName, params={}, defaultValue=None):
5342
5714
  """
5343
- * @ignore
5715
+ @ignore
5344
5716
  marginMode specified by params["marginMode"], self.options["marginMode"], self.options["defaultMarginMode"], params["margin"] = True or self.options["defaultType"] = 'margin'
5345
5717
  :param dict params: extra parameters specific to the exchange api endpoint
5346
5718
  :returns Array: the marginMode in lowercase
@@ -5466,7 +5838,9 @@ class coinex(Exchange, ImplicitAPI):
5466
5838
  def fetch_margin_adjustment_history(self, symbol: Str = None, type: Str = None, since: Num = None, limit: Num = None, params={}) -> List[MarginModification]:
5467
5839
  """
5468
5840
  fetches the history of margin added or reduced from contract isolated positions
5469
- :see: https://docs.coinex.com/api/v2/futures/position/http/list-position-margin-history
5841
+
5842
+ https://docs.coinex.com/api/v2/futures/position/http/list-position-margin-history
5843
+
5470
5844
  :param str symbol: unified market symbol
5471
5845
  :param str [type]: not used by coinex fetchMarginAdjustmentHistory
5472
5846
  :param int [since]: timestamp in ms of the earliest change to fetch