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