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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (529) hide show
  1. ccxt/__init__.py +39 -35
  2. ccxt/abantether.py +8 -8
  3. ccxt/abstract/alpaca.py +4 -0
  4. ccxt/abstract/apex.py +31 -0
  5. ccxt/abstract/bigone.py +1 -1
  6. ccxt/abstract/binance.py +106 -48
  7. ccxt/abstract/binancecoinm.py +106 -48
  8. ccxt/abstract/binanceus.py +141 -83
  9. ccxt/abstract/binanceusdm.py +106 -48
  10. ccxt/abstract/bingx.py +50 -1
  11. ccxt/abstract/bitbank.py +5 -0
  12. ccxt/abstract/bitfinex.py +136 -65
  13. ccxt/abstract/bitflyer.py +1 -0
  14. ccxt/abstract/bitget.py +67 -0
  15. ccxt/abstract/bitmart.py +19 -1
  16. ccxt/abstract/bitopro.py +1 -0
  17. ccxt/abstract/bitrue.py +68 -68
  18. ccxt/abstract/bitstamp.py +1 -0
  19. ccxt/abstract/blofin.py +30 -0
  20. ccxt/abstract/btcbox.py +2 -0
  21. ccxt/abstract/bybit.py +28 -13
  22. ccxt/abstract/cex.py +28 -29
  23. ccxt/abstract/coinbaseexchange.py +1 -0
  24. ccxt/abstract/coinbaseinternational.py +1 -1
  25. ccxt/abstract/cryptocom.py +16 -0
  26. ccxt/abstract/cryptomus.py +20 -0
  27. ccxt/abstract/defx.py +69 -0
  28. ccxt/abstract/deribit.py +1 -0
  29. ccxt/abstract/derive.py +117 -0
  30. ccxt/abstract/digifinex.py +1 -0
  31. ccxt/abstract/ellipx.py +25 -0
  32. ccxt/abstract/foxbit.py +26 -0
  33. ccxt/abstract/gate.py +19 -0
  34. ccxt/abstract/gateio.py +19 -0
  35. ccxt/abstract/gemini.py +1 -0
  36. ccxt/abstract/hibachi.py +26 -0
  37. ccxt/abstract/hyperliquid.py +1 -1
  38. ccxt/abstract/independentreserve.py +6 -0
  39. ccxt/abstract/kraken.py +1 -0
  40. ccxt/abstract/krakenfutures.py +4 -0
  41. ccxt/abstract/kucoin.py +10 -0
  42. ccxt/abstract/kucoinfutures.py +18 -0
  43. ccxt/abstract/lbank.py +2 -1
  44. ccxt/abstract/luno.py +1 -0
  45. ccxt/abstract/mexc.py +2 -0
  46. ccxt/abstract/modetrade.py +119 -0
  47. ccxt/abstract/myokx.py +349 -0
  48. ccxt/abstract/oceanex.py +5 -0
  49. ccxt/abstract/okx.py +25 -0
  50. ccxt/abstract/okxus.py +349 -0
  51. ccxt/abstract/onetrading.py +0 -12
  52. ccxt/abstract/paradex.py +23 -0
  53. ccxt/abstract/phemex.py +2 -0
  54. ccxt/abstract/poloniex.py +36 -0
  55. ccxt/abstract/tradeogre.py +3 -1
  56. ccxt/abstract/upbit.py +51 -34
  57. ccxt/abstract/whitebit.py +16 -0
  58. ccxt/abstract/woo.py +64 -6
  59. ccxt/abstract/xt.py +10 -5
  60. ccxt/afratether.py +7 -7
  61. ccxt/alpaca.py +828 -51
  62. ccxt/apex.py +1875 -0
  63. ccxt/arzinja.py +7 -7
  64. ccxt/arzplus.py +9 -9
  65. ccxt/ascendex.py +501 -306
  66. ccxt/async_support/__init__.py +39 -35
  67. ccxt/async_support/abantether.py +8 -8
  68. ccxt/async_support/afratether.py +9 -9
  69. ccxt/async_support/alpaca.py +828 -51
  70. ccxt/async_support/apex.py +1875 -0
  71. ccxt/async_support/arzinja.py +10 -10
  72. ccxt/async_support/arzplus.py +12 -12
  73. ccxt/async_support/ascendex.py +502 -306
  74. ccxt/async_support/base/exchange.py +303 -89
  75. ccxt/async_support/base/ws/cache.py +9 -3
  76. ccxt/async_support/base/ws/client.py +173 -38
  77. ccxt/async_support/base/ws/future.py +25 -37
  78. ccxt/async_support/bequant.py +5 -3
  79. ccxt/async_support/bigone.py +279 -144
  80. ccxt/async_support/binance.py +2347 -1158
  81. ccxt/async_support/binancecoinm.py +9 -3
  82. ccxt/async_support/binanceus.py +17 -3
  83. ccxt/async_support/binanceusdm.py +9 -4
  84. ccxt/async_support/bingx.py +2962 -920
  85. ccxt/async_support/bit2c.py +147 -27
  86. ccxt/async_support/bitbank.py +151 -23
  87. ccxt/async_support/bitbns.py +104 -30
  88. ccxt/async_support/bitfinex.py +3291 -1113
  89. ccxt/async_support/bitflyer.py +202 -27
  90. ccxt/async_support/bitget.py +3683 -1538
  91. ccxt/async_support/bithumb.py +195 -38
  92. ccxt/async_support/bitimen.py +12 -12
  93. ccxt/async_support/bitir.py +38 -38
  94. ccxt/async_support/bitmart.py +1288 -350
  95. ccxt/async_support/bitmex.py +260 -75
  96. ccxt/async_support/bitopro.py +262 -62
  97. ccxt/async_support/bitpin.py +17 -16
  98. ccxt/async_support/bitrue.py +459 -290
  99. ccxt/async_support/bitso.py +199 -54
  100. ccxt/async_support/bitstamp.py +230 -96
  101. ccxt/async_support/bitteam.py +167 -25
  102. ccxt/async_support/{huobijp.py → bittrade.py} +158 -30
  103. ccxt/async_support/bitvavo.py +213 -49
  104. ccxt/async_support/blockchaincom.py +160 -46
  105. ccxt/async_support/blofin.py +502 -120
  106. ccxt/async_support/btcalpha.py +169 -31
  107. ccxt/async_support/btcbox.py +292 -23
  108. ccxt/async_support/btcmarkets.py +211 -58
  109. ccxt/async_support/btcturk.py +161 -38
  110. ccxt/async_support/bybit.py +1775 -1030
  111. ccxt/async_support/cex.py +1440 -1303
  112. ccxt/async_support/coinbase.py +724 -212
  113. ccxt/async_support/coinbaseadvanced.py +2 -1
  114. ccxt/async_support/coinbaseexchange.py +388 -89
  115. ccxt/async_support/coinbaseinternational.py +412 -57
  116. ccxt/async_support/coincatch.py +177 -78
  117. ccxt/async_support/coincheck.py +135 -19
  118. ccxt/async_support/coinex.py +606 -232
  119. ccxt/async_support/coinmate.py +189 -63
  120. ccxt/async_support/coinmetro.py +195 -54
  121. ccxt/async_support/coinone.py +158 -51
  122. ccxt/async_support/coinsph.py +336 -61
  123. ccxt/async_support/coinspot.py +151 -52
  124. ccxt/async_support/cryptocom.py +661 -111
  125. ccxt/async_support/cryptomus.py +1137 -0
  126. ccxt/async_support/defx.py +2071 -0
  127. ccxt/async_support/delta.py +299 -99
  128. ccxt/async_support/deribit.py +348 -126
  129. ccxt/async_support/derive.py +2572 -0
  130. ccxt/async_support/digifinex.py +430 -214
  131. ccxt/async_support/ellipx.py +2029 -0
  132. ccxt/async_support/eterex.py +10 -10
  133. ccxt/async_support/excoino.py +31 -31
  134. ccxt/async_support/exir.py +14 -14
  135. ccxt/async_support/exmo.py +344 -131
  136. ccxt/async_support/exnovin.py +10 -10
  137. ccxt/async_support/farhadexchange.py +12 -12
  138. ccxt/async_support/fmfwio.py +2 -1
  139. ccxt/async_support/foxbit.py +1935 -0
  140. ccxt/async_support/gate.py +1351 -529
  141. ccxt/async_support/gateio.py +2 -1
  142. ccxt/async_support/gemini.py +144 -39
  143. ccxt/async_support/hashkey.py +152 -109
  144. ccxt/async_support/hibachi.py +2080 -0
  145. ccxt/async_support/hitbtc.py +395 -167
  146. ccxt/async_support/hitobit.py +12 -12
  147. ccxt/async_support/hollaex.py +307 -119
  148. ccxt/async_support/htx.py +851 -383
  149. ccxt/async_support/huobi.py +2 -1
  150. ccxt/async_support/hyperliquid.py +1848 -536
  151. ccxt/async_support/independentreserve.py +288 -15
  152. ccxt/async_support/indodax.py +190 -33
  153. ccxt/async_support/jibitex.py +12 -12
  154. ccxt/async_support/kraken.py +795 -351
  155. ccxt/async_support/krakenfutures.py +214 -62
  156. ccxt/async_support/kucoin.py +715 -396
  157. ccxt/async_support/kucoinfutures.py +652 -89
  158. ccxt/async_support/latoken.py +217 -113
  159. ccxt/async_support/lbank.py +425 -97
  160. ccxt/async_support/luno.py +382 -35
  161. ccxt/async_support/mercado.py +113 -6
  162. ccxt/async_support/mexc.py +874 -437
  163. ccxt/async_support/modetrade.py +2818 -0
  164. ccxt/async_support/myokx.py +54 -0
  165. ccxt/async_support/ndax.py +221 -64
  166. ccxt/async_support/nobitex.py +31 -37
  167. ccxt/async_support/novadax.py +190 -34
  168. ccxt/async_support/oceanex.py +217 -28
  169. ccxt/async_support/okcoin.py +253 -145
  170. ccxt/async_support/okexchange.py +11 -11
  171. ccxt/async_support/okx.py +1088 -351
  172. ccxt/async_support/okxus.py +54 -0
  173. ccxt/async_support/ompfinex.py +25 -24
  174. ccxt/async_support/onetrading.py +213 -392
  175. ccxt/async_support/oxfun.py +245 -166
  176. ccxt/async_support/p2b.py +151 -29
  177. ccxt/async_support/paradex.py +562 -49
  178. ccxt/async_support/paymium.py +82 -19
  179. ccxt/async_support/phemex.py +713 -172
  180. ccxt/async_support/poloniex.py +1602 -283
  181. ccxt/async_support/probit.py +224 -95
  182. ccxt/async_support/ramzinex.py +30 -27
  183. ccxt/async_support/sarmayex.py +9 -9
  184. ccxt/async_support/sarrafex.py +13 -13
  185. ccxt/async_support/tabdeal.py +14 -13
  186. ccxt/async_support/tetherland.py +9 -9
  187. ccxt/async_support/timex.py +210 -51
  188. ccxt/async_support/tokocrypto.py +167 -47
  189. ccxt/async_support/tradeogre.py +266 -31
  190. ccxt/async_support/twox.py +9 -9
  191. ccxt/async_support/ubitex.py +12 -12
  192. ccxt/async_support/upbit.py +568 -165
  193. ccxt/async_support/vertex.py +160 -32
  194. ccxt/async_support/wallex.py +12 -12
  195. ccxt/async_support/wavesexchange.py +165 -30
  196. ccxt/async_support/whitebit.py +975 -127
  197. ccxt/async_support/woo.py +1918 -1016
  198. ccxt/async_support/woofipro.py +433 -141
  199. ccxt/async_support/xt.py +649 -193
  200. ccxt/async_support/yobit.py +195 -70
  201. ccxt/async_support/zaif.py +91 -15
  202. ccxt/async_support/zonda.py +151 -36
  203. ccxt/base/decimal_to_precision.py +14 -10
  204. ccxt/base/errors.py +49 -18
  205. ccxt/base/exchange.py +1556 -450
  206. ccxt/base/precise.py +10 -0
  207. ccxt/base/types.py +114 -6
  208. ccxt/bequant.py +5 -3
  209. ccxt/bigone.py +279 -144
  210. ccxt/binance.py +2347 -1158
  211. ccxt/binancecoinm.py +9 -3
  212. ccxt/binanceus.py +17 -3
  213. ccxt/binanceusdm.py +9 -4
  214. ccxt/bingx.py +2962 -920
  215. ccxt/bit2c.py +147 -27
  216. ccxt/bitbank.py +151 -23
  217. ccxt/bitbns.py +104 -30
  218. ccxt/bitfinex.py +3290 -1113
  219. ccxt/bitflyer.py +202 -27
  220. ccxt/bitget.py +3683 -1538
  221. ccxt/bithumb.py +194 -38
  222. ccxt/bitimen.py +9 -9
  223. ccxt/bitir.py +35 -35
  224. ccxt/bitmart.py +1288 -350
  225. ccxt/bitmex.py +260 -75
  226. ccxt/bitopro.py +262 -62
  227. ccxt/bitpin.py +15 -14
  228. ccxt/bitrue.py +459 -290
  229. ccxt/bitso.py +199 -54
  230. ccxt/bitstamp.py +230 -96
  231. ccxt/bitteam.py +167 -25
  232. ccxt/{huobijp.py → bittrade.py} +158 -30
  233. ccxt/bitvavo.py +213 -49
  234. ccxt/blockchaincom.py +160 -46
  235. ccxt/blofin.py +502 -120
  236. ccxt/btcalpha.py +169 -31
  237. ccxt/btcbox.py +291 -23
  238. ccxt/btcmarkets.py +211 -58
  239. ccxt/btcturk.py +161 -38
  240. ccxt/bybit.py +1775 -1030
  241. ccxt/cex.py +1439 -1303
  242. ccxt/coinbase.py +724 -212
  243. ccxt/coinbaseadvanced.py +2 -1
  244. ccxt/coinbaseexchange.py +388 -89
  245. ccxt/coinbaseinternational.py +412 -57
  246. ccxt/coincatch.py +177 -78
  247. ccxt/coincheck.py +135 -19
  248. ccxt/coinex.py +606 -232
  249. ccxt/coinmate.py +189 -63
  250. ccxt/coinmetro.py +194 -54
  251. ccxt/coinone.py +158 -51
  252. ccxt/coinsph.py +336 -61
  253. ccxt/coinspot.py +151 -52
  254. ccxt/cryptocom.py +661 -111
  255. ccxt/cryptomus.py +1137 -0
  256. ccxt/defx.py +2070 -0
  257. ccxt/delta.py +299 -99
  258. ccxt/deribit.py +348 -126
  259. ccxt/derive.py +2571 -0
  260. ccxt/digifinex.py +430 -214
  261. ccxt/ellipx.py +2029 -0
  262. ccxt/eterex.py +7 -7
  263. ccxt/excoino.py +29 -29
  264. ccxt/exir.py +11 -11
  265. ccxt/exmo.py +343 -131
  266. ccxt/exnovin.py +8 -8
  267. ccxt/farhadexchange.py +10 -10
  268. ccxt/fmfwio.py +2 -1
  269. ccxt/foxbit.py +1935 -0
  270. ccxt/gate.py +1351 -529
  271. ccxt/gateio.py +2 -1
  272. ccxt/gemini.py +144 -39
  273. ccxt/hashkey.py +152 -109
  274. ccxt/hibachi.py +2079 -0
  275. ccxt/hitbtc.py +395 -167
  276. ccxt/hitobit.py +9 -9
  277. ccxt/hollaex.py +307 -119
  278. ccxt/htx.py +851 -383
  279. ccxt/huobi.py +2 -1
  280. ccxt/hyperliquid.py +1848 -536
  281. ccxt/independentreserve.py +287 -15
  282. ccxt/indodax.py +190 -33
  283. ccxt/jibitex.py +9 -9
  284. ccxt/kraken.py +794 -351
  285. ccxt/krakenfutures.py +214 -62
  286. ccxt/kucoin.py +715 -396
  287. ccxt/kucoinfutures.py +652 -89
  288. ccxt/latoken.py +217 -113
  289. ccxt/lbank.py +425 -97
  290. ccxt/luno.py +382 -35
  291. ccxt/mercado.py +113 -6
  292. ccxt/mexc.py +873 -437
  293. ccxt/modetrade.py +2818 -0
  294. ccxt/myokx.py +54 -0
  295. ccxt/ndax.py +221 -64
  296. ccxt/nobitex.py +29 -35
  297. ccxt/novadax.py +190 -34
  298. ccxt/oceanex.py +217 -28
  299. ccxt/okcoin.py +253 -145
  300. ccxt/okexchange.py +9 -9
  301. ccxt/okx.py +1088 -351
  302. ccxt/okxus.py +54 -0
  303. ccxt/ompfinex.py +22 -21
  304. ccxt/onetrading.py +213 -392
  305. ccxt/oxfun.py +245 -166
  306. ccxt/p2b.py +151 -29
  307. ccxt/paradex.py +562 -49
  308. ccxt/paymium.py +82 -19
  309. ccxt/phemex.py +712 -172
  310. ccxt/poloniex.py +1601 -283
  311. ccxt/pro/__init__.py +76 -17
  312. ccxt/pro/alpaca.py +21 -6
  313. ccxt/pro/apex.py +984 -0
  314. ccxt/pro/ascendex.py +58 -10
  315. ccxt/pro/bequant.py +6 -1
  316. ccxt/pro/binance.py +728 -156
  317. ccxt/pro/binancecoinm.py +6 -2
  318. ccxt/pro/binanceus.py +8 -4
  319. ccxt/pro/binanceusdm.py +7 -2
  320. ccxt/pro/bingx.py +333 -142
  321. ccxt/pro/bitfinex.py +727 -262
  322. ccxt/pro/bitget.py +570 -79
  323. ccxt/pro/bithumb.py +20 -6
  324. ccxt/pro/bitmart.py +216 -87
  325. ccxt/pro/bitmex.py +47 -9
  326. ccxt/pro/bitopro.py +26 -14
  327. ccxt/pro/bitrue.py +22 -22
  328. ccxt/pro/bitstamp.py +54 -21
  329. ccxt/pro/{huobijp.py → bittrade.py} +7 -6
  330. ccxt/pro/bitvavo.py +191 -67
  331. ccxt/pro/blockchaincom.py +21 -8
  332. ccxt/pro/blofin.py +9 -1
  333. ccxt/pro/bybit.py +632 -245
  334. ccxt/pro/cex.py +59 -24
  335. ccxt/pro/coinbase.py +102 -73
  336. ccxt/pro/coinbaseadvanced.py +2 -1
  337. ccxt/pro/coinbaseexchange.py +8 -8
  338. ccxt/pro/coinbaseinternational.py +181 -25
  339. ccxt/pro/coincatch.py +6 -7
  340. ccxt/pro/coincheck.py +11 -6
  341. ccxt/pro/coinex.py +967 -665
  342. ccxt/pro/coinone.py +16 -9
  343. ccxt/pro/cryptocom.py +448 -45
  344. ccxt/pro/defx.py +831 -0
  345. ccxt/pro/deribit.py +150 -14
  346. ccxt/pro/derive.py +704 -0
  347. ccxt/pro/exmo.py +239 -6
  348. ccxt/pro/gate.py +623 -65
  349. ccxt/pro/gateio.py +2 -1
  350. ccxt/pro/gemini.py +27 -11
  351. ccxt/pro/hashkey.py +2 -2
  352. ccxt/pro/hitbtc.py +196 -91
  353. ccxt/pro/hollaex.py +23 -7
  354. ccxt/pro/htx.py +51 -14
  355. ccxt/pro/huobi.py +2 -1
  356. ccxt/pro/hyperliquid.py +591 -27
  357. ccxt/pro/independentreserve.py +9 -6
  358. ccxt/pro/kraken.py +640 -320
  359. ccxt/pro/krakenfutures.py +62 -35
  360. ccxt/pro/kucoin.py +267 -46
  361. ccxt/pro/kucoinfutures.py +165 -21
  362. ccxt/pro/lbank.py +102 -21
  363. ccxt/pro/luno.py +12 -8
  364. ccxt/pro/mexc.py +877 -111
  365. ccxt/pro/modetrade.py +1271 -0
  366. ccxt/pro/myokx.py +38 -0
  367. ccxt/pro/ndax.py +15 -2
  368. ccxt/pro/okcoin.py +23 -4
  369. ccxt/pro/okx.py +573 -98
  370. ccxt/pro/okxus.py +38 -0
  371. ccxt/pro/onetrading.py +30 -13
  372. ccxt/pro/oxfun.py +131 -27
  373. ccxt/pro/p2b.py +88 -22
  374. ccxt/pro/paradex.py +3 -3
  375. ccxt/pro/phemex.py +75 -21
  376. ccxt/pro/poloniex.py +124 -41
  377. ccxt/pro/probit.py +87 -80
  378. ccxt/pro/tradeogre.py +272 -0
  379. ccxt/pro/upbit.py +152 -12
  380. ccxt/pro/vertex.py +8 -3
  381. ccxt/pro/whitebit.py +58 -5
  382. ccxt/pro/woo.py +228 -37
  383. ccxt/pro/woofipro.py +106 -18
  384. ccxt/pro/xt.py +111 -5
  385. ccxt/probit.py +224 -95
  386. ccxt/protobuf/__init__.py +0 -0
  387. ccxt/protobuf/mexc/PrivateAccountV3Api_pb2.py +37 -0
  388. ccxt/protobuf/mexc/PrivateDealsV3Api_pb2.py +37 -0
  389. ccxt/protobuf/mexc/PrivateOrdersV3Api_pb2.py +37 -0
  390. ccxt/protobuf/mexc/PublicAggreBookTickerV3Api_pb2.py +37 -0
  391. ccxt/protobuf/mexc/PublicAggreDealsV3Api_pb2.py +39 -0
  392. ccxt/protobuf/mexc/PublicAggreDepthsV3Api_pb2.py +39 -0
  393. ccxt/protobuf/mexc/PublicBookTickerBatchV3Api_pb2.py +38 -0
  394. ccxt/protobuf/mexc/PublicBookTickerV3Api_pb2.py +37 -0
  395. ccxt/protobuf/mexc/PublicDealsV3Api_pb2.py +39 -0
  396. ccxt/protobuf/mexc/PublicIncreaseDepthsBatchV3Api_pb2.py +38 -0
  397. ccxt/protobuf/mexc/PublicIncreaseDepthsV3Api_pb2.py +39 -0
  398. ccxt/protobuf/mexc/PublicLimitDepthsV3Api_pb2.py +39 -0
  399. ccxt/protobuf/mexc/PublicMiniTickerV3Api_pb2.py +37 -0
  400. ccxt/protobuf/mexc/PublicMiniTickersV3Api_pb2.py +38 -0
  401. ccxt/protobuf/mexc/PublicSpotKlineV3Api_pb2.py +37 -0
  402. ccxt/protobuf/mexc/PushDataV3ApiWrapper_pb2.py +52 -0
  403. ccxt/protobuf/mexc/__init__.py +0 -0
  404. ccxt/ramzinex.py +28 -25
  405. ccxt/sarmayex.py +7 -7
  406. ccxt/sarrafex.py +10 -10
  407. ccxt/static_dependencies/__init__.py +1 -1
  408. ccxt/static_dependencies/lark/py.typed +0 -0
  409. ccxt/static_dependencies/marshmallow/py.typed +0 -0
  410. ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
  411. ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
  412. ccxt/tabdeal.py +12 -11
  413. ccxt/test/tests_async.py +261 -57
  414. ccxt/test/tests_helpers.py +1 -3
  415. ccxt/test/tests_init.py +4 -3
  416. ccxt/test/tests_sync.py +261 -57
  417. ccxt/tetherland.py +7 -7
  418. ccxt/timex.py +210 -51
  419. ccxt/tokocrypto.py +167 -47
  420. ccxt/tradeogre.py +266 -31
  421. ccxt/twox.py +7 -7
  422. ccxt/ubitex.py +9 -9
  423. ccxt/upbit.py +568 -165
  424. ccxt/vertex.py +160 -32
  425. ccxt/wallex.py +9 -9
  426. ccxt/wavesexchange.py +165 -30
  427. ccxt/whitebit.py +975 -127
  428. ccxt/woo.py +1917 -1016
  429. ccxt/woofipro.py +432 -141
  430. ccxt/xt.py +649 -193
  431. ccxt/yobit.py +194 -70
  432. ccxt/zaif.py +91 -15
  433. ccxt/zonda.py +151 -36
  434. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/METADATA +225 -73
  435. ccxt_ir-4.5.0.dist-info/RECORD +743 -0
  436. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/WHEEL +1 -1
  437. ccxt/__test__.py +0 -7
  438. ccxt/abstract/ace.py +0 -15
  439. ccxt/abstract/bitbay.py +0 -53
  440. ccxt/abstract/bitcoincom.py +0 -115
  441. ccxt/abstract/bitfinex2.py +0 -139
  442. ccxt/abstract/bitpanda.py +0 -35
  443. ccxt/abstract/bl3p.py +0 -19
  444. ccxt/abstract/coinlist.py +0 -54
  445. ccxt/abstract/currencycom.py +0 -68
  446. ccxt/abstract/hitbtc3.py +0 -115
  447. ccxt/abstract/idex.py +0 -26
  448. ccxt/abstract/kuna.py +0 -182
  449. ccxt/abstract/lykke.py +0 -29
  450. ccxt/abstract/poloniexfutures.py +0 -48
  451. ccxt/abstract/wazirx.py +0 -30
  452. ccxt/ace.py +0 -1012
  453. ccxt/async_support/ace.py +0 -1012
  454. ccxt/async_support/base/ws/aiohttp_client.py +0 -125
  455. ccxt/async_support/base/ws/fast_client.py +0 -96
  456. ccxt/async_support/bitbay.py +0 -17
  457. ccxt/async_support/bitcoincom.py +0 -17
  458. ccxt/async_support/bitfinex2.py +0 -3552
  459. ccxt/async_support/bitpanda.py +0 -16
  460. ccxt/async_support/bl3p.py +0 -485
  461. ccxt/async_support/coinlist.py +0 -2243
  462. ccxt/async_support/currencycom.py +0 -1950
  463. ccxt/async_support/hitbtc3.py +0 -16
  464. ccxt/async_support/idex.py +0 -1766
  465. ccxt/async_support/kuna.py +0 -1841
  466. ccxt/async_support/lykke.py +0 -1270
  467. ccxt/async_support/poloniexfutures.py +0 -1717
  468. ccxt/async_support/wazirx.py +0 -1224
  469. ccxt/bitbay.py +0 -17
  470. ccxt/bitcoincom.py +0 -17
  471. ccxt/bitfinex2.py +0 -3552
  472. ccxt/bitpanda.py +0 -16
  473. ccxt/bl3p.py +0 -485
  474. ccxt/coinlist.py +0 -2243
  475. ccxt/currencycom.py +0 -1950
  476. ccxt/hitbtc3.py +0 -16
  477. ccxt/idex.py +0 -1766
  478. ccxt/kuna.py +0 -1841
  479. ccxt/lykke.py +0 -1270
  480. ccxt/poloniexfutures.py +0 -1717
  481. ccxt/pro/bitcoincom.py +0 -34
  482. ccxt/pro/bitfinex2.py +0 -1083
  483. ccxt/pro/bitpanda.py +0 -15
  484. ccxt/pro/currencycom.py +0 -536
  485. ccxt/pro/idex.py +0 -672
  486. ccxt/pro/poloniexfutures.py +0 -990
  487. ccxt/pro/wazirx.py +0 -749
  488. ccxt/test/base/__init__.py +0 -29
  489. ccxt/test/base/test_account.py +0 -26
  490. ccxt/test/base/test_balance.py +0 -56
  491. ccxt/test/base/test_borrow_interest.py +0 -35
  492. ccxt/test/base/test_borrow_rate.py +0 -32
  493. ccxt/test/base/test_calculate_fee.py +0 -51
  494. ccxt/test/base/test_crypto.py +0 -127
  495. ccxt/test/base/test_currency.py +0 -76
  496. ccxt/test/base/test_datetime.py +0 -109
  497. ccxt/test/base/test_decimal_to_precision.py +0 -392
  498. ccxt/test/base/test_deep_extend.py +0 -68
  499. ccxt/test/base/test_deposit_withdrawal.py +0 -50
  500. ccxt/test/base/test_exchange_datetime_functions.py +0 -76
  501. ccxt/test/base/test_funding_rate_history.py +0 -29
  502. ccxt/test/base/test_last_price.py +0 -31
  503. ccxt/test/base/test_ledger_entry.py +0 -45
  504. ccxt/test/base/test_ledger_item.py +0 -48
  505. ccxt/test/base/test_leverage_tier.py +0 -33
  506. ccxt/test/base/test_liquidation.py +0 -50
  507. ccxt/test/base/test_margin_mode.py +0 -24
  508. ccxt/test/base/test_margin_modification.py +0 -35
  509. ccxt/test/base/test_market.py +0 -193
  510. ccxt/test/base/test_number.py +0 -411
  511. ccxt/test/base/test_ohlcv.py +0 -33
  512. ccxt/test/base/test_open_interest.py +0 -32
  513. ccxt/test/base/test_order.py +0 -64
  514. ccxt/test/base/test_order_book.py +0 -69
  515. ccxt/test/base/test_position.py +0 -60
  516. ccxt/test/base/test_shared_methods.py +0 -353
  517. ccxt/test/base/test_status.py +0 -24
  518. ccxt/test/base/test_throttle.py +0 -126
  519. ccxt/test/base/test_ticker.py +0 -92
  520. ccxt/test/base/test_trade.py +0 -47
  521. ccxt/test/base/test_trading_fee.py +0 -26
  522. ccxt/test/base/test_transaction.py +0 -39
  523. ccxt/test/test_async.py +0 -1649
  524. ccxt/test/test_sync.py +0 -1648
  525. ccxt/wazirx.py +0 -1224
  526. ccxt_ir-4.3.46.0.3.dist-info/RECORD +0 -773
  527. /ccxt/abstract/{huobijp.py → bittrade.py} +0 -0
  528. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info/licenses}/LICENSE.txt +0 -0
  529. {ccxt_ir-4.3.46.0.3.dist-info → ccxt_ir-4.5.0.dist-info}/top_level.txt +0 -0
