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/xt.py CHANGED
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.xt import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Currencies, Currency, Int, LeverageTier, MarginModification, Market, Num, Order, OrderSide, OrderType, Str, Tickers, Transaction, TransferEntry
9
+ 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
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -27,7 +27,7 @@ from ccxt.base.precise import Precise
27
27
 
28
28
  class xt(Exchange, ImplicitAPI):
29
29
 
30
- def describe(self):
30
+ def describe(self) -> Any:
31
31
  return self.deep_extend(super(xt, self).describe(), {
32
32
  'id': 'xt',
33
33
  'name': 'XT',
@@ -39,7 +39,7 @@ class xt(Exchange, ImplicitAPI):
39
39
  'rateLimit': 100,
40
40
  'version': 'v4',
41
41
  'certified': False,
42
- 'pro': False,
42
+ 'pro': True,
43
43
  'has': {
44
44
  'CORS': False,
45
45
  'spot': True,
@@ -58,7 +58,7 @@ class xt(Exchange, ImplicitAPI):
58
58
  'createOrder': True,
59
59
  'createPostOnlyOrder': False,
60
60
  'createReduceOnlyOrder': True,
61
- 'editOrder': False,
61
+ 'editOrder': True,
62
62
  'fetchAccounts': False,
63
63
  'fetchBalance': True,
64
64
  'fetchBidsAsks': True,
@@ -72,11 +72,15 @@ class xt(Exchange, ImplicitAPI):
72
72
  'fetchCurrencies': True,
73
73
  'fetchDeposit': False,
74
74
  'fetchDepositAddress': True,
75
+ 'fetchDepositAddresses': False,
76
+ 'fetchDepositAddressesByNetwork': False,
75
77
  'fetchDeposits': True,
76
78
  'fetchDepositWithdrawals': False,
77
79
  'fetchDepositWithdrawFee': False,
78
80
  'fetchDepositWithdrawFees': False,
79
81
  'fetchFundingHistory': True,
82
+ 'fetchFundingInterval': True,
83
+ 'fetchFundingIntervals': False,
80
84
  'fetchFundingRate': True,
81
85
  'fetchFundingRateHistory': True,
82
86
  'fetchFundingRates': False,
@@ -124,7 +128,7 @@ class xt(Exchange, ImplicitAPI):
124
128
  'repayMargin': False,
125
129
  'setLeverage': True,
126
130
  'setMargin': False,
127
- 'setMarginMode': False,
131
+ 'setMarginMode': True,
128
132
  'setPositionMode': False,
129
133
  'signIn': False,
130
134
  'transfer': True,
@@ -152,16 +156,16 @@ class xt(Exchange, ImplicitAPI):
152
156
  'spot': {
153
157
  'get': {
154
158
  'currencies': 1,
155
- 'depth': 0.05,
156
- 'kline': 0.1,
157
- 'symbol': 1, # 0.1 for a single symbol
158
- 'ticker': 1, # 0.1 for a single symbol
159
- 'ticker/book': 1, # 0.1 for a single symbol
160
- 'ticker/price': 1, # 0.1 for a single symbol
161
- 'ticker/24h': 1, # 0.1 for a single symbol
159
+ 'depth': 10,
160
+ 'kline': 1,
161
+ 'symbol': 1, # 1 for a single symbol
162
+ 'ticker': 1, # 1 for a single symbol
163
+ 'ticker/book': 1, # 1 for a single symbol
164
+ 'ticker/price': 1, # 1 for a single symbol
165
+ 'ticker/24h': 1, # 1 for a single symbol
162
166
  'time': 1,
163
- 'trade/history': 0.1,
164
- 'trade/recent': 0.1,
167
+ 'trade/history': 1,
168
+ 'trade/recent': 1,
165
169
  'wallet/support/currency': 1,
166
170
  },
167
171
  },
@@ -231,15 +235,19 @@ class xt(Exchange, ImplicitAPI):
231
235
  },
232
236
  'post': {
233
237
  'order': 0.2,
234
- 'withdraw': 1,
238
+ 'withdraw': 10,
235
239
  'balance/transfer': 1,
236
240
  'balance/account/transfer': 1,
241
+ 'ws-token': 1,
237
242
  },
238
243
  'delete': {
239
244
  'batch-order': 1,
240
245
  'open-order': 1,
241
246
  'order/{orderId}': 1,
242
247
  },
248
+ 'put': {
249
+ 'order/{orderId}': 1,
250
+ },
243
251
  },
244
252
  'linear': {
245
253
  'get': {
@@ -274,6 +282,7 @@ class xt(Exchange, ImplicitAPI):
274
282
  'future/trade/v1/order/cancel-all': 1,
275
283
  'future/trade/v1/order/create': 1,
276
284
  'future/trade/v1/order/create-batch': 1,
285
+ 'future/trade/v1/order/update': 1,
277
286
  'future/user/v1/account/open': 1,
278
287
  'future/user/v1/position/adjust-leverage': 1,
279
288
  'future/user/v1/position/auto-margin': 1,
@@ -281,6 +290,7 @@ class xt(Exchange, ImplicitAPI):
281
290
  'future/user/v1/position/margin': 1,
282
291
  'future/user/v1/user/collection/add': 1,
283
292
  'future/user/v1/user/collection/cancel': 1,
293
+ 'future/user/v1/position/change-type': 1,
284
294
  },
285
295
  },
286
296
  'inverse': {
@@ -316,6 +326,7 @@ class xt(Exchange, ImplicitAPI):
316
326
  'future/trade/v1/order/cancel-all': 1,
317
327
  'future/trade/v1/order/create': 1,
318
328
  'future/trade/v1/order/create-batch': 1,
329
+ 'future/trade/v1/order/update': 1,
319
330
  'future/user/v1/account/open': 1,
320
331
  'future/user/v1/position/adjust-leverage': 1,
321
332
  'future/user/v1/position/auto-margin': 1,
@@ -526,10 +537,12 @@ class xt(Exchange, ImplicitAPI):
526
537
  'TRANSFER_012': PermissionDenied, # Currency transfer prohibited
527
538
  '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}
528
539
  '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}
540
+ 'insufficient_balance': InsufficientFunds,
529
541
  },
530
542
  'broad': {
531
543
  '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}
532
544
  '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}
545
+ 'insufficient balance': InsufficientFunds,
533
546
  },
534
547
  },
535
548
  'timeframes': {
@@ -682,15 +695,134 @@ class xt(Exchange, ImplicitAPI):
682
695
  'createMarketBuyOrderRequiresPrice': True,
683
696
  'recvWindow': '5000', # in milliseconds, spot only
684
697
  },
698
+ 'features': {
699
+ 'default': {
700
+ 'sandbox': False,
701
+ 'createOrder': {
702
+ 'marginMode': False,
703
+ 'triggerPrice': False,
704
+ 'triggerDirection': False,
705
+ 'triggerPriceType': None,
706
+ 'stopLossPrice': False,
707
+ 'takeProfitPrice': False,
708
+ 'attachedStopLossTakeProfit': None,
709
+ 'timeInForce': {
710
+ 'IOC': True,
711
+ 'FOK': True,
712
+ 'PO': True,
713
+ 'GTD': False,
714
+ },
715
+ 'hedged': False,
716
+ 'trailing': False,
717
+ 'leverage': False,
718
+ 'marketBuyByCost': True,
719
+ 'marketBuyRequiresPrice': False,
720
+ 'selfTradePrevention': False,
721
+ 'iceberg': False,
722
+ },
723
+ 'createOrders': None,
724
+ 'fetchMyTrades': {
725
+ 'marginMode': True,
726
+ 'limit': 100,
727
+ 'daysBack': 100000, # todo
728
+ 'untilDays': 100000, # todo
729
+ 'marketType': True,
730
+ 'subType': True,
731
+ 'symbolRequired': False,
732
+ },
733
+ 'fetchOrder': {
734
+ 'marginMode': False,
735
+ 'trigger': True, # todo TPSL kind
736
+ 'trailing': False,
737
+ 'marketType': True,
738
+ 'subType': True,
739
+ 'symbolRequired': False,
740
+ },
741
+ 'fetchOpenOrders': {
742
+ 'marginMode': True,
743
+ 'limit': 100,
744
+ 'trigger': True, # todo TPSL
745
+ 'trailing': False,
746
+ 'marketType': True,
747
+ 'subType': True,
748
+ 'symbolRequired': False,
749
+ },
750
+ 'fetchOrders': {
751
+ 'marginMode': True,
752
+ 'limit': 100,
753
+ 'daysBack': 100000, # todo
754
+ 'untilDays': 100000, # todo
755
+ 'trigger': True, # todo TPSL
756
+ 'trailing': False,
757
+ 'marketType': True,
758
+ 'subType': True,
759
+ 'symbolRequired': False,
760
+ },
761
+ 'fetchClosedOrders': {
762
+ 'marginMode': True,
763
+ 'limit': 100,
764
+ 'daysBack': 100000, # todo
765
+ 'daysBackCanceled': 1, # todo
766
+ 'untilDays': 100000, # todo
767
+ 'trigger': True, # todo TPSL
768
+ 'trailing': False,
769
+ 'marketType': True,
770
+ 'subType': True,
771
+ 'symbolRequired': False,
772
+ },
773
+ 'fetchOHLCV': {
774
+ 'limit': 1000, # todo for derivatives
775
+ },
776
+ },
777
+ 'spot': {
778
+ 'extends': 'default',
779
+ },
780
+ 'forDerivatives': {
781
+ 'extends': 'default',
782
+ 'createOrder': {
783
+ 'triggerPrice': True,
784
+ # todo
785
+ 'triggerPriceType': {
786
+ 'last': True,
787
+ 'mark': True,
788
+ 'index': True,
789
+ },
790
+ 'stopLossPrice': True,
791
+ 'takeProfitPrice': True,
792
+ },
793
+ 'fetchMyTrades': {
794
+ 'daysBack': None,
795
+ 'untilDays': None,
796
+ },
797
+ },
798
+ 'swap': {
799
+ 'linear': {
800
+ 'extends': 'forDerivatives',
801
+ },
802
+ 'inverse': {
803
+ 'extends': 'forDerivatives',
804
+ },
805
+ },
806
+ 'future': {
807
+ 'linear': {
808
+ 'extends': 'forDerivatives',
809
+ },
810
+ 'inverse': {
811
+ 'extends': 'forDerivatives',
812
+ },
813
+ },
814
+ },
685
815
  })
