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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (528) hide show
  1. ccxt/__init__.py +39 -35
  2. ccxt/abantether.py +9 -9
  3. ccxt/abstract/alpaca.py +4 -0
  4. ccxt/abstract/apex.py +31 -0
  5. ccxt/abstract/bigone.py +1 -1
  6. ccxt/abstract/binance.py +106 -48
  7. ccxt/abstract/binancecoinm.py +106 -48
  8. ccxt/abstract/binanceus.py +141 -83
  9. ccxt/abstract/binanceusdm.py +106 -48
  10. ccxt/abstract/bingx.py +50 -1
  11. ccxt/abstract/bitbank.py +5 -0
  12. ccxt/abstract/bitfinex.py +136 -65
  13. ccxt/abstract/bitflyer.py +1 -0
  14. ccxt/abstract/bitget.py +67 -0
  15. ccxt/abstract/bitmart.py +19 -1
  16. ccxt/abstract/bitopro.py +1 -0
  17. ccxt/abstract/bitrue.py +68 -68
  18. ccxt/abstract/bitstamp.py +1 -0
  19. ccxt/abstract/blofin.py +30 -0
  20. ccxt/abstract/btcbox.py +2 -0
  21. ccxt/abstract/bybit.py +28 -13
  22. ccxt/abstract/cex.py +28 -29
  23. ccxt/abstract/coinbaseexchange.py +1 -0
  24. ccxt/abstract/coinbaseinternational.py +1 -1
  25. ccxt/abstract/cryptocom.py +16 -0
  26. ccxt/abstract/cryptomus.py +20 -0
  27. ccxt/abstract/defx.py +69 -0
  28. ccxt/abstract/deribit.py +1 -0
  29. ccxt/abstract/derive.py +117 -0
  30. ccxt/abstract/digifinex.py +1 -0
  31. ccxt/abstract/ellipx.py +25 -0
  32. ccxt/abstract/foxbit.py +26 -0
  33. ccxt/abstract/gate.py +19 -0
  34. ccxt/abstract/gateio.py +19 -0
  35. ccxt/abstract/gemini.py +1 -0
  36. ccxt/abstract/hibachi.py +26 -0
  37. ccxt/abstract/hyperliquid.py +1 -1
  38. ccxt/abstract/independentreserve.py +6 -0
  39. ccxt/abstract/kraken.py +1 -0
  40. ccxt/abstract/krakenfutures.py +4 -0
  41. ccxt/abstract/kucoin.py +10 -0
  42. ccxt/abstract/kucoinfutures.py +18 -0
  43. ccxt/abstract/lbank.py +2 -1
  44. ccxt/abstract/luno.py +1 -0
  45. ccxt/abstract/mexc.py +2 -0
  46. ccxt/abstract/modetrade.py +119 -0
  47. ccxt/abstract/myokx.py +349 -0
  48. ccxt/abstract/oceanex.py +5 -0
  49. ccxt/abstract/okx.py +25 -0
  50. ccxt/abstract/okxus.py +349 -0
  51. ccxt/abstract/onetrading.py +0 -12
  52. ccxt/abstract/paradex.py +23 -0
  53. ccxt/abstract/phemex.py +2 -0
  54. ccxt/abstract/poloniex.py +36 -0
  55. ccxt/abstract/tradeogre.py +3 -1
  56. ccxt/abstract/upbit.py +51 -34
  57. ccxt/abstract/whitebit.py +16 -0
  58. ccxt/abstract/woo.py +64 -6
  59. ccxt/abstract/xt.py +10 -5
  60. ccxt/afratether.py +7 -7
  61. ccxt/alpaca.py +828 -51
  62. ccxt/apex.py +1875 -0
  63. ccxt/arzinja.py +7 -7
  64. ccxt/arzplus.py +9 -9
  65. ccxt/ascendex.py +501 -306
  66. ccxt/async_support/__init__.py +39 -35
  67. ccxt/async_support/abantether.py +10 -10
  68. ccxt/async_support/afratether.py +9 -9
  69. ccxt/async_support/alpaca.py +828 -51
  70. ccxt/async_support/apex.py +1875 -0
  71. ccxt/async_support/arzinja.py +10 -10
  72. ccxt/async_support/arzplus.py +12 -12
  73. ccxt/async_support/ascendex.py +502 -306
  74. ccxt/async_support/base/exchange.py +303 -89
  75. ccxt/async_support/base/ws/cache.py +9 -3
  76. ccxt/async_support/base/ws/client.py +173 -38
  77. ccxt/async_support/base/ws/future.py +25 -37
  78. ccxt/async_support/bequant.py +5 -3
  79. ccxt/async_support/bigone.py +279 -144
  80. ccxt/async_support/binance.py +2347 -1158
  81. ccxt/async_support/binancecoinm.py +9 -3
  82. ccxt/async_support/binanceus.py +17 -3
  83. ccxt/async_support/binanceusdm.py +9 -4
  84. ccxt/async_support/bingx.py +2962 -920
  85. ccxt/async_support/bit2c.py +147 -27
  86. ccxt/async_support/bitbank.py +151 -23
  87. ccxt/async_support/bitbns.py +104 -30
  88. ccxt/async_support/bitfinex.py +3291 -1113
  89. ccxt/async_support/bitflyer.py +202 -27
  90. ccxt/async_support/bitget.py +3683 -1538
  91. ccxt/async_support/bithumb.py +195 -38
  92. ccxt/async_support/bitimen.py +12 -12
  93. ccxt/async_support/bitir.py +38 -38
  94. ccxt/async_support/bitmart.py +1288 -350
  95. ccxt/async_support/bitmex.py +260 -75
  96. ccxt/async_support/bitopro.py +262 -62
  97. ccxt/async_support/bitpin.py +17 -16
  98. ccxt/async_support/bitrue.py +459 -290
  99. ccxt/async_support/bitso.py +199 -54
  100. ccxt/async_support/bitstamp.py +230 -96
  101. ccxt/async_support/bitteam.py +167 -25
  102. ccxt/async_support/{huobijp.py → bittrade.py} +158 -30
  103. ccxt/async_support/bitvavo.py +213 -49
  104. ccxt/async_support/blockchaincom.py +160 -46
  105. ccxt/async_support/blofin.py +502 -120
  106. ccxt/async_support/btcalpha.py +169 -31
  107. ccxt/async_support/btcbox.py +292 -23
  108. ccxt/async_support/btcmarkets.py +211 -58
  109. ccxt/async_support/btcturk.py +161 -38
  110. ccxt/async_support/bybit.py +1775 -1030
  111. ccxt/async_support/cex.py +1440 -1303
  112. ccxt/async_support/coinbase.py +724 -212
  113. ccxt/async_support/coinbaseadvanced.py +2 -1
  114. ccxt/async_support/coinbaseexchange.py +388 -89
  115. ccxt/async_support/coinbaseinternational.py +412 -57
  116. ccxt/async_support/coincatch.py +177 -78
  117. ccxt/async_support/coincheck.py +135 -19
  118. ccxt/async_support/coinex.py +606 -232
  119. ccxt/async_support/coinmate.py +189 -63
  120. ccxt/async_support/coinmetro.py +195 -54
  121. ccxt/async_support/coinone.py +158 -51
  122. ccxt/async_support/coinsph.py +336 -61
  123. ccxt/async_support/coinspot.py +151 -52
  124. ccxt/async_support/cryptocom.py +661 -111
  125. ccxt/async_support/cryptomus.py +1137 -0
  126. ccxt/async_support/defx.py +2071 -0
  127. ccxt/async_support/delta.py +299 -99
  128. ccxt/async_support/deribit.py +348 -126
  129. ccxt/async_support/derive.py +2572 -0
  130. ccxt/async_support/digifinex.py +430 -214
  131. ccxt/async_support/ellipx.py +2029 -0
  132. ccxt/async_support/eterex.py +10 -10
  133. ccxt/async_support/excoino.py +31 -31
  134. ccxt/async_support/exir.py +14 -14
  135. ccxt/async_support/exmo.py +344 -131
  136. ccxt/async_support/exnovin.py +10 -10
  137. ccxt/async_support/farhadexchange.py +12 -12
  138. ccxt/async_support/fmfwio.py +2 -1
  139. ccxt/async_support/foxbit.py +1935 -0
  140. ccxt/async_support/gate.py +1351 -529
  141. ccxt/async_support/gateio.py +2 -1
  142. ccxt/async_support/gemini.py +144 -39
  143. ccxt/async_support/hashkey.py +152 -109
  144. ccxt/async_support/hibachi.py +2080 -0
  145. ccxt/async_support/hitbtc.py +395 -167
  146. ccxt/async_support/hitobit.py +12 -12
  147. ccxt/async_support/hollaex.py +307 -119
  148. ccxt/async_support/htx.py +851 -383
  149. ccxt/async_support/huobi.py +2 -1
  150. ccxt/async_support/hyperliquid.py +1848 -536
  151. ccxt/async_support/independentreserve.py +288 -15
  152. ccxt/async_support/indodax.py +190 -33
  153. ccxt/async_support/jibitex.py +12 -12
  154. ccxt/async_support/kraken.py +795 -351
  155. ccxt/async_support/krakenfutures.py +214 -62
  156. ccxt/async_support/kucoin.py +715 -396
  157. ccxt/async_support/kucoinfutures.py +652 -89
  158. ccxt/async_support/latoken.py +217 -113
  159. ccxt/async_support/lbank.py +425 -97
  160. ccxt/async_support/luno.py +382 -35
  161. ccxt/async_support/mercado.py +113 -6
  162. ccxt/async_support/mexc.py +874 -437
  163. ccxt/async_support/modetrade.py +2818 -0
  164. ccxt/async_support/myokx.py +54 -0
  165. ccxt/async_support/ndax.py +221 -64
  166. ccxt/async_support/nobitex.py +31 -37
  167. ccxt/async_support/novadax.py +190 -34
  168. ccxt/async_support/oceanex.py +217 -28
  169. ccxt/async_support/okcoin.py +253 -145
  170. ccxt/async_support/okexchange.py +11 -11
  171. ccxt/async_support/okx.py +1088 -351
  172. ccxt/async_support/okxus.py +54 -0
  173. ccxt/async_support/ompfinex.py +25 -24
  174. ccxt/async_support/onetrading.py +213 -392
  175. ccxt/async_support/oxfun.py +245 -166
  176. ccxt/async_support/p2b.py +151 -29
  177. ccxt/async_support/paradex.py +562 -49
  178. ccxt/async_support/paymium.py +82 -19
  179. ccxt/async_support/phemex.py +713 -172
  180. ccxt/async_support/poloniex.py +1602 -283
  181. ccxt/async_support/probit.py +224 -95
  182. ccxt/async_support/ramzinex.py +30 -27
  183. ccxt/async_support/sarmayex.py +9 -9
  184. ccxt/async_support/sarrafex.py +13 -13
  185. ccxt/async_support/tabdeal.py +14 -13
  186. ccxt/async_support/tetherland.py +9 -9
  187. ccxt/async_support/timex.py +210 -51
  188. ccxt/async_support/tokocrypto.py +167 -47
  189. ccxt/async_support/tradeogre.py +266 -31
  190. ccxt/async_support/twox.py +9 -9
  191. ccxt/async_support/ubitex.py +12 -12
  192. ccxt/async_support/upbit.py +568 -165
  193. ccxt/async_support/vertex.py +160 -32
  194. ccxt/async_support/wallex.py +12 -12
  195. ccxt/async_support/wavesexchange.py +165 -30
  196. ccxt/async_support/whitebit.py +975 -127
  197. ccxt/async_support/woo.py +1918 -1016
  198. ccxt/async_support/woofipro.py +433 -141
  199. ccxt/async_support/xt.py +649 -193
  200. ccxt/async_support/yobit.py +195 -70
  201. ccxt/async_support/zaif.py +91 -15
  202. ccxt/async_support/zonda.py +151 -36
  203. ccxt/base/decimal_to_precision.py +14 -10
  204. ccxt/base/errors.py +49 -18
  205. ccxt/base/exchange.py +1556 -450
  206. ccxt/base/precise.py +10 -0
  207. ccxt/base/types.py +114 -6
  208. ccxt/bequant.py +5 -3
  209. ccxt/bigone.py +279 -144
  210. ccxt/binance.py +2347 -1158
  211. ccxt/binancecoinm.py +9 -3
  212. ccxt/binanceus.py +17 -3
  213. ccxt/binanceusdm.py +9 -4
  214. ccxt/bingx.py +2962 -920
  215. ccxt/bit2c.py +147 -27
  216. ccxt/bitbank.py +151 -23
  217. ccxt/bitbns.py +104 -30
  218. ccxt/bitfinex.py +3290 -1113
  219. ccxt/bitflyer.py +202 -27
  220. ccxt/bitget.py +3683 -1538
  221. ccxt/bithumb.py +194 -38
  222. ccxt/bitimen.py +9 -9
  223. ccxt/bitir.py +35 -35
  224. ccxt/bitmart.py +1288 -350
  225. ccxt/bitmex.py +260 -75
  226. ccxt/bitopro.py +262 -62
  227. ccxt/bitpin.py +15 -14
  228. ccxt/bitrue.py +459 -290
  229. ccxt/bitso.py +199 -54
  230. ccxt/bitstamp.py +230 -96
  231. ccxt/bitteam.py +167 -25
  232. ccxt/{huobijp.py → bittrade.py} +158 -30
  233. ccxt/bitvavo.py +213 -49
  234. ccxt/blockchaincom.py +160 -46
  235. ccxt/blofin.py +502 -120
  236. ccxt/btcalpha.py +169 -31
  237. ccxt/btcbox.py +291 -23
  238. ccxt/btcmarkets.py +211 -58
  239. ccxt/btcturk.py +161 -38
  240. ccxt/bybit.py +1775 -1030
  241. ccxt/cex.py +1439 -1303
  242. ccxt/coinbase.py +724 -212
  243. ccxt/coinbaseadvanced.py +2 -1
  244. ccxt/coinbaseexchange.py +388 -89
  245. ccxt/coinbaseinternational.py +412 -57
  246. ccxt/coincatch.py +177 -78
  247. ccxt/coincheck.py +135 -19
  248. ccxt/coinex.py +606 -232
  249. ccxt/coinmate.py +189 -63
  250. ccxt/coinmetro.py +194 -54
  251. ccxt/coinone.py +158 -51
  252. ccxt/coinsph.py +336 -61
  253. ccxt/coinspot.py +151 -52
  254. ccxt/cryptocom.py +661 -111
  255. ccxt/cryptomus.py +1137 -0
  256. ccxt/defx.py +2070 -0
  257. ccxt/delta.py +299 -99
  258. ccxt/deribit.py +348 -126
  259. ccxt/derive.py +2571 -0
  260. ccxt/digifinex.py +430 -214
  261. ccxt/ellipx.py +2029 -0
  262. ccxt/eterex.py +7 -7
  263. ccxt/excoino.py +29 -29
  264. ccxt/exir.py +11 -11
  265. ccxt/exmo.py +343 -131
  266. ccxt/exnovin.py +8 -8
  267. ccxt/farhadexchange.py +10 -10
  268. ccxt/fmfwio.py +2 -1
  269. ccxt/foxbit.py +1935 -0
  270. ccxt/gate.py +1351 -529
  271. ccxt/gateio.py +2 -1
  272. ccxt/gemini.py +144 -39
  273. ccxt/hashkey.py +152 -109
  274. ccxt/hibachi.py +2079 -0
  275. ccxt/hitbtc.py +395 -167
  276. ccxt/hitobit.py +9 -9
  277. ccxt/hollaex.py +307 -119
  278. ccxt/htx.py +851 -383
  279. ccxt/huobi.py +2 -1
  280. ccxt/hyperliquid.py +1848 -536
  281. ccxt/independentreserve.py +287 -15
  282. ccxt/indodax.py +190 -33
  283. ccxt/jibitex.py +9 -9
  284. ccxt/kraken.py +794 -351
  285. ccxt/krakenfutures.py +214 -62
  286. ccxt/kucoin.py +715 -396
  287. ccxt/kucoinfutures.py +652 -89
  288. ccxt/latoken.py +217 -113
  289. ccxt/lbank.py +425 -97
  290. ccxt/luno.py +382 -35
  291. ccxt/mercado.py +113 -6
  292. ccxt/mexc.py +873 -437
  293. ccxt/modetrade.py +2818 -0
  294. ccxt/myokx.py +54 -0
  295. ccxt/ndax.py +221 -64
  296. ccxt/nobitex.py +29 -35
  297. ccxt/novadax.py +190 -34
  298. ccxt/oceanex.py +217 -28
  299. ccxt/okcoin.py +253 -145
  300. ccxt/okexchange.py +9 -9
  301. ccxt/okx.py +1088 -351
  302. ccxt/okxus.py +54 -0
  303. ccxt/ompfinex.py +22 -21
  304. ccxt/onetrading.py +213 -392
  305. ccxt/oxfun.py +245 -166
  306. ccxt/p2b.py +151 -29
  307. ccxt/paradex.py +562 -49
  308. ccxt/paymium.py +82 -19
  309. ccxt/phemex.py +712 -172
  310. ccxt/poloniex.py +1601 -283
  311. ccxt/pro/__init__.py +76 -17
  312. ccxt/pro/alpaca.py +21 -6
  313. ccxt/pro/apex.py +984 -0
  314. ccxt/pro/ascendex.py +58 -10
  315. ccxt/pro/bequant.py +6 -1
  316. ccxt/pro/binance.py +728 -156
  317. ccxt/pro/binancecoinm.py +6 -2
  318. ccxt/pro/binanceus.py +8 -4
  319. ccxt/pro/binanceusdm.py +7 -2
  320. ccxt/pro/bingx.py +333 -142
  321. ccxt/pro/bitfinex.py +727 -262
  322. ccxt/pro/bitget.py +570 -79
  323. ccxt/pro/bithumb.py +20 -6
  324. ccxt/pro/bitmart.py +216 -87
  325. ccxt/pro/bitmex.py +47 -9
  326. ccxt/pro/bitopro.py +26 -14
  327. ccxt/pro/bitrue.py +22 -22
  328. ccxt/pro/bitstamp.py +54 -21
  329. ccxt/pro/{huobijp.py → bittrade.py} +7 -6
  330. ccxt/pro/bitvavo.py +191 -67
  331. ccxt/pro/blockchaincom.py +21 -8
  332. ccxt/pro/blofin.py +9 -1
  333. ccxt/pro/bybit.py +632 -245
  334. ccxt/pro/cex.py +59 -24
  335. ccxt/pro/coinbase.py +102 -73
  336. ccxt/pro/coinbaseadvanced.py +2 -1
  337. ccxt/pro/coinbaseexchange.py +8 -8
  338. ccxt/pro/coinbaseinternational.py +181 -25
  339. ccxt/pro/coincatch.py +6 -7
  340. ccxt/pro/coincheck.py +11 -6
  341. ccxt/pro/coinex.py +967 -665
  342. ccxt/pro/coinone.py +16 -9
  343. ccxt/pro/cryptocom.py +448 -45
  344. ccxt/pro/defx.py +831 -0
  345. ccxt/pro/deribit.py +150 -14
  346. ccxt/pro/derive.py +704 -0
  347. ccxt/pro/exmo.py +239 -6
  348. ccxt/pro/gate.py +623 -65
  349. ccxt/pro/gateio.py +2 -1
  350. ccxt/pro/gemini.py +27 -11
  351. ccxt/pro/hashkey.py +2 -2
  352. ccxt/pro/hitbtc.py +196 -91
  353. ccxt/pro/hollaex.py +23 -7
  354. ccxt/pro/htx.py +51 -14
  355. ccxt/pro/huobi.py +2 -1
  356. ccxt/pro/hyperliquid.py +591 -27
  357. ccxt/pro/independentreserve.py +9 -6
  358. ccxt/pro/kraken.py +640 -320
  359. ccxt/pro/krakenfutures.py +62 -35
  360. ccxt/pro/kucoin.py +267 -46
  361. ccxt/pro/kucoinfutures.py +165 -21
  362. ccxt/pro/lbank.py +102 -21
  363. ccxt/pro/luno.py +12 -8
  364. ccxt/pro/mexc.py +877 -111
  365. ccxt/pro/modetrade.py +1271 -0
  366. ccxt/pro/myokx.py +38 -0
  367. ccxt/pro/ndax.py +15 -2
  368. ccxt/pro/okcoin.py +23 -4
  369. ccxt/pro/okx.py +573 -98
  370. ccxt/pro/okxus.py +38 -0
  371. ccxt/pro/onetrading.py +30 -13
  372. ccxt/pro/oxfun.py +131 -27
  373. ccxt/pro/p2b.py +88 -22
  374. ccxt/pro/paradex.py +3 -3
  375. ccxt/pro/phemex.py +75 -21
  376. ccxt/pro/poloniex.py +124 -41
  377. ccxt/pro/probit.py +87 -80
  378. ccxt/pro/tradeogre.py +272 -0
  379. ccxt/pro/upbit.py +152 -12
  380. ccxt/pro/vertex.py +8 -3
  381. ccxt/pro/whitebit.py +58 -5
  382. ccxt/pro/woo.py +228 -37
  383. ccxt/pro/woofipro.py +106 -18
  384. ccxt/pro/xt.py +111 -5
  385. ccxt/probit.py +224 -95
  386. ccxt/protobuf/__init__.py +0 -0
  387. ccxt/protobuf/mexc/PrivateAccountV3Api_pb2.py +37 -0
  388. ccxt/protobuf/mexc/PrivateDealsV3Api_pb2.py +37 -0
  389. ccxt/protobuf/mexc/PrivateOrdersV3Api_pb2.py +37 -0
  390. ccxt/protobuf/mexc/PublicAggreBookTickerV3Api_pb2.py +37 -0
  391. ccxt/protobuf/mexc/PublicAggreDealsV3Api_pb2.py +39 -0
  392. ccxt/protobuf/mexc/PublicAggreDepthsV3Api_pb2.py +39 -0
  393. ccxt/protobuf/mexc/PublicBookTickerBatchV3Api_pb2.py +38 -0
  394. ccxt/protobuf/mexc/PublicBookTickerV3Api_pb2.py +37 -0
  395. ccxt/protobuf/mexc/PublicDealsV3Api_pb2.py +39 -0
  396. ccxt/protobuf/mexc/PublicIncreaseDepthsBatchV3Api_pb2.py +38 -0
  397. ccxt/protobuf/mexc/PublicIncreaseDepthsV3Api_pb2.py +39 -0
  398. ccxt/protobuf/mexc/PublicLimitDepthsV3Api_pb2.py +39 -0
  399. ccxt/protobuf/mexc/PublicMiniTickerV3Api_pb2.py +37 -0
  400. ccxt/protobuf/mexc/PublicMiniTickersV3Api_pb2.py +38 -0
  401. ccxt/protobuf/mexc/PublicSpotKlineV3Api_pb2.py +37 -0
  402. ccxt/protobuf/mexc/PushDataV3ApiWrapper_pb2.py +52 -0
  403. ccxt/protobuf/mexc/__init__.py +0 -0
  404. ccxt/ramzinex.py +28 -25
  405. ccxt/sarmayex.py +7 -7
  406. ccxt/sarrafex.py +10 -10
  407. ccxt/static_dependencies/__init__.py +1 -1
  408. ccxt/static_dependencies/lark/py.typed +0 -0
  409. ccxt/static_dependencies/marshmallow/py.typed +0 -0
  410. ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
  411. ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
  412. ccxt/tabdeal.py +12 -11
  413. ccxt/test/tests_async.py +261 -57
  414. ccxt/test/tests_helpers.py +1 -3
  415. ccxt/test/tests_init.py +4 -3
  416. ccxt/test/tests_sync.py +261 -57
  417. ccxt/tetherland.py +7 -7
  418. ccxt/timex.py +210 -51
  419. ccxt/tokocrypto.py +167 -47
  420. ccxt/tradeogre.py +266 -31
  421. ccxt/twox.py +7 -7
  422. ccxt/ubitex.py +9 -9
  423. ccxt/upbit.py +568 -165
  424. ccxt/vertex.py +160 -32
  425. ccxt/wallex.py +9 -9
  426. ccxt/wavesexchange.py +165 -30
  427. ccxt/whitebit.py +975 -127
  428. ccxt/woo.py +1917 -1016
  429. ccxt/woofipro.py +432 -141
  430. ccxt/xt.py +649 -193
  431. ccxt/yobit.py +194 -70
  432. ccxt/zaif.py +91 -15
  433. ccxt/zonda.py +151 -36
  434. {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info}/METADATA +225 -73
  435. ccxt_ir-4.5.0.dist-info/RECORD +743 -0
  436. {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info}/WHEEL +1 -1
  437. ccxt/abstract/ace.py +0 -15
  438. ccxt/abstract/bitbay.py +0 -53
  439. ccxt/abstract/bitcoincom.py +0 -115
  440. ccxt/abstract/bitfinex2.py +0 -139
  441. ccxt/abstract/bitpanda.py +0 -35
  442. ccxt/abstract/bl3p.py +0 -19
  443. ccxt/abstract/coinlist.py +0 -54
  444. ccxt/abstract/currencycom.py +0 -68
  445. ccxt/abstract/hitbtc3.py +0 -115
  446. ccxt/abstract/idex.py +0 -26
  447. ccxt/abstract/kuna.py +0 -182
  448. ccxt/abstract/lykke.py +0 -29
  449. ccxt/abstract/poloniexfutures.py +0 -48
  450. ccxt/abstract/wazirx.py +0 -30
  451. ccxt/ace.py +0 -1012
  452. ccxt/async_support/ace.py +0 -1012
  453. ccxt/async_support/base/ws/aiohttp_client.py +0 -125
  454. ccxt/async_support/base/ws/fast_client.py +0 -96
  455. ccxt/async_support/bitbay.py +0 -17
  456. ccxt/async_support/bitcoincom.py +0 -17
  457. ccxt/async_support/bitfinex2.py +0 -3552
  458. ccxt/async_support/bitpanda.py +0 -16
  459. ccxt/async_support/bl3p.py +0 -485
  460. ccxt/async_support/coinlist.py +0 -2243
  461. ccxt/async_support/currencycom.py +0 -1950
  462. ccxt/async_support/hitbtc3.py +0 -16
  463. ccxt/async_support/idex.py +0 -1766
  464. ccxt/async_support/kuna.py +0 -1841
  465. ccxt/async_support/lykke.py +0 -1270
  466. ccxt/async_support/poloniexfutures.py +0 -1717
  467. ccxt/async_support/wazirx.py +0 -1224
  468. ccxt/bitbay.py +0 -17
  469. ccxt/bitcoincom.py +0 -17
  470. ccxt/bitfinex2.py +0 -3552
  471. ccxt/bitpanda.py +0 -16
  472. ccxt/bl3p.py +0 -485
  473. ccxt/coinlist.py +0 -2243
  474. ccxt/currencycom.py +0 -1950
  475. ccxt/hitbtc3.py +0 -16
  476. ccxt/idex.py +0 -1766
  477. ccxt/kuna.py +0 -1841
  478. ccxt/lykke.py +0 -1270
  479. ccxt/poloniexfutures.py +0 -1717
  480. ccxt/pro/bitcoincom.py +0 -34
  481. ccxt/pro/bitfinex2.py +0 -1083
  482. ccxt/pro/bitpanda.py +0 -15
  483. ccxt/pro/currencycom.py +0 -536
  484. ccxt/pro/idex.py +0 -672
  485. ccxt/pro/poloniexfutures.py +0 -990
  486. ccxt/pro/wazirx.py +0 -749
  487. ccxt/test/base/__init__.py +0 -29
  488. ccxt/test/base/test_account.py +0 -26
  489. ccxt/test/base/test_balance.py +0 -56
  490. ccxt/test/base/test_borrow_interest.py +0 -35
  491. ccxt/test/base/test_borrow_rate.py +0 -32
  492. ccxt/test/base/test_calculate_fee.py +0 -51
  493. ccxt/test/base/test_crypto.py +0 -127
  494. ccxt/test/base/test_currency.py +0 -76
  495. ccxt/test/base/test_datetime.py +0 -109
  496. ccxt/test/base/test_decimal_to_precision.py +0 -392
  497. ccxt/test/base/test_deep_extend.py +0 -68
  498. ccxt/test/base/test_deposit_withdrawal.py +0 -50
  499. ccxt/test/base/test_exchange_datetime_functions.py +0 -76
  500. ccxt/test/base/test_funding_rate_history.py +0 -29
  501. ccxt/test/base/test_last_price.py +0 -31
  502. ccxt/test/base/test_ledger_entry.py +0 -45
  503. ccxt/test/base/test_ledger_item.py +0 -48
  504. ccxt/test/base/test_leverage_tier.py +0 -33
  505. ccxt/test/base/test_liquidation.py +0 -50
  506. ccxt/test/base/test_margin_mode.py +0 -24
  507. ccxt/test/base/test_margin_modification.py +0 -35
  508. ccxt/test/base/test_market.py +0 -193
  509. ccxt/test/base/test_number.py +0 -411
  510. ccxt/test/base/test_ohlcv.py +0 -33
  511. ccxt/test/base/test_open_interest.py +0 -32
  512. ccxt/test/base/test_order.py +0 -64
  513. ccxt/test/base/test_order_book.py +0 -69
  514. ccxt/test/base/test_position.py +0 -60
  515. ccxt/test/base/test_shared_methods.py +0 -353
  516. ccxt/test/base/test_status.py +0 -24
  517. ccxt/test/base/test_throttle.py +0 -126
  518. ccxt/test/base/test_ticker.py +0 -92
  519. ccxt/test/base/test_trade.py +0 -47
  520. ccxt/test/base/test_trading_fee.py +0 -26
  521. ccxt/test/base/test_transaction.py +0 -39
  522. ccxt/test/test_async.py +0 -1649
  523. ccxt/test/test_sync.py +0 -1648
  524. ccxt/wazirx.py +0 -1224
  525. ccxt_ir-4.3.46.0.2.dist-info/RECORD +0 -772
  526. /ccxt/abstract/{huobijp.py → bittrade.py} +0 -0
  527. {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info/licenses}/LICENSE.txt +0 -0
  528. {ccxt_ir-4.3.46.0.2.dist-info → ccxt_ir-4.5.0.dist-info}/top_level.txt +0 -0
ccxt/async_support/htx.py CHANGED
@@ -7,7 +7,7 @@ from ccxt.async_support.base.exchange import Exchange
7
7
  from ccxt.abstract.htx import ImplicitAPI
8
8
  import asyncio
9
9
  import hashlib
10
- from ccxt.base.types import Account, Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
10
+ from ccxt.base.types import Account, Any, Balances, BorrowInterest, Currencies, Currency, DepositAddress, Int, IsolatedBorrowRate, IsolatedBorrowRates, LedgerEntry, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, Transaction, TransferEntry
11
11
  from typing import List
12
12
  from ccxt.base.errors import ExchangeError
13
13
  from ccxt.base.errors import AuthenticationError
@@ -32,7 +32,7 @@ from ccxt.base.precise import Precise
32
32
 
33
33
  class htx(Exchange, ImplicitAPI):
34
34
 
35
- def describe(self):
35
+ def describe(self) -> Any:
36
36
  return self.deep_extend(super(htx, self).describe(), {
37
37
  'id': 'htx',
38
38
  'name': 'HTX',
@@ -107,7 +107,7 @@ class htx(Exchange, ImplicitAPI):
107
107
  'fetchLeverageTiers': True,
108
108
  'fetchLiquidations': True,
109
109
  'fetchMarginAdjustmentHistory': False,
110
- 'fetchMarketLeverageTiers': True,
110
+ 'fetchMarketLeverageTiers': 'emulated',
111
111
  'fetchMarkets': True,
112
112
  'fetchMarkOHLCV': True,
113
113
  'fetchMyLiquidations': False,
@@ -115,6 +115,7 @@ class htx(Exchange, ImplicitAPI):
115
115
  'fetchOHLCV': True,
116
116
  'fetchOpenInterest': True,
117
117
  'fetchOpenInterestHistory': True,
118
+ 'fetchOpenInterests': True,
118
119
  'fetchOpenOrder': None,
119
120
  'fetchOpenOrders': True,
120
121
  'fetchOrder': True,
@@ -203,7 +204,7 @@ class htx(Exchange, ImplicitAPI):
203
204
  },
204
205
  'www': 'https://www.huobi.com',
205
206
  'referral': {
206
- 'url': 'https://www.huobi.com/en-us/v/register/double-invite/?inviter_id=11343840&invite_code=6rmm2223',
207
+ 'url': 'https://www.htx.com.vc/invite/en-us/1h?invite_code=6rmm2223',
207
208
  'discount': 0.15,
208
209
  },
209
210
  'doc': [
@@ -909,6 +910,7 @@ class htx(Exchange, ImplicitAPI):
909
910
  '1041': InvalidOrder, # {"status":"error","err_code":1041,"err_msg":"The order amount exceeds the limit(170000Cont), please modify and order again.","ts":1643802784940}
910
911
  '1047': InsufficientFunds, # {"status":"error","err_code":1047,"err_msg":"Insufficient margin available.","ts":1643802672652}
911
912
  '1048': InsufficientFunds, # {"status":"error","err_code":1048,"err_msg":"Insufficient close amount available.","ts":1652772408864}
913
+ '1061': OrderNotFound, # {"status":"ok","data":{"errors":[{"order_id":"1349442392365359104","err_code":1061,"err_msg":"The order does not exist."}],"successes":""},"ts":1741773744526}
912
914
  '1051': InvalidOrder, # {"status":"error","err_code":1051,"err_msg":"No orders to cancel.","ts":1652552125876}
913
915
  '1066': BadSymbol, # {"status":"error","err_code":1066,"err_msg":"The symbol field cannot be empty. Please re-enter.","ts":1640550819147}
914
916
  '1067': InvalidOrder, # {"status":"error","err_code":1067,"err_msg":"The client_order_id field is invalid. Please re-enter.","ts":1643802119413}
@@ -961,6 +963,7 @@ class htx(Exchange, ImplicitAPI):
961
963
  },
962
964
  'precisionMode': TICK_SIZE,
963
965
  'options': {
966
+ 'include_OS_certificates': False, # temporarily leave self, remove in future
964
967
  'fetchMarkets': {
965
968
  'types': {
966
969
  'spot': True,
@@ -968,6 +971,8 @@ class htx(Exchange, ImplicitAPI):
968
971
  'inverse': True,
969
972
  },
970
973
  },
974
+ 'timeDifference': 0, # the difference between system clock and exchange clock
975
+ 'adjustForTimeDifference': False, # controls the adjustment logic upon instantiation
971
976
  'fetchOHLCV': {
972
977
  'useHistoricalEndpointForSpot': True,
973
978
  },
@@ -1237,21 +1242,164 @@ class htx(Exchange, ImplicitAPI):
1237
1242
  # https://github.com/ccxt/ccxt/issues/6081
1238
1243
  # https://github.com/ccxt/ccxt/issues/3365
1239
1244
  # https://github.com/ccxt/ccxt/issues/2873
1240
- 'GET': 'Themis', # conflict with GET(Guaranteed Entrance Token, GET Protocol)
1241
- 'GTC': 'Game.com', # conflict with Gitcoin and Gastrocoin
1242
- 'HIT': 'HitChain',
1245
+ 'NGL': 'GFNGL',
1246
+ 'GET': 'THEMIS', # conflict with GET(Guaranteed Entrance Token, GET Protocol)
1247
+ 'GTC': 'GAMECOM', # conflict with Gitcoin and Gastrocoin
1248
+ 'HIT': 'HITCHAIN',
1243
1249
  # https://github.com/ccxt/ccxt/issues/7399
1244
1250
  # https://coinmarketcap.com/currencies/pnetwork/
1245
1251
  # https://coinmarketcap.com/currencies/penta/markets/
1246
1252
  # https://en.cryptonomist.ch/blog/eidoo/the-edo-to-pnt-upgrade-what-you-need-to-know-updated/
1247
- 'PNT': 'Penta',
1248
- 'SBTC': 'Super Bitcoin',
1249
- 'SOUL': 'Soulsaver',
1250
- 'BIFI': 'Bitcoin File', # conflict with Beefy.Finance https://github.com/ccxt/ccxt/issues/8706
1253
+ 'PNT': 'PENTA',
1254
+ 'SBTC': 'SUPERBITCOIN',
1255
+ 'SOUL': 'SOULSAVER',
1256
+ 'BIFI': 'BITCOINFILE', # conflict with Beefy.Finance https://github.com/ccxt/ccxt/issues/8706
1257
+ 'FUD': 'FTX Users Debt',
1258
+ },
1259
+ 'features': {
1260
+ 'spot': {
1261
+ 'sandbox': True,
1262
+ 'createOrder': {
1263
+ 'marginMode': True,
1264
+ 'triggerPrice': True,
1265
+ 'triggerDirection': True,
1266
+ 'triggerPriceType': None,
1267
+ 'stopLossPrice': False, # todo: add support by triggerprice
1268
+ 'takeProfitPrice': False,
1269
+ 'attachedStopLossTakeProfit': None,
1270
+ 'timeInForce': {
1271
+ 'IOC': True,
1272
+ 'FOK': True,
1273
+ 'PO': True,
1274
+ 'GTD': False,
1275
+ },
1276
+ 'hedged': False,
1277
+ 'trailing': False,
1278
+ 'iceberg': False,
1279
+ 'selfTradePrevention': True, # todo implement
1280
+ 'leverage': True, # todo implement
1281
+ 'marketBuyByCost': True,
1282
+ 'marketBuyRequiresPrice': True,
1283
+ },
1284
+ 'createOrders': {
1285
+ 'max': 10,
1286
+ },
1287
+ 'fetchMyTrades': {
1288
+ 'marginMode': False,
1289
+ 'limit': 500,
1290
+ 'daysBack': 120,
1291
+ 'untilDays': 2,
1292
+ 'symbolRequired': False,
1293
+ },
1294
+ 'fetchOrder': {
1295
+ 'marginMode': False,
1296
+ 'trigger': False,
1297
+ 'trailing': False,
1298
+ 'symbolRequired': False,
1299
+ },
1300
+ 'fetchOpenOrders': {
1301
+ 'marginMode': False,
1302
+ 'trigger': True,
1303
+ 'trailing': False,
1304
+ 'limit': 500,
1305
+ 'symbolRequired': False,
1306
+ },
1307
+ 'fetchOrders': {
1308
+ 'marginMode': False,
1309
+ 'trigger': True,
1310
+ 'trailing': False,
1311
+ 'limit': 500,
1312
+ 'untilDays': 2,
1313
+ 'daysBack': 180,
1314
+ 'symbolRequired': False,
1315
+ },
1316
+ 'fetchClosedOrders': {
1317
+ 'marginMode': False,
1318
+ 'trigger': True,
1319
+ 'trailing': False,
1320
+ 'untilDays': 2,
1321
+ 'limit': 500,
1322
+ 'daysBack': 180,
1323
+ 'daysBackCanceled': 1 / 12,
1324
+ 'symbolRequired': False,
1325
+ },
1326
+ 'fetchOHLCV': {
1327
+ 'limit': 1000, # 2000 for non-historical
1328
+ },
1329
+ },
1330
+ 'forDerivatives': {
1331
+ 'extends': 'spot',
1332
+ 'createOrder': {
1333
+ 'stopLossPrice': True,
1334
+ 'takeProfitPrice': True,
1335
+ 'trailing': True,
1336
+ 'hedged': True,
1337
+ # 'leverage': True, # todo
1338
+ },
1339
+ 'createOrders': {
1340
+ 'max': 25,
1341
+ },
1342
+ 'fetchOrder': {
1343
+ 'marginMode': True,
1344
+ },
1345
+ 'fetchOpenOrders': {
1346
+ 'marginMode': True,
1347
+ 'trigger': False,
1348
+ 'trailing': False,
1349
+ 'limit': 50,
1350
+ },
1351
+ 'fetchOrders': {
1352
+ 'marginMode': True,
1353
+ 'trigger': False,
1354
+ 'trailing': False,
1355
+ 'limit': 50,
1356
+ 'daysBack': 90,
1357
+ },
1358
+ 'fetchClosedOrders': {
1359
+ 'marginMode': True,
1360
+ 'trigger': False,
1361
+ 'trailing': False,
1362
+ 'untilDays': 2,
1363
+ 'limit': 50,
1364
+ 'daysBack': 90,
1365
+ 'daysBackCanceled': 1 / 12,
1366
+ },
1367
+ 'fetchOHLCV': {
1368
+ 'limit': 2000,
1369
+ },
1370
+ },
1371
+ 'swap': {
1372
+ 'linear': {
1373
+ 'extends': 'forDerivatives',
1374
+ },
1375
+ 'inverse': {
1376
+ 'extends': 'forDerivatives',
1377
+ },
1378
+ },
1379
+ 'future': {
1380
+ 'linear': {
1381
+ 'extends': 'forDerivatives',
1382
+ },
1383
+ 'inverse': {
1384
+ 'extends': 'forDerivatives',
1385
+ },
1386
+ },
1251
1387
  },
1252
1388
  })
1253
1389
 
1254
1390
  async def fetch_status(self, params={}):
1391
+ """
1392
+ the latest known information on the availability of the exchange API
1393
+
1394
+ https://huobiapi.github.io/docs/spot/v1/en/#get-system-status
1395
+ https://huobiapi.github.io/docs/dm/v1/en/#get-system-status
1396
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-system-status
1397
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#get-system-status
1398
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#query-whether-the-system-is-available # contractPublicGetHeartbeat
1399
+
1400
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1401
+ :returns dict: a `status structure <https://docs.ccxt.com/#/?id=exchange-status-structure>`
1402
+ """
1255
1403
  await self.load_markets()
1256
1404
  marketType = None
1257
1405
  marketType, params = self.handle_market_type_and_params('fetchStatus', None, params)
@@ -1460,9 +1608,13 @@ class htx(Exchange, ImplicitAPI):
1460
1608
  'info': response,
1461
1609
  }
1462
1610
 
1463
- async def fetch_time(self, params={}):
1611
+ async def fetch_time(self, params={}) -> Int:
1464
1612
  """
1465
1613
  fetches the current integer timestamp in milliseconds from the exchange server
1614
+
1615
+ https://huobiapi.github.io/docs/spot/v1/en/#get-current-timestamp
1616
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-current-system-timestamp
1617
+
1466
1618
  :param dict [params]: extra parameters specific to the exchange API endpoint
1467
1619
  :returns int: the current integer timestamp in milliseconds from the exchange server
1468
1620
  """
@@ -1509,6 +1661,9 @@ class htx(Exchange, ImplicitAPI):
1509
1661
  async def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
1510
1662
  """
1511
1663
  fetch the trading fees for a market
1664
+
1665
+ https://huobiapi.github.io/docs/spot/v1/en/#get-current-fee-rate-applied-to-the-user
1666
+
1512
1667
  :param str symbol: unified market symbol
1513
1668
  :param dict [params]: extra parameters specific to the exchange API endpoint
1514
1669
  :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -1552,6 +1707,15 @@ class htx(Exchange, ImplicitAPI):
1552
1707
  return result
1553
1708
 
1554
1709
  async def fetch_trading_limits_by_id(self, id: str, params={}):
1710
+ """
1711
+ @ignore
1712
+
1713
+ https://huobiapi.github.io/docs/spot/v1/en/#get-current-fee-rate-applied-to-the-user
1714
+
1715
+ :param str id: market id
1716
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1717
+ :returns dict: the limits object of a market structure
1718
+ """
1555
1719
  request: dict = {
1556
1720
  'symbol': id,
1557
1721
  }
@@ -1606,9 +1770,17 @@ class htx(Exchange, ImplicitAPI):
1606
1770
  async def fetch_markets(self, params={}) -> List[Market]:
1607
1771
  """
1608
1772
  retrieves data on all markets for huobi
1773
+
1774
+ https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
1775
+ https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
1776
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
1777
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info
1778
+
1609
1779
  :param dict [params]: extra parameters specific to the exchange API endpoint
1610
1780
  :returns dict[]: an array of objects representing market data
1611
1781
  """
1782
+ if self.options['adjustForTimeDifference']:
1783
+ await self.load_time_difference()
1612
1784
  types = None
1613
1785
  types, params = self.handle_option_and_params(params, 'fetchMarkets', 'types', {})
1614
1786
  allMarkets = []
@@ -1629,7 +1801,21 @@ class htx(Exchange, ImplicitAPI):
1629
1801
  allMarkets = self.array_concat(allMarkets, promises[i])
1630
1802
  return allMarkets
1631
1803
 
1632
- async def fetch_markets_by_type_and_sub_type(self, type, subType, params={}):
1804
+ async def fetch_markets_by_type_and_sub_type(self, type: Str, subType: Str, params={}):
1805
+ """
1806
+ @ignore
1807
+ retrieves data on all markets of a certain type and/or subtype
1808
+
1809
+ https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-trading-symbol-v1-deprecated
1810
+ https://huobiapi.github.io/docs/dm/v1/en/#get-contract-info
1811
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-swap-info
1812
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-swap-info
1813
+
1814
+ :param str [type]: 'spot', 'swap' or 'future'
1815
+ :param str [subType]: 'linear' or 'inverse'
1816
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1817
+ :returns dict[]: an array of objects representing market data
1818
+ """
1633
1819
  isSpot = (type == 'spot')
1634
1820
  request: dict = {}
1635
1821
  response = None
@@ -1988,14 +2174,14 @@ class htx(Exchange, ImplicitAPI):
1988
2174
  ask = None
1989
2175
  askVolume = None
1990
2176
  if 'bid' in ticker:
1991
- if isinstance(ticker['bid'], list):
2177
+ if ticker['bid'] is not None and isinstance(ticker['bid'], list):
1992
2178
  bid = self.safe_string(ticker['bid'], 0)
1993
2179
  bidVolume = self.safe_string(ticker['bid'], 1)
1994
2180
  else:
1995
2181
  bid = self.safe_string(ticker, 'bid')
1996
2182
  bidVolume = self.safe_string(ticker, 'bidSize')
1997
2183
  if 'ask' in ticker:
1998
- if isinstance(ticker['ask'], list):
2184
+ if ticker['ask'] is not None and isinstance(ticker['ask'], list):
1999
2185
  ask = self.safe_string(ticker['ask'], 0)
2000
2186
  askVolume = self.safe_string(ticker['ask'], 1)
2001
2187
  else:
@@ -2031,6 +2217,12 @@ class htx(Exchange, ImplicitAPI):
2031
2217
  async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
2032
2218
  """
2033
2219
  fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
2220
+
2221
+ https://huobiapi.github.io/docs/spot/v1/en/#get-latest-aggregated-ticker
2222
+ https://huobiapi.github.io/docs/dm/v1/en/#get-market-data-overview
2223
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-market-data-overview
2224
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-market-data-overview
2225
+
2034
2226
  :param str symbol: unified symbol of the market to fetch the ticker for
2035
2227
  :param dict [params]: extra parameters specific to the exchange API endpoint
2036
2228
  :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -2105,10 +2297,12 @@ class htx(Exchange, ImplicitAPI):
2105
2297
  async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
2106
2298
  """
2107
2299
  fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
2108
- :see: https://huobiapi.github.io/docs/spot/v1/en/#get-latest-tickers-for-all-pairs
2109
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-a-batch-of-market-data-overview
2110
- :see: https://huobiapi.github.io/docs/dm/v1/en/#get-a-batch-of-market-data-overview
2111
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-a-batch-of-market-data-overview-v2
2300
+
2301
+ https://huobiapi.github.io/docs/spot/v1/en/#get-latest-tickers-for-all-pairs
2302
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-a-batch-of-market-data-overview
2303
+ https://huobiapi.github.io/docs/dm/v1/en/#get-a-batch-of-market-data-overview
2304
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-a-batch-of-market-data-overview-v2
2305
+
2112
2306
  :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
2113
2307
  :param dict [params]: extra parameters specific to the exchange API endpoint
2114
2308
  :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
@@ -2209,9 +2403,11 @@ class htx(Exchange, ImplicitAPI):
2209
2403
  async def fetch_last_prices(self, symbols: Strings = None, params={}):
2210
2404
  """
2211
2405
  fetches the last price for multiple markets
2212
- :see: https://www.htx.com/en-us/opend/newApiPages/?id=8cb81024-77b5-11ed-9966-0242ac110003 linear swap & linear future
2213
- :see: https://www.htx.com/en-us/opend/newApiPages/?id=28c2e8fc-77ae-11ed-9966-0242ac110003 inverse future
2214
- :see: https://www.htx.com/en-us/opend/newApiPages/?id=5d517ef5-77b6-11ed-9966-0242ac110003 inverse swap
2406
+
2407
+ https://www.htx.com/en-us/opend/newApiPages/?id=8cb81024-77b5-11ed-9966-0242ac110003 linear swap & linear future
2408
+ https://www.htx.com/en-us/opend/newApiPages/?id=28c2e8fc-77ae-11ed-9966-0242ac110003 inverse future
2409
+ https://www.htx.com/en-us/opend/newApiPages/?id=5d517ef5-77b6-11ed-9966-0242ac110003 inverse swap
2410
+
2215
2411
  :param str[] [symbols]: unified symbols of the markets to fetch the last prices
2216
2412
  :param dict [params]: extra parameters specific to the exchange API endpoint
2217
2413
  :returns dict: a dictionary of lastprices structures
@@ -2324,6 +2520,12 @@ class htx(Exchange, ImplicitAPI):
2324
2520
  async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
2325
2521
  """
2326
2522
  fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
2523
+
2524
+ https://huobiapi.github.io/docs/spot/v1/en/#get-market-depth
2525
+ https://huobiapi.github.io/docs/dm/v1/en/#get-market-depth
2526
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-market-depth
2527
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-market-depth
2528
+
2327
2529
  :param str symbol: unified symbol of the market to fetch the order book for
2328
2530
  :param int [limit]: the maximum amount of order book entries to return
2329
2531
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -2535,6 +2737,9 @@ class htx(Exchange, ImplicitAPI):
2535
2737
  async def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2536
2738
  """
2537
2739
  fetch all the trades made from a single order
2740
+
2741
+ https://huobiapi.github.io/docs/spot/v1/en/#get-the-match-result-of-an-order
2742
+
2538
2743
  :param str id: order id
2539
2744
  :param str symbol: unified market symbol
2540
2745
  :param int [since]: the earliest time in ms to fetch trades for
@@ -2552,6 +2757,19 @@ class htx(Exchange, ImplicitAPI):
2552
2757
  return await self.fetch_spot_order_trades(id, symbol, since, limit, params)
2553
2758
 
2554
2759
  async def fetch_spot_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2760
+ """
2761
+ @ignore
2762
+ fetch all the trades made from a single order
2763
+
2764
+ https://huobiapi.github.io/docs/spot/v1/en/#get-the-match-result-of-an-order
2765
+
2766
+ :param str id: order id
2767
+ :param str symbol: unified market symbol
2768
+ :param int [since]: the earliest time in ms to fetch trades for
2769
+ :param int [limit]: the maximum number of trades to retrieve
2770
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2771
+ :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
2772
+ """
2555
2773
  await self.load_markets()
2556
2774
  request: dict = {
2557
2775
  'order-id': id,
@@ -2561,9 +2779,11 @@ class htx(Exchange, ImplicitAPI):
2561
2779
 
2562
2780
  async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2563
2781
  """
2564
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-match-results-via-multiple-fields-new
2565
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-match-results-via-multiple-fields-new
2566
- :see: https://huobiapi.github.io/docs/spot/v1/en/#search-match-results
2782
+
2783
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-match-results-via-multiple-fields-new
2784
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-match-results-via-multiple-fields-new
2785
+ https://huobiapi.github.io/docs/spot/v1/en/#search-match-results
2786
+
2567
2787
  fetch all trades made by the user
2568
2788
  :param str symbol: unified market symbol
2569
2789
  :param int [since]: the earliest time in ms to fetch trades for
@@ -2714,10 +2934,12 @@ class htx(Exchange, ImplicitAPI):
2714
2934
 
2715
2935
  async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = 1000, params={}) -> List[Trade]:
2716
2936
  """
2717
- :see: https://huobiapi.github.io/docs/spot/v1/en/#get-the-most-recent-trades
2718
- :see: https://huobiapi.github.io/docs/dm/v1/en/#query-a-batch-of-trade-records-of-a-contract
2719
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-a-batch-of-trade-records-of-a-contract
2720
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-a-batch-of-trade-records-of-a-contract
2937
+
2938
+ https://huobiapi.github.io/docs/spot/v1/en/#get-the-most-recent-trades
2939
+ https://huobiapi.github.io/docs/dm/v1/en/#query-a-batch-of-trade-records-of-a-contract
2940
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-a-batch-of-trade-records-of-a-contract
2941
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-a-batch-of-trade-records-of-a-contract
2942
+
2721
2943
  get the list of most recent trades for a particular symbol
2722
2944
  :param str symbol: unified symbol of the market to fetch trades for
2723
2945
  :param int [since]: timestamp in ms of the earliest trade to fetch
@@ -2809,10 +3031,12 @@ class htx(Exchange, ImplicitAPI):
2809
3031
  async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
2810
3032
  """
2811
3033
  fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
2812
- :see: https://huobiapi.github.io/docs/spot/v1/en/#get-klines-candles
2813
- :see: https://huobiapi.github.io/docs/dm/v1/en/#get-kline-data
2814
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-kline-data
2815
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
3034
+
3035
+ https://huobiapi.github.io/docs/spot/v1/en/#get-klines-candles
3036
+ https://huobiapi.github.io/docs/dm/v1/en/#get-kline-data
3037
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-kline-data
3038
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
3039
+
2816
3040
  :param str symbol: unified symbol of the market to fetch OHLCV data for
2817
3041
  :param str timeframe: the length of time each candle represents
2818
3042
  :param int [since]: timestamp in ms of the earliest candle to fetch
@@ -2936,6 +3160,9 @@ class htx(Exchange, ImplicitAPI):
2936
3160
  async def fetch_accounts(self, params={}) -> List[Account]:
2937
3161
  """
2938
3162
  fetch all the accounts associated with a profile
3163
+
3164
+ https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
3165
+
2939
3166
  :param dict [params]: extra parameters specific to the exchange API endpoint
2940
3167
  :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
2941
3168
  """
@@ -2972,7 +3199,18 @@ class htx(Exchange, ImplicitAPI):
2972
3199
  'code': None,
2973
3200
  }
2974
3201
 
2975
- async def fetch_account_id_by_type(self, type, marginMode=None, symbol=None, params={}):
3202
+ async def fetch_account_id_by_type(self, type: str, marginMode: Str = None, symbol: Str = None, params={}):
3203
+ """
3204
+ fetch all the accounts by a type and marginModeassociated with a profile
3205
+
3206
+ https://huobiapi.github.io/docs/spot/v1/en/#get-all-accounts-of-the-current-user
3207
+
3208
+ :param str type: 'spot', 'swap' or 'future
3209
+ :param str [marginMode]: 'cross' or 'isolated'
3210
+ :param str [symbol]: unified ccxt market symbol
3211
+ :param dict [params]: extra parameters specific to the exchange API endpoint
3212
+ :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
3213
+ """
2976
3214
  accounts = await self.load_accounts()
2977
3215
  accountId = self.safe_value_2(params, 'accountId', 'account-id')
2978
3216
  if accountId is not None:
@@ -2982,7 +3220,9 @@ class htx(Exchange, ImplicitAPI):
2982
3220
  type = 'super-margin'
2983
3221
  elif marginMode == 'isolated':
2984
3222
  type = 'margin'
2985
- marketId = None if (symbol is None) else self.market_id(symbol)
3223
+ marketId = None
3224
+ if symbol is not None:
3225
+ marketId = self.market_id(symbol)
2986
3226
  for i in range(0, len(accounts)):
2987
3227
  account = accounts[i]
2988
3228
  info = self.safe_value(account, 'info')
@@ -2999,6 +3239,9 @@ class htx(Exchange, ImplicitAPI):
2999
3239
  async def fetch_currencies(self, params={}) -> Currencies:
3000
3240
  """
3001
3241
  fetches all available currencies on an exchange
3242
+
3243
+ https://huobiapi.github.io/docs/spot/v1/en/#apiv2-currency-amp-chains
3244
+
3002
3245
  :param dict [params]: extra parameters specific to the exchange API endpoint
3003
3246
  :returns dict: an associative dictionary of currencies
3004
3247
  """
@@ -3029,7 +3272,7 @@ class htx(Exchange, ImplicitAPI):
3029
3272
  # "withdrawQuotaPerYear": null,
3030
3273
  # "withdrawQuotaTotal": null,
3031
3274
  # "withdrawFeeType": "fixed",
3032
- # "transactFeeWithdraw": "11.1653",
3275
+ # "transactFeeWithdraw": "11.1654",
3033
3276
  # "addrWithTag": False,
3034
3277
  # "addrDepositTag": False
3035
3278
  # }
@@ -3038,9 +3281,8 @@ class htx(Exchange, ImplicitAPI):
3038
3281
  # }
3039
3282
  # ]
3040
3283
  # }
3041
- # }
3042
3284
  #
3043
- data = self.safe_value(response, 'data', [])
3285
+ data = self.safe_list(response, 'data', [])
3044
3286
  result: dict = {}
3045
3287
  self.options['networkChainIdsByNames'] = {}
3046
3288
  self.options['networkNamesByChainIds'] = {}
@@ -3048,16 +3290,11 @@ class htx(Exchange, ImplicitAPI):
3048
3290
  entry = data[i]
3049
3291
  currencyId = self.safe_string(entry, 'currency')
3050
3292
  code = self.safe_currency_code(currencyId)
3293
+ assetType = self.safe_string(entry, 'assetType')
3294
+ type = assetType == 'crypto' if '1' else 'fiat'
3051
3295
  self.options['networkChainIdsByNames'][code] = {}
3052
- chains = self.safe_value(entry, 'chains', [])
3296
+ chains = self.safe_list(entry, 'chains', [])
3053
3297
  networks: dict = {}
3054
- instStatus = self.safe_string(entry, 'instStatus')
3055
- currencyActive = instStatus == 'normal'
3056
- minPrecision = None
3057
- minWithdraw = None
3058
- maxWithdraw = None
3059
- deposit = False
3060
- withdraw = False
3061
3298
  for j in range(0, len(chains)):
3062
3299
  chainEntry = chains[j]
3063
3300
  uniqueChainId = self.safe_string(chainEntry, 'chain') # i.e. usdterc20, trc20usdt ...
@@ -3065,65 +3302,53 @@ class htx(Exchange, ImplicitAPI):
3065
3302
  self.options['networkChainIdsByNames'][code][title] = uniqueChainId
3066
3303
  self.options['networkNamesByChainIds'][uniqueChainId] = title
3067
3304
  networkCode = self.network_id_to_code(uniqueChainId)
3068
- minWithdraw = self.safe_number(chainEntry, 'minWithdrawAmt')
3069
- maxWithdraw = self.safe_number(chainEntry, 'maxWithdrawAmt')
3070
- withdrawStatus = self.safe_string(chainEntry, 'withdrawStatus')
3071
- depositStatus = self.safe_string(chainEntry, 'depositStatus')
3072
- withdrawEnabled = (withdrawStatus == 'allowed')
3073
- depositEnabled = (depositStatus == 'allowed')
3074
- withdraw = withdrawEnabled if (withdrawEnabled) else withdraw
3075
- deposit = depositEnabled if (depositEnabled) else deposit
3076
- active = withdrawEnabled and depositEnabled
3077
- precision = self.parse_precision(self.safe_string(chainEntry, 'withdrawPrecision'))
3078
- if precision is not None:
3079
- minPrecision = precision if (minPrecision is None) else Precise.string_min(precision, minPrecision)
3080
- fee = self.safe_number(chainEntry, 'transactFeeWithdraw')
3081
3305
  networks[networkCode] = {
3082
3306
  'info': chainEntry,
3083
3307
  'id': uniqueChainId,
3084
3308
  'network': networkCode,
3085
3309
  'limits': {
3086
3310
  'deposit': {
3087
- 'min': None,
3311
+ 'min': self.safe_number(chainEntry, 'minDepositAmt'),
3088
3312
  'max': None,
3089
3313
  },
3090
3314
  'withdraw': {
3091
- 'min': minWithdraw,
3092
- 'max': maxWithdraw,
3315
+ 'min': self.safe_number(chainEntry, 'minWithdrawAmt'),
3316
+ 'max': self.safe_number(chainEntry, 'maxWithdrawAmt'),
3093
3317
  },
3094
3318
  },
3095
- 'active': active,
3096
- 'deposit': depositEnabled,
3097
- 'withdraw': withdrawEnabled,
3098
- 'fee': fee,
3099
- 'precision': self.parse_number(precision),
3319
+ 'active': None,
3320
+ 'deposit': self.safe_string(chainEntry, 'depositStatus') == 'allowed',
3321
+ 'withdraw': self.safe_string(chainEntry, 'withdrawStatus') == 'allowed',
3322
+ 'fee': self.safe_number(chainEntry, 'transactFeeWithdraw'),
3323
+ 'precision': self.parse_number(self.parse_precision(self.safe_string(chainEntry, 'withdrawPrecision'))),
3100
3324
  }
3101
- result[code] = {
3325
+ result[code] = self.safe_currency_structure({
3102
3326
  'info': entry,
3103
3327
  'code': code,
3104
3328
  'id': currencyId,
3105
- 'active': currencyActive,
3106
- 'deposit': deposit,
3107
- 'withdraw': withdraw,
3329
+ 'active': self.safe_string(entry, 'instStatus') == 'normal',
3330
+ 'deposit': None,
3331
+ 'withdraw': None,
3108
3332
  'fee': None,
3109
3333
  'name': None,
3334
+ 'type': type,
3110
3335
  'limits': {
3111
3336
  'amount': {
3112
3337
  'min': None,
3113
3338
  'max': None,
3114
3339
  },
3115
3340
  'withdraw': {
3116
- 'min': minWithdraw,
3117
- 'max': maxWithdraw,
3341
+ 'min': None,
3342
+ 'max': None,
3118
3343
  },
3119
3344
  'deposit': {
3120
3345
  'min': None,
3121
3346
  'max': None,
3122
3347
  },
3123
3348
  },
3124
- 'precision': self.parse_number(minPrecision),
3349
+ 'precision': None,
3125
3350
  'networks': networks,
3126
- }
3351
+ })
3127
3352
  return result
3128
3353
 
3129
3354
  def network_id_to_code(self, networkId: Str = None, currencyCode: Str = None):
@@ -3151,13 +3376,15 @@ class htx(Exchange, ImplicitAPI):
3151
3376
 
3152
3377
  async def fetch_balance(self, params={}) -> Balances:
3153
3378
  """
3154
- :see: https://huobiapi.github.io/docs/spot/v1/en/#get-account-balance-of-a-specific-account
3155
- :see: https://www.htx.com/en-us/opend/newApiPages/?id=7ec4b429-7773-11ed-9966-0242ac110003
3156
- :see: https://www.htx.com/en-us/opend/newApiPages/?id=10000074-77b7-11ed-9966-0242ac110003
3157
- :see: https://huobiapi.github.io/docs/dm/v1/en/#query-asset-valuation
3158
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-user-s-account-information
3159
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-user-s-account-information
3160
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-user-39-s-account-information
3379
+
3380
+ https://huobiapi.github.io/docs/spot/v1/en/#get-account-balance-of-a-specific-account
3381
+ https://www.htx.com/en-us/opend/newApiPages/?id=7ec4b429-7773-11ed-9966-0242ac110003
3382
+ https://www.htx.com/en-us/opend/newApiPages/?id=10000074-77b7-11ed-9966-0242ac110003
3383
+ https://huobiapi.github.io/docs/dm/v1/en/#query-asset-valuation
3384
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-user-s-account-information
3385
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-user-s-account-information
3386
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-user-39-s-account-information
3387
+
3161
3388
  query for balance and get the amount of funds available for trading or funds locked in orders
3162
3389
  :param dict [params]: extra parameters specific to the exchange API endpoint
3163
3390
  :param bool [params.unified]: provide self parameter if you have a recent account with unified cross+isolated margin account
@@ -3456,6 +3683,15 @@ class htx(Exchange, ImplicitAPI):
3456
3683
  async def fetch_order(self, id: str, symbol: Str = None, params={}):
3457
3684
  """
3458
3685
  fetches information on an order made by the user
3686
+
3687
+ https://huobiapi.github.io/docs/spot/v1/en/#get-the-order-detail-of-an-order-based-on-client-order-id
3688
+ https://huobiapi.github.io/docs/spot/v1/en/#get-the-order-detail-of-an-order
3689
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-information-of-an-order
3690
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-information-of-order
3691
+ https://huobiapi.github.io/docs/dm/v1/en/#get-information-of-an-order
3692
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-information-of-an-order
3693
+
3694
+ :param str id: order id
3459
3695
  :param str symbol: unified symbol of the market the order was made in
3460
3696
  :param dict [params]: extra parameters specific to the exchange API endpoint
3461
3697
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -3747,11 +3983,11 @@ class htx(Exchange, ImplicitAPI):
3747
3983
  'status': '0', # support multiple query seperated by ',',such as '3,4,5', 0: all. 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled
3748
3984
  }
3749
3985
  response = None
3750
- stop = self.safe_value(params, 'stop')
3986
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
3751
3987
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
3752
3988
  trailing = self.safe_bool(params, 'trailing', False)
3753
- params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing'])
3754
- if stop or stopLossTakeProfit or trailing:
3989
+ params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
3990
+ if trigger or stopLossTakeProfit or trailing:
3755
3991
  if limit is not None:
3756
3992
  request['page_size'] = limit
3757
3993
  request['contract_code'] = market['id']
@@ -3768,7 +4004,7 @@ class htx(Exchange, ImplicitAPI):
3768
4004
  marginMode, params = self.handle_margin_mode_and_params('fetchContractOrders', params)
3769
4005
  marginMode = 'cross' if (marginMode is None) else marginMode
3770
4006
  if marginMode == 'isolated':
3771
- if stop:
4007
+ if trigger:
3772
4008
  response = await self.contractPrivatePostLinearSwapApiV1SwapTriggerHisorders(self.extend(request, params))
3773
4009
  elif stopLossTakeProfit:
3774
4010
  response = await self.contractPrivatePostLinearSwapApiV1SwapTpslHisorders(self.extend(request, params))
@@ -3777,7 +4013,7 @@ class htx(Exchange, ImplicitAPI):
3777
4013
  else:
3778
4014
  response = await self.contractPrivatePostLinearSwapApiV3SwapHisorders(self.extend(request, params))
3779
4015
  elif marginMode == 'cross':
3780
- if stop:
4016
+ if trigger:
3781
4017
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerHisorders(self.extend(request, params))
3782
4018
  elif stopLossTakeProfit:
3783
4019
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTpslHisorders(self.extend(request, params))
@@ -3787,7 +4023,7 @@ class htx(Exchange, ImplicitAPI):
3787
4023
  response = await self.contractPrivatePostLinearSwapApiV3SwapCrossHisorders(self.extend(request, params))
3788
4024
  elif market['inverse']:
3789
4025
  if market['swap']:
3790
- if stop:
4026
+ if trigger:
3791
4027
  response = await self.contractPrivatePostSwapApiV1SwapTriggerHisorders(self.extend(request, params))
3792
4028
  elif stopLossTakeProfit:
3793
4029
  response = await self.contractPrivatePostSwapApiV1SwapTpslHisorders(self.extend(request, params))
@@ -3797,7 +4033,7 @@ class htx(Exchange, ImplicitAPI):
3797
4033
  response = await self.contractPrivatePostSwapApiV3SwapHisorders(self.extend(request, params))
3798
4034
  elif market['future']:
3799
4035
  request['symbol'] = market['settleId']
3800
- if stop:
4036
+ if trigger:
3801
4037
  response = await self.contractPrivatePostApiV1ContractTriggerHisorders(self.extend(request, params))
3802
4038
  elif stopLossTakeProfit:
3803
4039
  response = await self.contractPrivatePostApiV1ContractTpslHisorders(self.extend(request, params))
@@ -3960,18 +4196,20 @@ class htx(Exchange, ImplicitAPI):
3960
4196
 
3961
4197
  async def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
3962
4198
  """
3963
- :see: https://huobiapi.github.io/docs/spot/v1/en/#search-past-orders
3964
- :see: https://huobiapi.github.io/docs/spot/v1/en/#search-historical-orders-within-48-hours
3965
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-orders-new
3966
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-orders-new
3967
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-history-orders-new
3968
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-history-orders-via-multiple-fields-new
4199
+
4200
+ https://huobiapi.github.io/docs/spot/v1/en/#search-past-orders
4201
+ https://huobiapi.github.io/docs/spot/v1/en/#search-historical-orders-within-48-hours
4202
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-orders-new
4203
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-orders-new
4204
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-history-orders-new
4205
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-history-orders-via-multiple-fields-new
4206
+
3969
4207
  fetches information on multiple orders made by the user
3970
4208
  :param str symbol: unified market symbol of the market orders were made in
3971
4209
  :param int [since]: the earliest time in ms to fetch orders for
3972
4210
  :param int [limit]: the maximum number of order structures to retrieve
3973
4211
  :param dict [params]: extra parameters specific to the exchange API endpoint
3974
- :param bool [params.stop]: *contract only* if the orders are stop trigger orders or not
4212
+ :param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
3975
4213
  :param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
3976
4214
  :param int [params.until]: the latest time in ms to fetch entries for
3977
4215
  :param boolean [params.trailing]: *contract only* set to True if you want to fetch trailing stop orders
@@ -3993,12 +4231,14 @@ class htx(Exchange, ImplicitAPI):
3993
4231
 
3994
4232
  async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
3995
4233
  """
3996
- :see: https://huobiapi.github.io/docs/spot/v1/en/#search-past-orders
3997
- :see: https://huobiapi.github.io/docs/spot/v1/en/#search-historical-orders-within-48-hours
3998
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-orders-new
3999
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-orders-new
4000
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-history-orders-new
4001
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-history-orders-via-multiple-fields-new
4234
+
4235
+ https://huobiapi.github.io/docs/spot/v1/en/#search-past-orders
4236
+ https://huobiapi.github.io/docs/spot/v1/en/#search-historical-orders-within-48-hours
4237
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-history-orders-new
4238
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-history-orders-new
4239
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-history-orders-new
4240
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-history-orders-via-multiple-fields-new
4241
+
4002
4242
  fetches information on multiple closed orders made by the user
4003
4243
  :param str symbol: unified market symbol of the market orders were made in
4004
4244
  :param int [since]: the earliest time in ms to fetch orders for
@@ -4025,15 +4265,17 @@ class htx(Exchange, ImplicitAPI):
4025
4265
 
4026
4266
  async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
4027
4267
  """
4028
- :see: https://huobiapi.github.io/docs/spot/v1/en/#get-all-open-orders
4029
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-current-unfilled-order-acquisition
4030
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-current-unfilled-order-acquisition
4268
+
4269
+ https://huobiapi.github.io/docs/spot/v1/en/#get-all-open-orders
4270
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-current-unfilled-order-acquisition
4271
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-current-unfilled-order-acquisition
4272
+
4031
4273
  fetch all unfilled currently open orders
4032
4274
  :param str symbol: unified market symbol
4033
4275
  :param int [since]: the earliest time in ms to fetch open orders for
4034
4276
  :param int [limit]: the maximum number of open order structures to retrieve
4035
4277
  :param dict [params]: extra parameters specific to the exchange API endpoint
4036
- :param bool [params.stop]: *contract only* if the orders are stop trigger orders or not
4278
+ :param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
4037
4279
  :param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
4038
4280
  :param boolean [params.trailing]: *contract only* set to True if you want to fetch trailing stop orders
4039
4281
  :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
@@ -4045,6 +4287,8 @@ class htx(Exchange, ImplicitAPI):
4045
4287
  request: dict = {}
4046
4288
  marketType = None
4047
4289
  marketType, params = self.handle_market_type_and_params('fetchOpenOrders', market, params)
4290
+ subType = None
4291
+ subType, params = self.handle_sub_type_and_params('fetchOpenOrders', market, params, 'linear')
4048
4292
  response = None
4049
4293
  if marketType == 'spot':
4050
4294
  if symbol is not None:
@@ -4056,7 +4300,7 @@ class htx(Exchange, ImplicitAPI):
4056
4300
  await self.load_accounts()
4057
4301
  for i in range(0, len(self.accounts)):
4058
4302
  account = self.accounts[i]
4059
- if account['type'] == 'spot':
4303
+ if self.safe_string(account, 'type') == 'spot':
4060
4304
  accountId = self.safe_string(account, 'id')
4061
4305
  if accountId is not None:
4062
4306
  break
@@ -4066,21 +4310,21 @@ class htx(Exchange, ImplicitAPI):
4066
4310
  params = self.omit(params, 'account-id')
4067
4311
  response = await self.spotPrivateGetV1OrderOpenOrders(self.extend(request, params))
4068
4312
  else:
4069
- if symbol is None:
4070
- raise ArgumentsRequired(self.id + ' fetchOpenOrders() requires a symbol argument')
4313
+ if symbol is not None:
4314
+ # raise ArgumentsRequired(self.id + ' fetchOpenOrders() requires a symbol argument')
4315
+ request['contract_code'] = market['id']
4071
4316
  if limit is not None:
4072
4317
  request['page_size'] = limit
4073
- request['contract_code'] = market['id']
4074
- stop = self.safe_value(params, 'stop')
4318
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
4075
4319
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
4076
4320
  trailing = self.safe_bool(params, 'trailing', False)
4077
- params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing'])
4078
- if market['linear']:
4321
+ params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
4322
+ if subType == 'linear':
4079
4323
  marginMode = None
4080
4324
  marginMode, params = self.handle_margin_mode_and_params('fetchOpenOrders', params)
4081
4325
  marginMode = 'cross' if (marginMode is None) else marginMode
4082
4326
  if marginMode == 'isolated':
4083
- if stop:
4327
+ if trigger:
4084
4328
  response = await self.contractPrivatePostLinearSwapApiV1SwapTriggerOpenorders(self.extend(request, params))
4085
4329
  elif stopLossTakeProfit:
4086
4330
  response = await self.contractPrivatePostLinearSwapApiV1SwapTpslOpenorders(self.extend(request, params))
@@ -4089,7 +4333,7 @@ class htx(Exchange, ImplicitAPI):
4089
4333
  else:
4090
4334
  response = await self.contractPrivatePostLinearSwapApiV1SwapOpenorders(self.extend(request, params))
4091
4335
  elif marginMode == 'cross':
4092
- if stop:
4336
+ if trigger:
4093
4337
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOpenorders(self.extend(request, params))
4094
4338
  elif stopLossTakeProfit:
4095
4339
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTpslOpenorders(self.extend(request, params))
@@ -4097,9 +4341,9 @@ class htx(Exchange, ImplicitAPI):
4097
4341
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTrackOpenorders(self.extend(request, params))
4098
4342
  else:
4099
4343
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossOpenorders(self.extend(request, params))
4100
- elif market['inverse']:
4101
- if market['swap']:
4102
- if stop:
4344
+ elif subType == 'inverse':
4345
+ if marketType == 'swap':
4346
+ if trigger:
4103
4347
  response = await self.contractPrivatePostSwapApiV1SwapTriggerOpenorders(self.extend(request, params))
4104
4348
  elif stopLossTakeProfit:
4105
4349
  response = await self.contractPrivatePostSwapApiV1SwapTpslOpenorders(self.extend(request, params))
@@ -4107,9 +4351,9 @@ class htx(Exchange, ImplicitAPI):
4107
4351
  response = await self.contractPrivatePostSwapApiV1SwapTrackOpenorders(self.extend(request, params))
4108
4352
  else:
4109
4353
  response = await self.contractPrivatePostSwapApiV1SwapOpenorders(self.extend(request, params))
4110
- elif market['future']:
4111
- request['symbol'] = market['settleId']
4112
- if stop:
4354
+ elif marketType == 'future':
4355
+ request['symbol'] = self.safe_string(market, 'settleId', 'usdt')
4356
+ if trigger:
4113
4357
  response = await self.contractPrivatePostApiV1ContractTriggerOpenorders(self.extend(request, params))
4114
4358
  elif stopLossTakeProfit:
4115
4359
  response = await self.contractPrivatePostApiV1ContractTpslOpenorders(self.extend(request, params))
@@ -4704,14 +4948,10 @@ class htx(Exchange, ImplicitAPI):
4704
4948
  cost = None
4705
4949
  amount = None
4706
4950
  if (type is not None) and (type.find('market') >= 0):
4707
- # for market orders amount is in quote currency, meaning it is the cost
4708
- if side == 'sell':
4709
- cost = self.safe_string(order, 'field-cash-amount')
4710
- else:
4711
- cost = self.safe_string(order, 'amount')
4951
+ cost = self.safe_string(order, 'field-cash-amount')
4712
4952
  else:
4713
4953
  amount = self.safe_string_2(order, 'volume', 'amount')
4714
- cost = self.safe_string_n(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']) # same typo
4954
+ cost = self.safe_string_n(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']) # same typo here
4715
4955
  filled = self.safe_string_n(order, ['filled-amount', 'field-amount', 'trade_volume']) # typo in their API, filled amount
4716
4956
  price = self.safe_string_2(order, 'price', 'order_price')
4717
4957
  feeCost = self.safe_string_2(order, 'filled-fees', 'field-fees') # typo in their API, filled feeSide
@@ -4728,7 +4968,6 @@ class htx(Exchange, ImplicitAPI):
4728
4968
  'cost': feeCost,
4729
4969
  'currency': feeCurrency,
4730
4970
  }
4731
- stopPrice = self.safe_string_2(order, 'stop-price', 'trigger_price')
4732
4971
  average = self.safe_string(order, 'trade_avg_price')
4733
4972
  trades = self.safe_value(order, 'trades')
4734
4973
  reduceOnlyInteger = self.safe_integer(order, 'reduce_only')
@@ -4748,8 +4987,7 @@ class htx(Exchange, ImplicitAPI):
4748
4987
  'postOnly': None,
4749
4988
  'side': side,
4750
4989
  'price': price,
4751
- 'stopPrice': stopPrice,
4752
- 'triggerPrice': stopPrice,
4990
+ 'triggerPrice': self.safe_string_2(order, 'stop-price', 'trigger_price'),
4753
4991
  'average': average,
4754
4992
  'cost': cost,
4755
4993
  'amount': amount,
@@ -4764,7 +5002,9 @@ class htx(Exchange, ImplicitAPI):
4764
5002
  async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
4765
5003
  """
4766
5004
  create a market buy order by providing the symbol and cost
4767
- :see: https://www.htx.com/en-us/opend/newApiPages/?id=7ec4ee16-7773-11ed-9966-0242ac110003
5005
+
5006
+ https://www.htx.com/en-us/opend/newApiPages/?id=7ec4ee16-7773-11ed-9966-0242ac110003
5007
+
4768
5008
  :param str symbol: unified symbol of the market to create an order in
4769
5009
  :param float cost: how much you want to trade in units of the quote currency
4770
5010
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -4777,7 +5017,7 @@ class htx(Exchange, ImplicitAPI):
4777
5017
  params['createMarketBuyOrderRequiresPrice'] = False
4778
5018
  return await self.create_order(symbol, 'market', 'buy', cost, None, params)
4779
5019
 
4780
- async def create_trailing_percent_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingPercent=None, trailingTriggerPrice=None, params={}) -> Order:
5020
+ async def create_trailing_percent_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingPercent: Num = None, trailingTriggerPrice: Num = None, params={}) -> Order:
4781
5021
  """
4782
5022
  create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
4783
5023
  :param str symbol: unified symbol of the market to create an order in
@@ -4800,13 +5040,13 @@ class htx(Exchange, ImplicitAPI):
4800
5040
 
4801
5041
  async def create_spot_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
4802
5042
  """
4803
- * @ignore
5043
+ @ignore
4804
5044
  helper function to build request
4805
5045
  :param str symbol: unified symbol of the market to create an order in
4806
5046
  :param str type: 'market' or 'limit'
4807
5047
  :param str side: 'buy' or 'sell'
4808
5048
  :param float amount: how much you want to trade in units of the base currency
4809
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
5049
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
4810
5050
  :param dict [params]: extra parameters specific to the exchange API endpoint
4811
5051
  :param str [params.timeInForce]: supports 'IOC' and 'FOK'
4812
5052
  :param float [params.cost]: the quote quantity that can be used alternative for the amount for market buy orders
@@ -4833,15 +5073,15 @@ class htx(Exchange, ImplicitAPI):
4833
5073
  orderType = type.replace('buy-', '')
4834
5074
  orderType = orderType.replace('sell-', '')
4835
5075
  options = self.safe_value(self.options, market['type'], {})
4836
- stopPrice = self.safe_string_2(params, 'stopPrice', 'stop-price')
4837
- if stopPrice is None:
5076
+ triggerPrice = self.safe_string_n(params, ['triggerPrice', 'stopPrice', 'stop-price'])
5077
+ if triggerPrice is None:
4838
5078
  stopOrderTypes = self.safe_value(options, 'stopOrderTypes', {})
4839
5079
  if orderType in stopOrderTypes:
4840
- raise ArgumentsRequired(self.id + ' createOrder() requires a stopPrice or a stop-price parameter for a stop order')
5080
+ raise ArgumentsRequired(self.id + ' createOrder() requires a triggerPrice for a trigger order')
4841
5081
  else:
4842
5082
  defaultOperator = 'lte' if (side == 'sell') else 'gte'
4843
5083
  stopOperator = self.safe_string(params, 'operator', defaultOperator)
4844
- request['stop-price'] = self.price_to_precision(symbol, stopPrice)
5084
+ request['stop-price'] = self.price_to_precision(symbol, triggerPrice)
4845
5085
  request['operator'] = stopOperator
4846
5086
  if (orderType == 'limit') or (orderType == 'limit-fok'):
4847
5087
  orderType = 'stop-' + orderType
@@ -4899,18 +5139,18 @@ class htx(Exchange, ImplicitAPI):
4899
5139
  limitOrderTypes = self.safe_value(options, 'limitOrderTypes', {})
4900
5140
  if orderType in limitOrderTypes:
4901
5141
  request['price'] = self.price_to_precision(symbol, price)
4902
- params = self.omit(params, ['stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator', 'timeInForce'])
5142
+ params = self.omit(params, ['triggerPrice', 'stopPrice', 'stop-price', 'clientOrderId', 'client-order-id', 'operator', 'timeInForce'])
4903
5143
  return self.extend(request, params)
4904
5144
 
4905
5145
  def create_contract_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
4906
5146
  """
4907
- * @ignore
5147
+ @ignore
4908
5148
  helper function to build request
4909
5149
  :param str symbol: unified symbol of the market to create an order in
4910
5150
  :param str type: 'market' or 'limit'
4911
5151
  :param str side: 'buy' or 'sell'
4912
5152
  :param float amount: how much you want to trade in units of the base currency
4913
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
5153
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
4914
5154
  :param dict [params]: extra parameters specific to the exchange API endpoint
4915
5155
  :param str [params.timeInForce]: supports 'IOC' and 'FOK'
4916
5156
  :param float [params.trailingPercent]: *contract only* the percent to trail away from the current market price
@@ -4932,16 +5172,16 @@ class htx(Exchange, ImplicitAPI):
4932
5172
  type = 'fok'
4933
5173
  elif timeInForce == 'IOC':
4934
5174
  type = 'ioc'
4935
- triggerPrice = self.safe_number_2(params, 'stopPrice', 'trigger_price')
5175
+ triggerPrice = self.safe_number_n(params, ['triggerPrice', 'stopPrice', 'trigger_price'])
4936
5176
  stopLossTriggerPrice = self.safe_number_2(params, 'stopLossPrice', 'sl_trigger_price')
4937
5177
  takeProfitTriggerPrice = self.safe_number_2(params, 'takeProfitPrice', 'tp_trigger_price')
4938
5178
  trailingPercent = self.safe_string_2(params, 'trailingPercent', 'callback_rate')
4939
5179
  trailingTriggerPrice = self.safe_number(params, 'trailingTriggerPrice', price)
4940
5180
  isTrailingPercentOrder = trailingPercent is not None
4941
- isStop = triggerPrice is not None
5181
+ isTrigger = triggerPrice is not None
4942
5182
  isStopLossTriggerOrder = stopLossTriggerPrice is not None
4943
5183
  isTakeProfitTriggerOrder = takeProfitTriggerPrice is not None
4944
- if isStop:
5184
+ if isTrigger:
4945
5185
  triggerType = self.safe_string_2(params, 'triggerType', 'trigger_type', 'le')
4946
5186
  request['trigger_type'] = triggerType
4947
5187
  request['trigger_price'] = self.price_to_precision(symbol, triggerPrice)
@@ -4970,38 +5210,48 @@ class htx(Exchange, ImplicitAPI):
4970
5210
  params = self.omit(params, ['clientOrderId'])
4971
5211
  if type == 'limit' or type == 'ioc' or type == 'fok' or type == 'post_only':
4972
5212
  request['price'] = self.price_to_precision(symbol, price)
5213
+ reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only', False)
4973
5214
  if not isStopLossTriggerOrder and not isTakeProfitTriggerOrder:
4974
- reduceOnly = self.safe_value_2(params, 'reduceOnly', 'reduce_only', False)
4975
5215
  if reduceOnly:
4976
5216
  request['reduce_only'] = 1
4977
5217
  request['lever_rate'] = self.safe_integer_n(params, ['leverRate', 'lever_rate', 'leverage'], 1)
4978
5218
  if not isTrailingPercentOrder:
4979
5219
  request['order_price_type'] = type
5220
+ hedged = self.safe_bool(params, 'hedged', False)
5221
+ if hedged:
5222
+ if reduceOnly:
5223
+ request['offset'] = 'close'
5224
+ else:
5225
+ request['offset'] = 'open'
4980
5226
  broker = self.safe_value(self.options, 'broker', {})
4981
5227
  brokerId = self.safe_string(broker, 'id')
4982
5228
  request['channel_code'] = brokerId
4983
- params = self.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice'])
5229
+ params = self.omit(params, ['reduceOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice', 'hedged'])
4984
5230
  return self.extend(request, params)
4985
5231
 
4986
5232
  async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
4987
5233
  """
4988
5234
  create a trade order
4989
- :see: https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order # spot, margin
4990
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order # coin-m swap
4991
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-trigger-order # coin-m swap trigger
4992
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-an-order # usdt-m swap cross
4993
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-trigger-order # usdt-m swap cross trigger
4994
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order # usdt-m swap isolated
4995
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-trigger-order # usdt-m swap isolated trigger
4996
- :see: https://huobiapi.github.io/docs/dm/v1/en/#place-an-order # coin-m futures
4997
- :see: https://huobiapi.github.io/docs/dm/v1/en/#place-trigger-order # coin-m futures contract trigger
5235
+
5236
+ https://huobiapi.github.io/docs/spot/v1/en/#place-a-new-order # spot, margin
5237
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-an-order # coin-m swap
5238
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-trigger-order # coin-m swap trigger
5239
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-an-order # usdt-m swap cross
5240
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-trigger-order # usdt-m swap cross trigger
5241
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order # usdt-m swap isolated
5242
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-trigger-order # usdt-m swap isolated trigger
5243
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-set-a-take-profit-and-stop-loss-order-for-an-existing-position
5244
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-set-a-take-profit-and-stop-loss-order-for-an-existing-position
5245
+ https://huobiapi.github.io/docs/dm/v1/en/#place-an-order # coin-m futures
5246
+ https://huobiapi.github.io/docs/dm/v1/en/#place-trigger-order # coin-m futures contract trigger
5247
+
4998
5248
  :param str symbol: unified symbol of the market to create an order in
4999
5249
  :param str type: 'market' or 'limit'
5000
5250
  :param str side: 'buy' or 'sell'
5001
5251
  :param float amount: how much you want to trade in units of the base currency
5002
- :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
5252
+ :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
5003
5253
  :param dict [params]: extra parameters specific to the exchange API endpoint
5004
- :param float [params.stopPrice]: the price a trigger order is triggered at
5254
+ :param float [params.triggerPrice]: the price a trigger order is triggered at
5005
5255
  :param str [params.triggerType]: *contract trigger orders only* ge: greater than or equal to, le: less than or equal to
5006
5256
  :param float [params.stopLossPrice]: *contract only* the price a stop-loss order is triggered at
5007
5257
  :param float [params.takeProfitPrice]: *contract only* the price a take-profit order is triggered at
@@ -5013,16 +5263,17 @@ class htx(Exchange, ImplicitAPI):
5013
5263
  :param float [params.cost]: *spot market buy only* the quote quantity that can be used alternative for the amount
5014
5264
  :param float [params.trailingPercent]: *contract only* the percent to trail away from the current market price
5015
5265
  :param float [params.trailingTriggerPrice]: *contract only* the price to trigger a trailing order, default uses the price argument
5266
+ :param bool [params.hedged]: *contract only* True for hedged mode, False for one way mode, default is False
5016
5267
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
5017
5268
  """
5018
5269
  await self.load_markets()
5019
5270
  market = self.market(symbol)
5020
- triggerPrice = self.safe_number_2(params, 'stopPrice', 'trigger_price')
5271
+ triggerPrice = self.safe_number_n(params, ['triggerPrice', 'stopPrice', 'trigger_price'])
5021
5272
  stopLossTriggerPrice = self.safe_number_2(params, 'stopLossPrice', 'sl_trigger_price')
5022
5273
  takeProfitTriggerPrice = self.safe_number_2(params, 'takeProfitPrice', 'tp_trigger_price')
5023
5274
  trailingPercent = self.safe_number(params, 'trailingPercent')
5024
5275
  isTrailingPercentOrder = trailingPercent is not None
5025
- isStop = triggerPrice is not None
5276
+ isTrigger = triggerPrice is not None
5026
5277
  isStopLossTriggerOrder = stopLossTriggerPrice is not None
5027
5278
  isTakeProfitTriggerOrder = takeProfitTriggerPrice is not None
5028
5279
  response = None
@@ -5038,7 +5289,7 @@ class htx(Exchange, ImplicitAPI):
5038
5289
  marginMode, contractRequest = self.handle_margin_mode_and_params('createOrder', contractRequest)
5039
5290
  marginMode = 'cross' if (marginMode is None) else marginMode
5040
5291
  if marginMode == 'isolated':
5041
- if isStop:
5292
+ if isTrigger:
5042
5293
  response = await self.contractPrivatePostLinearSwapApiV1SwapTriggerOrder(contractRequest)
5043
5294
  elif isStopLossTriggerOrder or isTakeProfitTriggerOrder:
5044
5295
  response = await self.contractPrivatePostLinearSwapApiV1SwapTpslOrder(contractRequest)
@@ -5047,7 +5298,7 @@ class htx(Exchange, ImplicitAPI):
5047
5298
  else:
5048
5299
  response = await self.contractPrivatePostLinearSwapApiV1SwapOrder(contractRequest)
5049
5300
  elif marginMode == 'cross':
5050
- if isStop:
5301
+ if isTrigger:
5051
5302
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerOrder(contractRequest)
5052
5303
  elif isStopLossTriggerOrder or isTakeProfitTriggerOrder:
5053
5304
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder(contractRequest)
@@ -5060,7 +5311,7 @@ class htx(Exchange, ImplicitAPI):
5060
5311
  if offset is None:
5061
5312
  raise ArgumentsRequired(self.id + ' createOrder() requires an extra parameter params["offset"] to be set to "open" or "close" when placing orders in inverse markets')
5062
5313
  if market['swap']:
5063
- if isStop:
5314
+ if isTrigger:
5064
5315
  response = await self.contractPrivatePostSwapApiV1SwapTriggerOrder(contractRequest)
5065
5316
  elif isStopLossTriggerOrder or isTakeProfitTriggerOrder:
5066
5317
  response = await self.contractPrivatePostSwapApiV1SwapTpslOrder(contractRequest)
@@ -5069,7 +5320,7 @@ class htx(Exchange, ImplicitAPI):
5069
5320
  else:
5070
5321
  response = await self.contractPrivatePostSwapApiV1SwapOrder(contractRequest)
5071
5322
  elif market['future']:
5072
- if isStop:
5323
+ if isTrigger:
5073
5324
  response = await self.contractPrivatePostApiV1ContractTriggerOrder(contractRequest)
5074
5325
  elif isStopLossTriggerOrder or isTakeProfitTriggerOrder:
5075
5326
  response = await self.contractPrivatePostApiV1ContractTpslOrder(contractRequest)
@@ -5143,11 +5394,13 @@ class htx(Exchange, ImplicitAPI):
5143
5394
  async def create_orders(self, orders: List[OrderRequest], params={}):
5144
5395
  """
5145
5396
  create a list of trade orders
5146
- :see: https://huobiapi.github.io/docs/spot/v1/en/#place-a-batch-of-orders
5147
- :see: https://huobiapi.github.io/docs/dm/v1/en/#place-a-batch-of-orders
5148
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-a-batch-of-orders
5149
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-a-batch-of-orders
5150
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-a-batch-of-orders
5397
+
5398
+ https://huobiapi.github.io/docs/spot/v1/en/#place-a-batch-of-orders
5399
+ https://huobiapi.github.io/docs/dm/v1/en/#place-a-batch-of-orders
5400
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-a-batch-of-orders
5401
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-a-batch-of-orders
5402
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-a-batch-of-orders
5403
+
5151
5404
  :param Array orders: list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
5152
5405
  :param dict [params]: extra parameters specific to the exchange API endpoint
5153
5406
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -5260,7 +5513,7 @@ class htx(Exchange, ImplicitAPI):
5260
5513
  :param str id: order id
5261
5514
  :param str symbol: unified symbol of the market the order was made in
5262
5515
  :param dict [params]: extra parameters specific to the exchange API endpoint
5263
- :param boolean [params.stop]: *contract only* if the order is a stop trigger order or not
5516
+ :param boolean [params.trigger]: *contract only* if the order is a trigger trigger order or not
5264
5517
  :param boolean [params.stopLossTakeProfit]: *contract only* if the order is a stop-loss or take-profit order
5265
5518
  :param boolean [params.trailing]: *contract only* set to True if you want to cancel a trailing order
5266
5519
  :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
@@ -5306,16 +5559,16 @@ class htx(Exchange, ImplicitAPI):
5306
5559
  request['symbol'] = market['settleId']
5307
5560
  else:
5308
5561
  request['contract_code'] = market['id']
5309
- stop = self.safe_value(params, 'stop')
5562
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
5310
5563
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
5311
5564
  trailing = self.safe_bool(params, 'trailing', False)
5312
- params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing'])
5565
+ params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
5313
5566
  if market['linear']:
5314
5567
  marginMode = None
5315
5568
  marginMode, params = self.handle_margin_mode_and_params('cancelOrder', params)
5316
5569
  marginMode = 'cross' if (marginMode is None) else marginMode
5317
5570
  if marginMode == 'isolated':
5318
- if stop:
5571
+ if trigger:
5319
5572
  response = await self.contractPrivatePostLinearSwapApiV1SwapTriggerCancel(self.extend(request, params))
5320
5573
  elif stopLossTakeProfit:
5321
5574
  response = await self.contractPrivatePostLinearSwapApiV1SwapTpslCancel(self.extend(request, params))
@@ -5324,7 +5577,7 @@ class htx(Exchange, ImplicitAPI):
5324
5577
  else:
5325
5578
  response = await self.contractPrivatePostLinearSwapApiV1SwapCancel(self.extend(request, params))
5326
5579
  elif marginMode == 'cross':
5327
- if stop:
5580
+ if trigger:
5328
5581
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancel(self.extend(request, params))
5329
5582
  elif stopLossTakeProfit:
5330
5583
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(self.extend(request, params))
@@ -5334,7 +5587,7 @@ class htx(Exchange, ImplicitAPI):
5334
5587
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossCancel(self.extend(request, params))
5335
5588
  elif market['inverse']:
5336
5589
  if market['swap']:
5337
- if stop:
5590
+ if trigger:
5338
5591
  response = await self.contractPrivatePostSwapApiV1SwapTriggerCancel(self.extend(request, params))
5339
5592
  elif stopLossTakeProfit:
5340
5593
  response = await self.contractPrivatePostSwapApiV1SwapTpslCancel(self.extend(request, params))
@@ -5343,7 +5596,7 @@ class htx(Exchange, ImplicitAPI):
5343
5596
  else:
5344
5597
  response = await self.contractPrivatePostSwapApiV1SwapCancel(self.extend(request, params))
5345
5598
  elif market['future']:
5346
- if stop:
5599
+ if trigger:
5347
5600
  response = await self.contractPrivatePostApiV1ContractTriggerCancel(self.extend(request, params))
5348
5601
  elif stopLossTakeProfit:
5349
5602
  response = await self.contractPrivatePostApiV1ContractTpslCancel(self.extend(request, params))
@@ -5383,7 +5636,7 @@ class htx(Exchange, ImplicitAPI):
5383
5636
  :param str[] ids: order ids
5384
5637
  :param str symbol: unified market symbol, default is None
5385
5638
  :param dict [params]: extra parameters specific to the exchange API endpoint
5386
- :param bool [params.stop]: *contract only* if the orders are stop trigger orders or not
5639
+ :param bool [params.trigger]: *contract only* if the orders are trigger trigger orders or not
5387
5640
  :param bool [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
5388
5641
  :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
5389
5642
  """
@@ -5433,22 +5686,22 @@ class htx(Exchange, ImplicitAPI):
5433
5686
  request['symbol'] = market['settleId']
5434
5687
  else:
5435
5688
  request['contract_code'] = market['id']
5436
- stop = self.safe_value(params, 'stop')
5689
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
5437
5690
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
5438
- params = self.omit(params, ['stop', 'stopLossTakeProfit'])
5691
+ params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trigger'])
5439
5692
  if market['linear']:
5440
5693
  marginMode = None
5441
5694
  marginMode, params = self.handle_margin_mode_and_params('cancelOrders', params)
5442
5695
  marginMode = 'cross' if (marginMode is None) else marginMode
5443
5696
  if marginMode == 'isolated':
5444
- if stop:
5697
+ if trigger:
5445
5698
  response = await self.contractPrivatePostLinearSwapApiV1SwapTriggerCancel(self.extend(request, params))
5446
5699
  elif stopLossTakeProfit:
5447
5700
  response = await self.contractPrivatePostLinearSwapApiV1SwapTpslCancel(self.extend(request, params))
5448
5701
  else:
5449
5702
  response = await self.contractPrivatePostLinearSwapApiV1SwapCancel(self.extend(request, params))
5450
5703
  elif marginMode == 'cross':
5451
- if stop:
5704
+ if trigger:
5452
5705
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancel(self.extend(request, params))
5453
5706
  elif stopLossTakeProfit:
5454
5707
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(self.extend(request, params))
@@ -5456,14 +5709,14 @@ class htx(Exchange, ImplicitAPI):
5456
5709
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossCancel(self.extend(request, params))
5457
5710
  elif market['inverse']:
5458
5711
  if market['swap']:
5459
- if stop:
5712
+ if trigger:
5460
5713
  response = await self.contractPrivatePostSwapApiV1SwapTriggerCancel(self.extend(request, params))
5461
5714
  elif stopLossTakeProfit:
5462
5715
  response = await self.contractPrivatePostSwapApiV1SwapTpslCancel(self.extend(request, params))
5463
5716
  else:
5464
5717
  response = await self.contractPrivatePostSwapApiV1SwapCancel(self.extend(request, params))
5465
5718
  elif market['future']:
5466
- if stop:
5719
+ if trigger:
5467
5720
  response = await self.contractPrivatePostApiV1ContractTriggerCancel(self.extend(request, params))
5468
5721
  elif stopLossTakeProfit:
5469
5722
  response = await self.contractPrivatePostApiV1ContractTpslCancel(self.extend(request, params))
@@ -5522,14 +5775,69 @@ class htx(Exchange, ImplicitAPI):
5522
5775
  # "ts": 1604367997451
5523
5776
  # }
5524
5777
  #
5525
- return response
5778
+ data = self.safe_dict(response, 'data')
5779
+ return self.parse_cancel_orders(data)
5780
+
5781
+ def parse_cancel_orders(self, orders):
5782
+ #
5783
+ # {
5784
+ # "success": [
5785
+ # "5983466"
5786
+ # ],
5787
+ # "failed": [
5788
+ # {
5789
+ # "err-msg": "Incorrect order state",
5790
+ # "order-state": 7,
5791
+ # "order-id": "",
5792
+ # "err-code": "order-orderstate-error",
5793
+ # "client-order-id": "first"
5794
+ # },
5795
+ # ...
5796
+ # ]
5797
+ # }
5798
+ #
5799
+ # {
5800
+ # "errors": [
5801
+ # {
5802
+ # "order_id": "769206471845261312",
5803
+ # "err_code": 1061,
5804
+ # "err_msg": "This order doesnt exist."
5805
+ # }
5806
+ # ],
5807
+ # "successes": "1258075374411399168,1258075393254871040"
5808
+ # }
5809
+ #
5810
+ successes = self.safe_string(orders, 'successes')
5811
+ success = None
5812
+ if successes is not None:
5813
+ success = successes.split(',')
5814
+ else:
5815
+ success = self.safe_list(orders, 'success', [])
5816
+ failed = self.safe_list_2(orders, 'errors', 'failed', [])
5817
+ result = []
5818
+ for i in range(0, len(success)):
5819
+ order = success[i]
5820
+ result.append(self.safe_order({
5821
+ 'info': order,
5822
+ 'id': order,
5823
+ 'status': 'canceled',
5824
+ }))
5825
+ for i in range(0, len(failed)):
5826
+ order = failed[i]
5827
+ result.append(self.safe_order({
5828
+ 'info': order,
5829
+ 'id': self.safe_string_2(order, 'order-id', 'order_id'),
5830
+ 'status': 'failed',
5831
+ 'clientOrderId': self.safe_string(order, 'client-order-id'),
5832
+ }))
5833
+ return result
5526
5834
 
5527
5835
  async def cancel_all_orders(self, symbol: Str = None, params={}):
5528
5836
  """
5529
5837
  cancel all open orders
5530
5838
  :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
5531
5839
  :param dict [params]: extra parameters specific to the exchange API endpoint
5532
- :param boolean [params.stop]: *contract only* if the orders are stop trigger orders or not
5840
+ :param boolean [params.trigger]: *contract only* if the orders are trigger trigger orders or not
5533
5841
  :param boolean [params.stopLossTakeProfit]: *contract only* if the orders are stop-loss or take-profit orders
5534
5842
  :param boolean [params.trailing]: *contract only* set to True if you want to cancel all trailing orders
5535
5843
  :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
@@ -5559,22 +5867,38 @@ class htx(Exchange, ImplicitAPI):
5559
5867
  if symbol is not None:
5560
5868
  request['symbol'] = market['id']
5561
5869
  response = await self.spotPrivatePostV1OrderOrdersBatchCancelOpenOrders(self.extend(request, params))
5870
+ #
5871
+ # {
5872
+ # "code": 200,
5873
+ # "data": {
5874
+ # "success-count": 2,
5875
+ # "failed-count": 0,
5876
+ # "next-id": 5454600
5877
+ # }
5878
+ # }
5879
+ #
5880
+ data = self.safe_dict(response, 'data')
5881
+ return [
5882
+ self.safe_order({
5883
+ 'info': data,
5884
+ }),
5885
+ ]
5562
5886
  else:
5563
5887
  if symbol is None:
5564
5888
  raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
5565
5889
  if market['future']:
5566
5890
  request['symbol'] = market['settleId']
5567
5891
  request['contract_code'] = market['id']
5568
- stop = self.safe_value(params, 'stop')
5892
+ trigger = self.safe_bool_2(params, 'stop', 'trigger')
5569
5893
  stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
5570
5894
  trailing = self.safe_bool(params, 'trailing', False)
5571
- params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing'])
5895
+ params = self.omit(params, ['stop', 'stopLossTakeProfit', 'trailing', 'trigger'])
5572
5896
  if market['linear']:
5573
5897
  marginMode = None
5574
5898
  marginMode, params = self.handle_margin_mode_and_params('cancelAllOrders', params)
5575
5899
  marginMode = 'cross' if (marginMode is None) else marginMode
5576
5900
  if marginMode == 'isolated':
5577
- if stop:
5901
+ if trigger:
5578
5902
  response = await self.contractPrivatePostLinearSwapApiV1SwapTriggerCancelall(self.extend(request, params))
5579
5903
  elif stopLossTakeProfit:
5580
5904
  response = await self.contractPrivatePostLinearSwapApiV1SwapTpslCancelall(self.extend(request, params))
@@ -5583,7 +5907,7 @@ class htx(Exchange, ImplicitAPI):
5583
5907
  else:
5584
5908
  response = await self.contractPrivatePostLinearSwapApiV1SwapCancelall(self.extend(request, params))
5585
5909
  elif marginMode == 'cross':
5586
- if stop:
5910
+ if trigger:
5587
5911
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancelall(self.extend(request, params))
5588
5912
  elif stopLossTakeProfit:
5589
5913
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancelall(self.extend(request, params))
@@ -5593,7 +5917,7 @@ class htx(Exchange, ImplicitAPI):
5593
5917
  response = await self.contractPrivatePostLinearSwapApiV1SwapCrossCancelall(self.extend(request, params))
5594
5918
  elif market['inverse']:
5595
5919
  if market['swap']:
5596
- if stop:
5920
+ if trigger:
5597
5921
  response = await self.contractPrivatePostSwapApiV1SwapTriggerCancelall(self.extend(request, params))
5598
5922
  elif stopLossTakeProfit:
5599
5923
  response = await self.contractPrivatePostSwapApiV1SwapTpslCancelall(self.extend(request, params))
@@ -5602,7 +5926,7 @@ class htx(Exchange, ImplicitAPI):
5602
5926
  else:
5603
5927
  response = await self.contractPrivatePostSwapApiV1SwapCancelall(self.extend(request, params))
5604
5928
  elif market['future']:
5605
- if stop:
5929
+ if trigger:
5606
5930
  response = await self.contractPrivatePostApiV1ContractTriggerCancelall(self.extend(request, params))
5607
5931
  elif stopLossTakeProfit:
5608
5932
  response = await self.contractPrivatePostApiV1ContractTpslCancelall(self.extend(request, params))
@@ -5612,35 +5936,25 @@ class htx(Exchange, ImplicitAPI):
5612
5936
  response = await self.contractPrivatePostApiV1ContractCancelall(self.extend(request, params))
5613
5937
  else:
5614
5938
  raise NotSupported(self.id + ' cancelAllOrders() does not support ' + marketType + ' markets')
5615
- #
5616
- # spot
5617
- #
5618
- # {
5619
- # "code": 200,
5620
- # "data": {
5621
- # "success-count": 2,
5622
- # "failed-count": 0,
5623
- # "next-id": 5454600
5624
- # }
5625
- # }
5626
- #
5627
- # future and swap
5628
- #
5629
- # {
5630
- # "status": "ok",
5631
- # "data": {
5632
- # "errors": [],
5633
- # "successes": "1104754904426696704"
5634
- # },
5635
- # "ts": "1683435723755"
5636
- # }
5637
- #
5638
- return response
5939
+ #
5940
+ # {
5941
+ # "status": "ok",
5942
+ # "data": {
5943
+ # "errors": [],
5944
+ # "successes": "1104754904426696704"
5945
+ # },
5946
+ # "ts": "1683435723755"
5947
+ # }
5948
+ #
5949
+ data = self.safe_dict(response, 'data')
5950
+ return self.parse_cancel_orders(data)
5639
5951
 
5640
5952
  async def cancel_all_orders_after(self, timeout: Int, params={}):
5641
5953
  """
5642
5954
  dead man's switch, cancel all orders after the given timeout
5643
- :see: https://huobiapi.github.io/docs/spot/v1/en/#dead-man-s-switch
5955
+
5956
+ https://huobiapi.github.io/docs/spot/v1/en/#dead-man-s-switch
5957
+
5644
5958
  :param number timeout: time in milliseconds, 0 represents cancel the timer
5645
5959
  :param dict [params]: extra parameters specific to the exchange API endpoint
5646
5960
  :returns dict: the api result
@@ -5688,8 +6002,11 @@ class htx(Exchange, ImplicitAPI):
5688
6002
  'info': depositAddress,
5689
6003
  }
5690
6004
 
5691
- async def fetch_deposit_addresses_by_network(self, code: str, params={}):
6005
+ async def fetch_deposit_addresses_by_network(self, code: str, params={}) -> List[DepositAddress]:
5692
6006
  """
6007
+
6008
+ https://www.htx.com/en-us/opend/newApiPages/?id=7ec50029-7773-11ed-9966-0242ac110003
6009
+
5693
6010
  fetch a dictionary of addresses for a currency, indexed by network
5694
6011
  :param str code: unified currency code of the currency for the deposit address
5695
6012
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -5718,9 +6035,12 @@ class htx(Exchange, ImplicitAPI):
5718
6035
  parsed = self.parse_deposit_addresses(data, [currency['code']], False)
5719
6036
  return self.index_by(parsed, 'network')
5720
6037
 
5721
- async def fetch_deposit_address(self, code: str, params={}):
6038
+ async def fetch_deposit_address(self, code: str, params={}) -> DepositAddress:
5722
6039
  """
5723
6040
  fetch the deposit address for a currency associated with self account
6041
+
6042
+ https://www.htx.com/en-us/opend/newApiPages/?id=7ec50029-7773-11ed-9966-0242ac110003
6043
+
5724
6044
  :param str code: unified currency code
5725
6045
  :param dict [params]: extra parameters specific to the exchange API endpoint
5726
6046
  :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
@@ -5766,6 +6086,9 @@ class htx(Exchange, ImplicitAPI):
5766
6086
 
5767
6087
  async def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
5768
6088
  """
6089
+
6090
+ https://www.htx.com/en-us/opend/newApiPages/?id=7ec4f050-7773-11ed-9966-0242ac110003
6091
+
5769
6092
  fetch all deposits made to an account
5770
6093
  :param str code: unified currency code
5771
6094
  :param int [since]: the earliest time in ms to fetch deposits for
@@ -5820,6 +6143,9 @@ class htx(Exchange, ImplicitAPI):
5820
6143
  async def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
5821
6144
  """
5822
6145
  fetch all withdrawals made from an account
6146
+
6147
+ https://huobiapi.github.io/docs/spot/v1/en/#search-for-existed-withdraws-and-deposits
6148
+
5823
6149
  :param str code: unified currency code
5824
6150
  :param int [since]: the earliest time in ms to fetch withdrawals for
5825
6151
  :param int [limit]: the maximum number of withdrawals structures to retrieve
@@ -5983,8 +6309,11 @@ class htx(Exchange, ImplicitAPI):
5983
6309
  }
5984
6310
  return self.safe_string(statuses, status, status)
5985
6311
 
5986
- async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
6312
+ async def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
5987
6313
  """
6314
+
6315
+ https://www.htx.com/en-us/opend/newApiPages/?id=7ec4cc41-7773-11ed-9966-0242ac110003
6316
+
5988
6317
  make a withdrawal
5989
6318
  :param str code: unified currency code
5990
6319
  :param float amount: the amount to withdraw
@@ -6013,7 +6342,7 @@ class htx(Exchange, ImplicitAPI):
6013
6342
  fee = self.safe_number(params, 'fee')
6014
6343
  if fee is None:
6015
6344
  currencies = await self.fetch_currencies()
6016
- self.currencies = self.deep_extend(self.currencies, currencies)
6345
+ self.currencies = self.map_to_safe_map(self.deep_extend(self.currencies, currencies))
6017
6346
  targetNetwork = self.safe_value(currency['networks'], networkCode, {})
6018
6347
  fee = self.safe_number(targetNetwork, 'fee')
6019
6348
  if fee is None:
@@ -6062,13 +6391,15 @@ class htx(Exchange, ImplicitAPI):
6062
6391
  async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
6063
6392
  """
6064
6393
  transfer currency internally between wallets on the same account
6065
- :see: https://huobiapi.github.io/docs/dm/v1/en/#transfer-margin-between-spot-account-and-future-account
6066
- :see: https://huobiapi.github.io/docs/spot/v1/en/#transfer-fund-between-spot-account-and-future-contract-account
6067
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-transfer-margin-between-spot-account-and-usdt-margined-contracts-account
6068
- :see: https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-spot-trading-account-to-cross-margin-account-cross
6069
- :see: https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-spot-trading-account-to-isolated-margin-account-isolated
6070
- :see: https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-cross-margin-account-to-spot-trading-account-cross
6071
- :see: https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-isolated-margin-account-to-spot-trading-account-isolated
6394
+
6395
+ https://huobiapi.github.io/docs/dm/v1/en/#transfer-margin-between-spot-account-and-future-account
6396
+ https://huobiapi.github.io/docs/spot/v1/en/#transfer-fund-between-spot-account-and-future-contract-account
6397
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-transfer-margin-between-spot-account-and-usdt-margined-contracts-account
6398
+ https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-spot-trading-account-to-cross-margin-account-cross
6399
+ https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-spot-trading-account-to-isolated-margin-account-isolated
6400
+ https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-cross-margin-account-to-spot-trading-account-cross
6401
+ https://huobiapi.github.io/docs/spot/v1/en/#transfer-asset-from-isolated-margin-account-to-spot-trading-account-isolated
6402
+
6072
6403
  :param str code: unified currency code
6073
6404
  :param float amount: amount to transfer
6074
6405
  :param str fromAccount: account to transfer from 'spot', 'future', 'swap'
@@ -6144,6 +6475,9 @@ class htx(Exchange, ImplicitAPI):
6144
6475
  async def fetch_isolated_borrow_rates(self, params={}) -> IsolatedBorrowRates:
6145
6476
  """
6146
6477
  fetch the borrow interest rates of all currencies
6478
+
6479
+ https://huobiapi.github.io/docs/spot/v1/en/#get-loan-interest-rate-and-quota-isolated
6480
+
6147
6481
  :param dict [params]: extra parameters specific to the exchange API endpoint
6148
6482
  :returns dict: a list of `isolated borrow rate structures <https://docs.ccxt.com/#/?id=isolated-borrow-rate-structure>`
6149
6483
  """
@@ -6181,7 +6515,7 @@ class htx(Exchange, ImplicitAPI):
6181
6515
  data = self.safe_value(response, 'data', [])
6182
6516
  return self.parse_isolated_borrow_rates(data)
6183
6517
 
6184
- def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
6518
+ def parse_isolated_borrow_rate(self, info: dict, market: Market = None) -> IsolatedBorrowRate:
6185
6519
  #
6186
6520
  # {
6187
6521
  # "symbol": "1inchusdt",
@@ -6226,8 +6560,10 @@ class htx(Exchange, ImplicitAPI):
6226
6560
 
6227
6561
  async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
6228
6562
  """
6229
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-historical-funding-rate
6230
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-historical-funding-rate
6563
+
6564
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-historical-funding-rate
6565
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-historical-funding-rate
6566
+
6231
6567
  fetches historical funding rate prices
6232
6568
  :param str symbol: unified symbol of the market to fetch the funding rate history for
6233
6569
  :param int [since]: not used by huobi, but filtered internally by ccxt
@@ -6241,12 +6577,16 @@ class htx(Exchange, ImplicitAPI):
6241
6577
  paginate = False
6242
6578
  paginate, params = self.handle_option_and_params(params, 'fetchFundingRateHistory', 'paginate')
6243
6579
  if paginate:
6244
- return await self.fetch_paginated_call_cursor('fetchFundingRateHistory', symbol, since, limit, params, 'page_index', 'current_page', 1, 50)
6580
+ return await self.fetch_paginated_call_cursor('fetchFundingRateHistory', symbol, since, limit, params, 'current_page', 'page_index', 1, 50)
6245
6581
  await self.load_markets()
6246
6582
  market = self.market(symbol)
6247
6583
  request: dict = {
6248
6584
  'contract_code': market['id'],
6249
6585
  }
6586
+ if limit is not None:
6587
+ request['page_size'] = limit
6588
+ else:
6589
+ request['page_size'] = 50 # max
6250
6590
  response = None
6251
6591
  if market['inverse']:
6252
6592
  response = await self.contractPublicGetSwapApiV1SwapHistoricalFundingRate(self.extend(request, params))
@@ -6296,7 +6636,7 @@ class htx(Exchange, ImplicitAPI):
6296
6636
  sorted = self.sort_by(rates, 'timestamp')
6297
6637
  return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
6298
6638
 
6299
- def parse_funding_rate(self, contract, market: Market = None):
6639
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
6300
6640
  #
6301
6641
  # {
6302
6642
  # "status": "ok",
@@ -6315,6 +6655,9 @@ class htx(Exchange, ImplicitAPI):
6315
6655
  nextFundingRate = self.safe_number(contract, 'estimated_rate')
6316
6656
  fundingTimestamp = self.safe_integer(contract, 'funding_time')
6317
6657
  nextFundingTimestamp = self.safe_integer(contract, 'next_funding_time')
6658
+ fundingTimeString = self.safe_string(contract, 'funding_time')
6659
+ nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
6660
+ millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
6318
6661
  marketId = self.safe_string(contract, 'contract_code')
6319
6662
  symbol = self.safe_symbol(marketId, market)
6320
6663
  return {
@@ -6335,11 +6678,26 @@ class htx(Exchange, ImplicitAPI):
6335
6678
  'previousFundingRate': None,
6336
6679
  'previousFundingTimestamp': None,
6337
6680
  'previousFundingDatetime': None,
6681
+ 'interval': self.parse_funding_interval(millisecondsInterval),
6338
6682
  }
6339
6683
 
6340
- async def fetch_funding_rate(self, symbol: str, params={}):
6684
+ def parse_funding_interval(self, interval):
6685
+ intervals: dict = {
6686
+ '3600000': '1h',
6687
+ '14400000': '4h',
6688
+ '28800000': '8h',
6689
+ '57600000': '16h',
6690
+ '86400000': '24h',
6691
+ }
6692
+ return self.safe_string(intervals, interval, interval)
6693
+
6694
+ async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
6341
6695
  """
6342
6696
  fetch the current funding rate
6697
+
6698
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-funding-rate
6699
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-funding-rate
6700
+
6343
6701
  :param str symbol: unified market symbol
6344
6702
  :param dict [params]: extra parameters specific to the exchange API endpoint
6345
6703
  :returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
@@ -6374,23 +6732,30 @@ class htx(Exchange, ImplicitAPI):
6374
6732
  result = self.safe_value(response, 'data', {})
6375
6733
  return self.parse_funding_rate(result, market)
6376
6734
 
6377
- async def fetch_funding_rates(self, symbols: Strings = None, params={}):
6735
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
6378
6736
  """
6379
6737
  fetch the funding rate for multiple markets
6738
+
6739
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-a-batch-of-funding-rate
6740
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-a-batch-of-funding-rate
6741
+
6380
6742
  :param str[]|None symbols: list of unified market symbols
6381
6743
  :param dict [params]: extra parameters specific to the exchange API endpoint
6382
- :returns dict: a dictionary of `funding rates structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexe by market symbols
6744
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
6383
6745
  """
6384
6746
  await self.load_markets()
6385
6747
  symbols = self.market_symbols(symbols)
6386
- options = self.safe_value(self.options, 'fetchFundingRates', {})
6387
- defaultSubType = self.safe_string(self.options, 'defaultSubType', 'inverse')
6388
- subType = self.safe_string(options, 'subType', defaultSubType)
6389
- subType = self.safe_string(params, 'subType', subType)
6748
+ defaultSubType = self.safe_string(self.options, 'defaultSubType', 'linear')
6749
+ subType = None
6750
+ subType, params = self.handle_option_and_params(params, 'fetchFundingRates', 'subType', defaultSubType)
6751
+ if symbols is not None:
6752
+ firstSymbol = self.safe_string(symbols, 0)
6753
+ market = self.market(firstSymbol)
6754
+ isLinear = market['linear']
6755
+ subType = 'linear' if isLinear else 'inverse'
6390
6756
  request: dict = {
6391
6757
  # 'contract_code': market['id'],
6392
6758
  }
6393
- params = self.omit(params, 'subType')
6394
6759
  response = None
6395
6760
  if subType == 'linear':
6396
6761
  response = await self.contractPublicGetLinearSwapApiV1SwapBatchFundingRate(self.extend(request, params))
@@ -6417,12 +6782,15 @@ class htx(Exchange, ImplicitAPI):
6417
6782
  # }
6418
6783
  #
6419
6784
  data = self.safe_value(response, 'data', [])
6420
- result = self.parse_funding_rates(data)
6421
- return self.filter_by_array(result, 'symbol', symbols)
6785
+ return self.parse_funding_rates(data, symbols)
6422
6786
 
6423
- async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
6787
+ async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[BorrowInterest]:
6424
6788
  """
6425
6789
  fetch the interest owed by the user for borrowing currency for margin trading
6790
+
6791
+ https://huobiapi.github.io/docs/spot/v1/en/#search-past-margin-orders-cross
6792
+ https://huobiapi.github.io/docs/spot/v1/en/#search-past-margin-orders-isolated
6793
+
6426
6794
  :param str code: unified currency code
6427
6795
  :param str symbol: unified market symbol when fetch interest in isolated markets
6428
6796
  :param int [since]: the earliest time in ms to fetch borrrow interest for
@@ -6477,7 +6845,7 @@ class htx(Exchange, ImplicitAPI):
6477
6845
  interest = self.parse_borrow_interests(data, market)
6478
6846
  return self.filter_by_currency_since_limit(interest, code, since, limit)
6479
6847
 
6480
- def parse_borrow_interest(self, info: dict, market: Market = None):
6848
+ def parse_borrow_interest(self, info: dict, market: Market = None) -> BorrowInterest:
6481
6849
  # isolated
6482
6850
  # {
6483
6851
  # "interest-rate":"0.000040830000000000",
@@ -6525,18 +6893,20 @@ class htx(Exchange, ImplicitAPI):
6525
6893
  symbol = self.safe_string(market, 'symbol')
6526
6894
  timestamp = self.safe_integer(info, 'accrued-at')
6527
6895
  return {
6528
- 'account': symbol if (marginMode == 'isolated') else 'cross', # deprecated
6896
+ 'info': info,
6529
6897
  'symbol': symbol,
6530
- 'marginMode': marginMode,
6531
6898
  'currency': self.safe_currency_code(self.safe_string(info, 'currency')),
6532
6899
  'interest': self.safe_number(info, 'interest-amount'),
6533
6900
  'interestRate': self.safe_number(info, 'interest-rate'),
6534
6901
  'amountBorrowed': self.safe_number(info, 'loan-amount'),
6902
+ 'marginMode': marginMode,
6535
6903
  'timestamp': timestamp, # Interest accrued time
6536
6904
  'datetime': self.iso8601(timestamp),
6537
- 'info': info,
6538
6905
  }
6539
6906
 
6907
+ def nonce(self):
6908
+ return self.milliseconds() - self.options['timeDifference']
6909
+
6540
6910
  def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
6541
6911
  url = '/'
6542
6912
  query = self.omit(params, self.extract_params(path))
@@ -6549,7 +6919,7 @@ class htx(Exchange, ImplicitAPI):
6549
6919
  url += '/' + self.implode_params(path, params)
6550
6920
  if api == 'private' or api == 'v2Private':
6551
6921
  self.check_required_credentials()
6552
- timestamp = self.ymdhms(self.milliseconds(), 'T')
6922
+ timestamp = self.ymdhms(self.nonce(), 'T')
6553
6923
  request: dict = {
6554
6924
  'SignatureMethod': 'HmacSHA256',
6555
6925
  'SignatureVersion': '2',
@@ -6559,7 +6929,7 @@ class htx(Exchange, ImplicitAPI):
6559
6929
  if method != 'POST':
6560
6930
  request = self.extend(request, query)
6561
6931
  sortedRequest = self.keysort(request)
6562
- auth = self.urlencode(sortedRequest)
6932
+ auth = self.urlencode(sortedRequest, True) # True is a go only requirment
6563
6933
  # unfortunately, PHP demands double quotes for the escaped newline symbol
6564
6934
  payload = "\n".join([method, self.hostname, url, auth]) # eslint-disable-line quotes
6565
6935
  signature = self.hmac(self.encode(payload), self.encode(self.secret), hashlib.sha256, 'base64')
@@ -6613,17 +6983,19 @@ class htx(Exchange, ImplicitAPI):
6613
6983
  clientOrderId = self.safe_string(params, 'client-order-id')
6614
6984
  if clientOrderId is None:
6615
6985
  params['client-order-id'] = id + self.uuid()
6616
- timestamp = self.ymdhms(self.milliseconds(), 'T')
6986
+ timestamp = self.ymdhms(self.nonce(), 'T')
6617
6987
  request: dict = {
6618
6988
  'SignatureMethod': 'HmacSHA256',
6619
6989
  'SignatureVersion': '2',
6620
6990
  'AccessKeyId': self.apiKey,
6621
6991
  'Timestamp': timestamp,
6622
6992
  }
6623
- if method != 'POST':
6624
- request = self.extend(request, query)
6993
+ # sorting needs such flow exactly, before urlencoding(more at: https://github.com/ccxt/ccxt/issues/24930 )
6625
6994
  request = self.keysort(request)
6626
- auth = self.urlencode(request)
6995
+ if method != 'POST':
6996
+ sortedQuery = self.keysort(query)
6997
+ request = self.extend(request, sortedQuery)
6998
+ auth = self.urlencode(request, True).replace('%2c', '%2C') # in c# it manually needs to be uppercased
6627
6999
  # unfortunately, PHP demands double quotes for the escaped newline symbol
6628
7000
  payload = "\n".join([method, hostname, url, auth]) # eslint-disable-line quotes
6629
7001
  signature = self.hmac(self.encode(payload), self.encode(self.secret), hashlib.sha256, 'base64')
@@ -6651,6 +7023,7 @@ class htx(Exchange, ImplicitAPI):
6651
7023
  if 'status' in response:
6652
7024
  #
6653
7025
  # {"status":"error","err-code":"order-limitorder-amount-min-error","err-msg":"limit order amount error, min: `0.001`","data":null}
7026
+ # {"status":"ok","data":{"errors":[{"order_id":"1349442392365359104","err_code":1061,"err_msg":"The order does not exist."}],"successes":""},"ts":1741773744526}
6654
7027
  #
6655
7028
  status = self.safe_string(response, 'status')
6656
7029
  if status == 'error':
@@ -6666,14 +7039,25 @@ class htx(Exchange, ImplicitAPI):
6666
7039
  feedback = self.id + ' ' + body
6667
7040
  code = self.safe_string(response, 'code')
6668
7041
  self.throw_exactly_matched_exception(self.exceptions['exact'], code, feedback)
7042
+ data = self.safe_dict(response, 'data')
7043
+ errorsList = self.safe_list(data, 'errors')
7044
+ if errorsList is not None:
7045
+ first = self.safe_dict(errorsList, 0)
7046
+ errcode = self.safe_string(first, 'err_code')
7047
+ errmessage = self.safe_string(first, 'err_msg')
7048
+ feedBack = self.id + ' ' + body
7049
+ self.throw_exactly_matched_exception(self.exceptions['exact'], errcode, feedBack)
7050
+ self.throw_exactly_matched_exception(self.exceptions['exact'], errmessage, feedBack)
6669
7051
  return None
6670
7052
 
6671
7053
  async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
6672
7054
  """
6673
7055
  fetch the history of funding payments paid and received on self account
6674
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-account-financial-records-via-multiple-fields-new # linear swaps
6675
- :see: https://huobiapi.github.io/docs/dm/v1/en/#query-financial-records-via-multiple-fields-new # coin-m futures
6676
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-financial-records-via-multiple-fields-new # coin-m swaps
7056
+
7057
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-account-financial-records-via-multiple-fields-new # linear swaps
7058
+ https://huobiapi.github.io/docs/dm/v1/en/#query-financial-records-via-multiple-fields-new # coin-m futures
7059
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-financial-records-via-multiple-fields-new # coin-m swaps
7060
+
6677
7061
  :param str symbol: unified market symbol
6678
7062
  :param int [since]: the earliest time in ms to fetch funding history for
6679
7063
  :param int [limit]: the maximum number of funding history structures to retrieve
@@ -6750,9 +7134,15 @@ class htx(Exchange, ImplicitAPI):
6750
7134
  data = self.safe_list(response, 'data', [])
6751
7135
  return self.parse_incomes(data, market, since, limit)
6752
7136
 
6753
- async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
7137
+ async def set_leverage(self, leverage: int, symbol: Str = None, params={}):
6754
7138
  """
6755
7139
  set the level of leverage for a market
7140
+
7141
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-leverage
7142
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-switch-leverage
7143
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#switch-leverage
7144
+ https://huobiapi.github.io/docs/dm/v1/en/#switch-leverage # Coin-m futures
7145
+
6756
7146
  :param float leverage: the rate of leverage
6757
7147
  :param str symbol: unified market symbol
6758
7148
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -6914,7 +7304,7 @@ class htx(Exchange, ImplicitAPI):
6914
7304
  'entryPrice': entryPrice,
6915
7305
  'collateral': self.parse_number(collateral),
6916
7306
  'side': side,
6917
- 'unrealizedProfit': unrealizedProfit,
7307
+ 'unrealizedPnl': unrealizedProfit,
6918
7308
  'leverage': self.parse_number(leverage),
6919
7309
  'percentage': self.parse_number(percentage),
6920
7310
  'marginMode': marginMode,
@@ -6935,10 +7325,16 @@ class htx(Exchange, ImplicitAPI):
6935
7325
  'takeProfitPrice': None,
6936
7326
  })
6937
7327
 
6938
- async def fetch_positions(self, symbols: Strings = None, params={}):
7328
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> List[Position]:
6939
7329
  """
6940
7330
  fetch all open positions
6941
- :param str[]|None symbols: list of unified market symbols
7331
+
7332
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-user-39-s-position-information
7333
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-user-s-position-information
7334
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-user-s-position-information
7335
+ https://huobiapi.github.io/docs/dm/v1/en/#query-user-s-position-information
7336
+
7337
+ :param str[] [symbols]: list of unified market symbols
6942
7338
  :param dict [params]: extra parameters specific to the exchange API endpoint
6943
7339
  :param str [params.subType]: 'linear' or 'inverse'
6944
7340
  :param str [params.type]: *inverse only* 'future', or 'swap'
@@ -7068,6 +7464,12 @@ class htx(Exchange, ImplicitAPI):
7068
7464
  async def fetch_position(self, symbol: str, params={}):
7069
7465
  """
7070
7466
  fetch data on a single open contract trade position
7467
+
7468
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-query-assets-and-positions
7469
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-query-assets-and-positions
7470
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-assets-and-positions
7471
+ https://huobiapi.github.io/docs/dm/v1/en/#query-assets-and-positions
7472
+
7071
7473
  :param str symbol: unified market symbol of the market the position is held in, default is None
7072
7474
  :param dict [params]: extra parameters specific to the exchange API endpoint
7073
7475
  :returns dict: a `position structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -7328,7 +7730,7 @@ class htx(Exchange, ImplicitAPI):
7328
7730
  }
7329
7731
  return self.safe_string(types, type, type)
7330
7732
 
7331
- def parse_ledger_entry(self, item: dict, currency: Currency = None):
7733
+ def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
7332
7734
  #
7333
7735
  # {
7334
7736
  # "accountId": 10000001,
@@ -7342,45 +7744,44 @@ class htx(Exchange, ImplicitAPI):
7342
7744
  # "transferee": 13496526
7343
7745
  # }
7344
7746
  #
7345
- id = self.safe_string(item, 'transactId')
7346
7747
  currencyId = self.safe_string(item, 'currency')
7347
7748
  code = self.safe_currency_code(currencyId, currency)
7348
- amount = self.safe_number(item, 'transactAmt')
7749
+ currency = self.safe_currency(currencyId, currency)
7750
+ id = self.safe_string(item, 'transactId')
7349
7751
  transferType = self.safe_string(item, 'transferType')
7350
- type = self.parse_ledger_entry_type(transferType)
7351
- direction = self.safe_string(item, 'direction')
7352
7752
  timestamp = self.safe_integer(item, 'transactTime')
7353
- datetime = self.iso8601(timestamp)
7354
7753
  account = self.safe_string(item, 'accountId')
7355
- return {
7754
+ return self.safe_ledger_entry({
7755
+ 'info': item,
7356
7756
  'id': id,
7357
- 'direction': direction,
7757
+ 'direction': self.safe_string(item, 'direction'),
7358
7758
  'account': account,
7359
7759
  'referenceId': id,
7360
7760
  'referenceAccount': account,
7361
- 'type': type,
7761
+ 'type': self.parse_ledger_entry_type(transferType),
7362
7762
  'currency': code,
7363
- 'amount': amount,
7763
+ 'amount': self.safe_number(item, 'transactAmt'),
7364
7764
  'timestamp': timestamp,
7365
- 'datetime': datetime,
7765
+ 'datetime': self.iso8601(timestamp),
7366
7766
  'before': None,
7367
7767
  'after': None,
7368
7768
  'status': None,
7369
7769
  'fee': None,
7370
- 'info': item,
7371
- }
7770
+ }, currency)
7372
7771
 
7373
- async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
7772
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
7374
7773
  """
7375
- :see: https://huobiapi.github.io/docs/spot/v1/en/#get-account-history
7376
- fetch the history of changes, actions done by the user or operations that altered balance of the user
7377
- :param str code: unified currency code, default is None
7774
+ fetch the history of changes, actions done by the user or operations that altered the balance of the user
7775
+
7776
+ https://huobiapi.github.io/docs/spot/v1/en/#get-account-history
7777
+
7778
+ :param str [code]: unified currency code, default is None
7378
7779
  :param int [since]: timestamp in ms of the earliest ledger entry, default is None
7379
- :param int [limit]: max number of ledger entrys to return, default is None
7780
+ :param int [limit]: max number of ledger entries to return, default is None
7380
7781
  :param dict [params]: extra parameters specific to the exchange API endpoint
7381
7782
  :param int [params.until]: the latest time in ms to fetch entries for
7382
- :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
7383
- :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
7783
+ :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)
7784
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
7384
7785
  """
7385
7786
  await self.load_markets()
7386
7787
  paginate = False
@@ -7481,92 +7882,41 @@ class htx(Exchange, ImplicitAPI):
7481
7882
  # ]
7482
7883
  # }
7483
7884
  #
7484
- data = self.safe_list(response, 'data')
7885
+ data = self.safe_list(response, 'data', [])
7485
7886
  return self.parse_leverage_tiers(data, symbols, 'contract_code')
7486
7887
 
7487
- async def fetch_market_leverage_tiers(self, symbol: str, params={}) -> List[LeverageTier]:
7488
- """
7489
- retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market
7490
- :param str symbol: unified market symbol
7491
- :param dict [params]: extra parameters specific to the exchange API endpoint
7492
- :returns dict: a `leverage tiers structure <https://docs.ccxt.com/#/?id=leverage-tiers-structure>`
7493
- """
7494
- await self.load_markets()
7495
- request: dict = {}
7496
- if symbol is not None:
7497
- market = self.market(symbol)
7498
- if not market['contract']:
7499
- raise BadRequest(self.id + ' fetchMarketLeverageTiers() symbol supports contract markets only')
7500
- request['contract_code'] = market['id']
7501
- response = await self.contractPublicGetLinearSwapApiV1SwapAdjustfactor(self.extend(request, params))
7502
- #
7503
- # {
7504
- # "status": "ok",
7505
- # "data": [
7506
- # {
7507
- # "symbol": "MANA",
7508
- # "contract_code": "MANA-USDT",
7509
- # "margin_mode": "isolated",
7510
- # "trade_partition": "USDT",
7511
- # "list": [
7512
- # {
7513
- # "lever_rate": 75,
7514
- # "ladders": [
7515
- # {
7516
- # "ladder": 0,
7517
- # "min_size": 0,
7518
- # "max_size": 999,
7519
- # "adjust_factor": 0.7
7520
- # },
7521
- # ...
7522
- # ]
7523
- # }
7524
- # ...
7525
- # ]
7526
- # },
7527
- # ...
7528
- # ]
7529
- # }
7530
- #
7531
- data = self.safe_value(response, 'data')
7532
- tiers = self.parse_leverage_tiers(data, [symbol], 'contract_code')
7533
- return self.safe_value(tiers, symbol)
7534
-
7535
- def parse_leverage_tiers(self, response, symbols: Strings = None, marketIdKey=None):
7536
- result: dict = {}
7537
- for i in range(0, len(response)):
7538
- item = response[i]
7539
- list = self.safe_value(item, 'list', [])
7540
- tiers = []
7541
- currency = self.safe_string(item, 'trade_partition')
7542
- id = self.safe_string(item, marketIdKey)
7543
- symbol = self.safe_symbol(id)
7544
- if self.in_array(symbol, symbols):
7545
- for j in range(0, len(list)):
7546
- obj = list[j]
7547
- leverage = self.safe_string(obj, 'lever_rate')
7548
- ladders = self.safe_value(obj, 'ladders', [])
7549
- for k in range(0, len(ladders)):
7550
- bracket = ladders[k]
7551
- adjustFactor = self.safe_string(bracket, 'adjust_factor')
7552
- tiers.append({
7553
- 'tier': self.safe_integer(bracket, 'ladder'),
7554
- 'currency': self.safe_currency_code(currency),
7555
- 'minNotional': self.safe_number(bracket, 'min_size'),
7556
- 'maxNotional': self.safe_number(bracket, 'max_size'),
7557
- 'maintenanceMarginRate': self.parse_number(Precise.string_div(adjustFactor, leverage)),
7558
- 'maxLeverage': self.parse_number(leverage),
7559
- 'info': bracket,
7560
- })
7561
- result[symbol] = tiers
7562
- return result
7888
+ def parse_market_leverage_tiers(self, info, market: Market = None) -> List[LeverageTier]:
7889
+ currencyId = self.safe_string(info, 'trade_partition')
7890
+ marketId = self.safe_string(info, 'contract_code')
7891
+ tiers = []
7892
+ brackets = self.safe_list(info, 'list', [])
7893
+ for i in range(0, len(brackets)):
7894
+ item = brackets[i]
7895
+ leverage = self.safe_string(item, 'lever_rate')
7896
+ ladders = self.safe_list(item, 'ladders', [])
7897
+ for k in range(0, len(ladders)):
7898
+ bracket = ladders[k]
7899
+ adjustFactor = self.safe_string(bracket, 'adjust_factor')
7900
+ tiers.append({
7901
+ 'tier': self.safe_integer(bracket, 'ladder'),
7902
+ 'symbol': self.safe_symbol(marketId, market, None, 'swap'),
7903
+ 'currency': self.safe_currency_code(currencyId),
7904
+ 'minNotional': self.safe_number(bracket, 'min_size'),
7905
+ 'maxNotional': self.safe_number(bracket, 'max_size'),
7906
+ 'maintenanceMarginRate': self.parse_number(Precise.string_div(adjustFactor, leverage)),
7907
+ 'maxLeverage': self.parse_number(leverage),
7908
+ 'info': bracket,
7909
+ })
7910
+ return tiers
7563
7911
 
7564
7912
  async def fetch_open_interest_history(self, symbol: str, timeframe='1h', since: Int = None, limit: Int = None, params={}):
7565
7913
  """
7566
7914
  Retrieves the open interest history of a currency
7567
- :see: https://huobiapi.github.io/docs/dm/v1/en/#query-information-on-open-interest
7568
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-information-on-open-interest
7569
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-information-on-open-interest
7915
+
7916
+ https://huobiapi.github.io/docs/dm/v1/en/#query-information-on-open-interest
7917
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-information-on-open-interest
7918
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-information-on-open-interest
7919
+
7570
7920
  :param str symbol: Unified CCXT market symbol
7571
7921
  :param str timeframe: '1h', '4h', '12h', or '1d'
7572
7922
  :param int [since]: Not used by huobi api, but response parsed by CCXT
@@ -7671,14 +8021,109 @@ class htx(Exchange, ImplicitAPI):
7671
8021
  #
7672
8022
  data = self.safe_value(response, 'data')
7673
8023
  tick = self.safe_list(data, 'tick')
7674
- return self.parse_open_interests(tick, market, since, limit)
8024
+ return self.parse_open_interests_history(tick, market, since, limit)
8025
+
8026
+ async def fetch_open_interests(self, symbols: Strings = None, params={}):
8027
+ """
8028
+ Retrieves the open interest for a list of symbols
8029
+
8030
+ https://huobiapi.github.io/docs/dm/v1/en/#get-contract-open-interest-information
8031
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-swap-open-interest-information
8032
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-swap-open-interest-information
8033
+
8034
+ :param str[] [symbols]: a list of unified CCXT market symbols
8035
+ :param dict [params]: exchange specific parameters
8036
+ :returns dict[]: a list of `open interest structures <https://docs.ccxt.com/#/?id=open-interest-structure>`
8037
+ """
8038
+ await self.load_markets()
8039
+ symbols = self.market_symbols(symbols)
8040
+ market = None
8041
+ if symbols is not None:
8042
+ symbolsLength = len(symbols)
8043
+ if symbolsLength > 0:
8044
+ first = self.safe_string(symbols, 0)
8045
+ market = self.market(first)
8046
+ request: dict = {}
8047
+ subType = None
8048
+ subType, params = self.handle_sub_type_and_params('fetchPositions', market, params, 'linear')
8049
+ marketType = None
8050
+ marketType, params = self.handle_market_type_and_params('fetchPositions', market, params)
8051
+ response = None
8052
+ if marketType == 'future':
8053
+ response = await self.contractPublicGetApiV1ContractOpenInterest(self.extend(request, params))
8054
+ #
8055
+ # {
8056
+ # "status": "ok",
8057
+ # "data": [
8058
+ # {
8059
+ # "volume": 118850.000000000000000000,
8060
+ # "amount": 635.502025211544374189,
8061
+ # "symbol": "BTC",
8062
+ # "contract_type": "self_week",
8063
+ # "contract_code": "BTC220930",
8064
+ # "trade_amount": 1470.9400749347598691119206024033947897351,
8065
+ # "trade_volume": 286286,
8066
+ # "trade_turnover": 28628600.000000000000000000
8067
+ # }
8068
+ # ],
8069
+ # "ts": 1664337928805
8070
+ # }
8071
+ #
8072
+ elif subType == 'inverse':
8073
+ response = await self.contractPublicGetSwapApiV1SwapOpenInterest(self.extend(request, params))
8074
+ #
8075
+ # {
8076
+ # "status": "ok",
8077
+ # "data": [
8078
+ # {
8079
+ # "volume": 518018.000000000000000000,
8080
+ # "amount": 2769.675777407074725180,
8081
+ # "symbol": "BTC",
8082
+ # "contract_code": "BTC-USD",
8083
+ # "trade_amount": 9544.4032080046491323463688602729806842458,
8084
+ # "trade_volume": 1848448,
8085
+ # "trade_turnover": 184844800.000000000000000000
8086
+ # }
8087
+ # ],
8088
+ # "ts": 1664337226028
8089
+ # }
8090
+ #
8091
+ else:
8092
+ request['contract_type'] = 'swap'
8093
+ response = await self.contractPublicGetLinearSwapApiV1SwapOpenInterest(self.extend(request, params))
8094
+ #
8095
+ # {
8096
+ # "status": "ok",
8097
+ # "data": [
8098
+ # {
8099
+ # "volume": 7192610.000000000000000000,
8100
+ # "amount": 7192.610000000000000000,
8101
+ # "symbol": "BTC",
8102
+ # "value": 134654290.332000000000000000,
8103
+ # "contract_code": "BTC-USDT",
8104
+ # "trade_amount": 70692.804,
8105
+ # "trade_volume": 70692804,
8106
+ # "trade_turnover": 1379302592.9518,
8107
+ # "business_type": "swap",
8108
+ # "pair": "BTC-USDT",
8109
+ # "contract_type": "swap",
8110
+ # "trade_partition": "USDT"
8111
+ # }
8112
+ # ],
8113
+ # "ts": 1664336503144
8114
+ # }
8115
+ #
8116
+ data = self.safe_list(response, 'data', [])
8117
+ return self.parse_open_interests(data, symbols)
7675
8118
 
7676
8119
  async def fetch_open_interest(self, symbol: str, params={}):
7677
8120
  """
7678
8121
  Retrieves the open interest of a currency
7679
- :see: https://huobiapi.github.io/docs/dm/v1/en/#get-contract-open-interest-information
7680
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-swap-open-interest-information
7681
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-swap-open-interest-information
8122
+
8123
+ https://huobiapi.github.io/docs/dm/v1/en/#get-contract-open-interest-information
8124
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-swap-open-interest-information
8125
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-swap-open-interest-information
8126
+
7682
8127
  :param str symbol: Unified CCXT market symbol
7683
8128
  :param dict [params]: exchange specific parameters
7684
8129
  :returns dict} an open interest structure{@link https://docs.ccxt.com/#/?id=open-interest-structure:
@@ -7829,8 +8274,9 @@ class htx(Exchange, ImplicitAPI):
7829
8274
  timestamp = self.safe_integer(interest, 'ts')
7830
8275
  amount = self.safe_number(interest, 'volume')
7831
8276
  value = self.safe_number(interest, 'value')
8277
+ marketId = self.safe_string(interest, 'contract_code')
7832
8278
  return self.safe_open_interest({
7833
- 'symbol': self.safe_string(market, 'symbol'),
8279
+ 'symbol': self.safe_symbol(marketId, market),
7834
8280
  'baseVolume': amount, # deprecated
7835
8281
  'quoteVolume': value, # deprecated
7836
8282
  'openInterestAmount': amount,
@@ -7843,8 +8289,10 @@ class htx(Exchange, ImplicitAPI):
7843
8289
  async def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
7844
8290
  """
7845
8291
  create a loan to borrow margin
7846
- :see: https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
7847
- :see: https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-cross
8292
+
8293
+ https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
8294
+ https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-cross
8295
+
7848
8296
  :param str symbol: unified market symbol, required for isolated margin
7849
8297
  :param str code: unified currency code of the currency to borrow
7850
8298
  :param float amount: the amount to borrow
@@ -7876,8 +8324,10 @@ class htx(Exchange, ImplicitAPI):
7876
8324
  async def borrow_cross_margin(self, code: str, amount: float, params={}):
7877
8325
  """
7878
8326
  create a loan to borrow margin
7879
- :see: https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
7880
- :see: https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-cross
8327
+
8328
+ https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-isolated
8329
+ https://huobiapi.github.io/docs/spot/v1/en/#request-a-margin-loan-cross
8330
+
7881
8331
  :param str code: unified currency code of the currency to borrow
7882
8332
  :param float amount: the amount to borrow
7883
8333
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -7906,10 +8356,12 @@ class htx(Exchange, ImplicitAPI):
7906
8356
  async def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
7907
8357
  """
7908
8358
  repay borrowed margin and interest
7909
- :see: https://huobiapi.github.io/docs/spot/v1/en/#repay-margin-loan-cross-isolated
8359
+
8360
+ https://huobiapi.github.io/docs/spot/v1/en/#repay-margin-loan-cross-isolated
8361
+
8362
+ :param str symbol: unified market symbol
7910
8363
  :param str code: unified currency code of the currency to repay
7911
8364
  :param float amount: the amount to repay
7912
- :param str symbol: unified market symbol
7913
8365
  :param dict [params]: extra parameters specific to the exchange API endpoint
7914
8366
  :returns dict: a `margin loan structure <https://docs.ccxt.com/#/?id=margin-loan-structure>`
7915
8367
  """
@@ -7944,7 +8396,9 @@ class htx(Exchange, ImplicitAPI):
7944
8396
  async def repay_cross_margin(self, code: str, amount, params={}):
7945
8397
  """
7946
8398
  repay borrowed margin and interest
7947
- :see: https://huobiapi.github.io/docs/spot/v1/en/#repay-margin-loan-cross-isolated
8399
+
8400
+ https://huobiapi.github.io/docs/spot/v1/en/#repay-margin-loan-cross-isolated
8401
+
7948
8402
  :param str code: unified currency code of the currency to repay
7949
8403
  :param float amount: the amount to repay
7950
8404
  :param dict [params]: extra parameters specific to the exchange API endpoint
@@ -8013,6 +8467,11 @@ class htx(Exchange, ImplicitAPI):
8013
8467
  async def fetch_settlement_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
8014
8468
  """
8015
8469
  Fetches historical settlement records
8470
+
8471
+ https://huobiapi.github.io/docs/dm/v1/en/#query-historical-settlement-records-of-the-platform-interface
8472
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-historical-settlement-records-of-the-platform-interface
8473
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-historical-settlement-records-of-the-platform-interface
8474
+
8016
8475
  :param str symbol: unified symbol of the market to fetch the settlement history for
8017
8476
  :param int [since]: timestamp in ms, value range = current time - 90 days,default = current time - 90 days
8018
8477
  :param int [limit]: page items, default 20, shall not exceed 50
@@ -8106,7 +8565,9 @@ class htx(Exchange, ImplicitAPI):
8106
8565
  async def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
8107
8566
  """
8108
8567
  fetch deposit and withdraw fees
8109
- :see: https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-currencies-v2
8568
+
8569
+ https://huobiapi.github.io/docs/spot/v1/en/#get-all-supported-currencies-v2
8570
+
8110
8571
  :param str[]|None codes: list of unified currency codes
8111
8572
  :param dict [params]: extra parameters specific to the exchange API endpoint
8112
8573
  :returns dict[]: a list of `fees structures <https://docs.ccxt.com/#/?id=fee-structure>`
@@ -8307,9 +8768,11 @@ class htx(Exchange, ImplicitAPI):
8307
8768
  async def fetch_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
8308
8769
  """
8309
8770
  retrieves the public liquidations of a trading pair
8310
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-liquidation-orders-new
8311
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-liquidation-orders-new
8312
- :see: https://huobiapi.github.io/docs/dm/v1/en/#query-liquidation-order-information-new
8771
+
8772
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-query-liquidation-orders-new
8773
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#query-liquidation-orders-new
8774
+ https://huobiapi.github.io/docs/dm/v1/en/#query-liquidation-order-information-new
8775
+
8313
8776
  :param str symbol: unified CCXT market symbol
8314
8777
  :param int [since]: the earliest time in ms to fetch liquidations for
8315
8778
  :param int [limit]: the maximum number of liquidation structures to retrieve
@@ -8390,6 +8853,7 @@ class htx(Exchange, ImplicitAPI):
8390
8853
  'contracts': self.safe_number(liquidation, 'volume'),
8391
8854
  'contractSize': self.safe_number(market, 'contractSize'),
8392
8855
  'price': self.safe_number(liquidation, 'price'),
8856
+ 'side': self.safe_string_lower(liquidation, 'direction'),
8393
8857
  'baseValue': self.safe_number(liquidation, 'amount'),
8394
8858
  'quoteValue': self.safe_number(liquidation, 'trade_turnover'),
8395
8859
  'timestamp': timestamp,
@@ -8399,17 +8863,19 @@ class htx(Exchange, ImplicitAPI):
8399
8863
  async def close_position(self, symbol: str, side: OrderSide = None, params={}) -> Order:
8400
8864
  """
8401
8865
  closes open positions for a contract market, requires 'amount' in params, unlike other exchanges
8402
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-lightning-close-order # USDT-M(isolated)
8403
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-lightning-close-position # USDT-M(cross)
8404
- :see: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-lightning-close-order # Coin-M swap
8405
- :see: https://huobiapi.github.io/docs/dm/v1/en/#place-flash-close-order # Coin-M futures
8866
+
8867
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-lightning-close-order # USDT-M(isolated)
8868
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-lightning-close-position # USDT-M(cross)
8869
+ https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-lightning-close-order # Coin-M swap
8870
+ https://huobiapi.github.io/docs/dm/v1/en/#place-flash-close-order # Coin-M futures
8871
+
8406
8872
  :param str symbol: unified CCXT market symbol
8407
8873
  :param str side: 'buy' or 'sell', the side of the closing order, opposite side side
8408
8874
  :param dict [params]: extra parameters specific to the okx api endpoint
8409
8875
  :param str [params.clientOrderId]: client needs to provide unique API and have to maintain the API themselves afterwards. [1, 9223372036854775807]
8410
8876
  :param dict [params.marginMode]: 'cross' or 'isolated', required for linear markets
8411
- *
8412
- * EXCHANGE SPECIFIC PARAMETERS
8877
+
8878
+ EXCHANGE SPECIFIC PARAMETERS
8413
8879
  :param number [params.amount]: order quantity
8414
8880
  :param str [params.order_price_type]: 'lightning' by default, 'lightning_fok': lightning fok type, 'lightning_ioc': lightning ioc type 'market' by default, 'market': market order type, 'lightning_fok': lightning
8415
8881
  :returns dict: `an order structure <https://docs.ccxt.com/#/?id=position-structure>`
@@ -8450,8 +8916,10 @@ class htx(Exchange, ImplicitAPI):
8450
8916
  async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
8451
8917
  """
8452
8918
  set hedged to True or False
8453
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-position-mode
8454
- :see: https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-switch-position-mode
8919
+
8920
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-switch-position-mode
8921
+ https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-switch-position-mode
8922
+
8455
8923
  :param bool hedged: set to True to for hedged mode, must be set separately for each market in isolated margin mode, only valid for linear markets
8456
8924
  :param str [symbol]: unified market symbol, required for isolated margin mode
8457
8925
  :param dict [params]: extra parameters specific to the exchange API endpoint