ccxt/async_support/xt.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.xt import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Currencies, Currency, Int, LeverageTier, MarginModification, Market, Num, Order, OrderSide, OrderType, Str, Tickers, Transaction, TransferEntry
10
+ from ccxt.base.types import Any, Currencies, Currency, DepositAddress, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderSide, OrderType, Position, Str, Tickers, FundingRate, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -28,7 +28,7 @@ from ccxt.base.precise import Precise
28
28
 
29
29
  class xt(Exchange, ImplicitAPI):
30
30
 
31
- def describe(self):
31
+ def describe(self) -> Any:
32
32
  return self.deep_extend(super(xt, self).describe(), {
33
33
  'id': 'xt',
34
34
  'name': 'XT',
@@ -40,7 +40,7 @@ class xt(Exchange, ImplicitAPI):
40
40
  'rateLimit': 100,
41
41
  'version': 'v4',
42
42
  'certified': False,
43
- 'pro': False,
43
+ 'pro': True,
44
44
  'has': {
45
45
  'CORS': False,
46
46
  'spot': True,
@@ -59,7 +59,7 @@ class xt(Exchange, ImplicitAPI):
59
59
  'createOrder': True,
60
60
  'createPostOnlyOrder': False,
61
61
  'createReduceOnlyOrder': True,
62
- 'editOrder': False,
62
+ 'editOrder': True,
63
63
  'fetchAccounts': False,
64
64
  'fetchBalance': True,
65
65
  'fetchBidsAsks': True,
@@ -73,11 +73,15 @@ class xt(Exchange, ImplicitAPI):
73
73
  'fetchCurrencies': True,
74
74
  'fetchDeposit': False,
75
75
  'fetchDepositAddress': True,
76
+ 'fetchDepositAddresses': False,
77
+ 'fetchDepositAddressesByNetwork': False,
76
78
  'fetchDeposits': True,
77
79
  'fetchDepositWithdrawals': False,
78
80
  'fetchDepositWithdrawFee': False,
79
81
  'fetchDepositWithdrawFees': False,
80
82
  'fetchFundingHistory': True,
83
+ 'fetchFundingInterval': True,
84
+ 'fetchFundingIntervals': False,
81
85
  'fetchFundingRate': True,
82
86
  'fetchFundingRateHistory': True,
83
87
  'fetchFundingRates': False,
@@ -125,7 +129,7 @@ class xt(Exchange, ImplicitAPI):
125
129
  'repayMargin': False,
126
130
  'setLeverage': True,
127
131
  'setMargin': False,
128
- 'setMarginMode': False,
132
+ 'setMarginMode': True,
129
133
  'setPositionMode': False,
130
134
  'signIn': False,
131
135
  'transfer': True,
@@ -153,16 +157,16 @@ class xt(Exchange, ImplicitAPI):
153
157
  'spot': {
154
158
  'get': {
155
159
  'currencies': 1,
156
- 'depth': 0.05,
157
- 'kline': 0.1,
158
- 'symbol': 1, # 0.1 for a single symbol
159
- 'ticker': 1, # 0.1 for a single symbol
160
- 'ticker/book': 1, # 0.1 for a single symbol
161
- 'ticker/price': 1, # 0.1 for a single symbol
162
- 'ticker/24h': 1, # 0.1 for a single symbol
160
+ 'depth': 10,
161
+ 'kline': 1,
162
+ 'symbol': 1, # 1 for a single symbol
163
+ 'ticker': 1, # 1 for a single symbol
164
+ 'ticker/book': 1, # 1 for a single symbol
165
+ 'ticker/price': 1, # 1 for a single symbol
166
+ 'ticker/24h': 1, # 1 for a single symbol
163
167
  'time': 1,
164
- 'trade/history': 0.1,
165
- 'trade/recent': 0.1,
168
+ 'trade/history': 1,
169
+ 'trade/recent': 1,
166
170
  'wallet/support/currency': 1,
167
171
  },
168
172
  },
@@ -232,15 +236,19 @@ class xt(Exchange, ImplicitAPI):
232
236
  },
233
237
  'post': {
234
238
  'order': 0.2,
235
- 'withdraw': 1,
239
+ 'withdraw': 10,
236
240
  'balance/transfer': 1,
237
241
  'balance/account/transfer': 1,
242
+ 'ws-token': 1,
238
243
  },
239
244
  'delete': {
240
245
  'batch-order': 1,
241
246
  'open-order': 1,
242
247
  'order/{orderId}': 1,
243
248
  },
249
+ 'put': {
250
+ 'order/{orderId}': 1,
251
+ },
244
252
  },
245
253
  'linear': {
246
254
  'get': {
@@ -275,6 +283,7 @@ class xt(Exchange, ImplicitAPI):
275
283
  'future/trade/v1/order/cancel-all': 1,
276
284
  'future/trade/v1/order/create': 1,
277
285
  'future/trade/v1/order/create-batch': 1,
286
+ 'future/trade/v1/order/update': 1,
278
287
  'future/user/v1/account/open': 1,
279
288
  'future/user/v1/position/adjust-leverage': 1,
280
289
  'future/user/v1/position/auto-margin': 1,
@@ -282,6 +291,7 @@ class xt(Exchange, ImplicitAPI):
282
291
  'future/user/v1/position/margin': 1,
283
292
  'future/user/v1/user/collection/add': 1,
284
293
  'future/user/v1/user/collection/cancel': 1,
294
+ 'future/user/v1/position/change-type': 1,
285
295
  },
286
296
  },
287
297
  'inverse': {
@@ -317,6 +327,7 @@ class xt(Exchange, ImplicitAPI):
317
327
  'future/trade/v1/order/cancel-all': 1,
318
328
  'future/trade/v1/order/create': 1,
319
329
  'future/trade/v1/order/create-batch': 1,
330
+ 'future/trade/v1/order/update': 1,
320
331
  'future/user/v1/account/open': 1,
321
332
  'future/user/v1/position/adjust-leverage': 1,
322
333
  'future/user/v1/position/auto-margin': 1,
@@ -527,10 +538,12 @@ class xt(Exchange, ImplicitAPI):
527
538
  'TRANSFER_012': PermissionDenied, # Currency transfer prohibited
528
539
  'symbol_not_support_trading_via_api': BadSymbol, # {"returnCode":1,"msgInfo":"failure","error":{"code":"symbol_not_support_trading_via_api","msg":"The symbol does not support trading via API"},"result":null}
529
540
  'open_order_min_nominal_value_limit': InvalidOrder, # {"returnCode":1,"msgInfo":"failure","error":{"code":"open_order_min_nominal_value_limit","msg":"Exceeds the minimum notional value of a single order"},"result":null}
541
+ 'insufficient_balance': InsufficientFunds,
530
542
  },
531
543
  'broad': {
532
544
  'The symbol does not support trading via API': BadSymbol, # {"returnCode":1,"msgInfo":"failure","error":{"code":"symbol_not_support_trading_via_api","msg":"The symbol does not support trading via API"},"result":null}
533
545
  'Exceeds the minimum notional value of a single order': InvalidOrder, # {"returnCode":1,"msgInfo":"failure","error":{"code":"open_order_min_nominal_value_limit","msg":"Exceeds the minimum notional value of a single order"},"result":null}
546
+ 'insufficient balance': InsufficientFunds,
534
547
  },
535
548
  },
536
549
  'timeframes': {
@@ -683,15 +696,134 @@ class xt(Exchange, ImplicitAPI):
683
696
  'createMarketBuyOrderRequiresPrice': True,
684
697
  'recvWindow': '5000', # in milliseconds, spot only
685
698
  },
699
+ 'features': {
700
+ 'default': {
701
+ 'sandbox': False,
702
+ 'createOrder': {
703
+ 'marginMode': False,
704
+ 'triggerPrice': False,
705
+ 'triggerDirection': False,
706
+ 'triggerPriceType': None,
707
+ 'stopLossPrice': False,
708
+ 'takeProfitPrice': False,
709
+ 'attachedStopLossTakeProfit': None,
710
+ 'timeInForce': {
711
+ 'IOC': True,
712
+ 'FOK': True,
713
+ 'PO': True,
714
+ 'GTD': False,
715
+ },
716
+ 'hedged': False,
717
+ 'trailing': False,
718
+ 'leverage': False,
719
+ 'marketBuyByCost': True,
720
+ 'marketBuyRequiresPrice': False,
721
+ 'selfTradePrevention': False,
722
+ 'iceberg': False,
723
+ },
724
+ 'createOrders': None,
725
+ 'fetchMyTrades': {
726
+ 'marginMode': True,
727
+ 'limit': 100,
728
+ 'daysBack': 100000, # todo
729
+ 'untilDays': 100000, # todo
730
+ 'marketType': True,
731
+ 'subType': True,
732
+ 'symbolRequired': False,
733
+ },
734
+ 'fetchOrder': {
735
+ 'marginMode': False,
736
+ 'trigger': True, # todo TPSL kind
737
+ 'trailing': False,
738
+ 'marketType': True,
739
+ 'subType': True,
740
+ 'symbolRequired': False,
741
+ },
742
+ 'fetchOpenOrders': {
743
+ 'marginMode': True,
744
+ 'limit': 100,
745
+ 'trigger': True, # todo TPSL
746
+ 'trailing': False,
747
+ 'marketType': True,
748
+ 'subType': True,
749
+ 'symbolRequired': False,
750
+ },
751
+ 'fetchOrders': {
752
+ 'marginMode': True,
753
+ 'limit': 100,
754
+ 'daysBack': 100000, # todo
755
+ 'untilDays': 100000, # todo
756
+ 'trigger': True, # todo TPSL
757
+ 'trailing': False,
758
+ 'marketType': True,
759
+ 'subType': True,
760
+ 'symbolRequired': False,
761
+ },
762
+ 'fetchClosedOrders': {
763
+ 'marginMode': True,
764
+ 'limit': 100,
765
+ 'daysBack': 100000, # todo
766
+ 'daysBackCanceled': 1, # todo
767
+ 'untilDays': 100000, # todo
768
+ 'trigger': True, # todo TPSL
769
+ 'trailing': False,
770
+ 'marketType': True,
771
+ 'subType': True,
772
+ 'symbolRequired': False,
773
+ },
774
+ 'fetchOHLCV': {
775
+ 'limit': 1000, # todo for derivatives
776
+ },
777
+ },
778
+ 'spot': {
779
+ 'extends': 'default',
780
+ },
781
+ 'forDerivatives': {
782
+ 'extends': 'default',
783
+ 'createOrder': {
784
+ 'triggerPrice': True,
785
+ # todo
786
+ 'triggerPriceType': {
787
+ 'last': True,
788
+ 'mark': True,
789
+ 'index': True,
790
+ },
791
+ 'stopLossPrice': True,
792
+ 'takeProfitPrice': True,
793
+ },
794
+ 'fetchMyTrades': {
795
+ 'daysBack': None,
796
+ 'untilDays': None,
797
+ },
798
+ },
799
+ 'swap': {
800
+ 'linear': {
801
+ 'extends': 'forDerivatives',
802
+ },
803
+ 'inverse': {
804
+ 'extends': 'forDerivatives',
805
+ },
806
+ },
807
+ 'future': {
808
+ 'linear': {
809
+ 'extends': 'forDerivatives',
810
+ },
811
+ 'inverse': {
812
+ 'extends': 'forDerivatives',
813
+ },
814
+ },
815
+ },
686
816
  })
687
817
 
688
818
  def nonce(self):
689
819
  return self.milliseconds() - self.options['timeDifference']
690
820
 
691
- async def fetch_time(self, params={}):
821
+ async def fetch_time(self, params={}) -> Int:
692
822
  """
693
823
  fetches the current integer timestamp in milliseconds from the xt server
694
- :see: https://doc.xt.com/#market1serverInfo
824
+
825
+ https://doc.xt.com/#market1serverInfo
826
+
695
827
  :param dict params: extra parameters specific to the xt api endpoint
696
828
  :returns int: the current integer timestamp in milliseconds from the xt server
697
829
  """
@@ -712,7 +844,9 @@ class xt(Exchange, ImplicitAPI):
712
844
  async def fetch_currencies(self, params={}) -> Currencies:
713
845
  """
714
846
  fetches all available currencies on an exchange
715
- :see: https://doc.xt.com/#deposit_withdrawalsupportedCurrenciesGet
847
+
848
+ https://doc.xt.com/#deposit_withdrawalsupportedCurrenciesGet
849
+
716
850
  :param dict params: extra parameters specific to the xt api endpoint
717
851
  :returns dict: an associative dictionary of currencies
718
852
  """
@@ -778,48 +912,30 @@ class xt(Exchange, ImplicitAPI):
778
912
  entry = currenciesData[i]
779
913
  currencyId = self.safe_string(entry, 'currency')
780
914
  code = self.safe_currency_code(currencyId)
781
- minPrecision = self.parse_number(self.parse_precision(self.safe_string(entry, 'maxPrecision')))
782
915
  networkEntry = self.safe_value(chainsDataIndexed, currencyId, {})
783
916
  rawNetworks = self.safe_value(networkEntry, 'supportChains', [])
784
917
  networks = {}
785
- minWithdrawString = None
786
- minWithdrawFeeString = None
787
- active = False
788
- deposit = False
789
- withdraw = False
790
918
  for j in range(0, len(rawNetworks)):
791
919
  rawNetwork = rawNetworks[j]
792
920
  networkId = self.safe_string(rawNetwork, 'chain')
793
- network = self.network_id_to_code(networkId)
794
- depositEnabled = self.safe_value(rawNetwork, 'depositEnabled')
795
- deposit = depositEnabled if (depositEnabled) else deposit
796
- withdrawEnabled = self.safe_value(rawNetwork, 'withdrawEnabled')
797
- withdraw = withdrawEnabled if (withdrawEnabled) else withdraw
798
- networkActive = depositEnabled and withdrawEnabled
799
- active = networkActive if (networkActive) else active
800
- withdrawFeeString = self.safe_string(rawNetwork, 'withdrawFeeAmount')
801
- if withdrawFeeString is not None:
802
- minWithdrawFeeString = withdrawFeeString if (minWithdrawFeeString is None) else Precise.string_min(withdrawFeeString, minWithdrawFeeString)
803
- minNetworkWithdrawString = self.safe_string(rawNetwork, 'withdrawMinAmount')
804
- if minNetworkWithdrawString is not None:
805
- minWithdrawString = minNetworkWithdrawString if (minWithdrawString is None) else Precise.string_min(minNetworkWithdrawString, minWithdrawString)
806
- networks[network] = {
921
+ networkCode = self.network_id_to_code(networkId, code)
922
+ networks[networkCode] = {
807
923
  'info': rawNetwork,
808
924
  'id': networkId,
809
- 'network': network,
925
+ 'network': networkCode,
810
926
  'name': None,
811
- 'active': networkActive,
812
- 'fee': self.parse_number(withdrawFeeString),
813
- 'precision': minPrecision,
814
- 'deposit': depositEnabled,
815
- 'withdraw': withdrawEnabled,
927
+ 'active': None,
928
+ 'fee': self.safe_number(rawNetwork, 'withdrawFeeAmount'),
929
+ 'precision': None,
930
+ 'deposit': self.safe_bool(rawNetwork, 'depositEnabled'),
931
+ 'withdraw': self.safe_bool(rawNetwork, 'withdrawEnabled'),
816
932
  'limits': {
817
933
  'amount': {
818
934
  'min': None,
819
935
  'max': None,
820
936
  },
821
937
  'withdraw': {
822
- 'min': self.parse_number(minNetworkWithdrawString),
938
+ 'min': self.safe_number(rawNetwork, 'withdrawMinAmount'),
823
939
  'max': None,
824
940
  },
825
941
  'deposit': {
@@ -828,24 +944,31 @@ class xt(Exchange, ImplicitAPI):
828
944
  },
829
945
  },
830
946
  }
831
- result[code] = {
947
+ typeRaw = self.safe_string(entry, 'type')
948
+ type: Str = None
949
+ if typeRaw == 'FT':
950
+ type = 'crypto'
951
+ else:
952
+ type = 'other'
953
+ result[code] = self.safe_currency_structure({
832
954
  'info': entry,
833
955
  'id': currencyId,
834
956
  'code': code,
835
957
  'name': self.safe_string(entry, 'fullName'),
836
- 'active': active,
837
- 'fee': self.parse_number(minWithdrawFeeString),
838
- 'precision': None,
839
- 'deposit': deposit,
840
- 'withdraw': withdraw,
958
+ 'active': None,
959
+ 'fee': None,
960
+ 'precision': self.parse_number(self.parse_precision(self.safe_string(entry, 'maxPrecision'))),
961
+ 'deposit': self.safe_string(entry, 'depositStatus') == '1',
962
+ 'withdraw': self.safe_string(entry, 'withdrawStatus') == '1',
841
963
  'networks': networks,
964
+ 'type': type,
842
965
  'limits': {
843
966
  'amount': {
844
967
  'min': None,
845
968
  'max': None,
846
969
  },
847
970
  'withdraw': {
848
- 'min': self.parse_number(minWithdrawString),
971
+ 'min': None,
849
972
  'max': None,
850
973
  },
851
974
  'deposit': {
@@ -853,14 +976,16 @@ class xt(Exchange, ImplicitAPI):
853
976
  'max': None,
854
977
  },
855
978
  },
856
- }
979
+ })
857
980
  return result
858
981
 
859
982
  async def fetch_markets(self, params={}) -> List[Market]:
860
983
  """
861
984
  retrieves data on all markets for xt
862
- :see: https://doc.xt.com/#market2symbol
863
- :see: https://doc.xt.com/#futures_quotesgetSymbols
985
+
986
+ https://doc.xt.com/#market2symbol
987
+ https://doc.xt.com/#futures_quotesgetSymbols
988
+
864
989
  :param dict params: extra parameters specific to the xt api endpoint
865
990
  :returns dict[]: an array of objects representing market data
866
991
  """
@@ -1137,17 +1262,21 @@ class xt(Exchange, ImplicitAPI):
1137
1262
  maxCost = None
1138
1263
  minPrice = None
1139
1264
  maxPrice = None
1265
+ amountPrecision = None
1140
1266
  for i in range(0, len(filters)):
1141
1267
  entry = filters[i]
1142
1268
  filter = self.safe_string(entry, 'filter')
1143
1269
  if filter == 'QUANTITY':
1144
1270
  minAmount = self.safe_number(entry, 'min')
1145
1271
  maxAmount = self.safe_number(entry, 'max')
1272
+ amountPrecision = self.safe_number(entry, 'tickSize')
1146
1273
  if filter == 'QUOTE_QTY':
1147
1274
  minCost = self.safe_number(entry, 'min')
1148
1275
  if filter == 'PRICE':
1149
1276
  minPrice = self.safe_number(entry, 'min')
1150
1277
  maxPrice = self.safe_number(entry, 'max')
1278
+ if amountPrecision is None:
1279
+ amountPrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'quantityPrecision')))
1151
1280
  underlyingType = self.safe_string(market, 'underlyingType')
1152
1281
  linear = None
1153
1282
  inverse = None
@@ -1222,7 +1351,7 @@ class xt(Exchange, ImplicitAPI):
1222
1351
  'optionType': None,
1223
1352
  'precision': {
1224
1353
  'price': self.parse_number(self.parse_precision(self.safe_string(market, 'pricePrecision'))),
1225
- 'amount': self.parse_number(self.parse_precision(self.safe_string(market, 'quantityPrecision'))),
1354
+ 'amount': amountPrecision,
1226
1355
  'base': self.parse_number(self.parse_precision(self.safe_string(market, 'baseCoinPrecision'))),
1227
1356
  'quote': self.parse_number(self.parse_precision(self.safe_string(market, 'quoteCoinPrecision'))),
1228
1357
  },
@@ -1250,16 +1379,24 @@ class xt(Exchange, ImplicitAPI):
1250
1379
  async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
1251
1380
  """
1252
1381
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1253
- :see: https://doc.xt.com/#market4kline
1254
- :see: https://doc.xt.com/#futures_quotesgetKLine
1382
+
1383
+ https://doc.xt.com/#market4kline
1384
+ https://doc.xt.com/#futures_quotesgetKLine
1385
+
1255
1386
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1256
1387
  :param str timeframe: the length of time each candle represents
1257
1388
  :param int [since]: timestamp in ms of the earliest candle to fetch
1258
1389
  :param int [limit]: the maximum amount of candles to fetch
1259
1390
  :param dict params: extra parameters specific to the xt api endpoint
1391
+ :param int [params.until]: timestamp in ms of the latest candle to fetch
1392
+ :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
1260
1393
  :returns int[][]: A list of candles ordered, open, high, low, close, volume
1261
1394
  """
1262
1395
  await self.load_markets()
1396
+ paginate = False
1397
+ paginate, params = self.handle_option_and_params(params, 'fetchOHLCV', 'paginate', False)
1398
+ if paginate:
1399
+ return await self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000)
1263
1400
  market = self.market(symbol)
1264
1401
  request = {
1265
1402
  'symbol': market['id'],
@@ -1269,6 +1406,12 @@ class xt(Exchange, ImplicitAPI):
1269
1406
  request['startTime'] = since
1270
1407
  if limit is not None:
1271
1408
  request['limit'] = limit
1409
+ else:
1410
+ request['limit'] = 1000
1411
+ until = self.safe_integer(params, 'until')
1412
+ params = self.omit(params, ['until'])
1413
+ if until is not None:
1414
+ request['endTime'] = until
1272
1415
  response = None
1273
1416
  if market['linear']:
1274
1417
  response = await self.publicLinearGetFutureMarketV1PublicQKline(self.extend(request, params))
@@ -1355,13 +1498,15 @@ class xt(Exchange, ImplicitAPI):
1355
1498
  self.safe_number(ohlcv, 'h'),
1356
1499
  self.safe_number(ohlcv, 'l'),
1357
1500
  self.safe_number(ohlcv, 'c'),
1358
- self.safe_number_2(ohlcv, volumeIndex, 'v'),
1501
+ self.safe_number_2(ohlcv, 'q', volumeIndex),
1359
1502
  ]
1360
1503
 
1361
1504
  async def fetch_order_book(self, symbol: str, limit: Int = None, params={}):
1362
1505
  """
1363
- :see: https://doc.xt.com/#market3depth
1364
- :see: https://doc.xt.com/#futures_quotesgetDepth
1506
+
1507
+ https://doc.xt.com/#market3depth
1508
+ https://doc.xt.com/#futures_quotesgetDepth
1509
+
1365
1510
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1366
1511
  :param str symbol: unified market symbol to fetch the order book for
1367
1512
  :param int [limit]: the maximum amount of order book entries to return
@@ -1436,14 +1581,20 @@ class xt(Exchange, ImplicitAPI):
1436
1581
  orderBook = self.safe_value(response, 'result', {})
1437
1582
  timestamp = self.safe_integer_2(orderBook, 'timestamp', 't')
1438
1583
  if market['spot']:
1439
- return self.parse_order_book(orderBook, symbol, timestamp)
1440
- return self.parse_order_book(orderBook, symbol, timestamp, 'b', 'a')
1584
+ ob = self.parse_order_book(orderBook, symbol, timestamp)
1585
+ ob['nonce'] = self.safe_integer(orderBook, 'lastUpdateId')
1586
+ return ob
1587
+ swapOb = self.parse_order_book(orderBook, symbol, timestamp, 'b', 'a')
1588
+ swapOb['nonce'] = self.safe_integer_2(orderBook, 'u', 'lastUpdateId')
1589
+ return swapOb
1441
1590
 
1442
1591
  async def fetch_ticker(self, symbol: str, params={}):
1443
1592
  """
1444
1593
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1445
- :see: https://doc.xt.com/#market10ticker24h
1446
- :see: https://doc.xt.com/#futures_quotesgetAggTicker
1594
+
1595
+ https://doc.xt.com/#market10ticker24h
1596
+ https://doc.xt.com/#futures_quotesgetAggTicker
1597
+
1447
1598
  :param str symbol: unified market symbol to fetch the ticker for
1448
1599
  :param dict params: extra parameters specific to the xt api endpoint
1449
1600
  :returns dict: a `ticker structure <https://docs.ccxt.com/en/latest/manual.html#ticker-structure>`
@@ -1514,8 +1665,10 @@ class xt(Exchange, ImplicitAPI):
1514
1665
  async def fetch_tickers(self, symbols: List[str] = None, params={}) -> Tickers:
1515
1666
  """
1516
1667
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
1517
- :see: https://doc.xt.com/#market10ticker24h
1518
- :see: https://doc.xt.com/#futures_quotesgetAggTickers
1668
+
1669
+ https://doc.xt.com/#market10ticker24h
1670
+ https://doc.xt.com/#futures_quotesgetAggTickers
1671
+
1519
1672
  :param str [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1520
1673
  :param dict params: extra parameters specific to the xt api endpoint
1521
1674
  :returns dict: an array of `ticker structures <https://docs.ccxt.com/en/latest/manual.html#ticker-structure>`
@@ -1596,7 +1749,9 @@ class xt(Exchange, ImplicitAPI):
1596
1749
  async def fetch_bids_asks(self, symbols: List[str] = None, params={}):
1597
1750
  """