686
816
 
687
817
  def nonce(self):
688
818
  return self.milliseconds() - self.options['timeDifference']
689
819
 
690
- def fetch_time(self, params={}):
820
+ def fetch_time(self, params={}) -> Int:
691
821
  """
692
822
  fetches the current integer timestamp in milliseconds from the xt server
693
- :see: https://doc.xt.com/#market1serverInfo
823
+
824
+ https://doc.xt.com/#market1serverInfo
825
+
694
826
  :param dict params: extra parameters specific to the xt api endpoint
695
827
  :returns int: the current integer timestamp in milliseconds from the xt server
696
828
  """
@@ -711,7 +843,9 @@ class xt(Exchange, ImplicitAPI):
711
843
  def fetch_currencies(self, params={}) -> Currencies:
712
844
  """
713
845
  fetches all available currencies on an exchange
714
- :see: https://doc.xt.com/#deposit_withdrawalsupportedCurrenciesGet
846
+
847
+ https://doc.xt.com/#deposit_withdrawalsupportedCurrenciesGet
848
+
715
849
  :param dict params: extra parameters specific to the xt api endpoint
716
850
  :returns dict: an associative dictionary of currencies
717
851
  """
@@ -777,48 +911,30 @@ class xt(Exchange, ImplicitAPI):
777
911
  entry = currenciesData[i]
778
912
  currencyId = self.safe_string(entry, 'currency')
779
913
  code = self.safe_currency_code(currencyId)
780
- minPrecision = self.parse_number(self.parse_precision(self.safe_string(entry, 'maxPrecision')))
781
914
  networkEntry = self.safe_value(chainsDataIndexed, currencyId, {})
782
915
  rawNetworks = self.safe_value(networkEntry, 'supportChains', [])
783
916
  networks = {}
784
- minWithdrawString = None
785
- minWithdrawFeeString = None
786
- active = False
787
- deposit = False
788
- withdraw = False
789
917
  for j in range(0, len(rawNetworks)):
790
918
  rawNetwork = rawNetworks[j]
791
919
  networkId = self.safe_string(rawNetwork, 'chain')
792
- network = self.network_id_to_code(networkId)
793
- depositEnabled = self.safe_value(rawNetwork, 'depositEnabled')
794
- deposit = depositEnabled if (depositEnabled) else deposit
795
- withdrawEnabled = self.safe_value(rawNetwork, 'withdrawEnabled')
796
- withdraw = withdrawEnabled if (withdrawEnabled) else withdraw
797
- networkActive = depositEnabled and withdrawEnabled
798
- active = networkActive if (networkActive) else active
799
- withdrawFeeString = self.safe_string(rawNetwork, 'withdrawFeeAmount')
800
- if withdrawFeeString is not None:
801
- minWithdrawFeeString = withdrawFeeString if (minWithdrawFeeString is None) else Precise.string_min(withdrawFeeString, minWithdrawFeeString)
802
- minNetworkWithdrawString = self.safe_string(rawNetwork, 'withdrawMinAmount')
803
- if minNetworkWithdrawString is not None:
804
- minWithdrawString = minNetworkWithdrawString if (minWithdrawString is None) else Precise.string_min(minNetworkWithdrawString, minWithdrawString)
805
- networks[network] = {
920
+ networkCode = self.network_id_to_code(networkId, code)
921
+ networks[networkCode] = {
806
922
  'info': rawNetwork,
807
923
  'id': networkId,
808
- 'network': network,
924
+ 'network': networkCode,
809
925
  'name': None,
810
- 'active': networkActive,
811
- 'fee': self.parse_number(withdrawFeeString),
812
- 'precision': minPrecision,
813
- 'deposit': depositEnabled,
814
- 'withdraw': withdrawEnabled,
926
+ 'active': None,
927
+ 'fee': self.safe_number(rawNetwork, 'withdrawFeeAmount'),
928
+ 'precision': None,
929
+ 'deposit': self.safe_bool(rawNetwork, 'depositEnabled'),
930
+ 'withdraw': self.safe_bool(rawNetwork, 'withdrawEnabled'),
815
931
  'limits': {
816
932
  'amount': {
817
933
  'min': None,
818
934
  'max': None,
819
935
  },
820
936
  'withdraw': {
821
- 'min': self.parse_number(minNetworkWithdrawString),
937
+ 'min': self.safe_number(rawNetwork, 'withdrawMinAmount'),
822
938
  'max': None,
823
939
  },
824
940
  'deposit': {
@@ -827,24 +943,31 @@ class xt(Exchange, ImplicitAPI):
827
943
  },
828
944
  },
829
945
  }
830
- result[code] = {
946
+ typeRaw = self.safe_string(entry, 'type')
947
+ type: Str = None
948
+ if typeRaw == 'FT':
949
+ type = 'crypto'
950
+ else:
951
+ type = 'other'
952
+ result[code] = self.safe_currency_structure({
831
953
  'info': entry,
832
954
  'id': currencyId,
833
955
  'code': code,
834
956
  'name': self.safe_string(entry, 'fullName'),
835
- 'active': active,
836
- 'fee': self.parse_number(minWithdrawFeeString),
837
- 'precision': None,
838
- 'deposit': deposit,
839
- 'withdraw': withdraw,
957
+ 'active': None,
958
+ 'fee': None,
959
+ 'precision': self.parse_number(self.parse_precision(self.safe_string(entry, 'maxPrecision'))),
960
+ 'deposit': self.safe_string(entry, 'depositStatus') == '1',
961
+ 'withdraw': self.safe_string(entry, 'withdrawStatus') == '1',
840
962
  'networks': networks,
963
+ 'type': type,
841
964
  'limits': {
842
965
  'amount': {
843
966
  'min': None,
844
967
  'max': None,
845
968
  },
846
969
  'withdraw': {
847
- 'min': self.parse_number(minWithdrawString),
970
+ 'min': None,
848
971
  'max': None,
849
972
  },
850
973
  'deposit': {
@@ -852,14 +975,16 @@ class xt(Exchange, ImplicitAPI):
852
975
  'max': None,
853
976
  },
854
977
  },
855
- }
978
+ })
856
979
  return result
857
980
 
858
981
  def fetch_markets(self, params={}) -> List[Market]:
859
982
  """
860
983
  retrieves data on all markets for xt
861
- :see: https://doc.xt.com/#market2symbol
862
- :see: https://doc.xt.com/#futures_quotesgetSymbols
984
+
985
+ https://doc.xt.com/#market2symbol
986
+ https://doc.xt.com/#futures_quotesgetSymbols
987
+
863
988
  :param dict params: extra parameters specific to the xt api endpoint
864
989
  :returns dict[]: an array of objects representing market data
865
990
  """
@@ -1136,17 +1261,21 @@ class xt(Exchange, ImplicitAPI):
1136
1261
  maxCost = None
1137
1262
  minPrice = None
1138
1263
  maxPrice = None
1264
+ amountPrecision = None
1139
1265
  for i in range(0, len(filters)):
1140
1266
  entry = filters[i]
1141
1267
  filter = self.safe_string(entry, 'filter')
1142
1268
  if filter == 'QUANTITY':
1143
1269
  minAmount = self.safe_number(entry, 'min')
1144
1270
  maxAmount = self.safe_number(entry, 'max')
1271
+ amountPrecision = self.safe_number(entry, 'tickSize')
1145
1272
  if filter == 'QUOTE_QTY':
1146
1273
  minCost = self.safe_number(entry, 'min')
1147
1274
  if filter == 'PRICE':
1148
1275
  minPrice = self.safe_number(entry, 'min')
1149
1276
  maxPrice = self.safe_number(entry, 'max')
1277
+ if amountPrecision is None:
1278
+ amountPrecision = self.parse_number(self.parse_precision(self.safe_string(market, 'quantityPrecision')))
1150
1279
  underlyingType = self.safe_string(market, 'underlyingType')
1151
1280
  linear = None
1152
1281
  inverse = None
@@ -1221,7 +1350,7 @@ class xt(Exchange, ImplicitAPI):
1221
1350
  'optionType': None,
1222
1351
  'precision': {
1223
1352
  'price': self.parse_number(self.parse_precision(self.safe_string(market, 'pricePrecision'))),
1224
- 'amount': self.parse_number(self.parse_precision(self.safe_string(market, 'quantityPrecision'))),
1353
+ 'amount': amountPrecision,
1225
1354
  'base': self.parse_number(self.parse_precision(self.safe_string(market, 'baseCoinPrecision'))),
1226
1355
  'quote': self.parse_number(self.parse_precision(self.safe_string(market, 'quoteCoinPrecision'))),
1227
1356
  },
@@ -1249,16 +1378,24 @@ class xt(Exchange, ImplicitAPI):
1249
1378
  def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
1250
1379
  """
1251
1380
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1252
- :see: https://doc.xt.com/#market4kline
1253
- :see: https://doc.xt.com/#futures_quotesgetKLine
1381
+
1382
+ https://doc.xt.com/#market4kline
1383
+ https://doc.xt.com/#futures_quotesgetKLine
1384
+
1254
1385
  :param str symbol: unified symbol of the market to fetch OHLCV data for
1255
1386
  :param str timeframe: the length of time each candle represents
1256
1387
  :param int [since]: timestamp in ms of the earliest candle to fetch
1257
1388
  :param int [limit]: the maximum amount of candles to fetch
1258
1389
  :param dict params: extra parameters specific to the xt api endpoint
1390
+ :param int [params.until]: timestamp in ms of the latest candle to fetch
1391
+ :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)
1259
1392
  :returns int[][]: A list of candles ordered, open, high, low, close, volume
1260
1393
  """
1261
1394
  self.load_markets()
1395
+ paginate = False
1396
+ paginate, params = self.handle_option_and_params(params, 'fetchOHLCV', 'paginate', False)
1397
+ if paginate:
1398
+ return self.fetch_paginated_call_deterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000)
1262
1399
  market = self.market(symbol)
1263
1400
  request = {
1264
1401
  'symbol': market['id'],
@@ -1268,6 +1405,12 @@ class xt(Exchange, ImplicitAPI):
1268
1405
  request['startTime'] = since
1269
1406
  if limit is not None:
1270
1407
  request['limit'] = limit
1408
+ else:
1409
+ request['limit'] = 1000
1410
+ until = self.safe_integer(params, 'until')
1411
+ params = self.omit(params, ['until'])
1412
+ if until is not None:
1413
+ request['endTime'] = until
1271
1414
  response = None
1272
1415
  if market['linear']:
1273
1416
  response = self.publicLinearGetFutureMarketV1PublicQKline(self.extend(request, params))
@@ -1354,13 +1497,15 @@ class xt(Exchange, ImplicitAPI):
1354
1497
  self.safe_number(ohlcv, 'h'),
1355
1498
  self.safe_number(ohlcv, 'l'),
1356
1499
  self.safe_number(ohlcv, 'c'),
1357
- self.safe_number_2(ohlcv, volumeIndex, 'v'),
1500
+ self.safe_number_2(ohlcv, 'q', volumeIndex),
1358
1501
  ]
1359
1502
 
1360
1503
  def fetch_order_book(self, symbol: str, limit: Int = None, params={}):
1361
1504
  """
1362
- :see: https://doc.xt.com/#market3depth
1363
- :see: https://doc.xt.com/#futures_quotesgetDepth
1505
+
1506
+ https://doc.xt.com/#market3depth
1507
+ https://doc.xt.com/#futures_quotesgetDepth
1508
+
1364
1509
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
1365
1510
  :param str symbol: unified market symbol to fetch the order book for
1366
1511
  :param int [limit]: the maximum amount of order book entries to return
@@ -1435,14 +1580,20 @@ class xt(Exchange, ImplicitAPI):
1435
1580
  orderBook = self.safe_value(response, 'result', {})
1436
1581
  timestamp = self.safe_integer_2(orderBook, 'timestamp', 't')
1437
1582
  if market['spot']:
1438
- return self.parse_order_book(orderBook, symbol, timestamp)
1439
- return self.parse_order_book(orderBook, symbol, timestamp, 'b', 'a')
1583
+ ob = self.parse_order_book(orderBook, symbol, timestamp)
1584
+ ob['nonce'] = self.safe_integer(orderBook, 'lastUpdateId')
1585
+ return ob
1586
+ swapOb = self.parse_order_book(orderBook, symbol, timestamp, 'b', 'a')
1587
+ swapOb['nonce'] = self.safe_integer_2(orderBook, 'u', 'lastUpdateId')
1588
+ return swapOb
1440
1589
 
1441
1590
  def fetch_ticker(self, symbol: str, params={}):
1442
1591
  """
1443
1592
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1444
- :see: https://doc.xt.com/#market10ticker24h
1445
- :see: https://doc.xt.com/#futures_quotesgetAggTicker
1593
+
1594
+ https://doc.xt.com/#market10ticker24h
1595
+ https://doc.xt.com/#futures_quotesgetAggTicker
1596
+
1446
1597
  :param str symbol: unified market symbol to fetch the ticker for
1447
1598
  :param dict params: extra parameters specific to the xt api endpoint
1448
1599
  :returns dict: a `ticker structure <https://docs.ccxt.com/en/latest/manual.html#ticker-structure>`
@@ -1513,8 +1664,10 @@ class xt(Exchange, ImplicitAPI):
1513
1664
  def fetch_tickers(self, symbols: List[str] = None, params={}) -> Tickers:
1514
1665
  """
1515
1666
  fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
1516
- :see: https://doc.xt.com/#market10ticker24h
1517
- :see: https://doc.xt.com/#futures_quotesgetAggTickers
1667
+
1668
+ https://doc.xt.com/#market10ticker24h
1669
+ https://doc.xt.com/#futures_quotesgetAggTickers
1670
+
1518
1671
  :param str [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1519
1672
  :param dict params: extra parameters specific to the xt api endpoint
1520
1673
  :returns dict: an array of `ticker structures <https://docs.ccxt.com/en/latest/manual.html#ticker-structure>`
@@ -1595,7 +1748,9 @@ class xt(Exchange, ImplicitAPI):
1595
1748
  def fetch_bids_asks(self, symbols: List[str] = None, params={}):
1596
1749
  """
1597
1750
  fetches the bid and ask price and volume for multiple markets
1598
- :see: https://doc.xt.com/#market9tickerBook
1751
+
1752
+ https://doc.xt.com/#market9tickerBook
1753
+
1599
1754
  :param str [symbols]: unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
1600
1755
  :param dict params: extra parameters specific to the xt api endpoint
1601
1756
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/en/latest/manual.html#ticker-structure>`
@@ -1679,11 +1834,15 @@ class xt(Exchange, ImplicitAPI):
1679
1834
  #
1680
1835
  marketId = self.safe_string(ticker, 's')
1681
1836
  marketType = market['type'] if (market is not None) else None
1837
+ hasSpotKeys = ('cv' in ticker) or ('aq' in ticker)
1682
1838
  if marketType is None:
1683
- marketType = ('cv' in ticker) or 'spot' if ('aq' in ticker) else 'contract'
1839
+ marketType = 'spot' if hasSpotKeys else 'contract'
1684
1840
  market = self.safe_market(marketId, market, '_', marketType)
1685
1841
  symbol = market['symbol']
1686
1842
  timestamp = self.safe_integer(ticker, 't')
1843
+ percentage = self.safe_string_2(ticker, 'cr', 'r')
1844
+ if percentage is not None:
1845
+ percentage = Precise.string_mul(percentage, '100')
1687
1846
  return self.safe_ticker({
1688
1847
  'symbol': symbol,
1689
1848
  'timestamp': timestamp,
@@ -1700,7 +1859,7 @@ class xt(Exchange, ImplicitAPI):
1700
1859
  'last': self.safe_string(ticker, 'c'),
1701
1860
  'previousClose': None,
1702
1861
  'change': self.safe_number(ticker, 'cv'),
1703
- 'percentage': self.safe_number_2(ticker, 'cr', 'r'),
1862
+ 'percentage': self.parse_number(percentage),
1704
1863
  'average': None,
1705
1864
  'baseVolume': None,
1706
1865
  'quoteVolume': self.safe_number_2(ticker, 'a', 'v'),
@@ -1710,8 +1869,10 @@ class xt(Exchange, ImplicitAPI):
1710
1869
  def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}):
1711
1870
  """
1712
1871
  get the list of most recent trades for a particular symbol
1713
- :see: https://doc.xt.com/#market5tradeRecent
1714
- :see: https://doc.xt.com/#futures_quotesgetDeal
1872
+
1873
+ https://doc.xt.com/#market5tradeRecent
1874
+ https://doc.xt.com/#futures_quotesgetDeal
1875
+
1715
1876
  :param str symbol: unified market symbol to fetch trades for
1716
1877
  :param int [since]: timestamp in ms of the earliest trade to fetch
1717
1878
  :param int [limit]: the maximum amount of trades to fetch
@@ -1777,8 +1938,10 @@ class xt(Exchange, ImplicitAPI):
1777
1938
  def fetch_my_trades(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
1778
1939
  """
1779
1940
  fetch all trades made by the user
1780
- :see: https://doc.xt.com/#tradetradeGet
1781
- :see: https://doc.xt.com/#futures_ordergetTrades
1941
+
1942
+ https://doc.xt.com/#tradetradeGet
1943
+ https://doc.xt.com/#futures_ordergetTrades
1944
+
1782
1945
  :param str [symbol]: unified market symbol to fetch trades for
1783
1946
  :param int [since]: timestamp in ms of the earliest trade to fetch
1784
1947
  :param int [limit]: the maximum amount of trades to fetch
@@ -1888,6 +2051,29 @@ class xt(Exchange, ImplicitAPI):
1888
2051
  # "b": True
1889
2052
  # }
1890
2053
  #
2054
+ # spot: watchTrades
2055
+ #
2056
+ # {
2057
+ # s: 'btc_usdt',
2058
+ # i: '228825383103928709',
2059
+ # t: 1684258222702,
2060
+ # p: '27003.65',
2061
+ # q: '0.000796',
2062
+ # b: True
2063
+ # }
2064
+ #
2065
+ # spot: watchMyTrades
2066
+ #
2067
+ # {
2068
+ # "s": "btc_usdt", # symbol
2069
+ # "t": 1656043204763, # time
2070
+ # "i": "6316559590087251233", # tradeId
2071
+ # "oi": "6216559590087220004", # orderId
2072
+ # "p": "30000", # trade price
2073
+ # "q": "3", # qty quantity
2074
+ # "v": "90000" # volume trade amount
2075
+ # }
2076
+ #
1891
2077
  # swap and future: fetchTrades
1892
2078
  #
1893
2079
  # {
@@ -1932,19 +2118,61 @@ class xt(Exchange, ImplicitAPI):
1932
2118
  # "takerMaker": "TAKER"
1933
2119
  # }
1934
2120
  #
2121
+ # contract watchMyTrades
2122
+ #
2123
+ # {
2124
+ # "symbol": 'btc_usdt',
2125
+ # "orderSide": 'SELL',
2126
+ # "positionSide": 'LONG',
2127
+ # "orderId": '231485367663419328',
2128
+ # "price": '27152.7',
2129
+ # "quantity": '33',
2130
+ # "marginUnfrozen": '2.85318000',
2131
+ # "timestamp": 1684892412565
2132
+ # }
2133
+ #
2134
+ # watchMyTrades(ws, swap)
2135
+ #
2136
+ # {
2137
+ # 'fee': '0.04080840',
2138
+ # 'isMaker': False,
2139
+ # 'marginUnfrozen': '0.75711984',
2140
+ # 'orderId': '376172779053188416',
2141
+ # 'orderSide': 'BUY',
2142
+ # 'positionSide': 'LONG',
2143
+ # 'price': '3400.70',
2144
+ # 'quantity': '2',
2145
+ # 'symbol': 'eth_usdt',
2146
+ # 'timestamp': 1719388579622
2147
+ # }
2148
+ #
1935
2149
  marketId = self.safe_string_2(trade, 's', 'symbol')
1936
2150
  marketType = market['type'] if (market is not None) else None
2151
+ hasSpotKeys = ('b' in trade) or ('bizType' in trade) or ('oi' in trade)
1937
2152
  if marketType is None:
1938
- marketType = ('b' in trade) or 'spot' if ('bizType' in trade) else 'contract'
2153
+ marketType = 'spot' if hasSpotKeys else 'contract'
1939
2154
  market = self.safe_market(marketId, market, '_', marketType)
1940
- bidOrAsk = self.safe_string(trade, 'm')
1941
- side = self.safe_string_lower(trade, 'orderSide')
1942
- if bidOrAsk is not None:
1943
- side = 'buy' if (bidOrAsk == 'BID') else 'sell'
1944
- buyerMaker = self.safe_value(trade, 'b')
1945
- takerOrMaker = self.safe_string_lower(trade, 'takerMaker')
1946
- if buyerMaker is not None:
1947
- takerOrMaker = 'maker' if buyerMaker else 'taker'
2155
+ side = None
2156
+ takerOrMaker = None
2157
+ isBuyerMaker = self.safe_bool(trade, 'b')
2158
+ if isBuyerMaker is not None:
2159
+ side = 'sell' if isBuyerMaker else 'buy'
2160
+ takerOrMaker = 'taker' # public trades always taker
2161
+ else:
2162
+ takerMaker = self.safe_string_lower(trade, 'takerMaker')
2163
+ if takerMaker is not None:
2164
+ takerOrMaker = takerMaker
2165
+ else:
2166
+ isMaker = self.safe_bool(trade, 'isMaker')
2167
+ if isMaker is not None:
2168
+ takerOrMaker = 'maker' if isMaker else 'taker'
2169
+ orderSide = self.safe_string_lower(trade, 'orderSide')
2170
+ if orderSide is not None:
2171
+ side = orderSide
2172
+ else:
2173
+ bidOrAsk = self.safe_string(trade, 'm')
2174
+ if bidOrAsk is not None:
2175
+ side = 'buy' if (bidOrAsk == 'BID') else 'sell'
1948
2176
  timestamp = self.safe_integer_n(trade, ['t', 'time', 'timestamp'])
1949
2177
  quantity = self.safe_string_2(trade, 'q', 'quantity')
1950
2178
  amount = None
@@ -1961,7 +2189,7 @@ class xt(Exchange, ImplicitAPI):
1961
2189
  'timestamp': timestamp,
1962
2190
  'datetime': self.iso8601(timestamp),
1963
2191
  'symbol': market['symbol'],
1964
- 'order': self.safe_string(trade, 'orderId'),
2192
+ 'order': self.safe_string_2(trade, 'orderId', 'oi'),
1965
2193
  'type': self.safe_string_lower(trade, 'orderType'),
1966
2194
  'side': side,
1967
2195
  'takerOrMaker': takerOrMaker,
@@ -1971,15 +2199,16 @@ class xt(Exchange, ImplicitAPI):
1971
2199
  'fee': {
1972
2200
  'currency': self.safe_currency_code(self.safe_string_2(trade, 'feeCurrency', 'feeCoin')),
1973
2201
  'cost': self.safe_string(trade, 'fee'),
1974
- 'rate': None,
1975
2202
  },
1976
2203
  }, market)
1977
2204
 
1978
2205
  def fetch_balance(self, params={}):
1979
2206
  """
1980
2207
  query for balance and get the amount of funds available for trading or funds locked in orders
1981
- :see: https://doc.xt.com/#balancebalancesGet
1982
- :see: https://doc.xt.com/#futures_usergetBalances
2208
+
2209
+ https://doc.xt.com/#balancebalancesGet
2210
+ https://doc.xt.com/#futures_usergetBalances
2211
+
1983
2212
  :param dict params: extra parameters specific to the xt api endpoint
1984
2213
  :returns dict: a `balance structure <https://docs.ccxt.com/en/latest/manual.html?#balance-structure>`
1985
2214
  """
@@ -2095,7 +2324,9 @@ class xt(Exchange, ImplicitAPI):
2095
2324
 
2096
2325
  def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
2097
2326
  """
2098
- :see: https://doc.xt.com/#orderorderPost
2327
+
2328
+ https://doc.xt.com/#orderorderPost
2329
+
2099
2330
  create a market buy order by providing the symbol and cost
2100
2331
  :param str symbol: unified symbol of the market to create an order in
2101
2332
  :param float cost: how much you want to trade in units of the quote currency
@@ -2111,10 +2342,12 @@ class xt(Exchange, ImplicitAPI):
2111
2342
  def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
2112
2343
  """
2113
2344
  create a trade order
2114
- :see: https://doc.xt.com/#orderorderPost
2115
- :see: https://doc.xt.com/#futures_ordercreate
2116
- :see: https://doc.xt.com/#futures_entrustcreatePlan
2117
- :see: https://doc.xt.com/#futures_entrustcreateProfit
2345
+
2346
+ https://doc.xt.com/#orderorderPost
2347
+ https://doc.xt.com/#futures_ordercreate
2348
+ https://doc.xt.com/#futures_entrustcreatePlan
2349
+ https://doc.xt.com/#futures_entrustcreateProfit
2350
+
2118
2351
  :param str symbol: unified symbol of the market to create an order in
2119
2352
  :param str type: 'market' or 'limit'
2120
2353
  :param str side: 'buy' or 'sell'
@@ -2124,7 +2357,8 @@ class xt(Exchange, ImplicitAPI):
2124
2357
  :param str [params.timeInForce]: 'GTC', 'IOC', 'FOK' or 'GTX'
2125
2358
  :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
2126
2359
  :param str [params.triggerPriceType]: 'INDEX_PRICE', 'MARK_PRICE', 'LATEST_PRICE', required if stopPrice is defined
2127
- :param float [params.stopPrice]: price to trigger a stop order
2360
+ :param float [params.triggerPrice]: price to trigger a stop order
2361
+ :param float [params.stopPrice]: alias for triggerPrice
2128
2362
  :param float [params.stopLoss]: price to set a stop-loss on an open position
2129
2363
  :param float [params.takeProfit]: price to set a take-profit on an open position
2130
2364
  :returns dict: an `order structure <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
@@ -2260,14 +2494,16 @@ class xt(Exchange, ImplicitAPI):
2260
2494
  def fetch_order(self, id: str, symbol: str = None, params={}):
2261
2495
  """
2262
2496
  fetches information on an order made by the user
2263
- :see: https://doc.xt.com/#orderorderGet
2264
- :see: https://doc.xt.com/#futures_ordergetById
2265
- :see: https://doc.xt.com/#futures_entrustgetPlanById
2266
- :see: https://doc.xt.com/#futures_entrustgetProfitById
2497
+
2498
+ https://doc.xt.com/#orderorderGet
2499
+ https://doc.xt.com/#futures_ordergetById
2500
+ https://doc.xt.com/#futures_entrustgetPlanById
2501
+ https://doc.xt.com/#futures_entrustgetProfitById
2502
+
2267
2503
  :param str id: order id
2268
2504
  :param str [symbol]: unified symbol of the market the order was made in
2269
2505
  :param dict params: extra parameters specific to the xt api endpoint
2270
- :param bool [params.stop]: if the order is a stop trigger order or not
2506
+ :param bool [params.trigger]: if the order is a trigger order or not
2271
2507
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2272
2508
  :returns dict: An `order structure <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2273
2509
  """
@@ -2281,15 +2517,15 @@ class xt(Exchange, ImplicitAPI):
2281
2517
  response = None
2282
2518
  type, params = self.handle_market_type_and_params('fetchOrder', market, params)
2283
2519
  subType, params = self.handle_sub_type_and_params('fetchOrder', market, params)
2284
- stop = self.safe_value(params, 'stop')
2520
+ trigger = self.safe_value(params, 'stop')
2285
2521
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
2286
- if stop:
2522
+ if trigger:
2287
2523
  request['entrustId'] = id
2288
2524
  elif stopLossTakeProfit:
2289
2525
  request['profitId'] = id
2290
2526
  else:
2291
2527
  request['orderId'] = id
2292
- if stop:
2528
+ if trigger:
2293
2529
  params = self.omit(params, 'stop')
2294
2530
  if subType == 'inverse':
2295
2531
  response = self.privateInverseGetFutureTradeV1EntrustPlanDetail(self.extend(request, params))
@@ -2430,14 +2666,16 @@ class xt(Exchange, ImplicitAPI):
2430
2666
  def fetch_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
2431
2667
  """
2432
2668
  fetches information on multiple orders made by the user
2433
- :see: https://doc.xt.com/#orderhistoryOrderGet
2434
- :see: https://doc.xt.com/#futures_ordergetHistory
2435
- :see: https://doc.xt.com/#futures_entrustgetPlanHistory
2669
+
2670
+ https://doc.xt.com/#orderhistoryOrderGet
2671
+ https://doc.xt.com/#futures_ordergetHistory
2672
+ https://doc.xt.com/#futures_entrustgetPlanHistory
2673
+
2436
2674
  :param str [symbol]: unified market symbol of the market the orders were made in
2437
2675
  :param int [since]: timestamp in ms of the earliest order
2438
2676
  :param int [limit]: the maximum number of order structures to retrieve
2439
2677
  :param dict params: extra parameters specific to the xt api endpoint
2440
- :param bool [params.stop]: if the order is a stop trigger order or not
2678
+ :param bool [params.trigger]: if the order is a trigger order or not
2441
2679
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2442
2680
  """
2443
2681
  self.load_markets()
@@ -2455,9 +2693,9 @@ class xt(Exchange, ImplicitAPI):
2455
2693
  response = None
2456
2694
  type, params = self.handle_market_type_and_params('fetchOrders', market, params)
2457
2695
  subType, params = self.handle_sub_type_and_params('fetchOrders', market, params)
2458
- stop = self.safe_value(params, 'stop')
2459
- if stop:
2460
- params = self.omit(params, 'stop')
2696
+ trigger = self.safe_value_2(params, 'trigger', 'stop')
2697
+ if trigger:
2698
+ params = self.omit(params, ['trigger', 'stop'])
2461
2699
  if subType == 'inverse':
2462
2700
  response = self.privateInverseGetFutureTradeV1EntrustPlanListHistory(self.extend(request, params))
2463
2701
  else:
@@ -2593,37 +2831,41 @@ class xt(Exchange, ImplicitAPI):
2593
2831
  if symbol is not None:
2594
2832
  market = self.market(symbol)
2595
2833
  request['symbol'] = market['id']
2834
+ if limit is not None:
2835
+ request['size'] = limit
2836
+ if since is not None:
2837
+ request['startTime'] = since
2596
2838
  type = None
2597
2839
  subType = None
2598
2840
  response = None
2599
2841
  type, params = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
2600
2842
  subType, params = self.handle_sub_type_and_params('fetchOrdersByStatus', market, params)
2601
- stop = self.safe_value(params, 'stop')
2843
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
2602
2844
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
2603
2845
  if status == 'open':
2604
- if stop or stopLossTakeProfit:
2846
+ if trigger or stopLossTakeProfit:
2605
2847
  request['state'] = 'NOT_TRIGGERED'
2606
- elif subType is not None:
2607
- request['state'] = 'NEW'
2848
+ elif type == 'swap':
2849
+ request['state'] = 'UNFINISHED' # NEW & PARTIALLY_FILLED
2608
2850
  elif status == 'closed':
2609
- if stop or stopLossTakeProfit:
2851
+ if trigger or stopLossTakeProfit:
2610
2852
  request['state'] = 'TRIGGERED'
2611
2853
  else:
2612
2854
  request['state'] = 'FILLED'
2613
2855
  elif status == 'canceled':
2614
- if stop or stopLossTakeProfit:
2856
+ if trigger or stopLossTakeProfit:
2615
2857
  request['state'] = 'USER_REVOCATION'
2616
2858
  else:
2617
2859
  request['state'] = 'CANCELED'
2618
2860
  else:
2619
2861
  request['state'] = status
2620
- if stop or stopLossTakeProfit or (subType is not None) or (type == 'swap') or (type == 'future'):
2862
+ if trigger or stopLossTakeProfit or (subType is not None) or (type == 'swap') or (type == 'future'):
2621
2863
  if since is not None:
2622
2864
  request['startTime'] = since
2623
2865
  if limit is not None:
2624
2866
  request['size'] = limit
2625
- if stop:
2626
- params = self.omit(params, 'stop')
2867
+ if trigger:
2868
+ params = self.omit(params, ['stop', 'trigger'])
2627
2869
  if subType == 'inverse':
2628
2870
  response = self.privateInverseGetFutureTradeV1EntrustPlanList(self.extend(request, params))
2629
2871
  else:
@@ -2648,6 +2890,7 @@ class xt(Exchange, ImplicitAPI):
2648
2890
  if since is not None:
2649
2891
  request['startTime'] = since
2650
2892
  if limit is not None:
2893
+ request = self.omit(request, 'size')
2651
2894
  request['limit'] = limit
2652
2895
  response = self.privateSpotGetHistoryOrder(self.extend(request, params))
2653
2896
  else:
@@ -2830,23 +3073,28 @@ class xt(Exchange, ImplicitAPI):
2830
3073
  # }
2831
3074
  # }
2832
3075
  #
2833
- isSpotOpenOrders = ((status == 'open') and (subType is None))
2834
- data = self.safe_value(response, 'result', {})
2835
- orders = self.safe_value(response, 'result', []) if isSpotOpenOrders else self.safe_value(data, 'items', [])
3076
+ orders = []
3077
+ resultDict = self.safe_dict(response, 'result')
3078
+ if resultDict is not None:
3079
+ orders = self.safe_list(resultDict, 'items', [])
3080
+ else:
3081
+ orders = self.safe_list(response, 'result')
2836
3082
  return self.parse_orders(orders, market, since, limit)
2837
3083
 
2838
3084
  def fetch_open_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
2839
3085
  """
2840
3086
  fetch all unfilled currently open orders
2841
- :see: https://doc.xt.com/#orderopenOrderGet
2842
- :see: https://doc.xt.com/#futures_ordergetOrders
2843
- :see: https://doc.xt.com/#futures_entrustgetPlan
2844
- :see: https://doc.xt.com/#futures_entrustgetProfit
3087
+
3088
+ https://doc.xt.com/#orderopenOrderGet
3089
+ https://doc.xt.com/#futures_ordergetOrders
3090
+ https://doc.xt.com/#futures_entrustgetPlan
3091
+ https://doc.xt.com/#futures_entrustgetProfit
3092
+
2845
3093
  :param str [symbol]: unified market symbol of the market the orders were made in
2846
3094
  :param int [since]: timestamp in ms of the earliest order
2847
3095
  :param int [limit]: the maximum number of open order structures to retrieve
2848
3096
  :param dict params: extra parameters specific to the xt api endpoint
2849
- :param bool [params.stop]: if the order is a stop trigger order or not
3097
+ :param bool [params.trigger]: if the order is a trigger order or not
2850
3098
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2851
3099
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2852
3100
  """
@@ -2855,15 +3103,17 @@ class xt(Exchange, ImplicitAPI):
2855
3103
  def fetch_closed_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
2856
3104
  """
2857
3105
  fetches information on multiple closed orders made by the user
2858
- :see: https://doc.xt.com/#orderhistoryOrderGet
2859
- :see: https://doc.xt.com/#futures_ordergetOrders
2860
- :see: https://doc.xt.com/#futures_entrustgetPlan
2861
- :see: https://doc.xt.com/#futures_entrustgetProfit
3106
+
3107
+ https://doc.xt.com/#orderhistoryOrderGet
3108
+ https://doc.xt.com/#futures_ordergetOrders
3109
+ https://doc.xt.com/#futures_entrustgetPlan
3110
+ https://doc.xt.com/#futures_entrustgetProfit
3111
+
2862
3112
  :param str [symbol]: unified market symbol of the market the orders were made in
2863
3113
  :param int [since]: timestamp in ms of the earliest order
2864
3114
  :param int [limit]: the maximum number of order structures to retrieve
2865
3115
  :param dict params: extra parameters specific to the xt api endpoint
2866
- :param bool [params.stop]: if the order is a stop trigger order or not
3116
+ :param bool [params.trigger]: if the order is a trigger order or not
2867
3117
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2868
3118
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2869
3119
  """
@@ -2872,15 +3122,17 @@ class xt(Exchange, ImplicitAPI):
2872
3122
  def fetch_canceled_orders(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
2873
3123
  """
2874
3124
  fetches information on multiple canceled orders made by the user
2875
- :see: https://doc.xt.com/#orderhistoryOrderGet
2876
- :see: https://doc.xt.com/#futures_ordergetOrders
2877
- :see: https://doc.xt.com/#futures_entrustgetPlan
2878
- :see: https://doc.xt.com/#futures_entrustgetProfit
3125
+
3126
+ https://doc.xt.com/#orderhistoryOrderGet
3127
+ https://doc.xt.com/#futures_ordergetOrders
3128
+ https://doc.xt.com/#futures_entrustgetPlan
3129
+ https://doc.xt.com/#futures_entrustgetProfit
3130
+
2879
3131
  :param str [symbol]: unified market symbol of the market the orders were made in
2880
3132
  :param int [since]: timestamp in ms of the earliest order
2881
3133
  :param int [limit]: the maximum number of order structures to retrieve
2882
3134
  :param dict params: extra parameters specific to the xt api endpoint
2883
- :param bool [params.stop]: if the order is a stop trigger order or not
3135
+ :param bool [params.trigger]: if the order is a trigger order or not
2884
3136
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2885
3137
  :returns dict: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2886
3138
  """
@@ -2889,14 +3141,16 @@ class xt(Exchange, ImplicitAPI):
2889
3141
  def cancel_order(self, id: str, symbol: str = None, params={}):
2890
3142
  """
2891
3143
  cancels an open order
2892
- :see: https://doc.xt.com/#orderorderDel
2893
- :see: https://doc.xt.com/#futures_ordercancel
2894
- :see: https://doc.xt.com/#futures_entrustcancelPlan
2895
- :see: https://doc.xt.com/#futures_entrustcancelProfit
3144
+
3145
+ https://doc.xt.com/#orderorderDel
3146
+ https://doc.xt.com/#futures_ordercancel
3147
+ https://doc.xt.com/#futures_entrustcancelPlan
3148
+ https://doc.xt.com/#futures_entrustcancelProfit
3149
+
2896
3150
  :param str id: order id
2897
3151
  :param str [symbol]: unified symbol of the market the order was made in
2898
3152
  :param dict params: extra parameters specific to the xt api endpoint
2899
- :param bool [params.stop]: if the order is a stop trigger order or not
3153
+ :param bool [params.trigger]: if the order is a trigger order or not
2900
3154
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2901
3155
  :returns dict: An `order structure <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2902
3156
  """
@@ -2910,16 +3164,16 @@ class xt(Exchange, ImplicitAPI):
2910
3164
  response = None
2911
3165
  type, params = self.handle_market_type_and_params('cancelOrder', market, params)
2912
3166
  subType, params = self.handle_sub_type_and_params('cancelOrder', market, params)
2913
- stop = self.safe_value(params, 'stop')
3167
+ trigger = self.safe_value_2(params, 'trigger', 'stop')
2914
3168
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
2915
- if stop:
3169
+ if trigger:
2916
3170
  request['entrustId'] = id
2917
3171
  elif stopLossTakeProfit:
2918
3172
  request['profitId'] = id
2919
3173
  else:
2920
3174
  request['orderId'] = id
2921
- if stop:
2922
- params = self.omit(params, 'stop')
3175
+ if trigger:
3176
+ params = self.omit(params, ['trigger', 'stop'])
2923
3177
  if subType == 'inverse':
2924
3178
  response = self.privateInversePostFutureTradeV1EntrustCancelPlan(self.extend(request, params))
2925
3179
  else:
@@ -2964,13 +3218,15 @@ class xt(Exchange, ImplicitAPI):
2964
3218
  def cancel_all_orders(self, symbol: str = None, params={}):
2965
3219
  """
2966
3220
  cancel all open orders in a market
2967
- :see: https://doc.xt.com/#orderopenOrderDel
2968
- :see: https://doc.xt.com/#futures_ordercancelBatch
2969
- :see: https://doc.xt.com/#futures_entrustcancelPlanBatch
2970
- :see: https://doc.xt.com/#futures_entrustcancelProfitBatch
3221
+
3222
+ https://doc.xt.com/#orderopenOrderDel
3223
+ https://doc.xt.com/#futures_ordercancelBatch
3224
+ https://doc.xt.com/#futures_entrustcancelPlanBatch
3225
+ https://doc.xt.com/#futures_entrustcancelProfitBatch
3226
+
2971
3227
  :param str [symbol]: unified market symbol of the market to cancel orders in
2972
3228
  :param dict params: extra parameters specific to the xt api endpoint
2973
- :param bool [params.stop]: if the order is a stop trigger order or not
3229
+ :param bool [params.trigger]: if the order is a trigger order or not
2974
3230
  :param bool [params.stopLossTakeProfit]: if the order is a stop-loss or take-profit order
2975
3231
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/en/latest/manual.html#order-structure>`
2976
3232
  """
@@ -2985,10 +3241,10 @@ class xt(Exchange, ImplicitAPI):
2985
3241
  response = None
2986
3242
  type, params = self.handle_market_type_and_params('cancelAllOrders', market, params)
2987
3243
  subType, params = self.handle_sub_type_and_params('cancelAllOrders', market, params)
2988
- stop = self.safe_value(params, 'stop')
3244
+ trigger = self.safe_value_2(params, 'trigger', 'stop')
2989
3245
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
2990
- if stop:
2991
- params = self.omit(params, 'stop')
3246
+ if trigger:
3247
+ params = self.omit(params, ['trigger', 'stop'])
2992
3248
  if subType == 'inverse':
2993
3249
  response = self.privateInversePostFutureTradeV1EntrustCancelAllPlan(self.extend(request, params))
2994
3250
  else:
@@ -3035,7 +3291,9 @@ class xt(Exchange, ImplicitAPI):
3035
3291
  def cancel_orders(self, ids: List[str], symbol: str = None, params={}) -> List[Order]:
3036
3292
  """
3037
3293
  cancel multiple orders
3038
- :see: https://doc.xt.com/#orderbatchOrderDel
3294
+
3295
+ https://doc.xt.com/#orderbatchOrderDel
3296
+
3039
3297
  :param str[] ids: order ids
3040
3298
  :param str [symbol]: unified market symbol of the market to cancel orders in
3041
3299
  :param dict params: extra parameters specific to the xt api endpoint
@@ -3081,7 +3339,7 @@ class xt(Exchange, ImplicitAPI):
3081
3339
  # "cancelId": "208322474307982720"
3082
3340
  # }
3083
3341
  #
3084
- # swap and future: createOrder, cancelOrder
3342
+ # swap and future: createOrder, cancelOrder, editOrder
3085
3343
  #
3086
3344
  # {
3087
3345
  # "returnCode": 0,
@@ -3186,6 +3444,14 @@ class xt(Exchange, ImplicitAPI):
3186
3444
  # "createdTime": 1681273420039
3187
3445
  # }
3188
3446
  #
3447
+ # spot editOrder
3448
+ #
3449
+ # {
3450
+ # "orderId": "484203027161892224",
3451
+ # "modifyId": "484203544105344000",
3452
+ # "clientModifyId": null
3453
+ # }
3454
+ #
3189
3455
  marketId = self.safe_string(order, 'symbol')
3190
3456
  marketType = ('result' in order) or 'contract' if ('positionSide' in order) else 'spot'
3191
3457
  market = self.safe_market(marketId, market, None, marketType)
@@ -3199,7 +3465,7 @@ class xt(Exchange, ImplicitAPI):
3199
3465
  return self.safe_order({
3200
3466
  'info': order,
3201
3467
  'id': self.safe_string_n(order, ['orderId', 'result', 'cancelId', 'entrustId', 'profitId']),
3202
- 'clientOrderId': self.safe_string(order, 'clientOrderId'),
3468
+ 'clientOrderId': self.safe_string_2(order, 'clientOrderId', 'clientModifyId'),
3203
3469
  'timestamp': timestamp,
3204
3470
  'datetime': self.iso8601(timestamp),
3205
3471
  'lastTradeTimestamp': lastUpdatedTimestamp,
@@ -3210,7 +3476,7 @@ class xt(Exchange, ImplicitAPI):
3210
3476
  'postOnly': None,
3211
3477
  'side': self.safe_string_lower_2(order, 'side', 'orderSide'),
3212
3478
  'price': self.safe_number(order, 'price'),
3213
- 'stopPrice': self.safe_number(order, 'stopPrice'),
3479
+ 'triggerPrice': self.safe_number(order, 'stopPrice'),
3214
3480
  'stopLoss': self.safe_number(order, 'triggerStopPrice'),
3215
3481
  'takeProfit': self.safe_number(order, 'triggerProfitPrice'),
3216
3482
  'amount': amount,
@@ -3244,10 +3510,12 @@ class xt(Exchange, ImplicitAPI):
3244
3510
  }
3245
3511
  return self.safe_string(statuses, status, status)
3246
3512
 
3247
- def fetch_ledger(self, code: str = None, since: Int = None, limit: Int = None, params={}):
3513
+ def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
3248
3514
  """
3249
3515
  fetch the history of changes, actions done by the user or operations that altered the balance of the user
3250
- :see: https://doc.xt.com/#futures_usergetBalanceBill
3516
+
3517
+ https://doc.xt.com/#futures_usergetBalanceBill
3518
+
3251
3519
  :param str [code]: unified currency code
3252
3520
  :param int [since]: timestamp in ms of the earliest ledger entry
3253
3521
  :param int [limit]: max number of ledger entries to return
@@ -3301,7 +3569,7 @@ class xt(Exchange, ImplicitAPI):
3301
3569
  ledger = self.safe_value(data, 'items', [])
3302
3570
  return self.parse_ledger(ledger, currency, since, limit)
3303
3571
 
3304
- def parse_ledger_entry(self, item, currency=None):
3572
+ def parse_ledger_entry(self, item, currency=None) -> LedgerEntry:
3305
3573
  #
3306
3574
  # {
3307
3575
  # "id": "207260567109387524",
@@ -3317,8 +3585,10 @@ class xt(Exchange, ImplicitAPI):
3317
3585
  side = self.safe_string(item, 'side')
3318
3586
  direction = 'in' if (side == 'ADD') else 'out'
3319
3587
  currencyId = self.safe_string(item, 'coin')
3588
+ currency = self.safe_currency(currencyId, currency)
3320
3589
  timestamp = self.safe_integer(item, 'createdTime')
3321
- return {
3590
+ return self.safe_ledger_entry({
3591
+ 'info': item,
3322
3592
  'id': self.safe_string(item, 'id'),
3323
3593
  'direction': direction,
3324
3594
  'account': None,
@@ -3336,8 +3606,7 @@ class xt(Exchange, ImplicitAPI):
3336
3606
  'currency': None,
3337
3607
  'cost': None,
3338
3608
  },
3339
- 'info': item,
3340
- }
3609
+ }, currency)
3341
3610
 
3342
3611
  def parse_ledger_entry_type(self, type):
3343
3612
  ledgerType = {
@@ -3352,10 +3621,12 @@ class xt(Exchange, ImplicitAPI):
3352
3621
  }
3353
3622
  return self.safe_string(ledgerType, type, type)
3354
3623
 
3355
- def fetch_deposit_address(self, code: str, params={}):
3624
+ def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
3356
3625
  """
3357
3626
  fetch the deposit address for a currency associated with self account
3358
- :see: https://doc.xt.com/#deposit_withdrawaldepositAddressGet
3627
+
3628
+ https://doc.xt.com/#deposit_withdrawaldepositAddressGet
3629
+
3359
3630
  :param str code: unified currency code
3360
3631
  :param dict params: extra parameters specific to the xt api endpoint
3361
3632
  :param str params['network']: required network id
@@ -3386,7 +3657,7 @@ class xt(Exchange, ImplicitAPI):
3386
3657
  result = self.safe_value(response, 'result', {})
3387
3658
  return self.parse_deposit_address(result, currency)
3388
3659
 
3389
- def parse_deposit_address(self, depositAddress, currency=None):
3660
+ def parse_deposit_address(self, depositAddress, currency=None) -> DepositAddress:
3390
3661
  #
3391
3662
  # {
3392
3663
  # "address": "0x7f7173cf29d3846d20ca5a3aec1120b93dbd157a",
@@ -3396,17 +3667,19 @@ class xt(Exchange, ImplicitAPI):
3396
3667
  address = self.safe_string(depositAddress, 'address')
3397
3668
  self.check_address(address)
3398
3669
  return {
3670
+ 'info': depositAddress,
3399
3671
  'currency': self.safe_currency_code(None, currency),
3672
+ 'network': None,
3400
3673
  'address': address,
3401
3674
  'tag': self.safe_string(depositAddress, 'memo'),
3402
- 'network': None,
3403
- 'info': depositAddress,
3404
3675
  }
3405
3676
 
3406
- def fetch_deposits(self, code: str = None, since: Int = None, limit: Int = None, params={}):
3677
+ def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
3407
3678
  """
3408
3679
  fetch all deposits made to an account
3409
- :see: https://doc.xt.com/#deposit_withdrawalhistoryDepositGet
3680
+
3681
+ https://doc.xt.com/#deposit_withdrawalhistoryDepositGet
3682
+
3410
3683
  :param str [code]: unified currency code
3411
3684
  :param int [since]: the earliest time in ms to fetch deposits for
3412
3685
  :param int [limit]: the maximum number of transaction structures to retrieve
@@ -3454,10 +3727,12 @@ class xt(Exchange, ImplicitAPI):
3454
3727
  deposits = self.safe_value(data, 'items', [])
3455
3728
  return self.parse_transactions(deposits, currency, since, limit, params)
3456
3729
 
3457
- def fetch_withdrawals(self, code: str = None, since: Int = None, limit: Int = None, params={}):
3730
+ def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
3458
3731
  """
3459
3732
  fetch all withdrawals made from an account
3460
- :see: https://doc.xt.com/#deposit_withdrawalwithdrawHistory
3733
+
3734
+ https://doc.xt.com/#deposit_withdrawalwithdrawHistory
3735
+
3461
3736
  :param str [code]: unified currency code
3462
3737
  :param int [since]: the earliest time in ms to fetch withdrawals for
3463
3738
  :param int [limit]: the maximum number of transaction structures to retrieve
@@ -3505,10 +3780,12 @@ class xt(Exchange, ImplicitAPI):
3505
3780
  withdrawals = self.safe_value(data, 'items', [])
3506
3781
  return self.parse_transactions(withdrawals, currency, since, limit, params)
3507
3782
 
3508
- def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
3783
+ def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
3509
3784
  """
3510
3785
  make a withdrawal
3511
- :see: https://doc.xt.com/#deposit_withdrawalwithdraw
3786
+
3787
+ https://doc.xt.com/#deposit_withdrawalwithdraw
3788
+
3512
3789
  :param str code: unified currency code
3513
3790
  :param float amount: the amount to withdraw
3514
3791
  :param str address: the address to withdraw to
@@ -3633,10 +3910,12 @@ class xt(Exchange, ImplicitAPI):
3633
3910
  }
3634
3911
  return self.safe_string(statuses, status, status)
3635
3912
 
3636
- def set_leverage(self, leverage: Int, symbol: str = None, params={}):
3913
+ def set_leverage(self, leverage: int, symbol: str = None, params={}):
3637
3914
  """
3638
3915
  set the level of leverage for a market
3639
- :see: https://doc.xt.com/#futures_useradjustLeverage
3916
+
3917
+ https://doc.xt.com/#futures_useradjustLeverage
3918
+
3640
3919
  :param float leverage: the rate of leverage
3641
3920
  :param str symbol: unified market symbol
3642
3921
  :param dict params: extra parameters specific to the xt api endpoint
@@ -3678,7 +3957,9 @@ class xt(Exchange, ImplicitAPI):
3678
3957
  def add_margin(self, symbol: str, amount: float, params={}):
3679
3958
  """
3680
3959
  add margin to a position
3681
- :see: https://doc.xt.com/#futures_useradjustMargin
3960
+
3961
+ https://doc.xt.com/#futures_useradjustMargin
3962
+
3682
3963
  :param str symbol: unified market symbol
3683
3964
  :param float amount: amount of margin to add
3684
3965
  :param dict params: extra parameters specific to the xt api endpoint
@@ -3690,7 +3971,9 @@ class xt(Exchange, ImplicitAPI):
3690
3971
  def reduce_margin(self, symbol: str, amount: float, params={}):
3691
3972
  """
3692
3973
  remove margin from a position
3693
- :see: https://doc.xt.com/#futures_useradjustMargin
3974
+
3975
+ https://doc.xt.com/#futures_useradjustMargin
3976
+
3694
3977
  :param str symbol: unified market symbol
3695
3978
  :param float amount: the amount of margin to remove
3696
3979
  :param dict params: extra parameters specific to the xt api endpoint
@@ -3741,10 +4024,12 @@ class xt(Exchange, ImplicitAPI):
3741
4024
  'datetime': None,
3742
4025
  }
3743
4026
 
3744
- def fetch_leverage_tiers(self, symbols: List[str] = None, params={}):
4027
+ def fetch_leverage_tiers(self, symbols: List[str] = None, params={}) -> LeverageTiers:
3745
4028
  """
3746
- :see: https://doc.xt.com/#futures_quotesgetLeverageBrackets
3747
4029
  retrieve information on the maximum leverage for different trade sizes
4030
+
4031
+ https://doc.xt.com/#futures_quotesgetLeverageBrackets
4032
+
3748
4033
  :param str [symbols]: a list of unified market symbols
3749
4034
  :param dict params: extra parameters specific to the xt api endpoint
3750
4035
  :returns dict: a dictionary of `leverage tiers structures <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
@@ -3785,7 +4070,7 @@ class xt(Exchange, ImplicitAPI):
3785
4070
  symbols = self.market_symbols(symbols)
3786
4071
  return self.parse_leverage_tiers(data, symbols, 'symbol')
3787
4072
 
3788
- def parse_leverage_tiers(self, response, symbols=None, marketIdKey=None):
4073
+ def parse_leverage_tiers(self, response, symbols=None, marketIdKey=None) -> LeverageTiers:
3789
4074
  #
3790
4075
  # {
3791
4076
  # "symbol": "rad_usdt",
@@ -3818,8 +4103,10 @@ class xt(Exchange, ImplicitAPI):
3818
4103
 
3819
4104
  def fetch_market_leverage_tiers(self, symbol: str, params={}) -> List[LeverageTier]:
3820
4105
  """
3821
- :see: https://doc.xt.com/#futures_quotesgetLeverageBracket
3822
4106
  retrieve information on the maximum leverage for different trade sizes of a single market
4107
+
4108
+ https://doc.xt.com/#futures_quotesgetLeverageBracket
4109
+
3823
4110
  :param str symbol: unified market symbol
3824
4111
  :param dict params: extra parameters specific to the xt api endpoint
3825
4112
  :returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
@@ -3861,7 +4148,7 @@ class xt(Exchange, ImplicitAPI):
3861
4148
  data = self.safe_value(response, 'result', {})
3862
4149
  return self.parse_market_leverage_tiers(data, market)
3863
4150
 
3864
- def parse_market_leverage_tiers(self, info, market=None):
4151
+ def parse_market_leverage_tiers(self, info, market=None) -> List[LeverageTier]:
3865
4152
  #
3866
4153
  # {
3867
4154
  # "symbol": "rad_usdt",
@@ -3887,6 +4174,7 @@ class xt(Exchange, ImplicitAPI):
3887
4174
  market = self.safe_market(marketId, market, '_', 'contract')
3888
4175
  tiers.append({
3889
4176
  'tier': self.safe_integer(tier, 'bracket'),
4177
+ 'symbol': self.safe_symbol(marketId, market, '_', 'contract'),
3890
4178
  'currency': market['settle'],
3891
4179
  'minNotional': self.safe_number(brackets[i - 1], 'maxNominalValue', 0),
3892
4180
  'maxNotional': self.safe_number(tier, 'maxNominalValue'),
@@ -3899,7 +4187,9 @@ class xt(Exchange, ImplicitAPI):
3899
4187
  def fetch_funding_rate_history(self, symbol: str = None, since: Int = None, limit: Int = None, params={}):
3900
4188
  """
3901
4189
  fetches historical funding rates
3902
- :see: https://doc.xt.com/#futures_quotesgetFundingRateRecord
4190
+
4191
+ https://doc.xt.com/#futures_quotesgetFundingRateRecord
4192
+
3903
4193
  :param str [symbol]: unified symbol of the market to fetch the funding rate history for
3904
4194
  :param int [since]: timestamp in ms of the earliest funding rate to fetch
3905
4195
  :param int [limit]: the maximum amount of [funding rate structures] to fetch
@@ -3962,10 +4252,24 @@ class xt(Exchange, ImplicitAPI):
3962
4252
  sorted = self.sort_by(rates, 'timestamp')
3963
4253
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
3964
4254
 
3965
- def fetch_funding_rate(self, symbol: str, params={}):
4255
+ def fetch_funding_interval(self, symbol: str, params={}) -> FundingRate:
4256
+ """
4257
+ fetch the current funding rate interval
4258
+
4259
+ https://doc.xt.com/#futures_quotesgetFundingRate
4260
+
4261
+ :param str symbol: unified market symbol
4262
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4263
+ :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
4264
+ """
4265
+ return self.fetch_funding_rate(symbol, params)
4266
+
4267
+ def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
3966
4268
  """
3967
4269
  fetch the current funding rate
3968
- :see: https://doc.xt.com/#futures_quotesgetFundingRate
4270
+
4271
+ https://doc.xt.com/#futures_quotesgetFundingRate
4272
+
3969
4273
  :param str symbol: unified market symbol
3970
4274
  :param dict params: extra parameters specific to the xt api endpoint
3971
4275
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -4000,7 +4304,7 @@ class xt(Exchange, ImplicitAPI):
4000
4304
  result = self.safe_value(response, 'result', {})
4001
4305
  return self.parse_funding_rate(result, market)
4002
4306
 
4003
- def parse_funding_rate(self, contract, market=None):
4307
+ def parse_funding_rate(self, contract, market=None) -> FundingRate:
4004
4308
  #
4005
4309
  # {
4006
4310
  # "symbol": "btc_usdt",
@@ -4012,6 +4316,9 @@ class xt(Exchange, ImplicitAPI):
4012
4316
  marketId = self.safe_string(contract, 'symbol')
4013
4317
  symbol = self.safe_symbol(marketId, market, '_', 'swap')
4014
4318
  timestamp = self.safe_integer(contract, 'nextCollectionTime')
4319
+ interval = self.safe_string(contract, 'collectionInternal')
4320
+ if interval is not None:
4321
+ interval = interval + 'h'
4015
4322
  return {
4016
4323
  'info': contract,
4017
4324
  'symbol': symbol,
@@ -4030,12 +4337,15 @@ class xt(Exchange, ImplicitAPI):
4030
4337
  'previousFundingRate': None,
4031
4338
  'previousFundingTimestamp': None,
4032
4339
  'previousFundingDatetime': None,
4340
+ 'interval': interval,
4033
4341
  }
4034
4342
 
4035
4343
  def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
4036
4344
  """
4037
4345
  fetch the funding history
4038
- :see: https://doc.xt.com/#futures_usergetFunding
4346
+
4347
+ https://doc.xt.com/#futures_usergetFunding
4348
+
4039
4349
  :param str symbol: unified market symbol
4040
4350
  :param int [since]: the starting timestamp in milliseconds
4041
4351
  :param int [limit]: the number of entries to return
@@ -4119,7 +4429,9 @@ class xt(Exchange, ImplicitAPI):
4119
4429
  def fetch_position(self, symbol: str, params={}):
4120
4430
  """
4121
4431
  fetch data on a single open contract trade position
4122
- :see: https://doc.xt.com/#futures_usergetPosition
4432
+
4433
+ https://doc.xt.com/#futures_usergetPosition
4434
+
4123
4435
  :param str symbol: unified market symbol of the market the position is held in
4124
4436
  :param dict params: extra parameters specific to the xt api endpoint
4125
4437
  :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -4171,10 +4483,12 @@ class xt(Exchange, ImplicitAPI):
4171
4483
  return self.parse_position(entry, marketInner)
4172
4484
  return None
4173
4485
 
4174
- def fetch_positions(self, symbols: List[str] = None, params={}):
4486
+ def fetch_positions(self, symbols: List[str] = None, params={}) -> List[Position]:
4175
4487
  """
4176
4488
  fetch all open positions
4177
- :see: https://doc.xt.com/#futures_usergetPosition
4489
+
4490
+ https://doc.xt.com/#futures_usergetPosition
4491
+
4178
4492
  :param str [symbols]: list of unified market symbols, not supported with xt
4179
4493
  :param dict params: extra parameters specific to the xt api endpoint
4180
4494
  :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -4275,7 +4589,9 @@ class xt(Exchange, ImplicitAPI):
4275
4589
  def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
4276
4590
  """
4277
4591
  transfer currency internally between wallets on the same account
4278
- :see: https://doc.xt.com/#transfersubTransferPost
4592
+
4593
+ https://doc.xt.com/#transfersubTransferPost
4594
+
4279
4595
  :param str code: unified currency code
4280
4596
  :param float amount: amount to transfer
4281
4597
  :param str fromAccount: account to transfer from - spot, swap, leverage, finance
@@ -4325,6 +4641,141 @@ class xt(Exchange, ImplicitAPI):
4325
4641
  'status': None,
4326
4642
  }
4327
4643
 
4644
+ def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
4645
+ """
4646
+ set margin mode to 'cross' or 'isolated'
4647
+
4648
+ https://doc.xt.com/#futures_userchangePositionType
4649
+
4650
+ :param str marginMode: 'cross' or 'isolated'
4651
+ :param str [symbol]: required
4652
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4653
+ :param str [params.positionSide]: *required* "long" or "short"
4654
+ :returns dict: response from the exchange
4655
+ """
4656
+ if symbol is None:
4657
+ raise ArgumentsRequired(self.id + ' setMarginMode() requires a symbol argument')
4658
+ self.load_markets()
4659
+ market = self.market(symbol)
4660
+ if market['spot']:
4661
+ raise BadSymbol(self.id + ' setMarginMode() supports contract markets only')
4662
+ marginMode = marginMode.lower()
4663
+ if marginMode != 'isolated' and marginMode != 'cross':
4664
+ raise BadRequest(self.id + ' setMarginMode() marginMode argument should be isolated or cross')
4665
+ if marginMode == 'cross':
4666
+ marginMode = 'CROSSED'
4667
+ else:
4668
+ marginMode = 'ISOLATED'
4669
+ posSide = self.safe_string_upper(params, 'positionSide')
4670
+ if posSide is None:
4671
+ raise ArgumentsRequired(self.id + ' setMarginMode() requires a positionSide parameter, either "LONG" or "SHORT"')
4672
+ request: dict = {
4673
+ 'positionType': marginMode,
4674
+ 'positionSide': posSide,
4675
+ 'symbol': market['id'],
4676
+ }
4677
+ response = self.privateLinearPostFutureUserV1PositionChangeType(self.extend(request, params))
4678
+ #
4679
+ # {
4680
+ # "error": {
4681
+ # "code": "",
4682
+ # "msg": ""
4683
+ # },
4684
+ # "msgInfo": "",
4685
+ # "result": {},
4686
+ # "returnCode": 0
4687
+ # }
4688
+ #
4689
+ return response # unify return type
4690
+
4691
+ def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}) -> Order:
4692
+ """
4693
+ cancels an order and places a new order
4694
+
4695
+ https://doc.xt.com/#orderorderUpdate
4696
+ https://doc.xt.com/#futures_orderupdate
4697
+ https://doc.xt.com/#futures_entrustupdateProfit
4698
+
4699
+ :param str id: order id
4700
+ :param str symbol: unified symbol of the market to create an order in
4701
+ :param str type: 'market' or 'limit'
4702
+ :param str side: 'buy' or 'sell'
4703
+ :param float amount: how much of the currency you want to trade in units of the base currency
4704
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
4705
+ :param dict [params]: extra parameters specific to the exchange API endpoint
4706
+ :param float [params.stopLoss]: price to set a stop-loss on an open position
4707
+ :param float [params.takeProfit]: price to set a take-profit on an open position
4708
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
4709
+ """
4710
+ if amount is None:
4711
+ raise ArgumentsRequired(self.id + ' editOrder() requires an amount argument')
4712
+ self.load_markets()
4713
+ market = self.market(symbol)
4714
+ request = {}
4715
+ stopLoss = self.safe_number_2(params, 'stopLoss', 'triggerStopPrice')
4716
+ takeProfit = self.safe_number_2(params, 'takeProfit', 'triggerProfitPrice')
4717
+ params = self.omit(params, ['stopLoss', 'takeProfit'])
4718
+ isStopLoss = (stopLoss is not None)
4719
+ isTakeProfit = (takeProfit is not None)
4720
+ if isStopLoss or isTakeProfit:
4721
+ request['profitId'] = id
4722
+ else:
4723
+ request['orderId'] = id
4724
+ request['price'] = self.price_to_precision(symbol, price)
4725
+ response = None
4726
+ if market['swap']:
4727
+ if isStopLoss:
4728
+ request['triggerStopPrice'] = self.price_to_precision(symbol, stopLoss)
4729
+ elif takeProfit is not None:
4730
+ request['triggerProfitPrice'] = self.price_to_precision(symbol, takeProfit)
4731
+ else:
4732
+ request['origQty'] = self.amount_to_precision(symbol, amount)
4733
+ subType = None
4734
+ subType, params = self.handle_sub_type_and_params('editOrder', market, params)
4735
+ if subType == 'inverse':
4736
+ if isStopLoss or isTakeProfit:
4737
+ response = self.privateInversePostFutureTradeV1EntrustUpdateProfitStop(self.extend(request, params))
4738
+ else:
4739
+ response = self.privateInversePostFutureTradeV1OrderUpdate(self.extend(request, params))
4740
+ #
4741
+ # {
4742
+ # "returnCode": 0,
4743
+ # "msgInfo": "success",
4744
+ # "error": null,
4745
+ # "result": "483869474947826752"
4746
+ # }
4747
+ #
4748
+ else:
4749
+ if isStopLoss or isTakeProfit:
4750
+ response = self.privateLinearPostFutureTradeV1EntrustUpdateProfitStop(self.extend(request, params))
4751
+ else:
4752
+ response = self.privateLinearPostFutureTradeV1OrderUpdate(self.extend(request, params))
4753
+ #
4754
+ # {
4755
+ # "returnCode": 0,
4756
+ # "msgInfo": "success",
4757
+ # "error": null,
4758
+ # "result": "483869474947826752"
4759
+ # }
4760
+ #
4761
+ else:
4762
+ request['quantity'] = self.amount_to_precision(symbol, amount)
4763
+ response = self.privateSpotPutOrderOrderId(self.extend(request, params))
4764
+ #
4765
+ # {
4766
+ # "rc": 0,
4767
+ # "mc": "SUCCESS",
4768
+ # "ma": [],
4769
+ # "result": {
4770
+ # "orderId": "484203027161892224",
4771
+ # "modifyId": "484203544105344000",
4772
+ # "clientModifyId": null
4773
+ # }
4774
+ # }
4775
+ #
4776
+ result = response if (market['swap']) else self.safe_dict(response, 'result', {})
4777
+ return self.parse_order(result, market)
4778
+
4328
4779
  def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
4329
4780
  #
4330
4781
  # spot: error
@@ -4375,6 +4826,9 @@ class xt(Exchange, ImplicitAPI):
4375
4826
  # "result": {}
4376
4827
  # }
4377
4828
  #
4829
+ # {"returnCode":1,"msgInfo":"failure","error":{"code":"insufficient_balance","msg":"insufficient balance","args":[]},"result":null}
4830
+ #
4831
+ #
4378
4832
  status = self.safe_string_upper_2(response, 'msgInfo', 'mc')
4379
4833
  if status is not None and status != 'SUCCESS':
4380
4834
  feedback = self.id + ' ' + body
@@ -4418,7 +4872,9 @@ class xt(Exchange, ImplicitAPI):
4418
4872
  body['clientMedia'] = id
4419
4873
  else:
4420
4874
  body['media'] = id
4421
- isUndefinedBody = ((method == 'GET') or (path == 'order/{orderId}'))
4875
+ isUndefinedBody = ((method == 'GET') or (path == 'order/{orderId}') or (path == 'ws-token'))
4876
+ if (method == 'PUT') and (endpoint == 'spot'):
4877
+ isUndefinedBody = False
4422
4878
  body = None if isUndefinedBody else self.json(body)
4423
4879
  payloadString = None
4424
4880
  if (endpoint == 'spot') or (endpoint == 'user'):
@@ -4426,7 +4882,7 @@ class xt(Exchange, ImplicitAPI):
4426
4882
  if isUndefinedBody:
4427
4883
  if urlencoded:
4428
4884
  url += '?' + urlencoded
4429
- payloadString += '#' + method + '#' + payload + '#' + urlencoded
4885
+ payloadString += '#' + method + '#' + payload + '#' + self.rawencode(self.keysort(query))
4430
4886
  else:
4431
4887
  payloadString += '#' + method + '#' + payload
4432
4888
  else: