ccxt-ir 4.3.46.0.3__py2.py3-none-any.whl → 4.5.1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (529) hide show
  1. ccxt/__init__.py +39 -35
  2. ccxt/abantether.py +8 -8
  3. ccxt/abstract/alpaca.py +4 -0
  4. ccxt/abstract/apex.py +31 -0
  5. ccxt/abstract/bigone.py +1 -1
  6. ccxt/abstract/binance.py +106 -48
  7. ccxt/abstract/binancecoinm.py +106 -48
  8. ccxt/abstract/binanceus.py +141 -83
  9. ccxt/abstract/binanceusdm.py +106 -48
  10. ccxt/abstract/bingx.py +50 -1
  11. ccxt/abstract/bitbank.py +5 -0
  12. ccxt/abstract/bitfinex.py +136 -65
  13. ccxt/abstract/bitflyer.py +1 -0
  14. ccxt/abstract/bitget.py +67 -0
  15. ccxt/abstract/bitmart.py +19 -1
  16. ccxt/abstract/bitopro.py +1 -0
  17. ccxt/abstract/bitrue.py +68 -68
  18. ccxt/abstract/bitstamp.py +1 -0
  19. ccxt/abstract/blofin.py +30 -0
  20. ccxt/abstract/btcbox.py +2 -0
  21. ccxt/abstract/bybit.py +28 -13
  22. ccxt/abstract/cex.py +28 -29
  23. ccxt/abstract/coinbaseexchange.py +1 -0
  24. ccxt/abstract/coinbaseinternational.py +1 -1
  25. ccxt/abstract/cryptocom.py +16 -0
  26. ccxt/abstract/cryptomus.py +20 -0
  27. ccxt/abstract/defx.py +69 -0
  28. ccxt/abstract/deribit.py +1 -0
  29. ccxt/abstract/derive.py +117 -0
  30. ccxt/abstract/digifinex.py +1 -0
  31. ccxt/abstract/ellipx.py +25 -0
  32. ccxt/abstract/foxbit.py +26 -0
  33. ccxt/abstract/gate.py +19 -0
  34. ccxt/abstract/gateio.py +19 -0
  35. ccxt/abstract/gemini.py +1 -0
  36. ccxt/abstract/hibachi.py +26 -0
  37. ccxt/abstract/hyperliquid.py +1 -1
  38. ccxt/abstract/independentreserve.py +6 -0
  39. ccxt/abstract/kraken.py +1 -0
  40. ccxt/abstract/krakenfutures.py +4 -0
  41. ccxt/abstract/kucoin.py +10 -0
  42. ccxt/abstract/kucoinfutures.py +18 -0
  43. ccxt/abstract/lbank.py +2 -1
  44. ccxt/abstract/luno.py +1 -0
  45. ccxt/abstract/mexc.py +2 -0
  46. ccxt/abstract/modetrade.py +119 -0
  47. ccxt/abstract/myokx.py +349 -0
  48. ccxt/abstract/oceanex.py +5 -0
  49. ccxt/abstract/okx.py +25 -0
  50. ccxt/abstract/okxus.py +349 -0
  51. ccxt/abstract/onetrading.py +0 -12
  52. ccxt/abstract/paradex.py +23 -0
  53. ccxt/abstract/phemex.py +2 -0
  54. ccxt/abstract/poloniex.py +36 -0
  55. ccxt/abstract/tradeogre.py +3 -1
  56. ccxt/abstract/upbit.py +51 -34
  57. ccxt/abstract/whitebit.py +16 -0
  58. ccxt/abstract/woo.py +64 -6
  59. ccxt/abstract/xt.py +10 -5
  60. ccxt/afratether.py +8 -8
  61. ccxt/alpaca.py +828 -51
  62. ccxt/apex.py +1875 -0
  63. ccxt/arzinja.py +7 -7
  64. ccxt/arzplus.py +9 -9
  65. ccxt/ascendex.py +501 -306
  66. ccxt/async_support/__init__.py +39 -35
  67. ccxt/async_support/abantether.py +8 -8
  68. ccxt/async_support/afratether.py +10 -10
  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 +32 -38
  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 +32 -27
  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 +34 -30
  183. ccxt/async_support/sarmayex.py +9 -9
  184. ccxt/async_support/sarrafex.py +13 -13
  185. ccxt/async_support/tabdeal.py +15 -14
  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 +30 -36
  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 +29 -24
  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 +32 -28
  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 +13 -12
  413. ccxt/test/tests_async.py +261 -57
  414. ccxt/test/tests_helpers.py +1 -3
  415. ccxt/test/tests_init.py +4 -3
  416. ccxt/test/tests_sync.py +261 -57
  417. ccxt/tetherland.py +7 -7
  418. ccxt/timex.py +210 -51
  419. ccxt/tokocrypto.py +167 -47
  420. ccxt/tradeogre.py +266 -31
  421. ccxt/twox.py +7 -7
  422. ccxt/ubitex.py +9 -9
  423. ccxt/upbit.py +568 -165
  424. ccxt/vertex.py +160 -32
  425. ccxt/wallex.py +9 -9
  426. ccxt/wavesexchange.py +165 -30
  427. ccxt/whitebit.py +975 -127
  428. ccxt/woo.py +1917 -1016
  429. ccxt/woofipro.py +432 -141
  430. ccxt/xt.py +649 -193
  431. ccxt/yobit.py +194 -70
  432. ccxt/zaif.py +91 -15
  433. ccxt/zonda.py +151 -36
  434. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.1.dist-info}/METADATA +225 -73
  435. ccxt_ir-4.5.1.dist-info/RECORD +743 -0
  436. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.1.dist-info}/WHEEL +1 -1
  437. ccxt/__test__.py +0 -7
  438. ccxt/abstract/ace.py +0 -15
  439. ccxt/abstract/bitbay.py +0 -53
  440. ccxt/abstract/bitcoincom.py +0 -115
  441. ccxt/abstract/bitfinex2.py +0 -139
  442. ccxt/abstract/bitpanda.py +0 -35
  443. ccxt/abstract/bl3p.py +0 -19
  444. ccxt/abstract/coinlist.py +0 -54
  445. ccxt/abstract/currencycom.py +0 -68
  446. ccxt/abstract/hitbtc3.py +0 -115
  447. ccxt/abstract/idex.py +0 -26
  448. ccxt/abstract/kuna.py +0 -182
  449. ccxt/abstract/lykke.py +0 -29
  450. ccxt/abstract/poloniexfutures.py +0 -48
  451. ccxt/abstract/wazirx.py +0 -30
  452. ccxt/ace.py +0 -1012
  453. ccxt/async_support/ace.py +0 -1012
  454. ccxt/async_support/base/ws/aiohttp_client.py +0 -125
  455. ccxt/async_support/base/ws/fast_client.py +0 -96
  456. ccxt/async_support/bitbay.py +0 -17
  457. ccxt/async_support/bitcoincom.py +0 -17
  458. ccxt/async_support/bitfinex2.py +0 -3552
  459. ccxt/async_support/bitpanda.py +0 -16
  460. ccxt/async_support/bl3p.py +0 -485
  461. ccxt/async_support/coinlist.py +0 -2243
  462. ccxt/async_support/currencycom.py +0 -1950
  463. ccxt/async_support/hitbtc3.py +0 -16
  464. ccxt/async_support/idex.py +0 -1766
  465. ccxt/async_support/kuna.py +0 -1841
  466. ccxt/async_support/lykke.py +0 -1270
  467. ccxt/async_support/poloniexfutures.py +0 -1717
  468. ccxt/async_support/wazirx.py +0 -1224
  469. ccxt/bitbay.py +0 -17
  470. ccxt/bitcoincom.py +0 -17
  471. ccxt/bitfinex2.py +0 -3552
  472. ccxt/bitpanda.py +0 -16
  473. ccxt/bl3p.py +0 -485
  474. ccxt/coinlist.py +0 -2243
  475. ccxt/currencycom.py +0 -1950
  476. ccxt/hitbtc3.py +0 -16
  477. ccxt/idex.py +0 -1766
  478. ccxt/kuna.py +0 -1841
  479. ccxt/lykke.py +0 -1270
  480. ccxt/poloniexfutures.py +0 -1717
  481. ccxt/pro/bitcoincom.py +0 -34
  482. ccxt/pro/bitfinex2.py +0 -1083
  483. ccxt/pro/bitpanda.py +0 -15
  484. ccxt/pro/currencycom.py +0 -536
  485. ccxt/pro/idex.py +0 -672
  486. ccxt/pro/poloniexfutures.py +0 -990
  487. ccxt/pro/wazirx.py +0 -749
  488. ccxt/test/base/__init__.py +0 -29
  489. ccxt/test/base/test_account.py +0 -26
  490. ccxt/test/base/test_balance.py +0 -56
  491. ccxt/test/base/test_borrow_interest.py +0 -35
  492. ccxt/test/base/test_borrow_rate.py +0 -32
  493. ccxt/test/base/test_calculate_fee.py +0 -51
  494. ccxt/test/base/test_crypto.py +0 -127
  495. ccxt/test/base/test_currency.py +0 -76
  496. ccxt/test/base/test_datetime.py +0 -109
  497. ccxt/test/base/test_decimal_to_precision.py +0 -392
  498. ccxt/test/base/test_deep_extend.py +0 -68
  499. ccxt/test/base/test_deposit_withdrawal.py +0 -50
  500. ccxt/test/base/test_exchange_datetime_functions.py +0 -76
  501. ccxt/test/base/test_funding_rate_history.py +0 -29
  502. ccxt/test/base/test_last_price.py +0 -31
  503. ccxt/test/base/test_ledger_entry.py +0 -45
  504. ccxt/test/base/test_ledger_item.py +0 -48
  505. ccxt/test/base/test_leverage_tier.py +0 -33
  506. ccxt/test/base/test_liquidation.py +0 -50
  507. ccxt/test/base/test_margin_mode.py +0 -24
  508. ccxt/test/base/test_margin_modification.py +0 -35
  509. ccxt/test/base/test_market.py +0 -193
  510. ccxt/test/base/test_number.py +0 -411
  511. ccxt/test/base/test_ohlcv.py +0 -33
  512. ccxt/test/base/test_open_interest.py +0 -32
  513. ccxt/test/base/test_order.py +0 -64
  514. ccxt/test/base/test_order_book.py +0 -69
  515. ccxt/test/base/test_position.py +0 -60
  516. ccxt/test/base/test_shared_methods.py +0 -353
  517. ccxt/test/base/test_status.py +0 -24
  518. ccxt/test/base/test_throttle.py +0 -126
  519. ccxt/test/base/test_ticker.py +0 -92
  520. ccxt/test/base/test_trade.py +0 -47
  521. ccxt/test/base/test_trading_fee.py +0 -26
  522. ccxt/test/base/test_transaction.py +0 -39
  523. ccxt/test/test_async.py +0 -1649
  524. ccxt/test/test_sync.py +0 -1648
  525. ccxt/wazirx.py +0 -1224
  526. ccxt_ir-4.3.46.0.3.dist-info/RECORD +0 -773
  527. /ccxt/abstract/{huobijp.py → bittrade.py} +0 -0
  528. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.1.dist-info/licenses}/LICENSE.txt +0 -0
  529. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.1.dist-info}/top_level.txt +0 -0
@@ -5,8 +5,9 @@
5
5
 
6
6
  from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.mexc import ImplicitAPI
8
+ import asyncio
8
9
  import hashlib
9
- from ccxt.base.types import Account, Balances, Currencies, Currency, IndexType, Int, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry, TransferEntries
10
+ from ccxt.base.types import Account, Any, Balances, Currencies, Currency, DepositAddress, IndexType, Int, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
10
11
  from typing import List
11
12
  from ccxt.base.errors import ExchangeError
12
13
  from ccxt.base.errors import AuthenticationError
@@ -27,7 +28,7 @@ from ccxt.base.precise import Precise
27
28
 
28
29
  class mexc(Exchange, ImplicitAPI):
29
30
 
30
- def describe(self):
31
+ def describe(self) -> Any:
31
32
  return self.deep_extend(super(mexc, self).describe(), {
32
33
  'id': 'mexc',
33
34
  'name': 'MEXC Global',
@@ -44,6 +45,9 @@ class mexc(Exchange, ImplicitAPI):
44
45
  'future': False,
45
46
  'option': False,
46
47
  'addMargin': True,
48
+ 'borrowCrossMargin': False,
49
+ 'borrowIsolatedMargin': False,
50
+ 'borrowMargin': False,
47
51
  'cancelAllOrders': True,
48
52
  'cancelOrder': True,
49
53
  'cancelOrders': None,
@@ -51,18 +55,27 @@ class mexc(Exchange, ImplicitAPI):
51
55
  'closePosition': False,
52
56
  'createDepositAddress': True,
53
57
  'createMarketBuyOrderWithCost': True,
54
- 'createMarketOrderWithCost': False,
55
- 'createMarketSellOrderWithCost': False,
58
+ 'createMarketOrderWithCost': True,
59
+ 'createMarketSellOrderWithCost': True,
56
60
  'createOrder': True,
57
61
  'createOrders': True,
58
62
  'createPostOnlyOrder': True,
59
63
  'createReduceOnlyOrder': True,
64
+ 'createStopLimitOrder': True,
65
+ 'createStopMarketOrder': True,
66
+ 'createStopOrder': True,
67
+ 'createTriggerOrder': True,
60
68
  'deposit': None,
61
69
  'editOrder': None,
62
70
  'fetchAccounts': True,
63
71
  'fetchBalance': True,
64
72
  'fetchBidsAsks': True,
65
- 'fetchBorrowRateHistory': None,
73
+ 'fetchBorrowInterest': False,
74
+ 'fetchBorrowRate': False,
75
+ 'fetchBorrowRateHistories': False,
76
+ 'fetchBorrowRateHistory': False,
77
+ 'fetchBorrowRates': False,
78
+ 'fetchBorrowRatesPerSymbol': False,
66
79
  'fetchCanceledOrders': True,
67
80
  'fetchClosedOrder': None,
68
81
  'fetchClosedOrders': True,
@@ -77,12 +90,15 @@ class mexc(Exchange, ImplicitAPI):
77
90
  'fetchDepositWithdrawFee': 'emulated',
78
91
  'fetchDepositWithdrawFees': True,
79
92
  'fetchFundingHistory': True,
93
+ 'fetchFundingInterval': True,
94
+ 'fetchFundingIntervals': False,
80
95
  'fetchFundingRate': True,
81
96
  'fetchFundingRateHistory': True,
82
- 'fetchFundingRates': None,
97
+ 'fetchFundingRates': False,
83
98
  'fetchIndexOHLCV': True,
84
99
  'fetchIsolatedBorrowRate': False,
85
100
  'fetchIsolatedBorrowRates': False,
101
+ 'fetchIsolatedPositions': False,
86
102
  'fetchL2OrderBook': True,
87
103
  'fetchLedger': None,
88
104
  'fetchLedgerEntry': None,
@@ -91,11 +107,13 @@ class mexc(Exchange, ImplicitAPI):
91
107
  'fetchLeverageTiers': True,
92
108
  'fetchMarginAdjustmentHistory': False,
93
109
  'fetchMarginMode': False,
94
- 'fetchMarketLeverageTiers': None,
110
+ 'fetchMarketLeverageTiers': 'emulated',
95
111
  'fetchMarkets': True,
96
112
  'fetchMarkOHLCV': True,
97
113
  'fetchMyTrades': True,
98
114
  'fetchOHLCV': True,
115
+ 'fetchOpenInterest': False,
116
+ 'fetchOpenInterestHistory': False,
99
117
  'fetchOpenOrder': None,
100
118
  'fetchOpenOrders': True,
101
119
  'fetchOrder': True,
@@ -103,7 +121,7 @@ class mexc(Exchange, ImplicitAPI):
103
121
  'fetchOrderBooks': None,
104
122
  'fetchOrders': True,
105
123
  'fetchOrderTrades': True,
106
- 'fetchPosition': True,
124
+ 'fetchPosition': 'emulated',
107
125
  'fetchPositionHistory': 'emulated',
108
126
  'fetchPositionMode': True,
109
127
  'fetchPositions': True,
@@ -115,8 +133,8 @@ class mexc(Exchange, ImplicitAPI):
115
133
  'fetchTickers': True,
116
134
  'fetchTime': True,
117
135
  'fetchTrades': True,
118
- 'fetchTradingFee': None,
119
- 'fetchTradingFees': True,
136
+ 'fetchTradingFee': True,
137
+ 'fetchTradingFees': False,
120
138
  'fetchTradingLimits': None,
121
139
  'fetchTransactionFee': 'emulated',
122
140
  'fetchTransactionFees': True,
@@ -129,7 +147,7 @@ class mexc(Exchange, ImplicitAPI):
129
147
  'repayCrossMargin': False,
130
148
  'repayIsolatedMargin': False,
131
149
  'setLeverage': True,
132
- 'setMarginMode': None,
150
+ 'setMarginMode': True,
133
151
  'setPositionMode': True,
134
152
  'signIn': None,
135
153
  'transfer': None,
@@ -189,6 +207,7 @@ class mexc(Exchange, ImplicitAPI):
189
207
  'allOrders': 10,
190
208
  'account': 10,
191
209
  'myTrades': 10,
210
+ 'tradeFee': 10,
192
211
  'sub-account/list': 1,
193
212
  'sub-account/apiKey': 1,
194
213
  'capital/config/getall': 10,
@@ -225,6 +244,7 @@ class mexc(Exchange, ImplicitAPI):
225
244
  'rebate/affiliate/commission/detail': 1,
226
245
  'mxDeduct/enable': 1,
227
246
  'userDataStream': 1,
247
+ 'selfSymbols': 1,
228
248
  },
229
249
  'post': {
230
250
  'order': 1,
@@ -413,7 +433,8 @@ class mexc(Exchange, ImplicitAPI):
413
433
  },
414
434
  },