1598
1751
  fetches the bid and ask price and volume for multiple markets
1599
- :see: https://doc.xt.com/#market9tickerBook
1752
+
1753
+ https://doc.xt.com/#market9tickerBook
1754
+
1600
1755
  :param str [symbols]: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
1601
1756
  :param dict params: extra parameters specific to the xt api endpoint
1602
1757
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/en/latest/manual.html#ticker-structure>`
@@ -1680,11 +1835,15 @@ class xt(Exchange, ImplicitAPI):
1680
1835
  #
1681
1836
  marketId = self.safe_string(ticker, 's')
1682
1837
  marketType = market['type'] if (market is not None) else None
1838
+ hasSpotKeys = ('cv' in ticker) or ('aq' in ticker)
1683
1839
  if marketType is None:
1684
- marketType = ('cv' in ticker) or 'spot' if ('aq' in ticker) else 'contract'
1840
+ marketType = 'spot' if hasSpotKeys else 'contract'
1685
1841
  market = self.safe_market(marketId, market, '_', marketType)
1686
1842
  symbol = market['symbol']
1687
1843
  timestamp = self.safe_integer(ticker, 't')
1844
+ percentage = self.safe_string_2(ticker, 'cr', 'r')
1845
+ if percentage is not None:
1846
+ percentage = Precise.string_mul(percentage, '100')
1688
1847
  return self.safe_ticker({
1689
1848
  'symbol': symbol,
1690
1849
  'timestamp': timestamp,
@@ -1701,7 +1860,7 @@ class xt(Exchange, ImplicitAPI):
1701
1860
  'last': self.safe_string(ticker, 'c'),
1702
1861
  'previousClose': None,
1703
1862
  'change': self.safe_number(ticker, 'cv'),
1704
- 'percentage': self.safe_number_2(ticker, 'cr', 'r'),
1863
+ 'percentage': self.parse_number(percentage),
1705
1864
  'average': None,
1706
1865
  'baseVolume': None,
1707
1866
  'quoteVolume': self.safe_number_2(ticker, 'a', 'v'),
@@ -1711,8 +1870,10 @@ class xt(Exchange, ImplicitAPI):
1711
1870
  async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}):
1712
1871
  """
1713
1872
  get the list of most recent trades for a particular symbol
1714
- :see: https://doc.xt.com/#market5tradeRecent
1715
- :see: https://doc.xt.com/#futures_quotesgetDeal
1873
+
1874
+ https://doc.xt.com/#market5tradeRecent
1875
+ https://doc.xt.com/#futures_quotesgetDeal
1876
+
1716
1877
  :param str symbol: unified market symbol to fetch trades for
1717
1878
  :param int [since]: timestamp in ms of the earliest trade to fetch
1718
1879
  :param int [limit]: the maximum amount of trades to fetch
@@ -1778,8 +1939,10 @@ class xt(Exchange, ImplicitAPI):
1778
1939
  async def fetch_my_trades(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
1779
1940
  """
1780
1941
  fetch all trades made by the user
1781
- :see: https://doc.xt.com/#tradetradeGet
1782
- :see: https://doc.xt.com/#futures_ordergetTrades
1942
+
1943
+ https://doc.xt.com/#tradetradeGet
1944
+ https://doc.xt.com/#futures_ordergetTrades
1945
+
1783
1946
  :param str [symbol]: unified market symbol to fetch trades for
1784
1947
  :param int [since]: timestamp in ms of the earliest trade to fetch
1785
1948
  :param int [limit]: the maximum amount of trades to fetch
@@ -1889,6 +2052,29 @@ class xt(Exchange, ImplicitAPI):
1889
2052
  # "b": True
1890
2053
  # }
1891
2054
  #
2055
+ # spot: watchTrades
2056
+ #
2057
+ # {
2058
+ # s: 'btc_usdt',
2059
+ # i: '228825383103928709',
2060
+ # t: 1684258222702,
2061
+ # p: '27003.65',
2062
+ # q: '0.000796',
2063
+ # b: True
2064
+ # }
2065
+ #
2066
+ # spot: watchMyTrades
2067
+ #
2068
+ # {
2069
+ # "s": "btc_usdt", # symbol
2070
+ # "t": 1656043204763, # time
2071
+ # "i": "6316559590087251233", # tradeId
2072
+ # "oi": "6216559590087220004", # orderId
2073
+ # "p": "30000", # trade price
2074
+ # "q": "3", # qty quantity
2075
+ # "v": "90000" # volume trade amount
2076
+ # }
2077
+ #
1892
2078
  # swap and future: fetchTrades
1893
2079
  #
1894
2080
  # {
@@ -1933,19 +2119,61 @@ class xt(Exchange, ImplicitAPI):
1933
2119
  # "takerMaker": "TAKER"
1934
2120
  # }
1935
2121
  #
2122
+ # contract watchMyTrades
2123
+ #
2124
+ # {
2125
+ # "symbol": 'btc_usdt',
2126
+ # "orderSide": 'SELL',
2127
+ # "positionSide": 'LONG',
2128
+ # "orderId": '231485367663419328',
2129
+ # "price": '27152.7',
2130
+ # "quantity": '33',
2131
+ # "marginUnfrozen": '2.85318000',
2132
+ # "timestamp": 1684892412565
2133
+ # }
2134
+ #
2135
+ # watchMyTrades(ws, swap)
2136
+ #
2137
+ # {
2138
+ # 'fee': '0.04080840',
2139
+ # 'isMaker': False,
2140
+ # 'marginUnfrozen': '0.75711984',
2141
+ # 'orderId': '376172779053188416',
2142
+ # 'orderSide': 'BUY',
2143
+ # 'positionSide': 'LONG',
2144
+ # 'price': '3400.70',
2145
+ # 'quantity': '2',
2146
+ # 'symbol': 'eth_usdt',
2147
+ # 'timestamp': 1719388579622
2148
+ # }
2149
+ #
1936
2150
  marketId = self.safe_string_2(trade, 's', 'symbol')
1937
2151
  marketType = market['type'] if (market is not None) else None
2152
+ hasSpotKeys = ('b' in trade) or ('bizType' in trade) or ('oi' in trade)
1938
2153
  if marketType is None:
1939
- marketType = ('b' in trade) or 'spot' if ('bizType' in trade) else 'contract'
2154
+ marketType = 'spot' if hasSpotKeys else 'contract'
1940
2155
  market = self.safe_market(marketId, market, '_', marketType)
1941
- bidOrAsk = self.safe_string(trade, 'm')
1942
- side = self.safe_string_lower(trade, 'orderSide')
1943
- if bidOrAsk is not None:
1944
- side = 'buy' if (bidOrAsk == 'BID') else 'sell'
1945
- buyerMaker = self.safe_value(trade, 'b')
1946
- takerOrMaker = self.safe_string_lower(trade, 'takerMaker')
1947
- if buyerMaker is not None:
1948
- takerOrMaker = 'maker' if buyerMaker else 'taker'
2156
+ side = None
2157
+ takerOrMaker = None
2158
+ isBuyerMaker = self.safe_bool(trade, 'b')
2159
+ if isBuyerMaker is not None:
2160
+ side = 'sell' if isBuyerMaker else 'buy'
2161
+ takerOrMaker = 'taker' # public trades always taker
2162
+ else:
2163
+ takerMaker = self.safe_string_lower(trade, 'takerMaker')
2164
+ if takerMaker is not None:
2165
+ takerOrMaker = takerMaker
2166
+ else:
2167
+ isMaker = self.safe_bool(trade, 'isMaker')
2168
+ if isMaker is not None:
2169
+ takerOrMaker = 'maker' if isMaker else 'taker'
2170
+ orderSide = self.safe_string_lower(trade, 'orderSide')
2171
+ if orderSide is not None:
2172
+ side = orderSide
2173
+ else:
2174
+ bidOrAsk = self.safe_string(trade, 'm')
2175
+ if bidOrAsk is not None:
2176
+ side = 'buy' if (bidOrAsk == 'BID') else 'sell'
1949
2177
  timestamp = self.safe_integer_n(trade, ['t', 'time', 'timestamp'])
1950
2178
  quantity = self.safe_string_2(trade, 'q', 'quantity')
1951
2179
  amount = None
@@ -1962,7 +2190,7 @@ class xt(Exchange, ImplicitAPI):
1962
2190
  'timestamp': timestamp,
1963
2191
  'datetime': self.iso8601(timestamp),
1964
2192
  'symbol': market['symbol'],
1965
- 'order': self.safe_string(trade, 'orderId'),
2193
+ 'order': self.safe_string_2(trade, 'orderId', 'oi'),
1966
2194
  'type': self.safe_string_lower(trade, 'orderType'),
1967
2195
  'side': side,
1968
2196
  'takerOrMaker': takerOrMaker,
@@ -1972,15 +2200,16 @@ class xt(Exchange, ImplicitAPI):
1972
2200
  'fee': {
1973
2201
  'currency': self.safe_currency_code(self.safe_string_2(trade, 'feeCurrency', 'feeCoin')),
1974
2202
  'cost': self.safe_string(trade, 'fee'),
1975
- 'rate': None,
1976
2203
  },
1977
2204
  }, market)
1978
2205
 
1979
2206
  async def fetch_balance(self, params={}):
1980
2207
  """
1981
2208
  query for balance and get the amount of funds available for trading or funds locked in orders
1982
- :see: https://doc.xt.com/#balancebalancesGet
1983
- :see: https://doc.xt.com/#futures_usergetBalances
2209
+
2210
+ https://doc.xt.com/#balancebalancesGet
2211
+ https://doc.xt.com/#futures_usergetBalances
2212
+
1984
2213
  :param dict params: extra parameters specific to the xt api endpoint
1985
2214
  :returns dict: a `balance structure <https://docs.ccxt.com/en/latest/manual.html?#balance-structure>`
1986
2215
  """
@@ -2096,7 +2325,9 @@ class xt(Exchange, ImplicitAPI):
2096
2325
 
2097
2326
  async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
2098
2327
  """
2099
- :see: https://doc.xt.com/#orderorderPost
2328
+
2329
+ https://doc.xt.com/#orderorderPost
2330
+
2100
2331
  create a market buy order by providing the symbol and cost
2101
2332
  :param str symbol: unified symbol of the market to create an order in
2102
2333
  :param float cost: how much you want to trade in units of the quote currency
@@ -2112,10 +2343,12 @@ class xt(Exchange, ImplicitAPI):
2112
2343
  async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
2113
2344
  """
2114
2345
  create a trade order
2115
- :see: https://doc.xt.com/#orderorderPost
2116
- :see: https://doc.xt.com/#futures_ordercreate
2117
- :see: https://doc.xt.com/#futures_entrustcreatePlan
2118
- :see: https://doc.xt.com/#futures_entrustcreateProfit
2346
+
2347
+ https://doc.xt.com/#orderorderPost
2348
+ https://doc.xt.com/#futures_ordercreate
2349
+ https://doc.xt.com/#futures_entrustcreatePlan
2350
+ https://doc.xt.com/#futures_entrustcreateProfit
2351
+
2119
2352
  :param str symbol: unified symbol of the market to create an order in
2120
2353
  :param str type: 'market' or 'limit'
2121
2354
  :param str side: 'buy' or 'sell'
@@ -2125,7 +2358,8 @@ class xt(Exchange, ImplicitAPI):
2125
2358
  :param str [params.timeInForce]: 'GTC', 'IOC', 'FOK' or 'GTX'
2126
2359
  :param str [params.entrustType]: 'TAKE_PROFIT', 'STOP', 'TAKE_PROFIT_MARKET', 'STOP_MARKET', 'TRAILING_STOP_MARKET', required if stopPrice is defined, currently isn't functioning on xt's side
2127
2360
  :param str [params.triggerPriceType]: 'INDEX_PRICE', 'MARK_PRICE', 'LATEST_PRICE', required if stopPrice is defined
2128
- :param float [params.stopPrice]: price to trigger a stop order
2361
+ :param float [params.triggerPrice]: price to trigger a stop order
2362
+ :param float [params.stopPrice]: alias for triggerPrice
2129
2363
  :param float [params.stopLoss]: price to set a stop-loss on an open position
2130
2364
  :param float [params.takeProfit]: price to set a take-profit on an open position
2131
2365
  :returns dict: an `order structure <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
@@ -2261,14 +2495,16 @@ class xt(Exchange, ImplicitAPI):
2261
2495
  async def fetch_order(self, id: str, symbol: str = None, params={}):
2262
2496
  """
2263
2497
  fetches information on an order made by the user
2264
- :see: https://doc.xt.com/#orderorderGet
2265
- :see: https://doc.xt.com/#futures_ordergetById
2266
- :see: https://doc.xt.com/#futures_entrustgetPlanById
2267
- :see: https://doc.xt.com/#futures_entrustgetProfitById
2498
+
2499
+ https://doc.xt.com/#orderorderGet
2500
+ https://doc.xt.com/#futures_ordergetById
2501
+ https://doc.xt.com/#futures_entrustgetPlanById
2502
+ https://doc.xt.com/#futures_entrustgetProfitById
2503
+
2268
2504
  :param str id: order id
2269
2505
  :param str [symbol]: unified symbol of the market the order was made in
2270
2506
  :param dict params: extra parameters specific to the xt api endpoint
2271
- :param bool [params.stop]: if the order is a stop trigger order or not
2507
+ :param bool [params.trigger]: if the order is a trigger order or not
2272
2508
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2273
2509
  :returns dict: An `order structure <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2274
2510
  """
@@ -2282,15 +2518,15 @@ class xt(Exchange, ImplicitAPI):
2282
2518
  response = None
2283
2519
  type, params = self.handle_market_type_and_params('fetchOrder', market, params)
2284
2520
  subType, params = self.handle_sub_type_and_params('fetchOrder', market, params)
2285
- stop = self.safe_value(params, 'stop')
2521
+ trigger = self.safe_value(params, 'stop')
2286
2522
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
2287
- if stop:
2523
+ if trigger:
2288
2524
  request['entrustId'] = id
2289
2525
  elif stopLossTakeProfit:
2290
2526
  request['profitId'] = id
2291
2527
  else:
2292
2528
  request['orderId'] = id
2293
- if stop:
2529
+ if trigger:
2294
2530
  params = self.omit(params, 'stop')
2295
2531
  if subType == 'inverse':
2296
2532
  response = await self.privateInverseGetFutureTradeV1EntrustPlanDetail(self.extend(request, params))
@@ -2431,14 +2667,16 @@ class xt(Exchange, ImplicitAPI):
2431
2667
  async def fetch_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
2432
2668
  """
2433
2669
  fetches information on multiple orders made by the user
2434
- :see: https://doc.xt.com/#orderhistoryOrderGet
2435
- :see: https://doc.xt.com/#futures_ordergetHistory
2436
- :see: https://doc.xt.com/#futures_entrustgetPlanHistory
2670
+
2671
+ https://doc.xt.com/#orderhistoryOrderGet
2672
+ https://doc.xt.com/#futures_ordergetHistory
2673
+ https://doc.xt.com/#futures_entrustgetPlanHistory
2674
+
2437
2675
  :param str [symbol]: unified market symbol of the market the orders were made in
2438
2676
  :param int [since]: timestamp in ms of the earliest order
2439
2677
  :param int [limit]: the maximum number of order structures to retrieve
2440
2678
  :param dict params: extra parameters specific to the xt api endpoint
2441
- :param bool [params.stop]: if the order is a stop trigger order or not
2679
+ :param bool [params.trigger]: if the order is a trigger order or not
2442
2680
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2443
2681
  """
2444
2682
  await self.load_markets()
@@ -2456,9 +2694,9 @@ class xt(Exchange, ImplicitAPI):
2456
2694
  response = None
2457
2695
  type, params = self.handle_market_type_and_params('fetchOrders', market, params)
2458
2696
  subType, params = self.handle_sub_type_and_params('fetchOrders', market, params)
2459
- stop = self.safe_value(params, 'stop')
2460
- if stop:
2461
- params = self.omit(params, 'stop')
2697
+ trigger = self.safe_value_2(params, 'trigger', 'stop')
2698
+ if trigger:
2699
+ params = self.omit(params, ['trigger', 'stop'])
2462
2700
  if subType == 'inverse':
2463
2701
  response = await self.privateInverseGetFutureTradeV1EntrustPlanListHistory(self.extend(request, params))
2464
2702
  else:
@@ -2594,37 +2832,41 @@ class xt(Exchange, ImplicitAPI):
2594
2832
  if symbol is not None:
2595
2833
  market = self.market(symbol)
2596
2834
  request['symbol'] = market['id']
2835
+ if limit is not None:
2836
+ request['size'] = limit
2837
+ if since is not None:
2838
+ request['startTime'] = since
2597
2839
  type = None
2598
2840
  subType = None
2599
2841
  response = None
2600
2842
  type, params = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
2601
2843
  subType, params = self.handle_sub_type_and_params('fetchOrdersByStatus', market, params)
2602
- stop = self.safe_value(params, 'stop')
2844
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
2603
2845
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
2604
2846
  if status == 'open':
2605
- if stop or stopLossTakeProfit:
2847
+ if trigger or stopLossTakeProfit:
2606
2848
  request['state'] = 'NOT_TRIGGERED'
2607
- elif subType is not None:
2608
- request['state'] = 'NEW'
2849
+ elif type == 'swap':
2850
+ request['state'] = 'UNFINISHED' # NEW & PARTIALLY_FILLED
2609
2851
  elif status == 'closed':
2610
- if stop or stopLossTakeProfit:
2852
+ if trigger or stopLossTakeProfit:
2611
2853
  request['state'] = 'TRIGGERED'
2612
2854
  else:
2613
2855
  request['state'] = 'FILLED'
2614
2856
  elif status == 'canceled':
2615
- if stop or stopLossTakeProfit:
2857
+ if trigger or stopLossTakeProfit:
2616
2858
  request['state'] = 'USER_REVOCATION'
2617
2859
  else:
2618
2860
  request['state'] = 'CANCELED'
2619
2861
  else:
2620
2862
  request['state'] = status
2621
- if stop or stopLossTakeProfit or (subType is not None) or (type == 'swap') or (type == 'future'):
2863
+ if trigger or stopLossTakeProfit or (subType is not None) or (type == 'swap') or (type == 'future'):
2622
2864
  if since is not None:
2623
2865
  request['startTime'] = since
2624
2866
  if limit is not None:
2625
2867
  request['size'] = limit
2626
- if stop:
2627
- params = self.omit(params, 'stop')
2868
+ if trigger:
2869
+ params = self.omit(params, ['stop', 'trigger'])
2628
2870
  if subType == 'inverse':
2629
2871
  response = await self.privateInverseGetFutureTradeV1EntrustPlanList(self.extend(request, params))
2630
2872
  else:
@@ -2649,6 +2891,7 @@ class xt(Exchange, ImplicitAPI):
2649
2891
  if since is not None:
2650
2892
  request['startTime'] = since
2651
2893
  if limit is not None:
2894
+ request = self.omit(request, 'size')
2652
2895
  request['limit'] = limit
2653
2896
  response = await self.privateSpotGetHistoryOrder(self.extend(request, params))
2654
2897
  else:
@@ -2831,23 +3074,28 @@ class xt(Exchange, ImplicitAPI):
2831
3074
  # }
2832
3075
  # }
2833
3076
  #
2834
- isSpotOpenOrders = ((status == 'open') and (subType is None))
2835
- data = self.safe_value(response, 'result', {})
2836
- orders = self.safe_value(response, 'result', []) if isSpotOpenOrders else self.safe_value(data, 'items', [])
3077
+ orders = []
3078
+ resultDict = self.safe_dict(response, 'result')
3079
+ if resultDict is not None:
3080
+ orders = self.safe_list(resultDict, 'items', [])
3081
+ else:
3082
+ orders = self.safe_list(response, 'result')
2837
3083
  return self.parse_orders(orders, market, since, limit)
2838
3084
 
2839
3085
  async def fetch_open_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
2840
3086
  """
2841
3087
  fetch all unfilled currently open orders
2842
- :see: https://doc.xt.com/#orderopenOrderGet
2843
- :see: https://doc.xt.com/#futures_ordergetOrders
2844
- :see: https://doc.xt.com/#futures_entrustgetPlan
2845
- :see: https://doc.xt.com/#futures_entrustgetProfit
3088
+
3089
+ https://doc.xt.com/#orderopenOrderGet
3090
+ https://doc.xt.com/#futures_ordergetOrders
3091
+ https://doc.xt.com/#futures_entrustgetPlan
3092
+ https://doc.xt.com/#futures_entrustgetProfit
3093
+
2846
3094
  :param str [symbol]: unified market symbol of the market the orders were made in
2847
3095
  :param int [since]: timestamp in ms of the earliest order
2848
3096
  :param int [limit]: the maximum number of open order structures to retrieve
2849
3097
  :param dict params: extra parameters specific to the xt api endpoint
2850
- :param bool [params.stop]: if the order is a stop trigger order or not
3098
+ :param bool [params.trigger]: if the order is a trigger order or not
2851
3099
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2852
3100
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2853
3101
  """
@@ -2856,15 +3104,17 @@ class xt(Exchange, ImplicitAPI):
2856
3104
  async def fetch_closed_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
2857
3105
  """
2858
3106
  fetches information on multiple closed orders made by the user
2859
- :see: https://doc.xt.com/#orderhistoryOrderGet
2860
- :see: https://doc.xt.com/#futures_ordergetOrders
2861
- :see: https://doc.xt.com/#futures_entrustgetPlan
2862
- :see: https://doc.xt.com/#futures_entrustgetProfit
3107
+
3108
+ https://doc.xt.com/#orderhistoryOrderGet
3109
+ https://doc.xt.com/#futures_ordergetOrders
3110
+ https://doc.xt.com/#futures_entrustgetPlan
3111
+ https://doc.xt.com/#futures_entrustgetProfit
3112
+
2863
3113
  :param str [symbol]: unified market symbol of the market the orders were made in
2864
3114
  :param int [since]: timestamp in ms of the earliest order
2865
3115
  :param int [limit]: the maximum number of order structures to retrieve
2866
3116
  :param dict params: extra parameters specific to the xt api endpoint
2867
- :param bool [params.stop]: if the order is a stop trigger order or not
3117
+ :param bool [params.trigger]: if the order is a trigger order or not
2868
3118
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2869
3119
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2870
3120
  """
@@ -2873,15 +3123,17 @@ class xt(Exchange, ImplicitAPI):
2873
3123
  async def fetch_canceled_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
2874
3124
  """
2875
3125
  fetches information on multiple canceled orders made by the user
2876
- :see: https://doc.xt.com/#orderhistoryOrderGet
2877
- :see: https://doc.xt.com/#futures_ordergetOrders
2878
- :see: https://doc.xt.com/#futures_entrustgetPlan
2879
- :see: https://doc.xt.com/#futures_entrustgetProfit
3126
+
3127
+ https://doc.xt.com/#orderhistoryOrderGet
3128
+ https://doc.xt.com/#futures_ordergetOrders
3129
+ https://doc.xt.com/#futures_entrustgetPlan
3130
+ https://doc.xt.com/#futures_entrustgetProfit
3131
+
2880
3132
  :param str [symbol]: unified market symbol of the market the orders were made in
2881
3133
  :param int [since]: timestamp in ms of the earliest order
2882
3134
  :param int [limit]: the maximum number of order structures to retrieve
2883
3135
  :param dict params: extra parameters specific to the xt api endpoint
2884
- :param bool [params.stop]: if the order is a stop trigger order or not
3136
+ :param bool [params.trigger]: if the order is a trigger order or not
2885
3137
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2886
3138
  :returns dict: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2887
3139
  """
@@ -2890,14 +3142,16 @@ class xt(Exchange, ImplicitAPI):
2890
3142
  async def cancel_order(self, id: str, symbol: str = None, params={}):
2891
3143
  """
2892
3144
  cancels an open order
2893
- :see: https://doc.xt.com/#orderorderDel
2894
- :see: https://doc.xt.com/#futures_ordercancel
2895
- :see: https://doc.xt.com/#futures_entrustcancelPlan
2896
- :see: https://doc.xt.com/#futures_entrustcancelProfit
3145
+
3146
+ https://doc.xt.com/#orderorderDel
3147
+ https://doc.xt.com/#futures_ordercancel
3148
+ https://doc.xt.com/#futures_entrustcancelPlan
3149
+ https://doc.xt.com/#futures_entrustcancelProfit
3150
+
2897
3151
  :param str id: order id
2898
3152
  :param str [symbol]: unified symbol of the market the order was made in
2899
3153
  :param dict params: extra parameters specific to the xt api endpoint