415
435
  'options': {
416
- 'createMarketBuyOrderRequiresPrice': True,
436
+ 'adjustForTimeDifference': False,
437
+ 'timeDifference': 0,
417
438
  'unavailableContracts': {
418
439
  'BTC/USDT:USDT': True,
419
440
  'LTC/USDT:USDT': True,
@@ -428,6 +449,7 @@ class mexc(Exchange, ImplicitAPI):
428
449
  },
429
450
  },
430
451
  },
452
+ 'useCcxtTradeId': True,
431
453
  'timeframes': {
432
454
  'spot': {
433
455
  '1m': '1m',
@@ -437,6 +459,7 @@ class mexc(Exchange, ImplicitAPI):
437
459
  '1h': '60m',
438
460
  '4h': '4h',
439
461
  '1d': '1d',
462
+ '1w': '1W',
440
463
  '1M': '1M',
441
464
  },
442
465
  'swap': {
@@ -462,164 +485,92 @@ class mexc(Exchange, ImplicitAPI):
462
485
  'LTC': 'LTC',
463
486
  },
464
487
  'networks': {
465
- 'ABBC': 'ABBC',
488
+ 'ZKSYNC': 'ZKSYNCERA',
489
+ 'TRC20': 'TRX',
490
+ 'TON': 'TONCOIN',
491
+ 'ARBITRUM': 'ARB',
492
+ 'STX': 'STACKS',
493
+ 'LUNC': 'LUNA',
494
+ 'STARK': 'STARKNET',
495
+ 'APT': 'APTOS',
496
+ 'PEAQ': 'PEAQEVM',
497
+ 'AVAXC': 'AVAX_CCHAIN',
498
+ 'ERC20': 'ETH',
466
499
  'ACA': 'ACALA',
467
- 'ADA': 'Cardano(ADA)',
468
- 'AE': 'AE',
469
- 'ALGO': 'Algorand(ALGO)',
470
- 'ALPH': 'Alephium(ALPH)',
471
- 'AME': 'AME',
472
- 'AOK': 'AOK',
473
- 'APT': 'APTOS(APT)',
474
- 'AR': 'AR',
475
- 'ARB': 'Arbitrum One(ARB)',
476
- 'ARBNOVA': 'ARBNOVA',
477
- 'ARBONE': 'ArbitrumOne(ARB)',
478
- 'ARK': 'ARK',
500
+ 'BEP20': 'BSC',
501
+ 'OPTIMISM': 'OP',
502
+ # 'ADA': 'Cardano(ADA)',
503
+ # 'AE': 'AE',
504
+ # 'ALGO': 'Algorand(ALGO)',
505
+ # 'ALPH': 'Alephium(ALPH)',
506
+ # 'ARB': 'Arbitrum One(ARB)',
507
+ # 'ARBONE': 'ArbitrumOne(ARB)',
479
508
  'ASTR': 'ASTAR', # ASTAREVM is different
480
- 'ATOM': 'Cosmos(ATOM)',
481
- 'AVAXC': 'Avalanche C Chain(AVAX CCHAIN)',
482
- 'AVAXX': 'Avalanche X Chain(AVAX XCHAIN)',
483
- 'AZERO': 'Aleph Zero(AZERO)',
484
- 'BCH': 'Bitcoin Cash(BCH)',
485
- 'BDX': 'BDX',
486
- 'BEAM': 'BEAM',
487
- 'BEP2': 'BNB Beacon Chain(BEP2)',
488
- 'BEP20': 'BNB Smart Chain(BEP20)',
489
- 'BITCI': 'BITCI',
490
- 'BNC': 'BNC',
491
- 'BNCDOT': 'BNCPOLKA',
492
- 'BOBA': 'BOBA',
493
- 'BSC': 'BEP20(BSC)',
494
- 'BSV': 'Bitcoin SV(BSV)',
495
- 'BTC': 'Bitcoin(BTC)',
509
+ # 'ATOM': 'Cosmos(ATOM)',
510
+ # 'AVAXC': 'Avalanche C Chain(AVAX CCHAIN)',
511
+ # 'AVAXX': 'Avalanche X Chain(AVAX XCHAIN)',
512
+ # 'AZERO': 'Aleph Zero(AZERO)',
513
+ # 'BCH': 'Bitcoin Cash(BCH)',
514
+ # 'BNCDOT': 'BNCPOLKA',
515
+ # 'BSV': 'Bitcoin SV(BSV)',
516
+ # 'BTC': 'Bitcoin(BTC)',
496
517
  'BTM': 'BTM2',
497
- 'CELO': 'CELO',
498
- 'CFX': 'CFX',
499
- 'CHZ': 'Chiliz Legacy Chain(CHZ)',
500
- 'CHZ2': 'Chiliz Chain(CHZ2)',
501
- 'CKB': 'CKB',
502
- 'CLORE': 'Clore.ai(CLORE)',
518
+ # 'CHZ': 'Chiliz Legacy Chain(CHZ)',
519
+ # 'CHZ2': 'Chiliz Chain(CHZ2)',
520
+ # 'CLORE': 'Clore.ai(CLORE)',
503
521
  'CRC20': 'CRONOS',
504
- 'CSPR': 'CSPR',
505
- 'DASH': 'DASH',
506
- 'DC': 'Dogechain(DC)',
507
- 'DCR': 'DCR',
508
- 'DNX': 'Dynex(DNX)',
509
- 'DOGE': 'Dogecoin(DOGE)',
510
- 'DOT': 'Polkadot(DOT)',
511
- 'DYM': 'Dymension(DYM)',
512
- 'EDG': 'EDG',
513
- 'EGLD': 'EGLD',
514
- 'EOS': 'EOS',
515
- 'ERC20': 'Ethereum(ERC20)',
516
- 'ETC': 'Ethereum Classic(ETC)',
522
+ # 'DC': 'Dogechain(DC)',
523
+ # 'DNX': 'Dynex(DNX)',
524
+ # 'DOGE': 'Dogecoin(DOGE)',
525
+ # 'DOT': 'Polkadot(DOT)',
526
+ 'DOT': 'DOTASSETHUB',
527
+ # 'DYM': 'Dymension(DYM)',
517
528
  'ETHF': 'ETF',
518
- 'ETHW': 'ETHW',
519
- 'EVER': 'EVER',
520
- 'FET': 'FET',
521
- 'FIL': 'FIL',
522
- 'FIO': 'FIO',
523
- 'FLOW': 'FLOW',
524
- 'FSN': 'FSN',
525
- 'FTM': 'Fantom(FTM)',
526
- 'FUSE': 'FUSE',
527
- 'GLMR': 'GLMR',
528
- 'GRIN': 'GRIN',
529
- 'HBAR': 'Hedera(HBAR)',
530
- 'HIVE': 'HIVE',
531
529
  'HRC20': 'HECO',
532
- 'HYDRA': 'HYDRA',
533
- 'ICP': 'Internet Computer(ICP)',
534
- 'INDEX': 'Index Chain',
535
- 'IOST': 'IOST',
536
- 'IOTA': 'IOTA',
537
- 'IOTX': 'IOTX',
538
- 'IRIS': 'IRIS',
539
- 'KAR': 'KAR',
540
- 'KAS': 'Kaspa(KAS)',
541
- 'KAVA': 'KAVA',
542
- 'KDA': 'KDA',
543
- 'KILT': 'KILT',
544
- 'KLAY': 'Klaytn(KLAY)',
545
- 'KMA': 'KMA',
546
- 'KSM': 'KSM',
547
- 'LAT': 'LAT',
548
- 'LAVA': 'Elysium(LAVA)',
549
- 'LTC': 'Litecoin(LTC)',
550
- 'LUNA': 'Terra(LUNA)',
551
- 'MASS': 'MASS',
552
- 'MATIC': 'Polygon(MATIC)',
553
- 'MCOIN': 'Mcoin Network',
554
- 'METIS': 'METIS',
555
- 'MINA': 'MINA',
556
- 'MNT': 'Mantle(MNT)',
557
- 'MOVR': 'MOVR',
558
- 'MTRG': 'Meter(MTRG)',
559
- 'NAS': 'NAS',
560
- 'NEAR': 'NEAR Protocol(NEAR)',
561
- 'NEBL': 'NEBL',
562
- 'NEM': 'NEM',
563
- 'NEO': 'NEO',
564
- 'NEO3': 'NEO3',
565
- 'NEOXA': 'Neoxa Network',
566
- 'NULS': 'NULS',
530
+ # 'KLAY': 'Klaytn(KLAY)',
567
531
  'OASIS': 'ROSE',
568
- 'OASYS': 'OASYS',
569
532
  'OKC': 'OKT',
570
- 'OMN': 'Omega Network(OMN)',
571
- 'OMNI': 'OMNI',
572
- 'ONE': 'ONE',
573
- 'ONT': 'ONT',
574
- 'OPTIMISM': 'Optimism(OP)',
575
- 'OSMO': 'OSMO',
576
- 'PLCU': 'PLCU',
577
- 'POKT': 'POKT',
578
- 'QKC': 'QKC',
579
- 'QTUM': 'QTUM',
580
- 'RAP20': 'RAP20(Rangers Mainnet)',
581
- 'REI': 'REI',
582
533
  'RSK': 'RBTC',
583
- 'RVN': 'Ravencoin(RVN)',
584
- 'SATOX': 'Satoxcoin(SATOX)',
585
- 'SC': 'SC',
586
- 'SCRT': 'SCRT',
587
- 'SDN': 'SDN',
588
- 'SGB': 'SGB',
589
- 'SOL': 'Solana(SOL)',
590
- 'STAR': 'STAR',
591
- 'STARK': 'Starknet(STARK)',
592
- 'STEEM': 'STEEM',
593
- 'SYS': 'SYS',
594
- 'TAO': 'Bittensor(TAO)',
595
- 'TIA': 'Celestia(TIA)',
596
- 'TOMO': 'TOMO',
597
- 'TON': 'Toncoin(TON)',
598
- 'TRC10': 'TRC10',
599
- 'TRC20': 'Tron(TRC20)',
600
- 'UGAS': 'UGAS(Ultrain)',
601
- 'VET': 'VeChain(VET)',
602
- 'VEX': 'Vexanium(VEX)',
603
- 'VSYS': 'VSYS',
604
- 'WAVES': 'WAVES',
605
- 'WAX': 'WAX',
606
- 'WEMIX': 'WEMIX',
607
- 'XCH': 'Chia(XCH)',
608
- 'XDC': 'XDC',
609
- 'XEC': 'XEC',
610
- 'XLM': 'Stellar(XLM)',
611
- 'XMR': 'Monero(XMR)',
612
- 'XNA': 'Neurai(XNA)',
613
- 'XPR': 'XPR Network',
614
- 'XRD': 'XRD',
615
- 'XRP': 'Ripple(XRP)',
616
- 'XTZ': 'XTZ',
617
- 'XVG': 'XVG',
618
- 'XYM': 'XYM',
619
- 'ZEC': 'ZEC',
620
- 'ZEN': 'ZEN',
621
- 'ZIL': 'Zilliqa(ZIL)',
622
- 'ZTG': 'ZTG',
534
+ # 'RVN': 'Ravencoin(RVN)',
535
+ # 'SATOX': 'Satoxcoin(SATOX)',
536
+ # 'SC': 'SC',
537
+ # 'SCRT': 'SCRT',
538
+ # 'SDN': 'SDN',
539
+ # 'SGB': 'SGB',
540
+ # 'SOL': 'Solana(SOL)',
541
+ # 'STAR': 'STAR',
542
+ # 'STARK': 'Starknet(STARK)',
543
+ # 'STEEM': 'STEEM',
544
+ # 'SYS': 'SYS',
545
+ # 'TAO': 'Bittensor(TAO)',
546
+ # 'TIA': 'Celestia(TIA)',
547
+ # 'TOMO': 'TOMO',
548
+ # 'TON': 'Toncoin(TON)',
549
+ # 'TRC10': 'TRC10',
550
+ # 'TRC20': 'Tron(TRC20)',
551
+ # 'UGAS': 'UGAS(Ultrain)',
552
+ # 'VET': 'VeChain(VET)',
553
+ # 'VEX': 'Vexanium(VEX)',
554
+ # 'VSYS': 'VSYS',
555
+ # 'WAVES': 'WAVES',
556
+ # 'WAX': 'WAX',
557
+ # 'WEMIX': 'WEMIX',
558
+ # 'XCH': 'Chia(XCH)',
559
+ # 'XDC': 'XDC',
560
+ # 'XEC': 'XEC',
561
+ # 'XLM': 'Stellar(XLM)',
562
+ # 'XMR': 'Monero(XMR)',
563
+ # 'XNA': 'Neurai(XNA)',
564
+ # 'XPR': 'XPR Network',
565
+ # 'XRD': 'XRD',
566
+ # 'XRP': 'Ripple(XRP)',
567
+ # 'XTZ': 'XTZ',
568
+ # 'XVG': 'XVG',
569
+ # 'XYM': 'XYM',
570
+ # 'ZEC': 'ZEC',
571
+ # 'ZEN': 'ZEN',
572
+ # 'ZIL': 'Zilliqa(ZIL)',
573
+ # 'ZTG': 'ZTG',
623
574
  # todo: uncomment below after concensus
624
575
  # 'ALAYA': 'ATP',
625
576
  # 'ANDUSCHAIN': 'DEB',
@@ -727,69 +678,10 @@ class mexc(Exchange, ImplicitAPI):
727
678
  # OKB <> OKT(for usdt it's exception) for OKC, PMEER, FLARE, STRD, ZEL, FUND, "NONE", CRING, FREETON, QTZ (probably unique network is meant), HT, BSC(RACAV1), BSC(RACAV2), AMBROSUS, BAJUN, NOM. their individual info is at https://www.mexc.com/api/platform/asset/spot/{COINNAME}
728
679
  },
729
680
  'networksById': {
730
- 'Aleph Zero(AZERO)': 'AZERO',
731
- 'Alephium(ALPH)': 'ALPH',
732
- 'Algorand(ALGO)': 'ALGO',
733
- 'APTOS(APT)': 'APT',
734
- 'Arbitrum One(ARB)': 'ARB',
735
- 'Avalanche C Chain(AVAX CCHAIN)': 'AVAXC',
736
- 'Avalanche X Chain(AVAX XCHAIN)': 'AVAXX',
737
- 'BEP20(BSC)': 'BSC',
738
- 'Bitcoin Cash(BCH)': 'BCH',
739
- 'Bitcoin SV(BSV)': 'BSV',
740
- 'Bitcoin(BTC)': 'BTC',
741
- 'Bittensor(TAO)': 'TAO',
742
- 'BNB Beacon Chain(BEP2)': 'BEP2',
743
681
  'BNB Smart Chain(BEP20-RACAV1)': 'BSC',
744
682
  'BNB Smart Chain(BEP20-RACAV2)': 'BSC',
745
683
  'BNB Smart Chain(BEP20)': 'BSC',
746
- 'Cardano(ADA)': 'ADA',
747
- 'Celestia(TIA)': 'TIA',
748
- 'Chia(XCH)': 'XCH',
749
- 'Chiliz Chain(CHZ2)': 'CHZ2',
750
- 'Chiliz Legacy Chain(CHZ)': 'CHZ',
751
- 'Clore.ai(CLORE)': 'CLORE',
752
- 'Cosmos(ATOM)': 'ATOM',
753
- 'Dogechain(DC)': 'DC',
754
- 'Dogecoin(DOGE)': 'DOGE',
755
- 'Dymension(DYM)': 'DYM',
756
- 'Dynex(DNX)': 'DNX',
757
- 'Elysium(LAVA)': 'LAVA',
758
- 'Ethereum Classic(ETC)': 'ETC',
759
684
  'Ethereum(ERC20)': 'ERC20',
760
- 'Fantom(FTM)': 'FTM',
761
- 'Hedera(HBAR)': 'HBAR',
762
- 'Index Chain': 'INDEX',
763
- 'Internet Computer(ICP)': 'ICP',
764
- 'Kaspa(KAS)': 'KAS',
765
- 'Klaytn(KLAY)': 'KLAY',
766
- 'Litecoin(LTC)': 'LTC',
767
- 'Mantle(MNT)': 'MNT',
768
- 'Mcoin Network': 'MCOIN',
769
- 'Meter(MTRG)': 'MTRG',
770
- 'Monero(XMR)': 'XMR',
771
- 'NEAR Protocol(NEAR)': 'NEAR',
772
- 'Neoxa Network': 'NEOXA',
773
- 'Neurai(XNA)': 'XNA',
774
- 'Omega Network(OMN)': 'OMN',
775
- 'Optimism(OP)': 'OPTIMISM',
776
- 'Polkadot(DOT)': 'DOT',
777
- 'Polygon(MATIC)': 'MATIC',
778
- 'RAP20(Rangers Mainnet)': 'RAP20',
779
- 'Ravencoin(RVN)': 'RVN',
780
- 'Ripple(XRP)': 'XRP',
781
- 'Satoxcoin(SATOX)': 'SATOX',
782
- 'Solana(SOL)': 'SOL',
783
- 'Starknet(STARK)': 'STARK',
784
- 'Stellar(XLM)': 'XLM',
785
- 'Terra(LUNA)': 'LUNA',
786
- 'Toncoin(TON)': 'TON',
787
- 'Tron(TRC20)': 'TRC20',
788
- 'UGAS(Ultrain)': 'UGAS',
789
- 'VeChain(VET)': 'VET',
790
- 'Vexanium(VEX)': 'VEX',
791
- 'XPR Network': 'XPR',
792
- 'Zilliqa(ZIL)': 'ZIL',
793
685
  # TODO: uncomment below after deciding unified name
794
686
  # 'PEPE COIN BSC':
795
687
  # 'SMART BLOCKCHAIN':
@@ -807,27 +699,172 @@ class mexc(Exchange, ImplicitAPI):
807
699
  'maxTimeTillEnd': 90 * 86400 * 1000 - 1, # 90 days
808
700
  'broker': 'CCXT',
809
701
  },
702
+ 'features': {
703
+ 'default': {
704
+ 'sandbox': False,
705
+ 'createOrder': {
706
+ 'marginMode': True,
707
+ 'triggerPrice': False,
708
+ 'triggerDirection': False,
709
+ 'triggerPriceType': {
710
+ 'last': False,
711
+ 'mark': False,
712
+ 'index': False,
713
+ },
714
+ 'stopLossPrice': False, # todo
715
+ 'takeProfitPrice': False,
716
+ 'attachedStopLossTakeProfit': None,
717
+ 'timeInForce': {
718
+ 'IOC': True,
719
+ 'FOK': True,
720
+ 'PO': True,
721
+ 'GTD': False,
722
+ },
723
+ 'hedged': True, # todo implement
724
+ 'trailing': False,
725
+ 'leverage': True, # todo implement
726
+ 'marketBuyByCost': True,
727
+ 'marketBuyRequiresPrice': False,
728
+ 'selfTradePrevention': False,
729
+ 'iceberg': False,
730
+ },
731
+ 'createOrders': {
732
+ 'max': 20,
733
+ },
734
+ 'fetchMyTrades': {
735
+ 'marginMode': False,
736
+ 'limit': 100,
737
+ 'daysBack': 30,
738
+ 'untilDays': None,
739
+ 'symbolRequired': True,
740
+ },
741
+ 'fetchOrder': {
742
+ 'marginMode': False,
743
+ 'trigger': False,
744
+ 'trailing': False,
745
+ 'symbolRequired': True,
746
+ },
747
+ 'fetchOpenOrders': {
748
+ 'marginMode': True,
749
+ 'limit': None,
750
+ 'trigger': False,
751
+ 'trailing': False,
752
+ 'symbolRequired': True,
753
+ },
754
+ 'fetchOrders': {
755
+ 'marginMode': True,
756
+ 'limit': 1000,
757
+ 'daysBack': 7,
758
+ 'untilDays': 7,
759
+ 'trigger': False,
760
+ 'trailing': False,
761
+ 'symbolRequired': True,
762
+ },
763
+ 'fetchClosedOrders': {
764
+ 'marginMode': True,
765
+ 'limit': 1000,
766
+ 'daysBack': 7,
767
+ 'daysBackCanceled': 7,
768
+ 'untilDays': 7,
769
+ 'trigger': False,
770
+ 'trailing': False,
771
+ 'symbolRequired': True,
772
+ },
773
+ 'fetchOHLCV': {
774
+ 'limit': 1000,
775
+ },
776
+ },
777
+ 'spot': {
778
+ 'extends': 'default',
779
+ },
780
+ 'forDerivs': {
781
+ 'extends': 'default',
782
+ 'createOrder': {
783
+ 'triggerPrice': True,
784
+ 'triggerPriceType': {
785
+ 'last': True,
786
+ 'mark': True,
787
+ 'index': True,
788
+ },
789
+ 'triggerDirection': True, # todo
790
+ 'stopLossPrice': False, # todo
791
+ 'takeProfitPrice': False, # todo
792
+ 'hedged': True,
793
+ 'leverage': True, # todo
794
+ 'marketBuyByCost': False,
795
+ },
796
+ 'createOrders': None, # todo: needs implementation https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance:~:text=Order%20the%20contract%20in%20batch
797
+ 'fetchMyTrades': {
798
+ 'marginMode': False,
799
+ 'limit': 100,
800
+ 'daysBack': 90,
801
+ 'untilDays': 90,
802
+ },
803
+ 'fetchOrder': {
804
+ 'marginMode': False,
805
+ },
806
+ 'fetchOpenOrders': {
807
+ 'marginMode': False,
808
+ 'limit': 100,
809
+ 'trigger': True,
810
+ 'trailing': False,
811
+ },
812
+ 'fetchOrders': {
813
+ 'marginMode': False,
814
+ 'limit': 100,
815
+ 'daysBack': 90,
816
+ 'untilDays': 90,
817
+ 'trigger': True,
818
+ 'trailing': False,
819
+ },
820
+ 'fetchClosedOrders': {
821
+ 'marginMode': False,
822
+ 'limit': 100,
823
+ 'daysBack': 90,
824
+ 'daysBackCanceled': None,
825
+ 'untilDays': 90,
826
+ 'trigger': True,
827
+ 'trailing': False,
828
+ },
829
+ 'fetchOHLCV': {
830
+ 'limit': 2000,
831
+ },
832
+ },
833
+ 'swap': {
834
+ 'linear': {
835
+ 'extends': 'forDerivs',
836
+ },
837
+ 'inverse': {
838
+ 'extends': 'forDerivs',
839
+ },
840
+ },
841
+ 'future': {
842
+ 'linear': None,
843
+ 'inverse': None,
844
+ },
845
+ },
810
846
  'commonCurrencies': {
811
847
  'BEYONDPROTOCOL': 'BEYOND',
812
848
  'BIFI': 'BIFIF',
813
- 'BYN': 'BeyondFi',
849
+ 'BYN': 'BEYONDFI',
814
850
  'COFI': 'COFIX', # conflict with CoinFi
815
- 'DFI': 'DfiStarter',
816
- 'DFT': 'dFuture',
851
+ 'DFI': 'DFISTARTER',
852
+ 'DFT': 'DFUTURE',
817
853
  'DRK': 'DRK',
818
- 'EGC': 'Egoras Credit',
854
+ 'EGC': 'EGORASCREDIT',
819
855
  'FLUX1': 'FLUX', # switched places
820
856
  'FLUX': 'FLUX1', # switched places
821
- 'FREE': 'FreeRossDAO', # conflict with FREE Coin
857
+ 'FREE': 'FREEROSSDAO', # conflict with FREE Coin
822
858
  'GAS': 'GASDAO',
823
859
  'GASNEO': 'GAS',
824
- 'GMT': 'GMT Token', # Conflict with GMT(STEPN)
860
+ 'GMT': 'GMTTOKEN', # Conflict with GMT(STEPN)
825
861
  'STEPN': 'GMT', # Conflict with GMT Token
826
- 'HERO': 'Step Hero', # conflict with Metahero
827
- 'MIMO': 'Mimosa',
828
- 'PROS': 'Pros.Finance', # conflict with Prosper
829
- 'SIN': 'Sin City Token',
830
- 'SOUL': 'Soul Swap',
862
+ 'HERO': 'STEPHERO', # conflict with Metahero
863
+ 'MIMO': 'MIMOSA',
864
+ 'PROS': 'PROSFINANCE', # conflict with Prosper
865
+ 'SIN': 'SINCITYTOKEN',
866
+ 'SOUL': 'SOULSWAP',
867
+ 'XBT': 'XBT', # restore original mapping
831
868
  },
832
869
  'exceptions': {
833
870
  'exact': {
@@ -951,6 +988,10 @@ class mexc(Exchange, ImplicitAPI):
951
988
  async def fetch_status(self, params={}):
952
989
  """
953
990
  the latest known information on the availability of the exchange API
991
+
992
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#test-connectivity
993
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-server-time
994
+
954
995
  :param dict [params]: extra parameters specific to the exchange API endpoint
955
996
  :returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
956
997
  """
@@ -981,9 +1022,13 @@ class mexc(Exchange, ImplicitAPI):
981
1022
  'info': response,
982
1023
  }
983
1024
 
984
- async def fetch_time(self, params={}):
1025
+ async def fetch_time(self, params={}) -> Int:
985
1026
  """
986
1027
  fetches the current integer timestamp in milliseconds from the exchange server
1028
+
1029
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#check-server-time
1030
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-server-time
1031
+
987
1032
  :param dict [params]: extra parameters specific to the exchange API endpoint
988
1033
  :returns int: the current integer timestamp in milliseconds from the exchange server
989
1034
  """
@@ -1006,7 +1051,9 @@ class mexc(Exchange, ImplicitAPI):
1006
1051
  async def fetch_currencies(self, params={}) -> Currencies:
1007
1052
  """
1008
1053
  fetches all available currencies on an exchange
1009
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
1054
+
1055
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
1056
+
1010
1057
  :param dict [params]: extra parameters specific to the exchange API endpoint
1011
1058
  :returns dict: an associative dictionary of currencies
1012
1059
  """
@@ -1060,94 +1107,77 @@ class mexc(Exchange, ImplicitAPI):
1060
1107
  currency = response[i]
1061
1108
  id = self.safe_string(currency, 'coin')
1062
1109
  code = self.safe_currency_code(id)
1063
- name = self.safe_string(currency, 'name')
1064
- currencyActive = False
1065
- currencyFee = None
1066
- currencyWithdrawMin = None
1067
- currencyWithdrawMax = None
1068
- depositEnabled = False
1069
- withdrawEnabled = False
1070
1110
  networks: dict = {}
1071
1111
  chains = self.safe_value(currency, 'networkList', [])
1072
1112
  for j in range(0, len(chains)):
1073
1113
  chain = chains[j]
1074
- networkId = self.safe_string_2(chain, 'network', 'netWork')
1114
+ networkId = self.safe_string_2(chain, 'netWork', 'network')
1075
1115
  network = self.network_id_to_code(networkId)
1076
- isDepositEnabled = self.safe_bool(chain, 'depositEnable', False)
1077
- isWithdrawEnabled = self.safe_bool(chain, 'withdrawEnable', False)
1078
- active = (isDepositEnabled and isWithdrawEnabled)
1079
- currencyActive = active or currencyActive
1080
- withdrawMin = self.safe_string(chain, 'withdrawMin')
1081
- withdrawMax = self.safe_string(chain, 'withdrawMax')
1082
- currencyWithdrawMin = withdrawMin if (currencyWithdrawMin is None) else currencyWithdrawMin
1083
- currencyWithdrawMax = withdrawMax if (currencyWithdrawMax is None) else currencyWithdrawMax
1084
- fee = self.safe_number(chain, 'withdrawFee')
1085
- currencyFee = fee if (currencyFee is None) else currencyFee
1086
- if Precise.string_gt(currencyWithdrawMin, withdrawMin):
1087
- currencyWithdrawMin = withdrawMin
1088
- if Precise.string_lt(currencyWithdrawMax, withdrawMax):
1089
- currencyWithdrawMax = withdrawMax
1090
- if isDepositEnabled:
1091
- depositEnabled = True
1092
- if isWithdrawEnabled:
1093
- withdrawEnabled = True
1094
1116
  networks[network] = {
1095
1117
  'info': chain,
1096
1118
  'id': networkId,
1097
1119
  'network': network,
1098
- 'active': active,
1099
- 'deposit': isDepositEnabled,
1100
- 'withdraw': isWithdrawEnabled,
1101
- 'fee': fee,
1120
+ 'active': None,
1121
+ 'deposit': self.safe_bool(chain, 'depositEnable', False),
1122
+ 'withdraw': self.safe_bool(chain, 'withdrawEnable', False),
1123
+ 'fee': self.safe_number(chain, 'withdrawFee'),
1102
1124
  'precision': None,
1103
1125
  'limits': {
1104
1126
  'withdraw': {
1105
- 'min': withdrawMin,
1106
- 'max': withdrawMax,
1127
+ 'min': self.safe_string(chain, 'withdrawMin'),
1128
+ 'max': self.safe_string(chain, 'withdrawMax'),
1107
1129
  },
1108
1130
  },
1131
+ 'contract': self.safe_string(chain, 'contract'),
1109
1132
  }
1110
- networkKeys = list(networks.keys())
1111
- networkKeysLength = len(networkKeys)
1112
- if (networkKeysLength == 1) or ('NONE' in networks):
1113
- defaultNetwork = self.safe_value_2(networks, 'NONE', networkKeysLength - 1)
1114
- if defaultNetwork is not None:
1115
- currencyFee = defaultNetwork['fee']
1116
- result[code] = {
1133
+ result[code] = self.safe_currency_structure({
1117
1134
  'info': currency,
1118
1135
  'id': id,
1119
1136
  'code': code,
1120
- 'name': name,
1121
- 'active': currencyActive,
1122
- 'deposit': depositEnabled,
1123
- 'withdraw': withdrawEnabled,
1124
- 'fee': currencyFee,
1137
+ 'name': self.safe_string(currency, 'name'),
1138
+ 'active': None,
1139
+ 'deposit': None,
1140
+ 'withdraw': None,
1141
+ 'fee': None,
1125
1142
  'precision': None,
1126
1143
  'limits': {
1127
1144
  'amount': {
1128
1145
  'min': None,
1129
1146
  'max': None,
1130
1147
  },
1131
- 'withdraw': {
1132
- 'min': currencyWithdrawMin,
1133
- 'max': currencyWithdrawMax,
1134
- },
1135
1148
  },
1149
+ 'type': 'crypto',
1136
1150
  'networks': networks,
1137
- }
1151
+ })
1138
1152
  return result
1139
1153
 
1140
1154
  async def fetch_markets(self, params={}) -> List[Market]:
1141
1155
  """
1142
1156
  retrieves data on all markets for mexc
1157
+
1158
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#exchange-information
1159
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
1160
+
1143
1161
  :param dict [params]: extra parameters specific to the exchange API endpoint
1144
1162
  :returns dict[]: an array of objects representing market data
1145
1163
  """
1146
- spotMarket = await self.fetch_spot_markets(params)
1147
- swapMarket = await self.fetch_swap_markets(params)
1164
+ if self.options['adjustForTimeDifference']:
1165
+ await self.load_time_difference()
1166
+ spotMarketPromise = self.fetch_spot_markets(params)
1167
+ swapMarketPromise = self.fetch_swap_markets(params)
1168
+ spotMarket, swapMarket = await asyncio.gather(*[spotMarketPromise, swapMarketPromise])
1148
1169
  return self.array_concat(spotMarket, swapMarket)
1149
1170
 
1150
1171
  async def fetch_spot_markets(self, params={}):
1172
+ """
1173
+ @ignore
1174
+ retrieves data on all spot markets for mexc
1175
+
1176
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#exchange-information
1177
+
1178
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1179
+ :returns dict[]: an array of objects representing market data
1180
+ """
1151
1181
  response = await self.spotPublicGetExchangeInfo(params)
1152
1182
  #
1153
1183
  # {
@@ -1158,7 +1188,7 @@ class mexc(Exchange, ImplicitAPI):
1158
1188
  # "symbols": [
1159
1189
  # {
1160
1190
  # "symbol": "OGNUSDT",
1161
- # "status": "ENABLED",
1191
+ # "status": "1",
1162
1192
  # "baseAsset": "OGN",
1163
1193
  # "baseAssetPrecision": "2",
1164
1194
  # "quoteAsset": "USDT",
@@ -1203,7 +1233,7 @@ class mexc(Exchange, ImplicitAPI):
1203
1233
  status = self.safe_string(market, 'status')
1204
1234
  isSpotTradingAllowed = self.safe_value(market, 'isSpotTradingAllowed')
1205
1235
  active = False
1206
- if (status == 'ENABLED') and (isSpotTradingAllowed):
1236
+ if (status == '1') and (isSpotTradingAllowed):
1207
1237
  active = True
1208
1238
  isMarginTradingAllowed = self.safe_value(market, 'isMarginTradingAllowed')
1209
1239
  makerCommission = self.safe_number(market, 'makerCommission')
@@ -1263,7 +1293,19 @@ class mexc(Exchange, ImplicitAPI):
1263
1293
  return result
1264
1294
 
1265
1295
  async def fetch_swap_markets(self, params={}):
1296
+ """
1297
+ @ignore
1298
+ retrieves data on all swap markets for mexc
1299
+
1300
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
1301
+
1302
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1303
+ :returns dict[]: an array of objects representing market data
1304
+ """
1305
+ currentRl: number = self.rateLimit
1306
+ self.set_property(self, 'rateLimit', 10) # see comment: https://github.com/ccxt/ccxt/pull/23698
1266
1307
  response = await self.contractPublicGetDetail(params)
1308
+ self.set_property(self, 'rateLimit', currentRl)
1267
1309
  #
1268
1310
  # {
1269
1311
  # "success":true,
@@ -1320,6 +1362,7 @@ class mexc(Exchange, ImplicitAPI):
1320
1362
  quote = self.safe_currency_code(quoteId)
1321
1363
  settle = self.safe_currency_code(settleId)
1322
1364
  state = self.safe_string(market, 'state')
1365
+ isLinear = quote == settle
1323
1366
  result.append({
1324
1367
  'id': id,
1325
1368
  'symbol': base + '/' + quote + ':' + settle,
@@ -1337,8 +1380,8 @@ class mexc(Exchange, ImplicitAPI):
1337
1380
  'option': False,
1338
1381
  'active': (state == '0'),
1339
1382
  'contract': True,
1340
- 'linear': True,
1341
- 'inverse': False,
1383
+ 'linear': isLinear,
1384
+ 'inverse': not isLinear,
1342
1385
  'taker': self.safe_number(market, 'takerFeeRate'),
1343
1386
  'maker': self.safe_number(market, 'makerFeeRate'),
1344
1387
  'contractSize': self.safe_number(market, 'contractSize'),
@@ -1375,8 +1418,10 @@ class mexc(Exchange, ImplicitAPI):
1375
1418
 
1376
1419
  async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
1377
1420
  """
1378
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#order-book
1379
- :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-s-depth-information
1421
+
1422
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#order-book
1423
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-s-depth-information
1424
+
1380
1425
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1381
1426
  :param str symbol: unified symbol of the market to fetch the order book for
1382
1427
  :param int [limit]: the maximum amount of order book entries to return
@@ -1446,9 +1491,11 @@ class mexc(Exchange, ImplicitAPI):
1446
1491
 
1447
1492
  async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1448
1493
  """
1449
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#recent-trades-list
1450
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#compressed-aggregate-trades-list
1451
- :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-transaction-data
1494
+
1495
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#recent-trades-list
1496
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#compressed-aggregate-trades-list
1497
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-transaction-data
1498
+
1452
1499
  get the list of most recent trades for a particular symbol
1453
1500
  :param str symbol: unified symbol of the market to fetch trades for
1454
1501
  :param int [since]: timestamp in ms of the earliest trade to fetch
@@ -1657,8 +1704,8 @@ class mexc(Exchange, ImplicitAPI):
1657
1704
  'cost': self.safe_string(trade, 'commission'),
1658
1705
  'currency': self.safe_currency_code(feeAsset),
1659
1706
  }
1660
- if id is None:
1661
- id = self.synthetic_trade_id(market, timestamp, side, amountString, priceString, type, takerOrMaker)
1707
+ if id is None and self.safe_bool(self.options, 'useCcxtTradeId', True):
1708
+ id = self.create_ccxt_trade_id(timestamp, side, amountString, priceString, takerOrMaker)
1662
1709
  return self.safe_trade({
1663
1710
  'id': id,
1664
1711
  'order': orderId,
@@ -1675,27 +1722,12 @@ class mexc(Exchange, ImplicitAPI):
1675
1722
  'info': trade,
1676
1723
  }, market)
1677
1724
 
1678
- def synthetic_trade_id(self, market=None, timestamp=None, side=None, amount=None, price=None, orderType=None, takerOrMaker=None):
1679
- # TODO: can be unified method? self approach is being used by multiple exchanges(mexc, woo-coinsbit, dydx, ...)
1680
- id = ''
1681
- if timestamp is not None:
1682
- id = self.number_to_string(timestamp) + '-' + self.safe_string(market, 'id', '_')
1683
- if side is not None:
1684
- id += '-' + side
1685
- if amount is not None:
1686
- id += '-' + self.number_to_string(amount)
1687
- if price is not None:
1688
- id += '-' + self.number_to_string(price)
1689
- if takerOrMaker is not None:
1690
- id += '-' + takerOrMaker
1691
- if orderType is not None:
1692
- id += '-' + orderType
1693
- return id
1694
-
1695
1725
  async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1696
1726
  """
1697
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-candlestick-data
1698
- :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#k-line-data
1727
+
1728
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-candlestick-data
1729
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#k-line-data
1730
+
1699
1731
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1700
1732
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1701
1733
  :param str timeframe: the length of time each candle represents
@@ -1802,6 +1834,10 @@ class mexc(Exchange, ImplicitAPI):
1802
1834
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
1803
1835
  """
1804
1836
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1837
+
1838
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
1839
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
1840
+
1805
1841
  :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1806
1842
  :param dict [params]: extra parameters specific to the exchange API endpoint
1807
1843
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -1883,6 +1919,10 @@ class mexc(Exchange, ImplicitAPI):
1883
1919
  async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
1884
1920
  """
1885
1921
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1922
+
1923
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
1924
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-trend-data
1925
+
1886
1926
  :param str symbol: unified symbol of the market to fetch the ticker for
1887
1927
  :param dict [params]: extra parameters specific to the exchange API endpoint
1888
1928
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -2065,6 +2105,9 @@ class mexc(Exchange, ImplicitAPI):
2065
2105
  async def fetch_bids_asks(self, symbols: Strings = None, params={}):
2066
2106
  """
2067
2107
  fetches the bid and ask price and volume for multiple markets
2108
+
2109
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#symbol-order-book-ticker
2110
+
2068
2111
  :param str[]|None symbols: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
2069
2112
  :param dict [params]: extra parameters specific to the exchange API endpoint
2070
2113
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -2101,7 +2144,29 @@ class mexc(Exchange, ImplicitAPI):
2101
2144
  async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
2102
2145
  """
2103
2146
  create a market buy order by providing the symbol and cost
2104
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2147
+
2148
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2149
+
2150
+ :param str symbol: unified symbol of the market to create an order in
2151
+ :param float cost: how much you want to trade in units of the quote currency
2152
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2153
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2154
+ """
2155
+ await self.load_markets()
2156
+ market = self.market(symbol)
2157
+ if not market['spot']:
2158
+ raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
2159
+ req = {
2160
+ 'cost': cost,
2161
+ }
2162
+ return await self.create_order(symbol, 'market', 'buy', 0, None, self.extend(req, params))
2163
+
2164
+ async def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
2165
+ """
2166
+ create a market sell order by providing the symbol and cost
2167
+
2168
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2169
+
2105
2170
  :param str symbol: unified symbol of the market to create an order in
2106
2171
  :param float cost: how much you want to trade in units of the quote currency
2107
2172
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2111,31 +2176,37 @@ class mexc(Exchange, ImplicitAPI):
2111
2176
  market = self.market(symbol)
2112
2177
  if not market['spot']:
2113
2178
  raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
2114
- params['createMarketBuyOrderRequiresPrice'] = False
2115
- return await self.create_order(symbol, 'market', 'buy', cost, None, params)
2179
+ req = {
2180
+ 'cost': cost,
2181
+ }
2182
+ return await self.create_order(symbol, 'market', 'sell', 0, None, self.extend(req, params))
2116
2183
 
2117
2184
  async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
2118
2185
  """
2119
2186
  create a trade order
2120
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2121
- :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
2122
- :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
2187
+
2188
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2189
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
2190
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
2191
+
2123
2192
  :param str symbol: unified symbol of the market to create an order in
2124
2193
  :param str type: 'market' or 'limit'
2125
2194
  :param str side: 'buy' or 'sell'
2126
2195
  :param float amount: how much of currency you want to trade in units of base currency
2127
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
2196
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2128
2197
  :param dict [params]: extra parameters specific to the exchange API endpoint
2129
2198
  :param str [params.marginMode]: only 'isolated' is supported for spot-margin trading
2130
2199
  :param float [params.triggerPrice]: The price at which a trigger order is triggered at
2131
2200
  :param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
2132
2201
  :param bool [params.reduceOnly]: *contract only* indicates if self order is to reduce the size of a position
2133
- *
2134
- * EXCHANGE SPECIFIC PARAMETERS
2202
+ :param bool [params.hedged]: *swap only* True for hedged mode, False for one way mode, default is False
2203
+ :param str [params.timeInForce]: 'IOC' or 'FOK', default is 'GTC'
2204
+ EXCHANGE SPECIFIC PARAMETERS
2135
2205
  :param int [params.leverage]: *contract only* leverage is necessary on isolated margin
2136
2206
  :param long [params.positionId]: *contract only* it is recommended to hasattr(self, fill) parameter when closing a position
2137
2207
  :param str [params.externalOid]: *contract only* external order ID
2138
2208
  :param int [params.positionMode]: *contract only* 1:hedge, 2:one-way, default: the user's current config
2209
+ :param boolean [params.test]: *spot only* whether to use the test endpoint or not, default is False
2139
2210
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2140
2211
  """
2141
2212
  await self.load_markets()
@@ -2154,22 +2225,21 @@ class mexc(Exchange, ImplicitAPI):
2154
2225
  'side': orderSide,
2155
2226
  'type': type.upper(),
2156
2227
  }
2157
- if orderSide == 'BUY' and type == 'market':
2158
- createMarketBuyOrderRequiresPrice = True
2159
- createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
2228
+ if type == 'market':
2160
2229
  cost = self.safe_number_2(params, 'cost', 'quoteOrderQty')
2161
2230
  params = self.omit(params, 'cost')
2162
2231
  if cost is not None:
2163
2232
  amount = cost
2164
- elif createMarketBuyOrderRequiresPrice:
2233
+ request['quoteOrderQty'] = self.cost_to_precision(symbol, amount)
2234
+ else:
2165
2235
  if price is None:
2166
- raise InvalidOrder(self.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argument')
2236
+ request['quantity'] = self.amount_to_precision(symbol, amount)
2167
2237
  else:
2168
2238
  amountString = self.number_to_string(amount)
2169
2239
  priceString = self.number_to_string(price)
2170
2240
  quoteAmount = Precise.string_mul(amountString, priceString)
2171
2241
  amount = quoteAmount
2172
- request['quoteOrderQty'] = self.cost_to_precision(symbol, amount)
2242
+ request['quoteOrderQty'] = self.cost_to_precision(symbol, amount)
2173
2243
  else:
2174
2244
  request['quantity'] = self.amount_to_precision(symbol, amount)
2175
2245
  if price is not None:
@@ -2185,12 +2255,41 @@ class mexc(Exchange, ImplicitAPI):
2185
2255
  postOnly, params = self.handle_post_only(type == 'market', type == 'LIMIT_MAKER', params)
2186
2256
  if postOnly:
2187
2257
  request['type'] = 'LIMIT_MAKER'
2258
+ tif = self.safe_string(params, 'timeInForce')
2259
+ if tif is not None:
2260
+ params = self.omit(params, 'timeInForce')
2261
+ if tif == 'IOC':
2262
+ request['type'] = 'IMMEDIATE_OR_CANCEL'
2263
+ elif tif == 'FOK':
2264
+ request['type'] = 'FILL_OR_KILL'
2188
2265
  return self.extend(request, params)
2189
2266
 
2190
2267
  async def create_spot_order(self, market, type, side, amount, price=None, marginMode=None, params={}):
2268
+ """
2269
+ @ignore
2270
+ create a trade order
2271
+
2272
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2273
+
2274
+ :param str market: unified symbol of the market to create an order in
2275
+ :param str type: 'market' or 'limit'
2276
+ :param str side: 'buy' or 'sell'
2277
+ :param float amount: how much of currency you want to trade in units of base currency
2278
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2279
+ :param str [marginMode]: only 'isolated' is supported for spot-margin trading
2280
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2281
+ :param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
2282
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2283
+ """
2191
2284
  await self.load_markets()
2285
+ test = self.safe_bool(params, 'test', False)
2286
+ params = self.omit(params, 'test')
2192
2287
  request = self.create_spot_order_request(market, type, side, amount, price, marginMode, params)
2193
- response = await self.spotPrivatePostOrder(self.extend(request, params))
2288
+ response = None
2289
+ if test:
2290
+ response = await self.spotPrivatePostOrderTest(request)
2291
+ else:
2292
+ response = await self.spotPrivatePostOrder(request)
2194
2293
  #
2195
2294
  # spot
2196
2295
  #
@@ -2213,11 +2312,40 @@ class mexc(Exchange, ImplicitAPI):
2213
2312
  order = self.parse_order(response, market)
2214
2313
  order['side'] = side
2215
2314
  order['type'] = type
2216
- order['price'] = price
2217
- order['amount'] = amount
2315
+ if self.safe_string(order, 'price') is None:
2316
+ order['price'] = price
2317
+ if self.safe_string(order, 'amount') is None:
2318
+ order['amount'] = amount
2218
2319
  return order
2219
2320
 
2220
2321
  async def create_swap_order(self, market, type, side, amount, price=None, marginMode=None, params={}):
2322
+ """
2323
+ @ignore
2324
+ create a trade order
2325
+
2326
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#new-order
2327
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#order-under-maintenance
2328
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#trigger-order-under-maintenance
2329
+
2330
+ :param str market: unified symbol of the market to create an order in
2331
+ :param str type: 'market' or 'limit'
2332
+ :param str side: 'buy' or 'sell'
2333
+ :param float amount: how much of currency you want to trade in units of base currency
2334
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
2335
+ :param str [marginMode]: only 'isolated' is supported for spot-margin trading
2336
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2337
+ :param float [params.triggerPrice]: The price at which a trigger order is triggered at
2338
+ :param bool [params.postOnly]: if True, the order will only be posted if it will be a maker order
2339
+ :param bool [params.reduceOnly]: indicates if self order is to reduce the size of a position
2340
+ :param bool [params.hedged]: *swap only* True for hedged mode, False for one way mode, default is False
2341
+
2342
+ EXCHANGE SPECIFIC PARAMETERS
2343
+ :param int [params.leverage]: leverage is necessary on isolated margin
2344
+ :param long [params.positionId]: it is recommended to hasattr(self, fill) parameter when closing a position
2345
+ :param str [params.externalOid]: external order ID
2346
+ :param int [params.positionMode]: 1:hedge, 2:one-way, default: the user's current config
2347
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2348
+ """
2221
2349
  await self.load_markets()
2222
2350
  symbol = market['symbol']
2223
2351
  unavailableContracts = self.safe_value(self.options, 'unavailableContracts', {})
@@ -2277,18 +2405,28 @@ class mexc(Exchange, ImplicitAPI):
2277
2405
  if leverage is None:
2278
2406
  raise ArgumentsRequired(self.id + ' createSwapOrder() requires a leverage parameter for isolated margin orders')
2279
2407
  reduceOnly = self.safe_bool(params, 'reduceOnly', False)
2280
- if reduceOnly:
2281
- request['side'] = 2 if (side == 'buy') else 4
2408
+ hedged = self.safe_bool(params, 'hedged', False)
2409
+ sideInteger = None
2410
+ if hedged:
2411
+ if reduceOnly:
2412
+ params = self.omit(params, 'reduceOnly') # hedged mode does not accept self parameter
2413
+ side = 'sell' if (side == 'buy') else 'buy'
2414
+ sideInteger = 1 if (side == 'buy') else 3
2415
+ request['positionMode'] = 1
2282
2416
  else:
2283
- request['side'] = 1 if (side == 'buy') else 3
2417
+ if reduceOnly:
2418
+ sideInteger = 2 if (side == 'buy') else 4
2419
+ else:
2420
+ sideInteger = 1 if (side == 'buy') else 3
2421
+ request['side'] = sideInteger
2284
2422
  clientOrderId = self.safe_string_2(params, 'clientOrderId', 'externalOid')
2285
2423
  if clientOrderId is not None:
2286
2424
  request['externalOid'] = clientOrderId
2287
- stopPrice = self.safe_number_2(params, 'triggerPrice', 'stopPrice')
2288
- params = self.omit(params, ['clientOrderId', 'externalOid', 'postOnly', 'stopPrice', 'triggerPrice'])
2425
+ triggerPrice = self.safe_number_2(params, 'triggerPrice', 'stopPrice')
2426
+ params = self.omit(params, ['clientOrderId', 'externalOid', 'postOnly', 'stopPrice', 'triggerPrice', 'hedged'])
2289
2427
  response = None
2290
- if stopPrice:
2291
- request['triggerPrice'] = self.price_to_precision(symbol, stopPrice)
2428
+ if triggerPrice:
2429
+ request['triggerPrice'] = self.price_to_precision(symbol, triggerPrice)
2292
2430
  request['triggerType'] = self.safe_integer(params, 'triggerType', 1)
2293
2431
  request['executeCycle'] = self.safe_integer(params, 'executeCycle', 1)
2294
2432
  request['trend'] = self.safe_integer(params, 'trend', 1)
@@ -2309,7 +2447,9 @@ class mexc(Exchange, ImplicitAPI):
2309
2447
  async def create_orders(self, orders: List[OrderRequest], params={}):
2310
2448
  """
2311
2449
  *spot only* *all orders must have the same symbol* create a list of trade orders
2312
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#batch-orders
2450
+
2451
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#batch-orders
2452
+
2313
2453
  :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
2314
2454
  :param dict [params]: extra parameters specific to api endpoint
2315
2455
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -2366,6 +2506,11 @@ class mexc(Exchange, ImplicitAPI):
2366
2506
  async def fetch_order(self, id: str, symbol: Str = None, params={}):
2367
2507
  """
2368
2508
  fetches information on an order made by the user
2509
+
2510
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-order
2511
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
2512
+
2513
+ :param str id: order id
2369
2514
  :param str symbol: unified symbol of the market the order was made in
2370
2515
  :param dict [params]: extra parameters specific to the exchange API endpoint
2371
2516
  :param str [params.marginMode]: only 'isolated' is supported, for spot-margin trading
@@ -2478,10 +2623,16 @@ class mexc(Exchange, ImplicitAPI):
2478
2623
  async def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2479
2624
  """
2480
2625
  fetches information on multiple orders made by the user
2626
+
2627
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
2628
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
2629
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
2630
+
2481
2631
  :param str symbol: unified market symbol of the market orders were made in
2482
2632
  :param int [since]: the earliest time in ms to fetch orders for
2483
2633
  :param int [limit]: the maximum number of order structures to retrieve
2484
2634
  :param dict [params]: extra parameters specific to the exchange API endpoint
2635
+ :param int [params.until]: the latest time in ms to fetch orders for
2485
2636
  :param str [params.marginMode]: only 'isolated' is supported, for spot-margin trading
2486
2637
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2487
2638
  """
@@ -2491,6 +2642,8 @@ class mexc(Exchange, ImplicitAPI):
2491
2642
  if symbol is not None:
2492
2643
  market = self.market(symbol)
2493
2644
  request['symbol'] = market['id']
2645
+ until = self.safe_integer(params, 'until')
2646
+ params = self.omit(params, 'until')
2494
2647
  marketType, query = self.handle_market_type_and_params('fetchOrders', market, params)
2495
2648
  if marketType == 'spot':
2496
2649
  if symbol is None:
@@ -2498,6 +2651,8 @@ class mexc(Exchange, ImplicitAPI):
2498
2651
  marginMode, queryInner = self.handle_margin_mode_and_params('fetchOrders', params)
2499
2652
  if since is not None:
2500
2653
  request['startTime'] = since
2654
+ if until is not None:
2655
+ request['endTime'] = until
2501
2656
  if limit is not None:
2502
2657
  request['limit'] = limit
2503
2658
  response = None
@@ -2559,9 +2714,17 @@ class mexc(Exchange, ImplicitAPI):
2559
2714
  else:
2560
2715
  if since is not None:
2561
2716
  request['start_time'] = since
2562
- end = self.safe_integer(params, 'end_time')
2717
+ end = self.safe_integer(params, 'end_time', until)
2563
2718
  if end is None:
2564
2719
  request['end_time'] = self.sum(since, self.options['maxTimeTillEnd'])
2720
+ else:
2721
+ if (end - since) > self.options['maxTimeTillEnd']:
2722
+ raise BadRequest(self.id + ' end is invalid, i.e. exceeds allowed 90 days.')
2723
+ else:
2724
+ request['end_time'] = until
2725
+ elif until is not None:
2726
+ request['start_time'] = self.sum(until, self.options['maxTimeTillEnd'] * -1)
2727
+ request['end_time'] = until
2565
2728
  if limit is not None:
2566
2729
  request['page_size'] = limit
2567
2730
  method = self.safe_string(self.options, 'fetchOrders', 'contractPrivateGetOrderListHistoryOrders')
@@ -2691,6 +2854,11 @@ class mexc(Exchange, ImplicitAPI):
2691
2854
  async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2692
2855
  """
2693
2856
  fetch all unfilled currently open orders
2857
+
2858
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#current-open-orders
2859
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
2860
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
2861
+
2694
2862
  :param str symbol: unified market symbol
2695
2863
  :param int [since]: the earliest time in ms to fetch open orders for
2696
2864
  :param int [limit]: the maximum number of open orders structures to retrieve
@@ -2773,6 +2941,11 @@ class mexc(Exchange, ImplicitAPI):
2773
2941
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
2774
2942
  """
2775
2943
  fetches information on multiple closed orders made by the user
2944
+
2945
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
2946
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
2947
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
2948
+
2776
2949
  :param str symbol: unified market symbol of the market orders were made in
2777
2950
  :param int [since]: the earliest time in ms to fetch orders for
2778
2951
  :param int [limit]: the maximum number of order structures to retrieve
@@ -2784,6 +2957,11 @@ class mexc(Exchange, ImplicitAPI):
2784
2957
  async def fetch_canceled_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2785
2958
  """
2786
2959
  fetches information on multiple canceled orders made by the user
2960
+
2961
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#all-orders
2962
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-of-the-user-39-s-historical-orders
2963
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#gets-the-trigger-order-list
2964
+
2787
2965
  :param str symbol: unified market symbol of the market orders were made in
2788
2966
  :param int [since]: timestamp in ms of the earliest order, default is None
2789
2967
  :param int [limit]: max number of orders to return, default is None
@@ -2808,6 +2986,11 @@ class mexc(Exchange, ImplicitAPI):
2808
2986
  async def cancel_order(self, id: str, symbol: Str = None, params={}):
2809
2987
  """
2810
2988
  cancels an open order
2989
+
2990
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-order
2991
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
2992
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-stop-limit-trigger-order-under-maintenance
2993
+
2811
2994
  :param str id: order id
2812
2995
  :param str symbol: unified symbol of the market the order was made in
2813
2996
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2910,6 +3093,9 @@ class mexc(Exchange, ImplicitAPI):
2910
3093
  async def cancel_orders(self, ids, symbol: Str = None, params={}):
2911
3094
  """
2912
3095
  cancel multiple orders
3096
+
3097
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-the-order-under-maintenance
3098
+
2913
3099
  :param str[] ids: order ids
2914
3100
  :param str symbol: unified market symbol, default is None
2915
3101
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2941,6 +3127,11 @@ class mexc(Exchange, ImplicitAPI):
2941
3127
  async def cancel_all_orders(self, symbol: Str = None, params={}):
2942
3128
  """
2943
3129
  cancel all open orders
3130
+
3131
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#cancel-all-open-orders-on-a-symbol
3132
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-orders-under-a-contract-under-maintenance
3133
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#cancel-all-trigger-orders-under-maintenance
3134
+
2944
3135
  :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
2945
3136
  :param dict [params]: extra parameters specific to the exchange API endpoint
2946
3137
  :param str [params.marginMode]: only 'isolated' is supported for spot-margin trading
@@ -3023,13 +3214,27 @@ class mexc(Exchange, ImplicitAPI):
3023
3214
 
3024
3215
  def parse_order(self, order: dict, market: Market = None) -> Order:
3025
3216
  #
3026
- # spot: createOrder
3217
+ # spot
3218
+ # createOrder
3027
3219
  #
3028
- # {
3220
+ # {
3221
+ # "symbol": "FARTCOINUSDT",
3222
+ # "orderId": "C02__342252993005723644225",
3223
+ # "orderListId": "-1",
3224
+ # "price": "1.1",
3225
+ # "origQty": "6.3",
3226
+ # "type": "IMMEDIATE_OR_CANCEL",
3227
+ # "side": "SELL",
3228
+ # "transactTime": "1745852205223"
3229
+ # }
3230
+ #
3231
+ # unknown endpoint on spot
3232
+ #
3233
+ # {
3029
3234
  # "symbol": "BTCUSDT",
3030
3235
  # "orderId": "123738410679123456",
3031
3236
  # "orderListId": -1
3032
- # }
3237
+ # }
3033
3238
  #
3034
3239
  # margin: createOrder
3035
3240
  #
@@ -3191,6 +3396,10 @@ class mexc(Exchange, ImplicitAPI):
3191
3396
  id = order
3192
3397
  else:
3193
3398
  id = self.safe_string_2(order, 'orderId', 'id')
3399
+ timeInForce = self.parse_order_time_in_force(self.safe_string(order, 'timeInForce'))
3400
+ typeRaw = self.safe_string(order, 'type')
3401
+ if timeInForce is None:
3402
+ timeInForce = self.get_tif_from_raw_order_type(typeRaw)
3194
3403
  marketId = self.safe_string(order, 'symbol')
3195
3404
  market = self.safe_market(marketId, market)
3196
3405
  timestamp = self.safe_integer_n(order, ['time', 'createTime', 'transactTime'])
@@ -3212,11 +3421,10 @@ class mexc(Exchange, ImplicitAPI):
3212
3421
  'lastTradeTimestamp': None, # TODO: self might be 'updateTime' if order-status is filled, otherwise cancellation time. needs to be checked
3213
3422
  'status': self.parse_order_status(self.safe_string_2(order, 'status', 'state')),
3214
3423
  'symbol': market['symbol'],
3215
- 'type': self.parse_order_type(self.safe_string(order, 'type')),
3216
- 'timeInForce': self.parse_order_time_in_force(self.safe_string(order, 'timeInForce')),
3424
+ 'type': self.parse_order_type(typeRaw),
3425
+ 'timeInForce': timeInForce,
3217
3426
  'side': self.parse_order_side(self.safe_string(order, 'side')),
3218
3427
  'price': self.safe_number(order, 'price'),
3219
- 'stopPrice': self.safe_number_2(order, 'stopPrice', 'triggerPrice'),
3220
3428
  'triggerPrice': self.safe_number_2(order, 'stopPrice', 'triggerPrice'),
3221
3429
  'average': self.safe_number(order, 'dealAvgPrice'),
3222
3430
  'amount': self.safe_number_2(order, 'origQty', 'vol'),
@@ -3243,6 +3451,9 @@ class mexc(Exchange, ImplicitAPI):
3243
3451
  'MARKET': 'market',
3244
3452
  'LIMIT': 'limit',
3245
3453
  'LIMIT_MAKER': 'limit',
3454
+ # on spot, during submission below types are used only accepted order
3455
+ 'IMMEDIATE_OR_CANCEL': 'limit',
3456
+ 'FILL_OR_KILL': 'limit',
3246
3457
  }
3247
3458
  return self.safe_string(statuses, status, status)
3248
3459
 
@@ -3270,6 +3481,16 @@ class mexc(Exchange, ImplicitAPI):
3270
3481
  }
3271
3482
  return self.safe_string(statuses, status, status)
3272
3483
 
3484
+ def get_tif_from_raw_order_type(self, orderType: Str = None):
3485
+ statuses: dict = {
3486
+ 'LIMIT': 'GTC',
3487
+ 'LIMIT_MAKER': 'POST_ONLY',
3488
+ 'IMMEDIATE_OR_CANCEL': 'IOC',
3489
+ 'FILL_OR_KILL': 'FOK',
3490
+ 'MARKET': 'IOC',
3491
+ }
3492
+ return self.safe_string(statuses, orderType, orderType)
3493
+
3273
3494
  async def fetch_account_helper(self, type, params):
3274
3495
  if type == 'spot':
3275
3496
  return await self.spotPrivateGetAccount(params)
@@ -3327,6 +3548,10 @@ class mexc(Exchange, ImplicitAPI):
3327
3548
  async def fetch_accounts(self, params={}) -> List[Account]:
3328
3549
  """
3329
3550
  fetch all the accounts associated with a profile
3551
+
3552
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3553
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3554
+
3330
3555
  :param dict [params]: extra parameters specific to the exchange API endpoint
3331
3556
  :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
3332
3557
  """
@@ -3348,30 +3573,44 @@ class mexc(Exchange, ImplicitAPI):
3348
3573
  })
3349
3574
  return result
3350
3575
 
3351
- async def fetch_trading_fees(self, params={}) -> TradingFees:
3576
+ async def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
3352
3577
  """
3353
- fetch the trading fees for multiple markets
3578
+ fetch the trading fees for a market
3579
+
3580
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-mx-deduct-status
3581
+
3582
+ :param str symbol: unified market symbol
3354
3583
  :param dict [params]: extra parameters specific to the exchange API endpoint
3355
- :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
3584
+ :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
3356
3585
  """
3357
3586
  await self.load_markets()
3358
- response = await self.fetch_account_helper('spot', params)
3359
- makerFee = self.safe_string(response, 'makerCommission')
3360
- takerFee = self.safe_string(response, 'takerCommission')
3361
- makerFee = Precise.string_div(makerFee, '1000')
3362
- takerFee = Precise.string_div(takerFee, '1000')
3363
- result: dict = {}
3364
- for i in range(0, len(self.symbols)):
3365
- symbol = self.symbols[i]
3366
- result[symbol] = {
3367
- 'symbol': symbol,
3368
- 'maker': self.parse_number(makerFee),
3369
- 'taker': self.parse_number(takerFee),
3370
- 'percentage': True,
3371
- 'tierBased': False,
3372
- 'info': response,
3373
- }
3374
- return result
3587
+ market = self.market(symbol)
3588
+ if not market['spot']:
3589
+ raise BadRequest(self.id + ' fetchTradingFee() supports spot markets only')
3590
+ request: dict = {
3591
+ 'symbol': market['id'],
3592
+ }
3593
+ response = await self.spotPrivateGetTradeFee(self.extend(request, params))
3594
+ #
3595
+ # {
3596
+ # "data":{
3597
+ # "makerCommission":0.003000000000000000,
3598
+ # "takerCommission":0.003000000000000000
3599
+ # },
3600
+ # "code":0,
3601
+ # "msg":"success",
3602
+ # "timestamp":1669109672717
3603
+ # }
3604
+ #
3605
+ data = self.safe_dict(response, 'data', {})
3606
+ return {
3607
+ 'info': data,
3608
+ 'symbol': symbol,
3609
+ 'maker': self.safe_number(data, 'makerCommission'),
3610
+ 'taker': self.safe_number(data, 'takerCommission'),
3611
+ 'percentage': None,
3612
+ 'tierBased': None,
3613
+ }
3375
3614
 
3376
3615
  def custom_parse_balance(self, response, marketType) -> Balances:
3377
3616
  #
@@ -3490,9 +3729,11 @@ class mexc(Exchange, ImplicitAPI):
3490
3729
  async def fetch_balance(self, params={}) -> Balances:
3491
3730
  """
3492
3731
  query for balance and get the amount of funds available for trading or funds locked in orders
3493
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3494
- :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3495
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#isolated-account
3732
+
3733
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-information
3734
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-informations-of-user-39-s-asset
3735
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#isolated-account
3736
+
3496
3737
  :param dict [params]: extra parameters specific to the exchange API endpoint
3497
3738
  :param str [params.symbols]: # required for margin, market id's separated by commas
3498
3739
  :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
@@ -3615,27 +3856,37 @@ class mexc(Exchange, ImplicitAPI):
3615
3856
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3616
3857
  """
3617
3858
  fetch all trades made by the user
3859
+
3860
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
3861
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-all-transaction-details-of-the-user-s-order
3862
+
3618
3863
  :param str symbol: unified market symbol
3619
3864
  :param int [since]: the earliest time in ms to fetch trades for
3620
3865
  :param int [limit]: the maximum number of trades structures to retrieve
3621
3866
  :param dict [params]: extra parameters specific to the exchange API endpoint
3867
+ :param int [params.until]: the latest time in ms to fetch trades for
3622
3868
  :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
3623
3869
  """
3624
3870
  if symbol is None:
3625
3871
  raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol argument')
3626
3872
  await self.load_markets()
3627
3873
  market = self.market(symbol)
3628
- marketType, query = self.handle_market_type_and_params('fetchMyTrades', market, params)
3874
+ marketType: Str = None
3875
+ marketType, params = self.handle_market_type_and_params('fetchMyTrades', market, params)
3629
3876
  request: dict = {
3630
3877
  'symbol': market['id'],
3631
3878
  }
3632
3879
  trades = None
3633
3880
  if marketType == 'spot':
3634
3881
  if since is not None:
3635
- request['start_time'] = since
3882
+ request['startTime'] = since
3636
3883
  if limit is not None:
3637
3884
  request['limit'] = limit
3638
- trades = await self.spotPrivateGetMyTrades(self.extend(request, query))
3885
+ until = self.safe_integer(params, 'until')
3886
+ if until is not None:
3887
+ params = self.omit(params, 'until')
3888
+ request['endTime'] = until
3889
+ trades = await self.spotPrivateGetMyTrades(self.extend(request, params))
3639
3890
  #
3640
3891
  # spot
3641
3892
  #
@@ -3665,7 +3916,7 @@ class mexc(Exchange, ImplicitAPI):
3665
3916
  request['end_time'] = self.sum(since, self.options['maxTimeTillEnd'])
3666
3917
  if limit is not None:
3667
3918
  request['page_size'] = limit
3668
- response = await self.contractPrivateGetOrderListOrderDeals(self.extend(request, query))
3919
+ response = await self.contractPrivateGetOrderListOrderDeals(self.extend(request, params))
3669
3920
  #
3670
3921
  # {
3671
3922
  # "success": True,
@@ -3695,6 +3946,10 @@ class mexc(Exchange, ImplicitAPI):
3695
3946
  async def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3696
3947
  """
3697
3948
  fetch all the trades made from a single order
3949
+
3950
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#account-trade-list
3951
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#query-the-order-based-on-the-order-number
3952
+
3698
3953
  :param str id: order id
3699
3954
  :param str symbol: unified market symbol
3700
3955
  :param int [since]: the earliest time in ms to fetch trades for
@@ -3786,6 +4041,9 @@ class mexc(Exchange, ImplicitAPI):
3786
4041
  async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3787
4042
  """
3788
4043
  remove margin from a position
4044
+
4045
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
4046
+
3789
4047
  :param str symbol: unified market symbol
3790
4048
  :param float amount: the amount of margin to remove
3791
4049
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3796,6 +4054,9 @@ class mexc(Exchange, ImplicitAPI):
3796
4054
  async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
3797
4055
  """
3798
4056
  add margin
4057
+
4058
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#increase-or-decrease-margin
4059
+
3799
4060
  :param str symbol: unified market symbol
3800
4061
  :param float amount: amount of margin to add
3801
4062
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3803,9 +4064,12 @@ class mexc(Exchange, ImplicitAPI):
3803
4064
  """
3804
4065
  return await self.modify_margin_helper(symbol, amount, 'ADD', params)
3805
4066
 
3806
- async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
4067
+ async def set_leverage(self, leverage: int, symbol: Str = None, params={}):
3807
4068
  """
3808
4069
  set the level of leverage for a market
4070
+
4071
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#switch-leverage
4072
+
3809
4073
  :param float leverage: the rate of leverage
3810
4074
  :param str symbol: unified market symbol
3811
4075
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -3833,6 +4097,9 @@ class mexc(Exchange, ImplicitAPI):
3833
4097
  async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3834
4098
  """
3835
4099
  fetch the history of funding payments paid and received on self account
4100
+
4101
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-details-of-user-s-funding-rate
4102
+
3836
4103
  :param str symbol: unified market symbol
3837
4104
  :param int [since]: the earliest time in ms to fetch funding history for
3838
4105
  :param int [limit]: the maximum number of funding history structures to retrieve
@@ -3902,7 +4169,7 @@ class mexc(Exchange, ImplicitAPI):
3902
4169
  })
3903
4170
  return result
3904
4171
 
3905
- def parse_funding_rate(self, contract, market: Market = None):
4172
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
3906
4173
  #
3907
4174
  # {
3908
4175
  # "symbol": "BTC_USDT",
@@ -3917,9 +4184,12 @@ class mexc(Exchange, ImplicitAPI):
3917
4184
  nextFundingRate = self.safe_number(contract, 'fundingRate')
3918
4185
  nextFundingTimestamp = self.safe_integer(contract, 'nextSettleTime')
3919
4186
  marketId = self.safe_string(contract, 'symbol')
3920
- symbol = self.safe_symbol(marketId, market)
4187
+ symbol = self.safe_symbol(marketId, market, None, 'contract')
3921
4188
  timestamp = self.safe_integer(contract, 'timestamp')
3922
- datetime = self.iso8601(timestamp)
4189
+ interval = self.safe_string(contract, 'collectCycle')
4190
+ intervalString = None
4191
+ if interval is not None:
4192
+ intervalString = interval + 'h'
3923
4193
  return {
3924
4194
  'info': contract,
3925
4195
  'symbol': symbol,
@@ -3928,7 +4198,7 @@ class mexc(Exchange, ImplicitAPI):
3928
4198
  'interestRate': None,
3929
4199
  'estimatedSettlePrice': None,
3930
4200
  'timestamp': timestamp,
3931
- 'datetime': datetime,
4201
+ 'datetime': self.iso8601(timestamp),
3932
4202
  'fundingRate': nextFundingRate,
3933
4203
  'fundingTimestamp': nextFundingTimestamp,
3934
4204
  'fundingDatetime': self.iso8601(nextFundingTimestamp),
@@ -3938,11 +4208,27 @@ class mexc(Exchange, ImplicitAPI):
3938
4208
  'previousFundingRate': None,
3939
4209
  'previousFundingTimestamp': None,
3940
4210
  'previousFundingDatetime': None,
4211
+ 'interval': intervalString,
3941
4212
  }
3942
4213
 
3943
- async def fetch_funding_rate(self, symbol: str, params={}):
4214
+ async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
4215
+ """
4216
+ fetch the current funding rate interval
4217
+
4218
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
4219
+
4220
+ :param str symbol: unified market symbol
4221
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4222
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
4223
+ """
4224
+ return await self.fetch_funding_rate(symbol, params)
4225
+
4226
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
3944
4227
  """
3945
4228
  fetch the current funding rate
4229
+
4230
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate
4231
+
3946
4232
  :param str symbol: unified market symbol
3947
4233
  :param dict [params]: extra parameters specific to the exchange API endpoint
3948
4234
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -3974,6 +4260,9 @@ class mexc(Exchange, ImplicitAPI):
3974
4260
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3975
4261
  """
3976
4262
  fetches historical funding rate prices
4263
+
4264
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-contract-funding-rate-history
4265
+
3977
4266
  :param str symbol: unified symbol of the market to fetch the funding rate history for
3978
4267
  :param int [since]: not used by mexc, but filtered internally by ccxt
3979
4268
  :param int [limit]: mexc limit is page_size default 20, maximum is 100
@@ -4037,7 +4326,9 @@ class mexc(Exchange, ImplicitAPI):
4037
4326
  async def fetch_leverage_tiers(self, symbols: Strings = None, params={}) -> LeverageTiers:
4038
4327
  """
4039
4328
  retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes, if a market has a leverage tier of 0, then the leverage tiers cannot be obtained for self market
4040
- :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
4329
+
4330
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-contract-information
4331
+
4041
4332
  :param str[] [symbols]: list of unified market symbols
4042
4333
  :param dict [params]: extra parameters specific to the exchange API endpoint
4043
4334
  :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`, indexed by market symbols
@@ -4132,6 +4423,7 @@ class mexc(Exchange, ImplicitAPI):
4132
4423
  # "isHidden": False
4133
4424
  # }
4134
4425
  #
4426
+ marketId = self.safe_string(info, 'symbol')
4135
4427
  maintenanceMarginRate = self.safe_string(info, 'maintenanceMarginRate')
4136
4428
  initialMarginRate = self.safe_string(info, 'initialMarginRate')
4137
4429
  maxVol = self.safe_string(info, 'maxVol')
@@ -4145,6 +4437,7 @@ class mexc(Exchange, ImplicitAPI):
4145
4437
  return [
4146
4438
  {
4147
4439
  'tier': 0,
4440
+ 'symbol': self.safe_symbol(marketId, market, None, 'contract'),
4148
4441
  'currency': self.safe_currency_code(quoteId),
4149
4442
  'minNotional': None,
4150
4443
  'maxNotional': None,
@@ -4157,6 +4450,7 @@ class mexc(Exchange, ImplicitAPI):
4157
4450
  cap = Precise.string_add(floor, riskIncrVol)
4158
4451
  tiers.append({
4159
4452
  'tier': self.parse_number(Precise.string_div(cap, riskIncrVol)),
4453
+ 'symbol': self.safe_symbol(marketId, market, None, 'contract'),
4160
4454
  'currency': self.safe_currency_code(quoteId),
4161
4455
  'minNotional': self.parse_number(floor),
4162
4456
  'maxNotional': self.parse_number(cap),
@@ -4169,7 +4463,7 @@ class mexc(Exchange, ImplicitAPI):
4169
4463
  floor = cap
4170
4464
  return tiers
4171
4465
 
4172
- def parse_deposit_address(self, depositAddress, currency: Currency = None):
4466
+ def parse_deposit_address(self, depositAddress, currency: Currency = None) -> DepositAddress:
4173
4467
  #
4174
4468
  # {
4175
4469
  # coin: "USDT",
@@ -4180,20 +4474,22 @@ class mexc(Exchange, ImplicitAPI):
4180
4474
  #
4181
4475
  address = self.safe_string(depositAddress, 'address')
4182
4476
  currencyId = self.safe_string(depositAddress, 'coin')
4183
- networkId = self.safe_string(depositAddress, 'network')
4477
+ networkId = self.safe_string(depositAddress, 'netWork')
4184
4478
  self.check_address(address)
4185
4479
  return {
4480
+ 'info': depositAddress,
4186
4481
  'currency': self.safe_currency_code(currencyId, currency),
4482
+ 'network': self.network_id_to_code(networkId, currencyId),
4187
4483
  'address': address,
4188
4484
  'tag': self.safe_string(depositAddress, 'memo'),
4189
- 'network': self.network_id_to_code(networkId),
4190
- 'info': depositAddress,
4191
4485
  }
4192
4486
 
4193
- async def fetch_deposit_addresses_by_network(self, code: str, params={}):
4487
+ async def fetch_deposit_addresses_by_network(self, code: str, params={}) -> List[DepositAddress]:
4194
4488
  """
4195
4489
  fetch a dictionary of addresses for a currency, indexed by network
4196
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
4490
+
4491
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
4492
+
4197
4493
  :param str code: unified currency code of the currency for the deposit address
4198
4494
  :param dict [params]: extra parameters specific to the exchange API endpoint
4199
4495
  :returns dict: a dictionary of `address structures <https://docs.ccxt.com/#/?id=address-structure>` indexed by the network
@@ -4206,7 +4502,15 @@ class mexc(Exchange, ImplicitAPI):
4206
4502
  networkCode = self.safe_string(params, 'network')
4207
4503
  networkId = None
4208
4504
  if networkCode is not None:
4209
- networkId = self.network_code_to_id(networkCode, code)
4505
+ # createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
4506
+ networkUnified = self.network_id_to_code(networkCode, code)
4507
+ networks = self.safe_dict(currency, 'networks', {})
4508
+ if networkUnified in networks:
4509
+ network = self.safe_dict(networks, networkUnified, {})
4510
+ networkInfo = self.safe_value(network, 'info', {})
4511
+ networkId = self.safe_string(networkInfo, 'network')
4512
+ else:
4513
+ networkId = self.network_code_to_id(networkCode, code)
4210
4514
  if networkId is not None:
4211
4515
  request['network'] = networkId
4212
4516
  params = self.omit(params, 'network')
@@ -4225,10 +4529,12 @@ class mexc(Exchange, ImplicitAPI):
4225
4529
  addressStructures = self.parse_deposit_addresses(response, None, False)
4226
4530
  return self.index_by(addressStructures, 'network')
4227
4531
 
4228
- async def create_deposit_address(self, code: str, params={}):
4532
+ async def create_deposit_address(self, code: str, params={}) -> DepositAddress:
4229
4533
  """
4230
4534
  create a currency deposit address
4231
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#generate-deposit-address-supporting-network
4535
+
4536
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#generate-deposit-address-supporting-network
4537
+
4232
4538
  :param str code: unified currency code of the currency for the deposit address
4233
4539
  :param dict [params]: extra parameters specific to the exchange API endpoint
4234
4540
  :param str [params.network]: the blockchain network name
@@ -4242,7 +4548,16 @@ class mexc(Exchange, ImplicitAPI):
4242
4548
  networkCode = self.safe_string(params, 'network')
4243
4549
  if networkCode is None:
4244
4550
  raise ArgumentsRequired(self.id + ' createDepositAddress requires a `network` parameter')
4245
- networkId = self.network_code_to_id(networkCode, code)
4551
+ # createDepositAddress and fetchDepositAddress use a different network-id compared to withdraw
4552
+ networkId = None
4553
+ networkUnified = self.network_id_to_code(networkCode, code)
4554
+ networks = self.safe_dict(currency, 'networks', {})
4555
+ if networkUnified in networks:
4556
+ network = self.safe_dict(networks, networkUnified, {})
4557
+ networkInfo = self.safe_value(network, 'info', {})
4558
+ networkId = self.safe_string(networkInfo, 'network')
4559
+ else:
4560
+ networkId = self.network_code_to_id(networkCode, code)
4246
4561
  if networkId is not None:
4247
4562
  request['network'] = networkId
4248
4563
  params = self.omit(params, 'network')
@@ -4255,17 +4570,18 @@ class mexc(Exchange, ImplicitAPI):
4255
4570
  # }
4256
4571
  return self.parse_deposit_address(response, currency)
4257
4572
 
4258
- async def fetch_deposit_address(self, code: str, params={}):
4573
+ async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
4259
4574
  """
4260
4575
  fetch the deposit address for a currency associated with self account
4261
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
4576
+
4577
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-address-supporting-network
4578
+
4262
4579
  :param str code: unified currency code
4263
4580
  :param dict [params]: extra parameters specific to the exchange API endpoint
4264
4581
  :param str [params.network]: the chain of currency, self only apply for multi-chain currency, and there is no need for single chain currency
4265
4582
  :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
4266
4583
  """
4267
4584
  network = self.safe_string(params, 'network')
4268
- params = self.omit(params, ['network'])
4269
4585
  addressStructures = await self.fetch_deposit_addresses_by_network(code, params)
4270
4586
  result = None
4271
4587
  if network is not None:
@@ -4286,7 +4602,9 @@ class mexc(Exchange, ImplicitAPI):
4286
4602
  async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
4287
4603
  """
4288
4604
  fetch all deposits made to an account
4289
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-history-supporting-network
4605
+
4606
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#deposit-history-supporting-network
4607
+
4290
4608
  :param str code: unified currency code
4291
4609
  :param int [since]: the earliest time in ms to fetch deposits for
4292
4610
  :param int [limit]: the maximum number of deposits structures to retrieve
@@ -4298,7 +4616,7 @@ class mexc(Exchange, ImplicitAPI):
4298
4616
  # 'coin': currency['id'] + network example: USDT-TRX,
4299
4617
  # 'status': 'status',
4300
4618
  # 'startTime': since, # default 90 days
4301
- # 'endTime': self.milliseconds(),
4619
+ # 'endTime': self.nonce(),
4302
4620
  # 'limit': limit, # default 1000, maximum 1000
4303
4621
  }
4304
4622
  currency = None
@@ -4310,7 +4628,7 @@ class mexc(Exchange, ImplicitAPI):
4310
4628
  rawNetwork = self.safe_string(params, 'network')
4311
4629
  if rawNetwork is not None:
4312
4630
  params = self.omit(params, 'network')
4313
- request['coin'] += '-' + rawNetwork
4631
+ request['coin'] = request['coin'] + '-' + rawNetwork
4314
4632
  if since is not None:
4315
4633
  request['startTime'] = since
4316
4634
  if limit is not None:
@@ -4326,11 +4644,14 @@ class mexc(Exchange, ImplicitAPI):
4326
4644
  # "network": "TRX",
4327
4645
  # "status": "5",
4328
4646
  # "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh",
4329
- # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4647
+ # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0",
4330
4648
  # "insertTime": "1664805021000",
4331
4649
  # "unlockConfirm": "200",
4332
4650
  # "confirmTimes": "203",
4333
- # "memo": "xxyy1122"
4651
+ # "memo": "xxyy1122",
4652
+ # "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4653
+ # "updateTime": "1664805621000",
4654
+ # "netWork: "TRX"
4334
4655
  # }
4335
4656
  # ]
4336
4657
  #
@@ -4339,7 +4660,9 @@ class mexc(Exchange, ImplicitAPI):
4339
4660
  async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
4340
4661
  """
4341
4662
  fetch all withdrawals made from an account
4342
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-history-supporting-network
4663
+
4664
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-history-supporting-network
4665
+
4343
4666
  :param str code: unified currency code
4344
4667
  :param int [since]: the earliest time in ms to fetch withdrawals for
4345
4668
  :param int [limit]: the maximum number of withdrawals structures to retrieve
@@ -4351,7 +4674,7 @@ class mexc(Exchange, ImplicitAPI):
4351
4674
  # 'coin': currency['id'],
4352
4675
  # 'status': 'status',
4353
4676
  # 'startTime': since, # default 90 days
4354
- # 'endTime': self.milliseconds(),
4677
+ # 'endTime': self.nonce(),
4355
4678
  # 'limit': limit, # default 1000, maximum 1000
4356
4679
  }
4357
4680
  currency = None
@@ -4369,7 +4692,7 @@ class mexc(Exchange, ImplicitAPI):
4369
4692
  # [
4370
4693
  # {
4371
4694
  # "id": "adcd1c8322154de691b815eedcd10c42",
4372
- # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4695
+ # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0",
4373
4696
  # "coin": "USDC-MATIC",
4374
4697
  # "network": "MATIC",
4375
4698
  # "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62",
@@ -4380,7 +4703,11 @@ class mexc(Exchange, ImplicitAPI):
4380
4703
  # "confirmNo": null,
4381
4704
  # "applyTime": "1664882739000",
4382
4705
  # "remark": '',
4383
- # "memo": null
4706
+ # "memo": null,
4707
+ # "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4708
+ # "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4709
+ # "updateTime": "1664882799000",
4710
+ # "netWork: "MATIC"
4384
4711
  # }
4385
4712
  # ]
4386
4713
  #
@@ -4396,18 +4723,21 @@ class mexc(Exchange, ImplicitAPI):
4396
4723
  # "network": "TRX",
4397
4724
  # "status": "5",
4398
4725
  # "address": "TSMcEDDvkqY9dz8RkFnrS86U59GwEZjfvh",
4399
- # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4726
+ # "txId": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b:0",
4400
4727
  # "insertTime": "1664805021000",
4401
4728
  # "unlockConfirm": "200",
4402
4729
  # "confirmTimes": "203",
4403
- # "memo": "xxyy1122"
4730
+ # "memo": "xxyy1122",
4731
+ # "transHash": "51a8f49e6f03f2c056e71fe3291aa65e1032880be855b65cecd0595a1b8af95b",
4732
+ # "updateTime": "1664805621000",
4733
+ # "netWork: "TRX"
4404
4734
  # }
4405
4735
  #
4406
4736
  # fetchWithdrawals
4407
4737
  #
4408
4738
  # {
4409
4739
  # "id": "adcd1c8322154de691b815eedcd10c42",
4410
- # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4740
+ # "txId": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0:0",
4411
4741
  # "coin": "USDC-MATIC",
4412
4742
  # "network": "MATIC",
4413
4743
  # "address": "0xeE6C7a415995312ED52c53a0f8f03e165e0A5D62",
@@ -4417,8 +4747,12 @@ class mexc(Exchange, ImplicitAPI):
4417
4747
  # "transactionFee": "1",
4418
4748
  # "confirmNo": null,
4419
4749
  # "applyTime": "1664882739000",
4420
- # "remark": '',
4421
- # "memo": null
4750
+ # "remark": "",
4751
+ # "memo": null,
4752
+ # "explorerUrl": "https://etherscan.io/tx/0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4753
+ # "transHash": "0xc8c918cd69b2246db493ef6225a72ffdc664f15b08da3e25c6879b271d05e9d0",
4754
+ # "updateTime": "1664882799000",
4755
+ # "netWork: "MATIC"
4422
4756
  # }
4423
4757
  #
4424
4758
  # withdraw
@@ -4430,6 +4764,7 @@ class mexc(Exchange, ImplicitAPI):
4430
4764
  id = self.safe_string(transaction, 'id')
4431
4765
  type = 'deposit' if (id is None) else 'withdrawal'
4432
4766
  timestamp = self.safe_integer_2(transaction, 'insertTime', 'applyTime')
4767
+ updated = self.safe_integer(transaction, 'updateTime')
4433
4768
  currencyId = None
4434
4769
  currencyWithNetwork = self.safe_string(transaction, 'coin')
4435
4770
  if currencyWithNetwork is not None:
@@ -4442,7 +4777,7 @@ class mexc(Exchange, ImplicitAPI):
4442
4777
  status = self.parse_transaction_status_by_type(self.safe_string(transaction, 'status'), type)
4443
4778
  amountString = self.safe_string(transaction, 'amount')
4444
4779
  address = self.safe_string(transaction, 'address')
4445
- txid = self.safe_string(transaction, 'txId')
4780
+ txid = self.safe_string_2(transaction, 'transHash', 'txId')
4446
4781
  fee = None
4447
4782
  feeCostString = self.safe_string(transaction, 'transactionFee')
4448
4783
  if feeCostString is not None:
@@ -4470,8 +4805,8 @@ class mexc(Exchange, ImplicitAPI):
4470
4805
  'amount': self.parse_number(amountString),
4471
4806
  'currency': code,
4472
4807
  'status': status,
4473
- 'updated': None,
4474
- 'comment': None,
4808
+ 'updated': updated,
4809
+ 'comment': self.safe_string(transaction, 'remark'),
4475
4810
  'internal': None,
4476
4811
  'fee': fee,
4477
4812
  }
@@ -4506,6 +4841,9 @@ class mexc(Exchange, ImplicitAPI):
4506
4841
  async def fetch_position(self, symbol: str, params={}):
4507
4842
  """
4508
4843
  fetch data on a single open contract trade position
4844
+
4845
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
4846
+
4509
4847
  :param str symbol: unified market symbol of the market the position is held in, default is None
4510
4848
  :param dict [params]: extra parameters specific to the exchange API endpoint
4511
4849
  :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -4518,9 +4856,12 @@ class mexc(Exchange, ImplicitAPI):
4518
4856
  response = await self.fetch_positions(None, self.extend(request, params))
4519
4857
  return self.safe_value(response, 0)
4520
4858
 
4521
- async def fetch_positions(self, symbols: Strings = None, params={}):
4859
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
4522
4860
  """
4523
4861
  fetch all open positions
4862
+
4863
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
4864
+
4524
4865
  :param str[]|None symbols: list of unified market symbols
4525
4866
  :param dict [params]: extra parameters specific to the exchange API endpoint
4526
4867
  :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -4621,7 +4962,7 @@ class mexc(Exchange, ImplicitAPI):
4621
4962
  # positionShowStatus: 'CLOSED'
4622
4963
  # }
4623
4964
  #
4624
- market = self.safe_market(self.safe_string(position, 'symbol'), market)
4965
+ market = self.safe_market(self.safe_string(position, 'symbol'), market, None, 'swap')
4625
4966
  symbol = market['symbol']
4626
4967
  contracts = self.safe_string(position, 'holdVol')
4627
4968
  entryPrice = self.safe_number(position, 'openAvgPrice')
@@ -4642,7 +4983,7 @@ class mexc(Exchange, ImplicitAPI):
4642
4983
  'entryPrice': entryPrice,
4643
4984
  'collateral': None,
4644
4985
  'side': side,
4645
- 'unrealizedProfit': None,
4986
+ 'unrealizedPnl': None,
4646
4987
  'leverage': self.parse_number(leverage),
4647
4988
  'percentage': None,
4648
4989
  'marginMode': marginType,
@@ -4664,6 +5005,16 @@ class mexc(Exchange, ImplicitAPI):
4664
5005
  })
4665
5006
 
4666
5007
  async def fetch_transfer(self, id: str, code: Str = None, params={}) -> TransferEntry:
5008
+ """
5009
+ fetches a transfer
5010
+
5011
+ https://mexcdevelop.github.io/apidocs/spot_v2_en/#internal-assets-transfer-order-inquiry
5012
+
5013
+ :param str id: transfer id
5014
+ :param str [code]: not used by mexc fetchTransfer
5015
+ :param dict params: extra parameters specific to the exchange api endpoint
5016
+ :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
5017
+ """
4667
5018
  marketType, query = self.handle_market_type_and_params('fetchTransfer', None, params)
4668
5019
  await self.load_markets()
4669
5020
  if marketType == 'spot':
@@ -4690,9 +5041,13 @@ class mexc(Exchange, ImplicitAPI):
4690
5041
  raise BadRequest(self.id + ' fetchTransfer() is not supported for ' + marketType)
4691
5042
  return None
4692
5043
 
4693
- async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> TransferEntries:
5044
+ async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
4694
5045
  """
4695
5046
  fetch a history of internal transfers made on an account
5047
+
5048
+ https://mexcdevelop.github.io/apidocs/spot_v2_en/#get-internal-assets-transfer-records
5049
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-39-s-asset-transfer-records
5050
+
4696
5051
  :param str code: unified currency code of the currency transferred
4697
5052
  :param int [since]: the earliest time in ms to fetch transfers for
4698
5053
  :param int [limit]: the maximum number of transfers structures to retrieve
@@ -4771,7 +5126,9 @@ class mexc(Exchange, ImplicitAPI):
4771
5126
  async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
4772
5127
  """
4773
5128
  transfer currency internally between wallets on the same account
4774
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#user-universal-transfer
5129
+
5130
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#user-universal-transfer
5131
+
4775
5132
  :param str code: unified currency code
4776
5133
  :param float amount: amount to transfer
4777
5134
  :param str fromAccount: account to transfer from
@@ -4893,10 +5250,12 @@ class mexc(Exchange, ImplicitAPI):
4893
5250
  }
4894
5251
  return self.safe_string(statuses, status, status)
4895
5252
 
4896
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
5253
+ async def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
4897
5254
  """
4898
5255
  make a withdrawal
4899
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-new
5256
+
5257
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#withdraw-new
5258
+
4900
5259
  :param str code: unified currency code
4901
5260
  :param float amount: the amount to withdraw
4902
5261
  :param str address: the address to withdraw to
@@ -4904,13 +5263,14 @@ class mexc(Exchange, ImplicitAPI):
4904
5263
  :param dict [params]: extra parameters specific to the exchange API endpoint
4905
5264
  :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
4906
5265
  """
5266
+ await self.load_markets()
5267
+ currency = self.currency(code)
4907
5268
  tag, params = self.handle_withdraw_tag_and_params(tag, params)
4908
- networks = self.safe_value(self.options, 'networks', {})
5269
+ networks = self.safe_dict(self.options, 'networks', {})
4909
5270
  network = self.safe_string_2(params, 'network', 'netWork') # self line allows the user to specify either ERC20 or ETH
4910
5271
  network = self.safe_string(networks, network, network) # handle ETH > ERC-20 alias
5272
+ network = self.network_code_to_id(network, currency['code'])
4911
5273
  self.check_address(address)
4912
- await self.load_markets()
4913
- currency = self.currency(code)
4914
5274
  request: dict = {
4915
5275
  'coin': currency['id'],
4916
5276
  'address': address,
@@ -4930,6 +5290,16 @@ class mexc(Exchange, ImplicitAPI):
4930
5290
  return self.parse_transaction(response, currency)
4931
5291
 
4932
5292
  async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
5293
+ """
5294
+ set hedged to True or False for a market
5295
+
5296
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#change-position-mode
5297
+
5298
+ :param bool hedged: set to True to use dualSidePosition
5299
+ :param str symbol: not used by mexc setPositionMode()
5300
+ :param dict [params]: extra parameters specific to the exchange API endpoint
5301
+ :returns dict: response from the exchange
5302
+ """
4933
5303
  request: dict = {
4934
5304
  'positionMode': 1 if hedged else 2, # 1 Hedge, 2 One-way, before changing position mode make sure that there are no active orders, planned orders, or open positions, the risk limit level will be reset to 1
4935
5305
  }
@@ -4943,6 +5313,15 @@ class mexc(Exchange, ImplicitAPI):
4943
5313
  return response
4944
5314
 
4945
5315
  async def fetch_position_mode(self, symbol: Str = None, params={}):
5316
+ """
5317
+ fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets
5318
+
5319
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-position-mode
5320
+
5321
+ :param str symbol: not used by mexc fetchPositionMode
5322
+ :param dict [params]: extra parameters specific to the exchange API endpoint
5323
+ :returns dict: an object detailing whether the market is in hedged or one-way mode
5324
+ """
4946
5325
  response = await self.contractPrivateGetPositionPositionMode(params)
4947
5326
  #
4948
5327
  # {
@@ -4960,7 +5339,9 @@ class mexc(Exchange, ImplicitAPI):
4960
5339
  async def fetch_transaction_fees(self, codes: Strings = None, params={}):
4961
5340
  """
4962
5341
  fetch deposit and withdrawal fees
4963
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
5342
+
5343
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
5344
+
4964
5345
  :param str[]|None codes: returns fees for all currencies if None
4965
5346
  :param dict [params]: extra parameters specific to the exchange API endpoint
4966
5347
  :returns dict[]: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -5053,7 +5434,9 @@ class mexc(Exchange, ImplicitAPI):
5053
5434
  async def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
5054
5435
  """
5055
5436
  fetch deposit and withdrawal fees
5056
- :see: https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
5437
+
5438
+ https://mexcdevelop.github.io/apidocs/spot_v3_en/#query-the-currency-information
5439
+
5057
5440
  :param str[]|None codes: returns fees for all currencies if None
5058
5441
  :param dict [params]: extra parameters specific to the exchange API endpoint
5059
5442
  :returns dict[]: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -5139,7 +5522,9 @@ class mexc(Exchange, ImplicitAPI):
5139
5522
  async def fetch_leverage(self, symbol: str, params={}) -> Leverage:
5140
5523
  """
5141
5524
  fetch the set leverage for a market
5142
- :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-leverage
5525
+
5526
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-leverage
5527
+
5143
5528
  :param str symbol: unified market symbol
5144
5529
  :param dict [params]: extra parameters specific to the exchange API endpoint
5145
5530
  :returns dict: a `leverage structure <https://docs.ccxt.com/#/?id=leverage-structure>`
@@ -5206,7 +5591,7 @@ class mexc(Exchange, ImplicitAPI):
5206
5591
 
5207
5592
  def handle_margin_mode_and_params(self, methodName, params={}, defaultValue=None):
5208
5593
  """
5209
- * @ignore
5594
+ @ignore
5210
5595
  marginMode specified by params["marginMode"], self.options["marginMode"], self.options["defaultMarginMode"], params["margin"] = True or self.options["defaultType"] = 'margin'
5211
5596
  :param dict [params]: extra parameters specific to the exchange API endpoint
5212
5597
  :param bool [params.margin]: True for trading spot-margin
@@ -5223,15 +5608,17 @@ class mexc(Exchange, ImplicitAPI):
5223
5608
  async def fetch_positions_history(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}) -> List[Position]:
5224
5609
  """
5225
5610
  fetches historical positions
5226
- :see: https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
5611
+
5612
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#get-the-user-s-history-position-information
5613
+
5227
5614
  :param str[] [symbols]: unified contract symbols
5228
5615
  :param int [since]: not used by mexc fetchPositionsHistory
5229
5616
  :param int [limit]: the maximum amount of candles to fetch, default=1000
5230
- :param dict params: extra parameters specific to the exchange api endpoint
5231
- *
5232
- * EXCHANGE SPECIFIC PARAMETERS
5233
- :param int type: position type,1: long, 2: short
5234
- :param int page_num: current page number, default is 1
5617
+ :param dict [params]: extra parameters specific to the exchange api endpoint
5618
+
5619
+ EXCHANGE SPECIFIC PARAMETERS
5620
+ :param int [params.type]: position type,1: long, 2: short
5621
+ :param int [params.page_num]: current page number, default is 1
5235
5622
  :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
5236
5623
  """
5237
5624
  await self.load_markets()
@@ -5288,6 +5675,48 @@ class mexc(Exchange, ImplicitAPI):
5288
5675
  positions = self.parse_positions(data, symbols, params)
5289
5676
  return self.filter_by_since_limit(positions, since, limit)
5290
5677
 
5678
+ async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
5679
+ """
5680
+ set margin mode to 'cross' or 'isolated'
5681
+
5682
+ https://mexcdevelop.github.io/apidocs/contract_v1_en/#switch-leverage
5683
+
5684
+ :param str marginMode: 'cross' or 'isolated'
5685
+ :param str [symbol]: required when there is no position, else provide params["positionId"]
5686
+ :param dict [params]: extra parameters specific to the exchange API endpoint
5687
+ :param str [params.positionId]: required when a position is set
5688
+ :param str [params.direction]: "long" or "short" required when there is no position
5689
+ :returns dict: response from the exchange
5690
+ """
5691
+ await self.load_markets()
5692
+ market = self.market(symbol)
5693
+ if market['spot']:
5694
+ raise BadSymbol(self.id + ' setMarginMode() supports contract markets only')
5695
+ marginMode = marginMode.lower()
5696
+ if marginMode != 'isolated' and marginMode != 'cross':
5697
+ raise BadRequest(self.id + ' setMarginMode() marginMode argument should be isolated or cross')
5698
+ leverage = self.safe_integer(params, 'leverage')
5699
+ if leverage is None:
5700
+ raise ArgumentsRequired(self.id + ' setMarginMode() requires a leverage parameter')
5701
+ direction = self.safe_string_lower_2(params, 'direction', 'positionId')
5702
+ request: dict = {
5703
+ 'leverage': leverage,
5704
+ 'openType': 1 if (marginMode == 'isolated') else 2,
5705
+ }
5706
+ if symbol is not None:
5707
+ request['symbol'] = market['id']
5708
+ if direction is not None:
5709
+ request['positionType'] = 2 if (direction == 'short') else 1
5710
+ params = self.omit(params, 'direction')
5711
+ response = await self.contractPrivatePostPositionChangeLeverage(self.extend(request, params))
5712
+ #
5713
+ # {success: True, code: '0'}
5714
+ #
5715
+ return self.parse_leverage(response, market) # tmp revert type
5716
+
5717
+ def nonce(self):
5718
+ return self.milliseconds() - self.safe_integer(self.options, 'timeDifference', 0)
5719
+
5291
5720
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
5292
5721
  section = self.safe_string(api, 0)
5293
5722
  access = self.safe_string(api, 1)
@@ -5298,12 +5727,20 @@ class mexc(Exchange, ImplicitAPI):
5298
5727
  url = self.urls['api'][section][access] + '/' + path
5299
5728
  else:
5300
5729
  url = self.urls['api'][section][access] + '/api/' + self.version + '/' + path
5301
- paramsEncoded = ''
5730
+ urlParams = params
5302
5731
  if access == 'private':
5303
- params['timestamp'] = self.milliseconds()
5304
- params['recvWindow'] = self.safe_integer(self.options, 'recvWindow', 5000)
5305
- if params:
5306
- paramsEncoded = self.urlencode(params)
5732
+ if section == 'broker' and ((method == 'POST') or (method == 'PUT') or (method == 'DELETE')):
5733
+ urlParams = {
5734
+ 'timestamp': self.nonce(),
5735
+ 'recvWindow': self.safe_integer(self.options, 'recvWindow', 5000),
5736
+ }
5737
+ body = self.json(params)
5738
+ else:
5739
+ urlParams['timestamp'] = self.nonce()
5740
+ urlParams['recvWindow'] = self.safe_integer(self.options, 'recvWindow', 5000)
5741
+ paramsEncoded = ''
5742
+ if urlParams:
5743
+ paramsEncoded = self.urlencode(urlParams)
5307
5744
  url += '?' + paramsEncoded
5308
5745
  if access == 'private':
5309
5746
  self.check_required_credentials()
@@ -5323,7 +5760,7 @@ class mexc(Exchange, ImplicitAPI):
5323
5760
  url += '?' + self.urlencode(params)
5324
5761
  else:
5325
5762
  self.check_required_credentials()
5326
- timestamp = str(self.milliseconds())
5763
+ timestamp = str(self.nonce())
5327
5764
  auth = ''
5328
5765
  headers = {
5329
5766
  'ApiKey': self.apiKey,