2900
- :param bool [params.stop]: if the order is a stop trigger order or not
3154
+ :param bool [params.trigger]: if the order is a trigger order or not
2901
3155
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2902
3156
  :returns dict: An `order structure <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2903
3157
  """
@@ -2911,16 +3165,16 @@ class xt(Exchange, ImplicitAPI):
2911
3165
  response = None
2912
3166
  type, params = self.handle_market_type_and_params('cancelOrder', market, params)
2913
3167
  subType, params = self.handle_sub_type_and_params('cancelOrder', market, params)
2914
- stop = self.safe_value(params, 'stop')
3168
+ trigger = self.safe_value_2(params, 'trigger', 'stop')
2915
3169
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
2916
- if stop:
3170
+ if trigger:
2917
3171
  request['entrustId'] = id
2918
3172
  elif stopLossTakeProfit:
2919
3173
  request['profitId'] = id
2920
3174
  else:
2921
3175
  request['orderId'] = id
2922
- if stop:
2923
- params = self.omit(params, 'stop')
3176
+ if trigger:
3177
+ params = self.omit(params, ['trigger', 'stop'])
2924
3178
  if subType == 'inverse':
2925
3179
  response = await self.privateInversePostFutureTradeV1EntrustCancelPlan(self.extend(request, params))
2926
3180
  else:
@@ -2965,13 +3219,15 @@ class xt(Exchange, ImplicitAPI):
2965
3219
  async def cancel_all_orders(self, symbol: str = None, params={}):
2966
3220
  """
2967
3221
  cancel all open orders in a market
2968
- :see: https://doc.xt.com/#orderopenOrderDel
2969
- :see: https://doc.xt.com/#futures_ordercancelBatch
2970
- :see: https://doc.xt.com/#futures_entrustcancelPlanBatch
2971
- :see: https://doc.xt.com/#futures_entrustcancelProfitBatch
3222
+
3223
+ https://doc.xt.com/#orderopenOrderDel
3224
+ https://doc.xt.com/#futures_ordercancelBatch
3225
+ https://doc.xt.com/#futures_entrustcancelPlanBatch
3226
+ https://doc.xt.com/#futures_entrustcancelProfitBatch
3227
+
2972
3228
  :param str [symbol]: unified market symbol of the market to cancel orders in
2973
3229
  :param dict params: extra parameters specific to the xt api endpoint
2974
- :param bool [params.stop]: if the order is a stop trigger order or not
3230
+ :param bool [params.trigger]: if the order is a trigger order or not
2975
3231
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2976
3232
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2977
3233
  """
@@ -2986,10 +3242,10 @@ class xt(Exchange, ImplicitAPI):
2986
3242
  response = None
2987
3243
  type, params = self.handle_market_type_and_params('cancelAllOrders', market, params)
2988
3244
  subType, params = self.handle_sub_type_and_params('cancelAllOrders', market, params)
2989
- stop = self.safe_value(params, 'stop')
3245
+ trigger = self.safe_value_2(params, 'trigger', 'stop')
2990
3246
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
2991
- if stop:
2992
- params = self.omit(params, 'stop')
3247
+ if trigger:
3248
+ params = self.omit(params, ['trigger', 'stop'])
2993
3249
  if subType == 'inverse':
2994
3250
  response = await self.privateInversePostFutureTradeV1EntrustCancelAllPlan(self.extend(request, params))
2995
3251
  else:
@@ -3036,7 +3292,9 @@ class xt(Exchange, ImplicitAPI):
3036
3292
  async def cancel_orders(self, ids: List[str], symbol: str = None, params={}) -> List[Order]:
3037
3293
  """
3038
3294
  cancel multiple orders
3039
- :see: https://doc.xt.com/#orderbatchOrderDel
3295
+
3296
+ https://doc.xt.com/#orderbatchOrderDel
3297
+
3040
3298
  :param str[] ids: order ids
3041
3299
  :param str [symbol]: unified market symbol of the market to cancel orders in
3042
3300
  :param dict params: extra parameters specific to the xt api endpoint
@@ -3082,7 +3340,7 @@ class xt(Exchange, ImplicitAPI):
3082
3340
  # "cancelId": "208322474307982720"
3083
3341
  # }
3084
3342
  #
3085
- # swap and future: createOrder, cancelOrder
3343
+ # swap and future: createOrder, cancelOrder, editOrder
3086
3344
  #
3087
3345
  # {
3088
3346
  # "returnCode": 0,
@@ -3187,6 +3445,14 @@ class xt(Exchange, ImplicitAPI):
3187
3445
  # "createdTime": 1681273420039
3188
3446
  # }
3189
3447
  #
3448
+ # spot editOrder
3449
+ #
3450
+ # {
3451
+ # "orderId": "484203027161892224",
3452
+ # "modifyId": "484203544105344000",
3453
+ # "clientModifyId": null
3454
+ # }
3455
+ #
3190
3456
  marketId = self.safe_string(order, 'symbol')
3191
3457
  marketType = ('result' in order) or 'contract' if ('positionSide' in order) else 'spot'
3192
3458
  market = self.safe_market(marketId, market, None, marketType)
@@ -3200,7 +3466,7 @@ class xt(Exchange, ImplicitAPI):
3200
3466
  return self.safe_order({
3201
3467
  'info': order,
3202
3468
  'id': self.safe_string_n(order, ['orderId', 'result', 'cancelId', 'entrustId', 'profitId']),
3203
- 'clientOrderId': self.safe_string(order, 'clientOrderId'),
3469
+ 'clientOrderId': self.safe_string_2(order, 'clientOrderId', 'clientModifyId'),
3204
3470
  'timestamp': timestamp,
3205
3471
  'datetime': self.iso8601(timestamp),
3206
3472
  'lastTradeTimestamp': lastUpdatedTimestamp,
@@ -3211,7 +3477,7 @@ class xt(Exchange, ImplicitAPI):
3211
3477
  'postOnly': None,
3212
3478
  'side': self.safe_string_lower_2(order, 'side', 'orderSide'),
3213
3479
  'price': self.safe_number(order, 'price'),
3214
- 'stopPrice': self.safe_number(order, 'stopPrice'),
3480
+ 'triggerPrice': self.safe_number(order, 'stopPrice'),
3215
3481
  'stopLoss': self.safe_number(order, 'triggerStopPrice'),
3216
3482
  'takeProfit': self.safe_number(order, 'triggerProfitPrice'),
3217
3483
  'amount': amount,
@@ -3245,10 +3511,12 @@ class xt(Exchange, ImplicitAPI):
3245
3511
  }
3246
3512
  return self.safe_string(statuses, status, status)
3247
3513
 
3248
- async def fetch_ledger(self, code: str = None, since: Int = None, limit: Int = None, params={}):
3514
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
3249
3515
  """
3250
3516
  fetch the history of changes, actions done by the user or operations that altered the balance of the user
3251
- :see: https://doc.xt.com/#futures_usergetBalanceBill
3517
+
3518
+ https://doc.xt.com/#futures_usergetBalanceBill
3519
+
3252
3520
  :param str [code]: unified currency code
3253
3521
  :param int [since]: timestamp in ms of the earliest ledger entry
3254
3522
  :param int [limit]: max number of ledger entries to return
@@ -3302,7 +3570,7 @@ class xt(Exchange, ImplicitAPI):
3302
3570
  ledger = self.safe_value(data, 'items', [])
3303
3571
  return self.parse_ledger(ledger, currency, since, limit)
3304
3572
 
3305
- def parse_ledger_entry(self, item, currency=None):
3573
+ def parse_ledger_entry(self, item, currency=None) -> LedgerEntry:
3306
3574
  #
3307
3575
  # {
3308
3576
  # "id": "207260567109387524",
@@ -3318,8 +3586,10 @@ class xt(Exchange, ImplicitAPI):
3318
3586
  side = self.safe_string(item, 'side')
3319
3587
  direction = 'in' if (side == 'ADD') else 'out'
3320
3588
  currencyId = self.safe_string(item, 'coin')
3589
+ currency = self.safe_currency(currencyId, currency)
3321
3590
  timestamp = self.safe_integer(item, 'createdTime')
3322
- return {
3591
+ return self.safe_ledger_entry({
3592
+ 'info': item,
3323
3593
  'id': self.safe_string(item, 'id'),
3324
3594
  'direction': direction,
3325
3595
  'account': None,
@@ -3337,8 +3607,7 @@ class xt(Exchange, ImplicitAPI):
3337
3607
  'currency': None,
3338
3608
  'cost': None,
3339
3609
  },
3340
- 'info': item,
3341
- }
3610
+ }, currency)
3342
3611
 
3343
3612
  def parse_ledger_entry_type(self, type):
3344
3613
  ledgerType = {
@@ -3353,10 +3622,12 @@ class xt(Exchange, ImplicitAPI):
3353
3622
  }
3354
3623
  return self.safe_string(ledgerType, type, type)
3355
3624
 
3356
- async def fetch_deposit_address(self, code: str, params={}):
3625
+ async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
3357
3626
  """
3358
3627
  fetch the deposit address for a currency associated with self account
3359
- :see: https://doc.xt.com/#deposit_withdrawaldepositAddressGet
3628
+
3629
+ https://doc.xt.com/#deposit_withdrawaldepositAddressGet
3630
+
3360
3631
  :param str code: unified currency code
3361
3632
  :param dict params: extra parameters specific to the xt api endpoint
3362
3633
  :param str params['network']: required network id
@@ -3387,7 +3658,7 @@ class xt(Exchange, ImplicitAPI):
3387
3658
  result = self.safe_value(response, 'result', {})
3388
3659
  return self.parse_deposit_address(result, currency)
3389
3660
 
3390
- def parse_deposit_address(self, depositAddress, currency=None):
3661
+ def parse_deposit_address(self, depositAddress, currency=None) -> DepositAddress:
3391
3662
  #
3392
3663
  # {
3393
3664
  # "address": "0x7f7173cf29d3846d20ca5a3aec1120b93dbd157a",
@@ -3397,17 +3668,19 @@ class xt(Exchange, ImplicitAPI):
3397
3668
  address = self.safe_string(depositAddress, 'address')
3398
3669
  self.check_address(address)
3399
3670
  return {
3671
+ 'info': depositAddress,
3400
3672
  'currency': self.safe_currency_code(None, currency),
3673
+ 'network': None,
3401
3674
  'address': address,
3402
3675
  'tag': self.safe_string(depositAddress, 'memo'),
3403
- 'network': None,
3404
- 'info': depositAddress,
3405
3676
  }
3406
3677
 
3407
- async def fetch_deposits(self, code: str = None, since: Int = None, limit: Int = None, params={}):
3678
+ async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
3408
3679
  """
3409
3680
  fetch all deposits made to an account
3410
- :see: https://doc.xt.com/#deposit_withdrawalhistoryDepositGet
3681
+
3682
+ https://doc.xt.com/#deposit_withdrawalhistoryDepositGet
3683
+
3411
3684
  :param str [code]: unified currency code
3412
3685
  :param int [since]: the earliest time in ms to fetch deposits for
3413
3686
  :param int [limit]: the maximum number of transaction structures to retrieve
@@ -3455,10 +3728,12 @@ class xt(Exchange, ImplicitAPI):
3455
3728
  deposits = self.safe_value(data, 'items', [])
3456
3729
  return self.parse_transactions(deposits, currency, since, limit, params)
3457
3730
 
3458
- async def fetch_withdrawals(self, code: str = None, since: Int = None, limit: Int = None, params={}):
3731
+ async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
3459
3732
  """
3460
3733
  fetch all withdrawals made from an account
3461
- :see: https://doc.xt.com/#deposit_withdrawalwithdrawHistory
3734
+
3735
+ https://doc.xt.com/#deposit_withdrawalwithdrawHistory
3736
+
3462
3737
  :param str [code]: unified currency code
3463
3738
  :param int [since]: the earliest time in ms to fetch withdrawals for
3464
3739
  :param int [limit]: the maximum number of transaction structures to retrieve
@@ -3506,10 +3781,12 @@ class xt(Exchange, ImplicitAPI):
3506
3781
  withdrawals = self.safe_value(data, 'items', [])
3507
3782
  return self.parse_transactions(withdrawals, currency, since, limit, params)
3508
3783
 
3509
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
3784
+ async def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
3510
3785
  """
3511
3786
  make a withdrawal
3512
- :see: https://doc.xt.com/#deposit_withdrawalwithdraw
3787
+
3788
+ https://doc.xt.com/#deposit_withdrawalwithdraw
3789
+
3513
3790
  :param str code: unified currency code
3514
3791
  :param float amount: the amount to withdraw
3515
3792
  :param str address: the address to withdraw to
@@ -3634,10 +3911,12 @@ class xt(Exchange, ImplicitAPI):
3634
3911
  }
3635
3912
  return self.safe_string(statuses, status, status)
3636
3913
 
3637
- async def set_leverage(self, leverage: Int, symbol: str = None, params={}):
3914
+ async def set_leverage(self, leverage: int, symbol: str = None, params={}):
3638
3915
  """
3639
3916
  set the level of leverage for a market
3640
- :see: https://doc.xt.com/#futures_useradjustLeverage
3917
+
3918
+ https://doc.xt.com/#futures_useradjustLeverage
3919
+
3641
3920
  :param float leverage: the rate of leverage
3642
3921
  :param str symbol: unified market symbol
3643
3922
  :param dict params: extra parameters specific to the xt api endpoint
@@ -3679,7 +3958,9 @@ class xt(Exchange, ImplicitAPI):
3679
3958
  async def add_margin(self, symbol: str, amount: float, params={}):
3680
3959
  """
3681
3960
  add margin to a position
3682
- :see: https://doc.xt.com/#futures_useradjustMargin
3961
+
3962
+ https://doc.xt.com/#futures_useradjustMargin
3963
+
3683
3964
  :param str symbol: unified market symbol
3684
3965
  :param float amount: amount of margin to add
3685
3966
  :param dict params: extra parameters specific to the xt api endpoint
@@ -3691,7 +3972,9 @@ class xt(Exchange, ImplicitAPI):
3691
3972
  async def reduce_margin(self, symbol: str, amount: float, params={}):
3692
3973
  """
3693
3974
  remove margin from a position
3694
- :see: https://doc.xt.com/#futures_useradjustMargin
3975
+
3976
+ https://doc.xt.com/#futures_useradjustMargin
3977
+
3695
3978
  :param str symbol: unified market symbol
3696
3979
  :param float amount: the amount of margin to remove
3697
3980
  :param dict params: extra parameters specific to the xt api endpoint
@@ -3742,10 +4025,12 @@ class xt(Exchange, ImplicitAPI):
3742
4025
  'datetime': None,
3743
4026
  }
3744
4027
 
3745
- async def fetch_leverage_tiers(self, symbols: List[str] = None, params={}):
4028
+ async def fetch_leverage_tiers(self, symbols: List[str] = None, params={}) -> LeverageTiers:
3746
4029
  """
3747
- :see: https://doc.xt.com/#futures_quotesgetLeverageBrackets
3748
4030
  retrieve information on the maximum leverage for different trade sizes
4031
+
4032
+ https://doc.xt.com/#futures_quotesgetLeverageBrackets
4033
+
3749
4034
  :param str [symbols]: a list of unified market symbols
3750
4035
  :param dict params: extra parameters specific to the xt api endpoint
3751
4036
  :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
@@ -3786,7 +4071,7 @@ class xt(Exchange, ImplicitAPI):
3786
4071
  symbols = self.market_symbols(symbols)
3787
4072
  return self.parse_leverage_tiers(data, symbols, 'symbol')
3788
4073
 
3789
- def parse_leverage_tiers(self, response, symbols=None, marketIdKey=None):
4074
+ def parse_leverage_tiers(self, response, symbols=None, marketIdKey=None) -> LeverageTiers:
3790
4075
  #
3791
4076
  # {
3792
4077
  # "symbol": "rad_usdt",
@@ -3819,8 +4104,10 @@ class xt(Exchange, ImplicitAPI):
3819
4104
 
3820
4105
  async def fetch_market_leverage_tiers(self, symbol: str, params={}) -> List[LeverageTier]:
3821
4106
  """
3822
- :see: https://doc.xt.com/#futures_quotesgetLeverageBracket
3823
4107
  retrieve information on the maximum leverage for different trade sizes of a single market
4108
+
4109
+ https://doc.xt.com/#futures_quotesgetLeverageBracket
4110
+
3824
4111
  :param str symbol: unified market symbol
3825
4112
  :param dict params: extra parameters specific to the xt api endpoint
3826
4113
  :returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
@@ -3862,7 +4149,7 @@ class xt(Exchange, ImplicitAPI):
3862
4149
  data = self.safe_value(response, 'result', {})
3863
4150
  return self.parse_market_leverage_tiers(data, market)
3864
4151
 
3865
- def parse_market_leverage_tiers(self, info, market=None):
4152
+ def parse_market_leverage_tiers(self, info, market=None) -> List[LeverageTier]:
3866
4153
  #
3867
4154
  # {
3868
4155
  # "symbol": "rad_usdt",
@@ -3888,6 +4175,7 @@ class xt(Exchange, ImplicitAPI):
3888
4175
  market = self.safe_market(marketId, market, '_', 'contract')
3889
4176
  tiers.append({
3890
4177
  'tier': self.safe_integer(tier, 'bracket'),
4178
+ 'symbol': self.safe_symbol(marketId, market, '_', 'contract'),
3891
4179
  'currency': market['settle'],
3892
4180
  'minNotional': self.safe_number(brackets[i - 1], 'maxNominalValue', 0),
3893
4181
  'maxNotional': self.safe_number(tier, 'maxNominalValue'),
@@ -3900,7 +4188,9 @@ class xt(Exchange, ImplicitAPI):
3900
4188
  async def fetch_funding_rate_history(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
3901
4189
  """
3902
4190
  fetches historical funding rates
3903
- :see: https://doc.xt.com/#futures_quotesgetFundingRateRecord
4191
+
4192
+ https://doc.xt.com/#futures_quotesgetFundingRateRecord
4193
+
3904
4194
  :param str [symbol]: unified symbol of the market to fetch the funding rate history for
3905
4195
  :param int [since]: timestamp in ms of the earliest funding rate to fetch
3906
4196
  :param int [limit]: the maximum amount of [funding rate structures] to fetch
@@ -3963,10 +4253,24 @@ class xt(Exchange, ImplicitAPI):
3963
4253
  sorted = self.sort_by(rates, 'timestamp')
3964
4254
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
3965
4255
 
3966
- async def fetch_funding_rate(self, symbol: str, params={}):
4256
+ async def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
4257
+ """
4258
+ fetch the current funding rate interval
4259
+
4260
+ https://doc.xt.com/#futures_quotesgetFundingRate
4261
+
4262
+ :param str symbol: unified market symbol
4263
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4264
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
4265
+ """
4266
+ return await self.fetch_funding_rate(symbol, params)
4267
+
4268
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
3967
4269
  """
3968
4270
  fetch the current funding rate
3969
- :see: https://doc.xt.com/#futures_quotesgetFundingRate
4271
+
4272
+ https://doc.xt.com/#futures_quotesgetFundingRate
4273
+
3970
4274
  :param str symbol: unified market symbol
3971
4275
  :param dict params: extra parameters specific to the xt api endpoint
3972
4276
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -4001,7 +4305,7 @@ class xt(Exchange, ImplicitAPI):
4001
4305
  result = self.safe_value(response, 'result', {})
4002
4306
  return self.parse_funding_rate(result, market)
4003
4307
 
4004
- def parse_funding_rate(self, contract, market=None):
4308
+ def parse_funding_rate(self, contract, market=None) -> FundingRate:
4005
4309
  #
4006
4310
  # {
4007
4311
  # "symbol": "btc_usdt",
@@ -4013,6 +4317,9 @@ class xt(Exchange, ImplicitAPI):
4013
4317
  marketId = self.safe_string(contract, 'symbol')
4014
4318
  symbol = self.safe_symbol(marketId, market, '_', 'swap')
4015
4319
  timestamp = self.safe_integer(contract, 'nextCollectionTime')
4320
+ interval = self.safe_string(contract, 'collectionInternal')
4321
+ if interval is not None:
4322
+ interval = interval + 'h'
4016
4323
  return {
4017
4324
  'info': contract,
4018
4325
  'symbol': symbol,
@@ -4031,12 +4338,15 @@ class xt(Exchange, ImplicitAPI):
4031
4338
  'previousFundingRate': None,
4032
4339
  'previousFundingTimestamp': None,
4033
4340
  'previousFundingDatetime': None,
4341
+ 'interval': interval,
4034
4342
  }
4035
4343
 
4036
4344
  async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4037
4345
  """
4038
4346
  fetch the funding history
4039
- :see: https://doc.xt.com/#futures_usergetFunding
4347
+
4348
+ https://doc.xt.com/#futures_usergetFunding
4349
+
4040
4350
  :param str symbol: unified market symbol
4041
4351
  :param int [since]: the starting timestamp in milliseconds
4042
4352
  :param int [limit]: the number of entries to return
@@ -4120,7 +4430,9 @@ class xt(Exchange, ImplicitAPI):
4120
4430
  async def fetch_position(self, symbol: str, params={}):
4121
4431
  """
4122
4432
  fetch data on a single open contract trade position
4123
- :see: https://doc.xt.com/#futures_usergetPosition
4433
+
4434
+ https://doc.xt.com/#futures_usergetPosition
4435
+
4124
4436
  :param str symbol: unified market symbol of the market the position is held in
4125
4437
  :param dict params: extra parameters specific to the xt api endpoint
4126
4438
  :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -4172,10 +4484,12 @@ class xt(Exchange, ImplicitAPI):
4172
4484
  return self.parse_position(entry, marketInner)
4173
4485
  return None
4174
4486
 
4175
- async def fetch_positions(self, symbols: List[str] = None, params={}):
4487
+ async def fetch_positions(self, symbols: List[str] = None, params={}) -> List[Position]:
4176
4488
  """
4177
4489
  fetch all open positions
4178
- :see: https://doc.xt.com/#futures_usergetPosition
4490
+
4491
+ https://doc.xt.com/#futures_usergetPosition
4492
+
4179
4493
  :param str [symbols]: list of unified market symbols, not supported with xt
4180
4494
  :param dict params: extra parameters specific to the xt api endpoint
4181
4495
  :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -4276,7 +4590,9 @@ class xt(Exchange, ImplicitAPI):
4276
4590
  async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
4277
4591
  """
4278
4592
  transfer currency internally between wallets on the same account
4279
- :see: https://doc.xt.com/#transfersubTransferPost
4593
+
4594
+ https://doc.xt.com/#transfersubTransferPost
4595
+
4280
4596
  :param str code: unified currency code
4281
4597
  :param float amount: amount to transfer
4282
4598
  :param str fromAccount: account to transfer from - spot, swap, leverage, finance
@@ -4326,6 +4642,141 @@ class xt(Exchange, ImplicitAPI):
4326
4642
  'status': None,
4327
4643
  }
4328
4644
 
4645
+ async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
4646
+ """
4647
+ set margin mode to 'cross' or 'isolated'
4648
+
4649
+ https://doc.xt.com/#futures_userchangePositionType
4650
+
4651
+ :param str marginMode: 'cross' or 'isolated'
4652
+ :param str [symbol]: required
4653
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4654
+ :param str [params.positionSide]: *required* "long" or "short"
4655
+ :returns dict: response from the exchange
4656
+ """
4657
+ if symbol is None:
4658
+ raise ArgumentsRequired(self.id + ' setMarginMode() requires a symbol argument')
4659
+ await self.load_markets()
4660
+ market = self.market(symbol)
4661
+ if market['spot']:
4662
+ raise BadSymbol(self.id + ' setMarginMode() supports contract markets only')
4663
+ marginMode = marginMode.lower()
4664
+ if marginMode != 'isolated' and marginMode != 'cross':
4665
+ raise BadRequest(self.id + ' setMarginMode() marginMode argument should be isolated or cross')
4666
+ if marginMode == 'cross':
4667
+ marginMode = 'CROSSED'
4668
+ else:
4669
+ marginMode = 'ISOLATED'
4670
+ posSide = self.safe_string_upper(params, 'positionSide')
4671
+ if posSide is None:
4672
+ raise ArgumentsRequired(self.id + ' setMarginMode() requires a positionSide parameter, either "LONG" or "SHORT"')
4673
+ request: dict = {
4674
+ 'positionType': marginMode,
4675
+ 'positionSide': posSide,
4676
+ 'symbol': market['id'],
4677
+ }
4678
+ response = await self.privateLinearPostFutureUserV1PositionChangeType(self.extend(request, params))
4679
+ #
4680
+ # {
4681
+ # "error": {
4682
+ # "code": "",
4683
+ # "msg": ""
4684
+ # },
4685
+ # "msgInfo": "",
4686
+ # "result": {},
4687
+ # "returnCode": 0
4688
+ # }
4689
+ #
4690
+ return response # unify return type
4691
+
4692
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}) -> Order:
4693
+ """
4694
+ cancels an order and places a new order
4695
+
4696
+ https://doc.xt.com/#orderorderUpdate
4697
+ https://doc.xt.com/#futures_orderupdate
4698
+ https://doc.xt.com/#futures_entrustupdateProfit
4699
+
4700
+ :param str id: order id
4701
+ :param str symbol: unified symbol of the market to create an order in
4702
+ :param str type: 'market' or 'limit'
4703
+ :param str side: 'buy' or 'sell'
4704
+ :param float amount: how much of the currency you want to trade in units of the base currency
4705
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
4706
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4707
+ :param float [params.stopLoss]: price to set a stop-loss on an open position
4708
+ :param float [params.takeProfit]: price to set a take-profit on an open position
4709
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4710
+ """
4711
+ if amount is None:
4712
+ raise ArgumentsRequired(self.id + ' editOrder() requires an amount argument')
4713
+ await self.load_markets()
4714
+ market = self.market(symbol)
4715
+ request = {}
4716
+ stopLoss = self.safe_number_2(params, 'stopLoss', 'triggerStopPrice')
4717
+ takeProfit = self.safe_number_2(params, 'takeProfit', 'triggerProfitPrice')
4718
+ params = self.omit(params, ['stopLoss', 'takeProfit'])
4719
+ isStopLoss = (stopLoss is not None)
4720
+ isTakeProfit = (takeProfit is not None)
4721
+ if isStopLoss or isTakeProfit:
4722
+ request['profitId'] = id
4723
+ else:
4724
+ request['orderId'] = id
4725
+ request['price'] = self.price_to_precision(symbol, price)
4726
+ response = None
4727
+ if market['swap']:
4728
+ if isStopLoss:
4729
+ request['triggerStopPrice'] = self.price_to_precision(symbol, stopLoss)
4730
+ elif takeProfit is not None:
4731
+ request['triggerProfitPrice'] = self.price_to_precision(symbol, takeProfit)
4732
+ else:
4733
+ request['origQty'] = self.amount_to_precision(symbol, amount)
4734
+ subType = None
4735
+ subType, params = self.handle_sub_type_and_params('editOrder', market, params)
4736
+ if subType == 'inverse':
4737
+ if isStopLoss or isTakeProfit:
4738
+ response = await self.privateInversePostFutureTradeV1EntrustUpdateProfitStop(self.extend(request, params))
4739
+ else:
4740
+ response = await self.privateInversePostFutureTradeV1OrderUpdate(self.extend(request, params))
4741
+ #
4742
+ # {
4743
+ # "returnCode": 0,
4744
+ # "msgInfo": "success",
4745
+ # "error": null,
4746
+ # "result": "483869474947826752"
4747
+ # }
4748
+ #
4749
+ else:
4750
+ if isStopLoss or isTakeProfit:
4751
+ response = await self.privateLinearPostFutureTradeV1EntrustUpdateProfitStop(self.extend(request, params))
4752
+ else:
4753
+ response = await self.privateLinearPostFutureTradeV1OrderUpdate(self.extend(request, params))
4754
+ #
4755
+ # {
4756
+ # "returnCode": 0,
4757
+ # "msgInfo": "success",
4758
+ # "error": null,
4759
+ # "result": "483869474947826752"
4760
+ # }
4761
+ #
4762
+ else:
4763
+ request['quantity'] = self.amount_to_precision(symbol, amount)
4764
+ response = await self.privateSpotPutOrderOrderId(self.extend(request, params))
4765
+ #
4766
+ # {
4767
+ # "rc": 0,
4768
+ # "mc": "SUCCESS",
4769
+ # "ma": [],
4770
+ # "result": {
4771
+ # "orderId": "484203027161892224",
4772
+ # "modifyId": "484203544105344000",
4773
+ # "clientModifyId": null
4774
+ # }
4775
+ # }
4776
+ #
4777
+ result = response if (market['swap']) else self.safe_dict(response, 'result', {})
4778
+ return self.parse_order(result, market)
4779
+
4329
4780
  def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
4330
4781
  #
4331
4782
  # spot: error
@@ -4376,6 +4827,9 @@ class xt(Exchange, ImplicitAPI):
4376
4827
  # "result": {}
4377
4828
  # }
4378
4829
  #
4830
+ # {"returnCode":1,"msgInfo":"failure","error":{"code":"insufficient_balance","msg":"insufficient balance","args":[]},"result":null}
4831
+ #
4832
+ #
4379
4833
  status = self.safe_string_upper_2(response, 'msgInfo', 'mc')
4380
4834
  if status is not None and status != 'SUCCESS':
4381
4835
  feedback = self.id + ' ' + body
@@ -4419,7 +4873,9 @@ class xt(Exchange, ImplicitAPI):
4419
4873
  body['clientMedia'] = id
4420
4874
  else:
4421
4875
  body['media'] = id
4422
- isUndefinedBody = ((method == 'GET') or (path == 'order/{orderId}'))
4876
+ isUndefinedBody = ((method == 'GET') or (path == 'order/{orderId}') or (path == 'ws-token'))
4877
+ if (method == 'PUT') and (endpoint == 'spot'):
4878
+ isUndefinedBody = False
4423
4879
  body = None if isUndefinedBody else self.json(body)
4424
4880
  payloadString = None
4425
4881
  if (endpoint == 'spot') or (endpoint == 'user'):
@@ -4427,7 +4883,7 @@ class xt(Exchange, ImplicitAPI):
4427
4883
  if isUndefinedBody:
4428
4884
  if urlencoded:
4429
4885
  url += '?' + urlencoded
4430
- payloadString += '#' + method + '#' + payload + '#' + urlencoded
4886
+ payloadString += '#' + method + '#' + payload + '#' + self.rawencode(self.keysort(query))
4431
4887
  else:
4432
4888
  payloadString += '#' + method + '#' + payload
4433
4889
  else: