ccxt-ir 4.3.46.0.1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (772) hide show
  1. ccxt/__init__.py +358 -0
  2. ccxt/abantether.py +316 -0
  3. ccxt/abstract/__init__.py +0 -0
  4. ccxt/abstract/abantether.py +5 -0
  5. ccxt/abstract/ace.py +15 -0
  6. ccxt/abstract/afratether.py +6 -0
  7. ccxt/abstract/alpaca.py +70 -0
  8. ccxt/abstract/arzinja.py +5 -0
  9. ccxt/abstract/arzplus.py +7 -0
  10. ccxt/abstract/ascendex.py +77 -0
  11. ccxt/abstract/bequant.py +115 -0
  12. ccxt/abstract/bigone.py +45 -0
  13. ccxt/abstract/binance.py +712 -0
  14. ccxt/abstract/binancecoinm.py +712 -0
  15. ccxt/abstract/binanceus.py +764 -0
  16. ccxt/abstract/binanceusdm.py +712 -0
  17. ccxt/abstract/bingx.py +113 -0
  18. ccxt/abstract/bit2c.py +27 -0
  19. ccxt/abstract/bitbank.py +27 -0
  20. ccxt/abstract/bitbay.py +53 -0
  21. ccxt/abstract/bitbns.py +40 -0
  22. ccxt/abstract/bitcoincom.py +115 -0
  23. ccxt/abstract/bitfinex.py +69 -0
  24. ccxt/abstract/bitfinex2.py +139 -0
  25. ccxt/abstract/bitflyer.py +38 -0
  26. ccxt/abstract/bitget.py +508 -0
  27. ccxt/abstract/bithumb.py +32 -0
  28. ccxt/abstract/bitimen.py +7 -0
  29. ccxt/abstract/bitir.py +7 -0
  30. ccxt/abstract/bitmart.py +99 -0
  31. ccxt/abstract/bitmex.py +97 -0
  32. ccxt/abstract/bitopro.py +29 -0
  33. ccxt/abstract/bitpanda.py +35 -0
  34. ccxt/abstract/bitpin.py +7 -0
  35. ccxt/abstract/bitrue.py +72 -0
  36. ccxt/abstract/bitso.py +43 -0
  37. ccxt/abstract/bitstamp.py +258 -0
  38. ccxt/abstract/bitteam.py +29 -0
  39. ccxt/abstract/bitvavo.py +27 -0
  40. ccxt/abstract/bl3p.py +19 -0
  41. ccxt/abstract/blockchaincom.py +28 -0
  42. ccxt/abstract/blofin.py +37 -0
  43. ccxt/abstract/btcalpha.py +18 -0
  44. ccxt/abstract/btcbox.py +13 -0
  45. ccxt/abstract/btcmarkets.py +39 -0
  46. ccxt/abstract/btcturk.py +20 -0
  47. ccxt/abstract/bybit.py +298 -0
  48. ccxt/abstract/cex.py +33 -0
  49. ccxt/abstract/coinbase.py +94 -0
  50. ccxt/abstract/coinbaseadvanced.py +94 -0
  51. ccxt/abstract/coinbaseexchange.py +67 -0
  52. ccxt/abstract/coinbaseinternational.py +39 -0
  53. ccxt/abstract/coincatch.py +94 -0
  54. ccxt/abstract/coincheck.py +33 -0
  55. ccxt/abstract/coinex.py +237 -0
  56. ccxt/abstract/coinlist.py +54 -0
  57. ccxt/abstract/coinmate.py +62 -0
  58. ccxt/abstract/coinmetro.py +34 -0
  59. ccxt/abstract/coinone.py +67 -0
  60. ccxt/abstract/coinsph.py +54 -0
  61. ccxt/abstract/coinspot.py +28 -0
  62. ccxt/abstract/cryptocom.py +107 -0
  63. ccxt/abstract/currencycom.py +68 -0
  64. ccxt/abstract/delta.py +50 -0
  65. ccxt/abstract/deribit.py +125 -0
  66. ccxt/abstract/digifinex.py +91 -0
  67. ccxt/abstract/eterex.py +5 -0
  68. ccxt/abstract/excoino.py +7 -0
  69. ccxt/abstract/exir.py +8 -0
  70. ccxt/abstract/exmo.py +55 -0
  71. ccxt/abstract/exnovin.py +6 -0
  72. ccxt/abstract/farhadexchange.py +5 -0
  73. ccxt/abstract/fmfwio.py +115 -0
  74. ccxt/abstract/gate.py +265 -0
  75. ccxt/abstract/gateio.py +265 -0
  76. ccxt/abstract/gemini.py +58 -0
  77. ccxt/abstract/hashkey.py +67 -0
  78. ccxt/abstract/hitbtc.py +115 -0
  79. ccxt/abstract/hitbtc3.py +115 -0
  80. ccxt/abstract/hitobit.py +8 -0
  81. ccxt/abstract/hollaex.py +33 -0
  82. ccxt/abstract/htx.py +548 -0
  83. ccxt/abstract/huobi.py +548 -0
  84. ccxt/abstract/huobijp.py +114 -0
  85. ccxt/abstract/hyperliquid.py +6 -0
  86. ccxt/abstract/idex.py +26 -0
  87. ccxt/abstract/independentreserve.py +37 -0
  88. ccxt/abstract/indodax.py +26 -0
  89. ccxt/abstract/jibitex.py +7 -0
  90. ccxt/abstract/kraken.py +57 -0
  91. ccxt/abstract/krakenfutures.py +38 -0
  92. ccxt/abstract/kucoin.py +214 -0
  93. ccxt/abstract/kucoinfutures.py +233 -0
  94. ccxt/abstract/kuna.py +182 -0
  95. ccxt/abstract/latoken.py +56 -0
  96. ccxt/abstract/lbank.py +61 -0
  97. ccxt/abstract/luno.py +37 -0
  98. ccxt/abstract/lykke.py +29 -0
  99. ccxt/abstract/mercado.py +25 -0
  100. ccxt/abstract/mexc.py +178 -0
  101. ccxt/abstract/ndax.py +97 -0
  102. ccxt/abstract/nobitex.py +7 -0
  103. ccxt/abstract/novadax.py +29 -0
  104. ccxt/abstract/oceanex.py +22 -0
  105. ccxt/abstract/okcoin.py +74 -0
  106. ccxt/abstract/okexchange.py +8 -0
  107. ccxt/abstract/okx.py +324 -0
  108. ccxt/abstract/ompfinex.py +7 -0
  109. ccxt/abstract/onetrading.py +35 -0
  110. ccxt/abstract/oxfun.py +34 -0
  111. ccxt/abstract/p2b.py +22 -0
  112. ccxt/abstract/paradex.py +40 -0
  113. ccxt/abstract/paymium.py +28 -0
  114. ccxt/abstract/phemex.py +115 -0
  115. ccxt/abstract/poloniex.py +69 -0
  116. ccxt/abstract/poloniexfutures.py +48 -0
  117. ccxt/abstract/probit.py +23 -0
  118. ccxt/abstract/ramzinex.py +7 -0
  119. ccxt/abstract/sarmayex.py +5 -0
  120. ccxt/abstract/sarrafex.py +7 -0
  121. ccxt/abstract/tabdeal.py +7 -0
  122. ccxt/abstract/tetherland.py +5 -0
  123. ccxt/abstract/timex.py +62 -0
  124. ccxt/abstract/tokocrypto.py +37 -0
  125. ccxt/abstract/tradeogre.py +16 -0
  126. ccxt/abstract/twox.py +5 -0
  127. ccxt/abstract/ubitex.py +7 -0
  128. ccxt/abstract/upbit.py +38 -0
  129. ccxt/abstract/vertex.py +19 -0
  130. ccxt/abstract/wallex.py +8 -0
  131. ccxt/abstract/wavesexchange.py +154 -0
  132. ccxt/abstract/wazirx.py +30 -0
  133. ccxt/abstract/whitebit.py +98 -0
  134. ccxt/abstract/woo.py +83 -0
  135. ccxt/abstract/woofipro.py +119 -0
  136. ccxt/abstract/xt.py +152 -0
  137. ccxt/abstract/yobit.py +16 -0
  138. ccxt/abstract/zaif.py +38 -0
  139. ccxt/abstract/zonda.py +53 -0
  140. ccxt/ace.py +1012 -0
  141. ccxt/afratether.py +293 -0
  142. ccxt/alpaca.py +1083 -0
  143. ccxt/arzinja.py +285 -0
  144. ccxt/arzplus.py +412 -0
  145. ccxt/ascendex.py +3330 -0
  146. ccxt/async_support/__init__.py +337 -0
  147. ccxt/async_support/abantether.py +316 -0
  148. ccxt/async_support/ace.py +1012 -0
  149. ccxt/async_support/afratether.py +293 -0
  150. ccxt/async_support/alpaca.py +1083 -0
  151. ccxt/async_support/arzinja.py +285 -0
  152. ccxt/async_support/arzplus.py +412 -0
  153. ccxt/async_support/ascendex.py +3330 -0
  154. ccxt/async_support/base/__init__.py +1 -0
  155. ccxt/async_support/base/exchange.py +1966 -0
  156. ccxt/async_support/base/throttler.py +50 -0
  157. ccxt/async_support/base/ws/__init__.py +38 -0
  158. ccxt/async_support/base/ws/aiohttp_client.py +125 -0
  159. ccxt/async_support/base/ws/cache.py +212 -0
  160. ccxt/async_support/base/ws/client.py +193 -0
  161. ccxt/async_support/base/ws/fast_client.py +96 -0
  162. ccxt/async_support/base/ws/functions.py +59 -0
  163. ccxt/async_support/base/ws/future.py +58 -0
  164. ccxt/async_support/base/ws/order_book.py +78 -0
  165. ccxt/async_support/base/ws/order_book_side.py +174 -0
  166. ccxt/async_support/bequant.py +33 -0
  167. ccxt/async_support/bigone.py +2113 -0
  168. ccxt/async_support/binance.py +12234 -0
  169. ccxt/async_support/binancecoinm.py +45 -0
  170. ccxt/async_support/binanceus.py +211 -0
  171. ccxt/async_support/binanceusdm.py +58 -0
  172. ccxt/async_support/bingx.py +4325 -0
  173. ccxt/async_support/bit2c.py +866 -0
  174. ccxt/async_support/bitbank.py +1001 -0
  175. ccxt/async_support/bitbay.py +17 -0
  176. ccxt/async_support/bitbns.py +1154 -0
  177. ccxt/async_support/bitcoincom.py +17 -0
  178. ccxt/async_support/bitfinex.py +1617 -0
  179. ccxt/async_support/bitfinex2.py +3552 -0
  180. ccxt/async_support/bitflyer.py +995 -0
  181. ccxt/async_support/bitget.py +8273 -0
  182. ccxt/async_support/bithumb.py +1061 -0
  183. ccxt/async_support/bitimen.py +401 -0
  184. ccxt/async_support/bitir.py +490 -0
  185. ccxt/async_support/bitmart.py +4415 -0
  186. ccxt/async_support/bitmex.py +2756 -0
  187. ccxt/async_support/bitopro.py +1630 -0
  188. ccxt/async_support/bitpanda.py +16 -0
  189. ccxt/async_support/bitpin.py +454 -0
  190. ccxt/async_support/bitrue.py +3027 -0
  191. ccxt/async_support/bitso.py +1670 -0
  192. ccxt/async_support/bitstamp.py +2203 -0
  193. ccxt/async_support/bitteam.py +2239 -0
  194. ccxt/async_support/bitvavo.py +1968 -0
  195. ccxt/async_support/bl3p.py +485 -0
  196. ccxt/async_support/blockchaincom.py +1104 -0
  197. ccxt/async_support/blofin.py +2066 -0
  198. ccxt/async_support/btcalpha.py +891 -0
  199. ccxt/async_support/btcbox.py +544 -0
  200. ccxt/async_support/btcmarkets.py +1221 -0
  201. ccxt/async_support/btcturk.py +911 -0
  202. ccxt/async_support/bybit.py +8159 -0
  203. ccxt/async_support/cex.py +1605 -0
  204. ccxt/async_support/coinbase.py +4475 -0
  205. ccxt/async_support/coinbaseadvanced.py +17 -0
  206. ccxt/async_support/coinbaseexchange.py +1734 -0
  207. ccxt/async_support/coinbaseinternational.py +1899 -0
  208. ccxt/async_support/coincatch.py +5069 -0
  209. ccxt/async_support/coincheck.py +815 -0
  210. ccxt/async_support/coinex.py +5526 -0
  211. ccxt/async_support/coinlist.py +2243 -0
  212. ccxt/async_support/coinmate.py +1067 -0
  213. ccxt/async_support/coinmetro.py +1797 -0
  214. ccxt/async_support/coinone.py +1127 -0
  215. ccxt/async_support/coinsph.py +1850 -0
  216. ccxt/async_support/coinspot.py +534 -0
  217. ccxt/async_support/cryptocom.py +2822 -0
  218. ccxt/async_support/currencycom.py +1950 -0
  219. ccxt/async_support/delta.py +3376 -0
  220. ccxt/async_support/deribit.py +3437 -0
  221. ccxt/async_support/digifinex.py +3960 -0
  222. ccxt/async_support/eterex.py +286 -0
  223. ccxt/async_support/excoino.py +399 -0
  224. ccxt/async_support/exir.py +375 -0
  225. ccxt/async_support/exmo.py +2462 -0
  226. ccxt/async_support/exnovin.py +360 -0
  227. ccxt/async_support/farhadexchange.py +266 -0
  228. ccxt/async_support/fmfwio.py +34 -0
  229. ccxt/async_support/gate.py +6976 -0
  230. ccxt/async_support/gateio.py +16 -0
  231. ccxt/async_support/gemini.py +1825 -0
  232. ccxt/async_support/hashkey.py +4150 -0
  233. ccxt/async_support/hitbtc.py +3423 -0
  234. ccxt/async_support/hitbtc3.py +16 -0
  235. ccxt/async_support/hitobit.py +391 -0
  236. ccxt/async_support/hollaex.py +1813 -0
  237. ccxt/async_support/htx.py +8506 -0
  238. ccxt/async_support/huobi.py +16 -0
  239. ccxt/async_support/huobijp.py +1801 -0
  240. ccxt/async_support/hyperliquid.py +2431 -0
  241. ccxt/async_support/idex.py +1766 -0
  242. ccxt/async_support/independentreserve.py +784 -0
  243. ccxt/async_support/indodax.py +1247 -0
  244. ccxt/async_support/jibitex.py +395 -0
  245. ccxt/async_support/kraken.py +2894 -0
  246. ccxt/async_support/krakenfutures.py +2601 -0
  247. ccxt/async_support/kucoin.py +4602 -0
  248. ccxt/async_support/kucoinfutures.py +2698 -0
  249. ccxt/async_support/kuna.py +1841 -0
  250. ccxt/async_support/latoken.py +1664 -0
  251. ccxt/async_support/lbank.py +2683 -0
  252. ccxt/async_support/luno.py +1067 -0
  253. ccxt/async_support/lykke.py +1270 -0
  254. ccxt/async_support/mercado.py +842 -0
  255. ccxt/async_support/mexc.py +5369 -0
  256. ccxt/async_support/ndax.py +2354 -0
  257. ccxt/async_support/nobitex.py +419 -0
  258. ccxt/async_support/novadax.py +1484 -0
  259. ccxt/async_support/oceanex.py +903 -0
  260. ccxt/async_support/okcoin.py +2936 -0
  261. ccxt/async_support/okexchange.py +349 -0
  262. ccxt/async_support/okx.py +7827 -0
  263. ccxt/async_support/ompfinex.py +472 -0
  264. ccxt/async_support/onetrading.py +1911 -0
  265. ccxt/async_support/oxfun.py +2773 -0
  266. ccxt/async_support/p2b.py +1194 -0
  267. ccxt/async_support/paradex.py +2015 -0
  268. ccxt/async_support/paymium.py +564 -0
  269. ccxt/async_support/phemex.py +4473 -0
  270. ccxt/async_support/poloniex.py +2232 -0
  271. ccxt/async_support/poloniexfutures.py +1717 -0
  272. ccxt/async_support/probit.py +1734 -0
  273. ccxt/async_support/ramzinex.py +476 -0
  274. ccxt/async_support/sarmayex.py +357 -0
  275. ccxt/async_support/sarrafex.py +478 -0
  276. ccxt/async_support/tabdeal.py +364 -0
  277. ccxt/async_support/tetherland.py +349 -0
  278. ccxt/async_support/timex.py +1593 -0
  279. ccxt/async_support/tokocrypto.py +2405 -0
  280. ccxt/async_support/tradeogre.py +608 -0
  281. ccxt/async_support/twox.py +326 -0
  282. ccxt/async_support/ubitex.py +409 -0
  283. ccxt/async_support/upbit.py +1833 -0
  284. ccxt/async_support/vertex.py +2922 -0
  285. ccxt/async_support/wallex.py +445 -0
  286. ccxt/async_support/wavesexchange.py +2473 -0
  287. ccxt/async_support/wazirx.py +1224 -0
  288. ccxt/async_support/whitebit.py +2469 -0
  289. ccxt/async_support/woo.py +3114 -0
  290. ccxt/async_support/woofipro.py +2533 -0
  291. ccxt/async_support/xt.py +4454 -0
  292. ccxt/async_support/yobit.py +1283 -0
  293. ccxt/async_support/zaif.py +725 -0
  294. ccxt/async_support/zonda.py +1828 -0
  295. ccxt/base/__init__.py +27 -0
  296. ccxt/base/decimal_to_precision.py +174 -0
  297. ccxt/base/errors.py +242 -0
  298. ccxt/base/exchange.py +5941 -0
  299. ccxt/base/precise.py +287 -0
  300. ccxt/base/types.py +502 -0
  301. ccxt/bequant.py +33 -0
  302. ccxt/bigone.py +2112 -0
  303. ccxt/binance.py +12233 -0
  304. ccxt/binancecoinm.py +45 -0
  305. ccxt/binanceus.py +211 -0
  306. ccxt/binanceusdm.py +58 -0
  307. ccxt/bingx.py +4324 -0
  308. ccxt/bit2c.py +866 -0
  309. ccxt/bitbank.py +1001 -0
  310. ccxt/bitbay.py +17 -0
  311. ccxt/bitbns.py +1154 -0
  312. ccxt/bitcoincom.py +17 -0
  313. ccxt/bitfinex.py +1617 -0
  314. ccxt/bitfinex2.py +3552 -0
  315. ccxt/bitflyer.py +995 -0
  316. ccxt/bitget.py +8272 -0
  317. ccxt/bithumb.py +1061 -0
  318. ccxt/bitimen.py +401 -0
  319. ccxt/bitir.py +490 -0
  320. ccxt/bitmart.py +4415 -0
  321. ccxt/bitmex.py +2756 -0
  322. ccxt/bitopro.py +1630 -0
  323. ccxt/bitpanda.py +16 -0
  324. ccxt/bitpin.py +454 -0
  325. ccxt/bitrue.py +3026 -0
  326. ccxt/bitso.py +1670 -0
  327. ccxt/bitstamp.py +2203 -0
  328. ccxt/bitteam.py +2239 -0
  329. ccxt/bitvavo.py +1968 -0
  330. ccxt/bl3p.py +485 -0
  331. ccxt/blockchaincom.py +1104 -0
  332. ccxt/blofin.py +2066 -0
  333. ccxt/btcalpha.py +891 -0
  334. ccxt/btcbox.py +544 -0
  335. ccxt/btcmarkets.py +1221 -0
  336. ccxt/btcturk.py +911 -0
  337. ccxt/bybit.py +8158 -0
  338. ccxt/cex.py +1605 -0
  339. ccxt/coinbase.py +4474 -0
  340. ccxt/coinbaseadvanced.py +17 -0
  341. ccxt/coinbaseexchange.py +1734 -0
  342. ccxt/coinbaseinternational.py +1899 -0
  343. ccxt/coincatch.py +5069 -0
  344. ccxt/coincheck.py +815 -0
  345. ccxt/coinex.py +5525 -0
  346. ccxt/coinlist.py +2243 -0
  347. ccxt/coinmate.py +1067 -0
  348. ccxt/coinmetro.py +1797 -0
  349. ccxt/coinone.py +1127 -0
  350. ccxt/coinsph.py +1850 -0
  351. ccxt/coinspot.py +534 -0
  352. ccxt/cryptocom.py +2822 -0
  353. ccxt/currencycom.py +1950 -0
  354. ccxt/delta.py +3376 -0
  355. ccxt/deribit.py +3437 -0
  356. ccxt/digifinex.py +3959 -0
  357. ccxt/eterex.py +286 -0
  358. ccxt/excoino.py +399 -0
  359. ccxt/exir.py +375 -0
  360. ccxt/exmo.py +2462 -0
  361. ccxt/exnovin.py +360 -0
  362. ccxt/farhadexchange.py +266 -0
  363. ccxt/fmfwio.py +34 -0
  364. ccxt/gate.py +6975 -0
  365. ccxt/gateio.py +16 -0
  366. ccxt/gemini.py +1824 -0
  367. ccxt/hashkey.py +4150 -0
  368. ccxt/hitbtc.py +3423 -0
  369. ccxt/hitbtc3.py +16 -0
  370. ccxt/hitobit.py +391 -0
  371. ccxt/hollaex.py +1813 -0
  372. ccxt/htx.py +8505 -0
  373. ccxt/huobi.py +16 -0
  374. ccxt/huobijp.py +1801 -0
  375. ccxt/hyperliquid.py +2430 -0
  376. ccxt/idex.py +1766 -0
  377. ccxt/independentreserve.py +784 -0
  378. ccxt/indodax.py +1247 -0
  379. ccxt/jibitex.py +395 -0
  380. ccxt/kraken.py +2894 -0
  381. ccxt/krakenfutures.py +2601 -0
  382. ccxt/kucoin.py +4601 -0
  383. ccxt/kucoinfutures.py +2698 -0
  384. ccxt/kuna.py +1841 -0
  385. ccxt/latoken.py +1664 -0
  386. ccxt/lbank.py +2682 -0
  387. ccxt/luno.py +1067 -0
  388. ccxt/lykke.py +1270 -0
  389. ccxt/mercado.py +842 -0
  390. ccxt/mexc.py +5369 -0
  391. ccxt/ndax.py +2354 -0
  392. ccxt/nobitex.py +419 -0
  393. ccxt/novadax.py +1484 -0
  394. ccxt/oceanex.py +903 -0
  395. ccxt/okcoin.py +2936 -0
  396. ccxt/okexchange.py +349 -0
  397. ccxt/okx.py +7826 -0
  398. ccxt/ompfinex.py +472 -0
  399. ccxt/onetrading.py +1911 -0
  400. ccxt/oxfun.py +2772 -0
  401. ccxt/p2b.py +1194 -0
  402. ccxt/paradex.py +2015 -0
  403. ccxt/paymium.py +564 -0
  404. ccxt/phemex.py +4473 -0
  405. ccxt/poloniex.py +2232 -0
  406. ccxt/poloniexfutures.py +1717 -0
  407. ccxt/pro/__init__.py +149 -0
  408. ccxt/pro/alpaca.py +685 -0
  409. ccxt/pro/ascendex.py +916 -0
  410. ccxt/pro/bequant.py +38 -0
  411. ccxt/pro/binance.py +3488 -0
  412. ccxt/pro/binancecoinm.py +28 -0
  413. ccxt/pro/binanceus.py +48 -0
  414. ccxt/pro/binanceusdm.py +31 -0
  415. ccxt/pro/bingx.py +1264 -0
  416. ccxt/pro/bitcoincom.py +34 -0
  417. ccxt/pro/bitfinex.py +621 -0
  418. ccxt/pro/bitfinex2.py +1083 -0
  419. ccxt/pro/bitget.py +1692 -0
  420. ccxt/pro/bithumb.py +368 -0
  421. ccxt/pro/bitmart.py +1449 -0
  422. ccxt/pro/bitmex.py +1656 -0
  423. ccxt/pro/bitopro.py +445 -0
  424. ccxt/pro/bitpanda.py +15 -0
  425. ccxt/pro/bitrue.py +447 -0
  426. ccxt/pro/bitstamp.py +522 -0
  427. ccxt/pro/bitvavo.py +1270 -0
  428. ccxt/pro/blockchaincom.py +738 -0
  429. ccxt/pro/blofin.py +692 -0
  430. ccxt/pro/bybit.py +2000 -0
  431. ccxt/pro/cex.py +1440 -0
  432. ccxt/pro/coinbase.py +678 -0
  433. ccxt/pro/coinbaseadvanced.py +16 -0
  434. ccxt/pro/coinbaseexchange.py +895 -0
  435. ccxt/pro/coinbaseinternational.py +620 -0
  436. ccxt/pro/coincatch.py +1464 -0
  437. ccxt/pro/coincheck.py +199 -0
  438. ccxt/pro/coinex.py +1061 -0
  439. ccxt/pro/coinone.py +395 -0
  440. ccxt/pro/cryptocom.py +947 -0
  441. ccxt/pro/currencycom.py +536 -0
  442. ccxt/pro/deribit.py +892 -0
  443. ccxt/pro/exmo.py +629 -0
  444. ccxt/pro/gate.py +1416 -0
  445. ccxt/pro/gateio.py +15 -0
  446. ccxt/pro/gemini.py +865 -0
  447. ccxt/pro/hashkey.py +802 -0
  448. ccxt/pro/hitbtc.py +1216 -0
  449. ccxt/pro/hollaex.py +563 -0
  450. ccxt/pro/htx.py +2215 -0
  451. ccxt/pro/huobi.py +15 -0
  452. ccxt/pro/huobijp.py +570 -0
  453. ccxt/pro/hyperliquid.py +525 -0
  454. ccxt/pro/idex.py +672 -0
  455. ccxt/pro/independentreserve.py +270 -0
  456. ccxt/pro/kraken.py +1356 -0
  457. ccxt/pro/krakenfutures.py +1492 -0
  458. ccxt/pro/kucoin.py +1133 -0
  459. ccxt/pro/kucoinfutures.py +1081 -0
  460. ccxt/pro/lbank.py +843 -0
  461. ccxt/pro/luno.py +303 -0
  462. ccxt/pro/mexc.py +1122 -0
  463. ccxt/pro/ndax.py +506 -0
  464. ccxt/pro/okcoin.py +698 -0
  465. ccxt/pro/okx.py +1851 -0
  466. ccxt/pro/onetrading.py +1275 -0
  467. ccxt/pro/oxfun.py +950 -0
  468. ccxt/pro/p2b.py +419 -0
  469. ccxt/pro/paradex.py +352 -0
  470. ccxt/pro/phemex.py +1441 -0
  471. ccxt/pro/poloniex.py +1166 -0
  472. ccxt/pro/poloniexfutures.py +990 -0
  473. ccxt/pro/probit.py +551 -0
  474. ccxt/pro/upbit.py +520 -0
  475. ccxt/pro/vertex.py +943 -0
  476. ccxt/pro/wazirx.py +749 -0
  477. ccxt/pro/whitebit.py +864 -0
  478. ccxt/pro/woo.py +1078 -0
  479. ccxt/pro/woofipro.py +1183 -0
  480. ccxt/pro/xt.py +1067 -0
  481. ccxt/probit.py +1734 -0
  482. ccxt/ramzinex.py +476 -0
  483. ccxt/sarmayex.py +357 -0
  484. ccxt/sarrafex.py +478 -0
  485. ccxt/static_dependencies/__init__.py +1 -0
  486. ccxt/static_dependencies/ecdsa/__init__.py +14 -0
  487. ccxt/static_dependencies/ecdsa/_version.py +520 -0
  488. ccxt/static_dependencies/ecdsa/curves.py +56 -0
  489. ccxt/static_dependencies/ecdsa/der.py +221 -0
  490. ccxt/static_dependencies/ecdsa/ecdsa.py +310 -0
  491. ccxt/static_dependencies/ecdsa/ellipticcurve.py +197 -0
  492. ccxt/static_dependencies/ecdsa/keys.py +332 -0
  493. ccxt/static_dependencies/ecdsa/numbertheory.py +531 -0
  494. ccxt/static_dependencies/ecdsa/rfc6979.py +100 -0
  495. ccxt/static_dependencies/ecdsa/util.py +266 -0
  496. ccxt/static_dependencies/ethereum/__init__.py +7 -0
  497. ccxt/static_dependencies/ethereum/abi/__init__.py +16 -0
  498. ccxt/static_dependencies/ethereum/abi/abi.py +19 -0
  499. ccxt/static_dependencies/ethereum/abi/base.py +152 -0
  500. ccxt/static_dependencies/ethereum/abi/codec.py +217 -0
  501. ccxt/static_dependencies/ethereum/abi/constants.py +3 -0
  502. ccxt/static_dependencies/ethereum/abi/decoding.py +565 -0
  503. ccxt/static_dependencies/ethereum/abi/encoding.py +720 -0
  504. ccxt/static_dependencies/ethereum/abi/exceptions.py +139 -0
  505. ccxt/static_dependencies/ethereum/abi/grammar.py +443 -0
  506. ccxt/static_dependencies/ethereum/abi/packed.py +13 -0
  507. ccxt/static_dependencies/ethereum/abi/py.typed +0 -0
  508. ccxt/static_dependencies/ethereum/abi/registry.py +643 -0
  509. ccxt/static_dependencies/ethereum/abi/tools/__init__.py +3 -0
  510. ccxt/static_dependencies/ethereum/abi/tools/_strategies.py +230 -0
  511. ccxt/static_dependencies/ethereum/abi/utils/__init__.py +0 -0
  512. ccxt/static_dependencies/ethereum/abi/utils/numeric.py +83 -0
  513. ccxt/static_dependencies/ethereum/abi/utils/padding.py +27 -0
  514. ccxt/static_dependencies/ethereum/abi/utils/string.py +19 -0
  515. ccxt/static_dependencies/ethereum/account/__init__.py +3 -0
  516. ccxt/static_dependencies/ethereum/account/encode_typed_data/__init__.py +4 -0
  517. ccxt/static_dependencies/ethereum/account/encode_typed_data/encoding_and_hashing.py +239 -0
  518. ccxt/static_dependencies/ethereum/account/encode_typed_data/helpers.py +40 -0
  519. ccxt/static_dependencies/ethereum/account/messages.py +263 -0
  520. ccxt/static_dependencies/ethereum/account/py.typed +0 -0
  521. ccxt/static_dependencies/ethereum/hexbytes/__init__.py +5 -0
  522. ccxt/static_dependencies/ethereum/hexbytes/_utils.py +54 -0
  523. ccxt/static_dependencies/ethereum/hexbytes/main.py +65 -0
  524. ccxt/static_dependencies/ethereum/hexbytes/py.typed +0 -0
  525. ccxt/static_dependencies/ethereum/typing/__init__.py +63 -0
  526. ccxt/static_dependencies/ethereum/typing/abi.py +6 -0
  527. ccxt/static_dependencies/ethereum/typing/bls.py +7 -0
  528. ccxt/static_dependencies/ethereum/typing/discovery.py +5 -0
  529. ccxt/static_dependencies/ethereum/typing/encoding.py +7 -0
  530. ccxt/static_dependencies/ethereum/typing/enums.py +17 -0
  531. ccxt/static_dependencies/ethereum/typing/ethpm.py +9 -0
  532. ccxt/static_dependencies/ethereum/typing/evm.py +20 -0
  533. ccxt/static_dependencies/ethereum/typing/networks.py +1122 -0
  534. ccxt/static_dependencies/ethereum/typing/py.typed +0 -0
  535. ccxt/static_dependencies/ethereum/utils/__init__.py +115 -0
  536. ccxt/static_dependencies/ethereum/utils/abi.py +72 -0
  537. ccxt/static_dependencies/ethereum/utils/address.py +171 -0
  538. ccxt/static_dependencies/ethereum/utils/applicators.py +151 -0
  539. ccxt/static_dependencies/ethereum/utils/conversions.py +190 -0
  540. ccxt/static_dependencies/ethereum/utils/currency.py +107 -0
  541. ccxt/static_dependencies/ethereum/utils/curried/__init__.py +269 -0
  542. ccxt/static_dependencies/ethereum/utils/debug.py +20 -0
  543. ccxt/static_dependencies/ethereum/utils/decorators.py +132 -0
  544. ccxt/static_dependencies/ethereum/utils/encoding.py +6 -0
  545. ccxt/static_dependencies/ethereum/utils/exceptions.py +4 -0
  546. ccxt/static_dependencies/ethereum/utils/functional.py +75 -0
  547. ccxt/static_dependencies/ethereum/utils/hexadecimal.py +74 -0
  548. ccxt/static_dependencies/ethereum/utils/humanize.py +188 -0
  549. ccxt/static_dependencies/ethereum/utils/logging.py +159 -0
  550. ccxt/static_dependencies/ethereum/utils/module_loading.py +31 -0
  551. ccxt/static_dependencies/ethereum/utils/numeric.py +43 -0
  552. ccxt/static_dependencies/ethereum/utils/py.typed +0 -0
  553. ccxt/static_dependencies/ethereum/utils/toolz.py +76 -0
  554. ccxt/static_dependencies/ethereum/utils/types.py +54 -0
  555. ccxt/static_dependencies/ethereum/utils/typing/__init__.py +18 -0
  556. ccxt/static_dependencies/ethereum/utils/typing/misc.py +14 -0
  557. ccxt/static_dependencies/ethereum/utils/units.py +31 -0
  558. ccxt/static_dependencies/keccak/__init__.py +3 -0
  559. ccxt/static_dependencies/keccak/keccak.py +197 -0
  560. ccxt/static_dependencies/lark/__init__.py +38 -0
  561. ccxt/static_dependencies/lark/__pyinstaller/__init__.py +6 -0
  562. ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +14 -0
  563. ccxt/static_dependencies/lark/ast_utils.py +59 -0
  564. ccxt/static_dependencies/lark/common.py +86 -0
  565. ccxt/static_dependencies/lark/exceptions.py +292 -0
  566. ccxt/static_dependencies/lark/grammar.py +130 -0
  567. ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
  568. ccxt/static_dependencies/lark/indenter.py +143 -0
  569. ccxt/static_dependencies/lark/lark.py +658 -0
  570. ccxt/static_dependencies/lark/lexer.py +678 -0
  571. ccxt/static_dependencies/lark/load_grammar.py +1428 -0
  572. ccxt/static_dependencies/lark/parse_tree_builder.py +391 -0
  573. ccxt/static_dependencies/lark/parser_frontends.py +257 -0
  574. ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
  575. ccxt/static_dependencies/lark/parsers/cyk.py +340 -0
  576. ccxt/static_dependencies/lark/parsers/earley.py +314 -0
  577. ccxt/static_dependencies/lark/parsers/earley_common.py +42 -0
  578. ccxt/static_dependencies/lark/parsers/earley_forest.py +801 -0
  579. ccxt/static_dependencies/lark/parsers/grammar_analysis.py +203 -0
  580. ccxt/static_dependencies/lark/parsers/lalr_analysis.py +332 -0
  581. ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +158 -0
  582. ccxt/static_dependencies/lark/parsers/lalr_parser.py +122 -0
  583. ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +110 -0
  584. ccxt/static_dependencies/lark/parsers/xearley.py +165 -0
  585. ccxt/static_dependencies/lark/reconstruct.py +107 -0
  586. ccxt/static_dependencies/lark/tools/__init__.py +70 -0
  587. ccxt/static_dependencies/lark/tools/nearley.py +202 -0
  588. ccxt/static_dependencies/lark/tools/serialize.py +32 -0
  589. ccxt/static_dependencies/lark/tools/standalone.py +196 -0
  590. ccxt/static_dependencies/lark/tree.py +267 -0
  591. ccxt/static_dependencies/lark/tree_matcher.py +186 -0
  592. ccxt/static_dependencies/lark/tree_templates.py +180 -0
  593. ccxt/static_dependencies/lark/utils.py +343 -0
  594. ccxt/static_dependencies/lark/visitors.py +596 -0
  595. ccxt/static_dependencies/marshmallow/__init__.py +81 -0
  596. ccxt/static_dependencies/marshmallow/base.py +65 -0
  597. ccxt/static_dependencies/marshmallow/class_registry.py +94 -0
  598. ccxt/static_dependencies/marshmallow/decorators.py +231 -0
  599. ccxt/static_dependencies/marshmallow/error_store.py +60 -0
  600. ccxt/static_dependencies/marshmallow/exceptions.py +71 -0
  601. ccxt/static_dependencies/marshmallow/fields.py +2114 -0
  602. ccxt/static_dependencies/marshmallow/orderedset.py +89 -0
  603. ccxt/static_dependencies/marshmallow/schema.py +1228 -0
  604. ccxt/static_dependencies/marshmallow/types.py +12 -0
  605. ccxt/static_dependencies/marshmallow/utils.py +378 -0
  606. ccxt/static_dependencies/marshmallow/validate.py +678 -0
  607. ccxt/static_dependencies/marshmallow/warnings.py +2 -0
  608. ccxt/static_dependencies/marshmallow_dataclass/__init__.py +1047 -0
  609. ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +51 -0
  610. ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +45 -0
  611. ccxt/static_dependencies/marshmallow_dataclass/mypy.py +71 -0
  612. ccxt/static_dependencies/marshmallow_dataclass/typing.py +14 -0
  613. ccxt/static_dependencies/marshmallow_dataclass/union_field.py +82 -0
  614. ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +1 -0
  615. ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +193 -0
  616. ccxt/static_dependencies/msgpack/__init__.py +55 -0
  617. ccxt/static_dependencies/msgpack/exceptions.py +48 -0
  618. ccxt/static_dependencies/msgpack/ext.py +168 -0
  619. ccxt/static_dependencies/msgpack/fallback.py +951 -0
  620. ccxt/static_dependencies/parsimonious/__init__.py +10 -0
  621. ccxt/static_dependencies/parsimonious/exceptions.py +105 -0
  622. ccxt/static_dependencies/parsimonious/expressions.py +479 -0
  623. ccxt/static_dependencies/parsimonious/grammar.py +487 -0
  624. ccxt/static_dependencies/parsimonious/nodes.py +325 -0
  625. ccxt/static_dependencies/parsimonious/utils.py +40 -0
  626. ccxt/static_dependencies/starknet/__init__.py +0 -0
  627. ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
  628. ccxt/static_dependencies/starknet/cairo/data_types.py +123 -0
  629. ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
  630. ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +77 -0
  631. ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +46 -0
  632. ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +138 -0
  633. ccxt/static_dependencies/starknet/cairo/felt.py +64 -0
  634. ccxt/static_dependencies/starknet/cairo/type_parser.py +121 -0
  635. ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
  636. ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +59 -0
  637. ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
  638. ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +77 -0
  639. ccxt/static_dependencies/starknet/ccxt_utils.py +7 -0
  640. ccxt/static_dependencies/starknet/common.py +15 -0
  641. ccxt/static_dependencies/starknet/constants.py +39 -0
  642. ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
  643. ccxt/static_dependencies/starknet/hash/address.py +79 -0
  644. ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +111 -0
  645. ccxt/static_dependencies/starknet/hash/selector.py +16 -0
  646. ccxt/static_dependencies/starknet/hash/storage.py +12 -0
  647. ccxt/static_dependencies/starknet/hash/utils.py +78 -0
  648. ccxt/static_dependencies/starknet/models/__init__.py +0 -0
  649. ccxt/static_dependencies/starknet/models/typed_data.py +45 -0
  650. ccxt/static_dependencies/starknet/serialization/__init__.py +24 -0
  651. ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +40 -0
  652. ccxt/static_dependencies/starknet/serialization/_context.py +142 -0
  653. ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +10 -0
  654. ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +82 -0
  655. ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +43 -0
  656. ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +37 -0
  657. ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +66 -0
  658. ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +71 -0
  659. ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +71 -0
  660. ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +50 -0
  661. ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +58 -0
  662. ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +43 -0
  663. ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +40 -0
  664. ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +72 -0
  665. ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +36 -0
  666. ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +36 -0
  667. ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +76 -0
  668. ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +100 -0
  669. ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +32 -0
  670. ccxt/static_dependencies/starknet/serialization/errors.py +10 -0
  671. ccxt/static_dependencies/starknet/serialization/factory.py +229 -0
  672. ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +110 -0
  673. ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +59 -0
  674. ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
  675. ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +86 -0
  676. ccxt/static_dependencies/starknet/utils/iterable.py +13 -0
  677. ccxt/static_dependencies/starknet/utils/schema.py +13 -0
  678. ccxt/static_dependencies/starknet/utils/typed_data.py +182 -0
  679. ccxt/static_dependencies/starkware/__init__.py +0 -0
  680. ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
  681. ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +50 -0
  682. ccxt/static_dependencies/starkware/crypto/math_utils.py +78 -0
  683. ccxt/static_dependencies/starkware/crypto/signature.py +2344 -0
  684. ccxt/static_dependencies/starkware/crypto/utils.py +63 -0
  685. ccxt/static_dependencies/sympy/__init__.py +0 -0
  686. ccxt/static_dependencies/sympy/core/__init__.py +0 -0
  687. ccxt/static_dependencies/sympy/core/intfunc.py +35 -0
  688. ccxt/static_dependencies/sympy/external/__init__.py +0 -0
  689. ccxt/static_dependencies/sympy/external/gmpy.py +345 -0
  690. ccxt/static_dependencies/sympy/external/importtools.py +187 -0
  691. ccxt/static_dependencies/sympy/external/ntheory.py +637 -0
  692. ccxt/static_dependencies/sympy/external/pythonmpq.py +341 -0
  693. ccxt/static_dependencies/toolz/__init__.py +26 -0
  694. ccxt/static_dependencies/toolz/_signatures.py +784 -0
  695. ccxt/static_dependencies/toolz/_version.py +520 -0
  696. ccxt/static_dependencies/toolz/compatibility.py +30 -0
  697. ccxt/static_dependencies/toolz/curried/__init__.py +101 -0
  698. ccxt/static_dependencies/toolz/curried/exceptions.py +22 -0
  699. ccxt/static_dependencies/toolz/curried/operator.py +22 -0
  700. ccxt/static_dependencies/toolz/dicttoolz.py +339 -0
  701. ccxt/static_dependencies/toolz/functoolz.py +1049 -0
  702. ccxt/static_dependencies/toolz/itertoolz.py +1057 -0
  703. ccxt/static_dependencies/toolz/recipes.py +46 -0
  704. ccxt/static_dependencies/toolz/utils.py +9 -0
  705. ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
  706. ccxt/static_dependencies/typing_inspect/typing_inspect.py +851 -0
  707. ccxt/tabdeal.py +364 -0
  708. ccxt/test/__init__.py +3 -0
  709. ccxt/test/base/__init__.py +29 -0
  710. ccxt/test/base/test_account.py +26 -0
  711. ccxt/test/base/test_balance.py +56 -0
  712. ccxt/test/base/test_borrow_interest.py +35 -0
  713. ccxt/test/base/test_borrow_rate.py +32 -0
  714. ccxt/test/base/test_calculate_fee.py +51 -0
  715. ccxt/test/base/test_crypto.py +127 -0
  716. ccxt/test/base/test_currency.py +76 -0
  717. ccxt/test/base/test_datetime.py +109 -0
  718. ccxt/test/base/test_decimal_to_precision.py +392 -0
  719. ccxt/test/base/test_deep_extend.py +68 -0
  720. ccxt/test/base/test_deposit_withdrawal.py +50 -0
  721. ccxt/test/base/test_exchange_datetime_functions.py +76 -0
  722. ccxt/test/base/test_funding_rate_history.py +29 -0
  723. ccxt/test/base/test_last_price.py +31 -0
  724. ccxt/test/base/test_ledger_entry.py +45 -0
  725. ccxt/test/base/test_ledger_item.py +48 -0
  726. ccxt/test/base/test_leverage_tier.py +33 -0
  727. ccxt/test/base/test_liquidation.py +50 -0
  728. ccxt/test/base/test_margin_mode.py +24 -0
  729. ccxt/test/base/test_margin_modification.py +35 -0
  730. ccxt/test/base/test_market.py +193 -0
  731. ccxt/test/base/test_number.py +411 -0
  732. ccxt/test/base/test_ohlcv.py +33 -0
  733. ccxt/test/base/test_open_interest.py +32 -0
  734. ccxt/test/base/test_order.py +64 -0
  735. ccxt/test/base/test_order_book.py +69 -0
  736. ccxt/test/base/test_position.py +60 -0
  737. ccxt/test/base/test_shared_methods.py +353 -0
  738. ccxt/test/base/test_status.py +24 -0
  739. ccxt/test/base/test_throttle.py +126 -0
  740. ccxt/test/base/test_ticker.py +92 -0
  741. ccxt/test/base/test_trade.py +47 -0
  742. ccxt/test/base/test_trading_fee.py +26 -0
  743. ccxt/test/base/test_transaction.py +39 -0
  744. ccxt/test/test_async.py +1649 -0
  745. ccxt/test/test_sync.py +1648 -0
  746. ccxt/test/tests_async.py +1558 -0
  747. ccxt/test/tests_helpers.py +287 -0
  748. ccxt/test/tests_init.py +39 -0
  749. ccxt/test/tests_sync.py +1555 -0
  750. ccxt/tetherland.py +349 -0
  751. ccxt/timex.py +1593 -0
  752. ccxt/tokocrypto.py +2405 -0
  753. ccxt/tradeogre.py +608 -0
  754. ccxt/twox.py +326 -0
  755. ccxt/ubitex.py +409 -0
  756. ccxt/upbit.py +1833 -0
  757. ccxt/vertex.py +2922 -0
  758. ccxt/wallex.py +445 -0
  759. ccxt/wavesexchange.py +2472 -0
  760. ccxt/wazirx.py +1224 -0
  761. ccxt/whitebit.py +2469 -0
  762. ccxt/woo.py +3114 -0
  763. ccxt/woofipro.py +2533 -0
  764. ccxt/xt.py +4453 -0
  765. ccxt/yobit.py +1283 -0
  766. ccxt/zaif.py +725 -0
  767. ccxt/zonda.py +1828 -0
  768. ccxt_ir-4.3.46.0.1.dist-info/LICENSE.txt +21 -0
  769. ccxt_ir-4.3.46.0.1.dist-info/METADATA +655 -0
  770. ccxt_ir-4.3.46.0.1.dist-info/RECORD +772 -0
  771. ccxt_ir-4.3.46.0.1.dist-info/WHEEL +6 -0
  772. ccxt_ir-4.3.46.0.1.dist-info/top_level.txt +1 -0
ccxt/huobijp.py ADDED
@@ -0,0 +1,1801 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+
6
+ from ccxt.base.exchange import Exchange
7
+ from ccxt.abstract.huobijp import ImplicitAPI
8
+ import hashlib
9
+ from ccxt.base.types import Account, Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
10
+ from typing import List
11
+ from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
13
+ from ccxt.base.errors import PermissionDenied
14
+ from ccxt.base.errors import ArgumentsRequired
15
+ from ccxt.base.errors import BadRequest
16
+ from ccxt.base.errors import BadSymbol
17
+ from ccxt.base.errors import InsufficientFunds
18
+ from ccxt.base.errors import InvalidOrder
19
+ from ccxt.base.errors import OrderNotFound
20
+ from ccxt.base.errors import NotSupported
21
+ from ccxt.base.errors import NetworkError
22
+ from ccxt.base.errors import ExchangeNotAvailable
23
+ from ccxt.base.errors import OnMaintenance
24
+ from ccxt.base.errors import RequestTimeout
25
+ from ccxt.base.decimal_to_precision import TRUNCATE
26
+ from ccxt.base.decimal_to_precision import TICK_SIZE
27
+ from ccxt.base.precise import Precise
28
+
29
+
30
+ class huobijp(Exchange, ImplicitAPI):
31
+
32
+ def describe(self):
33
+ return self.deep_extend(super(huobijp, self).describe(), {
34
+ 'id': 'huobijp',
35
+ 'name': 'Huobi Japan',
36
+ 'countries': ['JP'],
37
+ 'rateLimit': 100,
38
+ 'userAgent': self.userAgents['chrome39'],
39
+ 'certified': False,
40
+ 'version': 'v1',
41
+ 'hostname': 'api-cloud.bittrade.co.jp',
42
+ 'pro': True,
43
+ 'has': {
44
+ 'CORS': None,
45
+ 'spot': True,
46
+ 'margin': None,
47
+ 'swap': False,
48
+ 'future': False,
49
+ 'option': False,
50
+ 'cancelAllOrders': True,
51
+ 'cancelOrder': True,
52
+ 'cancelOrders': True,
53
+ 'createMarketBuyOrderWithCost': True,
54
+ 'createMarketOrderWithCost': False,
55
+ 'createMarketSellOrderWithCost': False,
56
+ 'createOrder': True,
57
+ 'createStopLimitOrder': False,
58
+ 'createStopMarketOrder': False,
59
+ 'createStopOrder': False,
60
+ 'fetchAccounts': True,
61
+ 'fetchBalance': True,
62
+ 'fetchClosedOrders': True,
63
+ 'fetchCurrencies': True,
64
+ 'fetchDepositAddress': False,
65
+ 'fetchDepositAddressesByNetwork': False,
66
+ 'fetchDeposits': True,
67
+ 'fetchFundingHistory': False,
68
+ 'fetchFundingRate': False,
69
+ 'fetchFundingRateHistory': False,
70
+ 'fetchFundingRates': False,
71
+ 'fetchIndexOHLCV': False,
72
+ 'fetchMarkets': True,
73
+ 'fetchMarkOHLCV': False,
74
+ 'fetchMyTrades': True,
75
+ 'fetchOHLCV': True,
76
+ 'fetchOpenOrders': True,
77
+ 'fetchOrder': True,
78
+ 'fetchOrderBook': True,
79
+ 'fetchOrders': True,
80
+ 'fetchOrderTrades': True,
81
+ 'fetchPremiumIndexOHLCV': False,
82
+ 'fetchTicker': True,
83
+ 'fetchTickers': True,
84
+ 'fetchTime': True,
85
+ 'fetchTrades': True,
86
+ 'fetchTradingLimits': True,
87
+ 'fetchWithdrawals': True,
88
+ 'withdraw': True,
89
+ },
90
+ 'timeframes': {
91
+ '1m': '1min',
92
+ '5m': '5min',
93
+ '15m': '15min',
94
+ '30m': '30min',
95
+ '1h': '60min',
96
+ '4h': '4hour',
97
+ '1d': '1day',
98
+ '1w': '1week',
99
+ '1M': '1mon',
100
+ '1y': '1year',
101
+ },
102
+ 'urls': {
103
+ 'logo': 'https://user-images.githubusercontent.com/1294454/85734211-85755480-b705-11ea-8b35-0b7f1db33a2f.jpg',
104
+ 'api': {
105
+ 'market': 'https://{hostname}',
106
+ 'public': 'https://{hostname}',
107
+ 'private': 'https://{hostname}',
108
+ 'v2Public': 'https://{hostname}',
109
+ 'v2Private': 'https://{hostname}',
110
+ },
111
+ 'www': 'https://www.huobi.co.jp',
112
+ 'referral': 'https://www.huobi.co.jp/register/?invite_code=znnq3',
113
+ 'doc': 'https://api-doc.huobi.co.jp',
114
+ 'fees': 'https://www.huobi.co.jp/support/fee',
115
+ },
116
+ 'api': {
117
+ 'v2Public': {
118
+ 'get': {
119
+ 'reference/currencies': 1, # 币链参考信息
120
+ 'market-status': 1, # 获取当前市场状态
121
+ },
122
+ },
123
+ 'v2Private': {
124
+ 'get': {
125
+ 'account/ledger': 1,
126
+ 'account/withdraw/quota': 1,
127
+ 'account/withdraw/address': 1, # 提币地址查询(限母用户可用)
128
+ 'account/deposit/address': 1,
129
+ 'account/repayment': 5, # 还币交易记录查询
130
+ 'reference/transact-fee-rate': 1,
131
+ 'account/asset-valuation': 0.2, # 获取账户资产估值
132
+ 'point/account': 5, # 点卡余额查询
133
+ 'sub-user/user-list': 1, # 获取子用户列表
134
+ 'sub-user/user-state': 1, # 获取特定子用户的用户状态
135
+ 'sub-user/account-list': 1, # 获取特定子用户的账户列表
136
+ 'sub-user/deposit-address': 1, # 子用户充币地址查询
137
+ 'sub-user/query-deposit': 1, # 子用户充币记录查询
138
+ 'user/api-key': 1, # 母子用户API key信息查询
139
+ 'user/uid': 1, # 母子用户获取用户UID
140
+ 'algo-orders/opening': 1, # 查询未触发OPEN策略委托
141
+ 'algo-orders/history': 1, # 查询策略委托历史
142
+ 'algo-orders/specific': 1, # 查询特定策略委托
143
+ 'c2c/offers': 1, # 查询借入借出订单
144
+ 'c2c/offer': 1, # 查询特定借入借出订单及其交易记录
145
+ 'c2c/transactions': 1, # 查询借入借出交易记录
146
+ 'c2c/repayment': 1, # 查询还币交易记录
147
+ 'c2c/account': 1, # 查询账户余额
148
+ 'etp/reference': 1, # 基础参考信息
149
+ 'etp/transactions': 5, # 获取杠杆ETP申赎记录
150
+ 'etp/transaction': 5, # 获取特定杠杆ETP申赎记录
151
+ 'etp/rebalance': 1, # 获取杠杆ETP调仓记录
152
+ 'etp/limit': 1, # 获取ETP持仓限额
153
+ },
154
+ 'post': {
155
+ 'account/transfer': 1,
156
+ 'account/repayment': 5, # 归还借币(全仓逐仓通用)
157
+ 'point/transfer': 5, # 点卡划转
158
+ 'sub-user/management': 1, # 冻结/解冻子用户
159
+ 'sub-user/creation': 1, # 子用户创建
160
+ 'sub-user/tradable-market': 1, # 设置子用户交易权限
161
+ 'sub-user/transferability': 1, # 设置子用户资产转出权限
162
+ 'sub-user/api-key-generation': 1, # 子用户API key创建
163
+ 'sub-user/api-key-modification': 1, # 修改子用户API key
164
+ 'sub-user/api-key-deletion': 1, # 删除子用户API key
165
+ 'sub-user/deduct-mode': 1, # 设置子用户手续费抵扣模式
166
+ 'algo-orders': 1, # 策略委托下单
167
+ 'algo-orders/cancel-all-after': 1, # 自动撤销订单
168
+ 'algo-orders/cancellation': 1, # 策略委托(触发前)撤单
169
+ 'c2c/offer': 1, # 借入借出下单
170
+ 'c2c/cancellation': 1, # 借入借出撤单
171
+ 'c2c/cancel-all': 1, # 撤销所有借入借出订单
172
+ 'c2c/repayment': 1, # 还币
173
+ 'c2c/transfer': 1, # 资产划转
174
+ 'etp/creation': 5, # 杠杆ETP换入
175
+ 'etp/redemption': 5, # 杠杆ETP换出
176
+ 'etp/{transactId}/cancel': 10, # 杠杆ETP单个撤单
177
+ 'etp/batch-cancel': 50, # 杠杆ETP批量撤单
178
+ },
179
+ },
180
+ 'market': {
181
+ 'get': {
182
+ 'history/kline': 1, # 获取K线数据
183
+ 'detail/merged': 1, # 获取聚合行情(Ticker)
184
+ 'depth': 1, # 获取 Market Depth 数据
185
+ 'trade': 1, # 获取 Trade Detail 数据
186
+ 'history/trade': 1, # 批量获取最近的交易记录
187
+ 'detail': 1, # 获取 Market Detail 24小时成交量数据
188
+ 'tickers': 1,
189
+ 'etp': 1, # 获取杠杆ETP实时净值
190
+ },
191
+ },
192
+ 'public': {
193
+ 'get': {
194
+ 'common/symbols': 1, # 查询系统支持的所有交易对
195
+ 'common/currencys': 1, # 查询系统支持的所有币种
196
+ 'common/timestamp': 1, # 查询系统当前时间
197
+ 'common/exchange': 1, # order limits
198
+ 'settings/currencys': 1, # ?language=en-US
199
+ },
200
+ },
201
+ 'private': {
202
+ 'get': {
203
+ 'account/accounts': 0.2, # 查询当前用户的所有账户(即account-id)
204
+ 'account/accounts/{id}/balance': 0.2, # 查询指定账户的余额
205
+ 'account/accounts/{sub-uid}': 1,
206
+ 'account/history': 4,
207
+ 'cross-margin/loan-info': 1,
208
+ 'margin/loan-info': 1, # 查询借币币息率及额度
209
+ 'fee/fee-rate/get': 1,
210
+ 'order/openOrders': 0.4,
211
+ 'order/orders': 0.4,
212
+ 'order/orders/{id}': 0.4, # 查询某个订单详情
213
+ 'order/orders/{id}/matchresults': 0.4, # 查询某个订单的成交明细
214
+ 'order/orders/getClientOrder': 0.4,
215
+ 'order/history': 1, # 查询当前委托、历史委托
216
+ 'order/matchresults': 1, # 查询当前成交、历史成交
217
+ # 'dw/withdraw-virtual/addresses', # 查询虚拟币提现地址(Deprecated)
218
+ 'query/deposit-withdraw': 1,
219
+ # 'margin/loan-info', # duplicate
220
+ 'margin/loan-orders': 0.2, # 借贷订单
221
+ 'margin/accounts/balance': 0.2, # 借贷账户详情
222
+ 'cross-margin/loan-orders': 1, # 查询借币订单
223
+ 'cross-margin/accounts/balance': 1, # 借币账户详情
224
+ 'points/actions': 1,
225
+ 'points/orders': 1,
226
+ 'subuser/aggregate-balance': 10,
227
+ 'stable-coin/exchange_rate': 1,
228
+ 'stable-coin/quote': 1,
229
+ },
230
+ 'post': {
231
+ 'account/transfer': 1, # 资产划转(该节点为母用户和子用户进行资产划转的通用接口。)
232
+ 'futures/transfer': 1,
233
+ 'order/batch-orders': 0.4,
234
+ 'order/orders/place': 0.2, # 创建并执行一个新订单(一步下单, 推荐使用)
235
+ 'order/orders/submitCancelClientOrder': 0.2,
236
+ 'order/orders/batchCancelOpenOrders': 0.4,
237
+ # 'order/orders', # 创建一个新的订单请求 (仅创建订单,不执行下单)
238
+ # 'order/orders/{id}/place', # 执行一个订单 (仅执行已创建的订单)
239
+ 'order/orders/{id}/submitcancel': 0.2, # 申请撤销一个订单请求
240
+ 'order/orders/batchcancel': 0.4, # 批量撤销订单
241
+ # 'dw/balance/transfer', # 资产划转
242
+ 'dw/withdraw/api/create': 1, # 申请提现虚拟币
243
+ # 'dw/withdraw-virtual/create', # 申请提现虚拟币
244
+ # 'dw/withdraw-virtual/{id}/place', # 确认申请虚拟币提现(Deprecated)
245
+ 'dw/withdraw-virtual/{id}/cancel': 1, # 申请取消提现虚拟币
246
+ 'dw/transfer-in/margin': 10, # 现货账户划入至借贷账户
247
+ 'dw/transfer-out/margin': 10, # 借贷账户划出至现货账户
248
+ 'margin/orders': 10, # 申请借贷
249
+ 'margin/orders/{id}/repay': 10, # 归还借贷
250
+ 'cross-margin/transfer-in': 1, # 资产划转
251
+ 'cross-margin/transfer-out': 1, # 资产划转
252
+ 'cross-margin/orders': 1, # 申请借币
253
+ 'cross-margin/orders/{id}/repay': 1, # 归还借币
254
+ 'stable-coin/exchange': 1,
255
+ 'subuser/transfer': 10,
256
+ },
257
+ },
258
+ },
259
+ 'fees': {
260
+ 'trading': {
261
+ 'feeSide': 'get',
262
+ 'tierBased': False,
263
+ 'percentage': True,
264
+ 'maker': self.parse_number('0.002'),
265
+ 'taker': self.parse_number('0.002'),
266
+ },
267
+ },
268
+ 'precisionMode': TICK_SIZE,
269
+ 'exceptions': {
270
+ 'broad': {
271
+ 'contract is restricted of closing positions on API. Please contact customer service': OnMaintenance,
272
+ 'maintain': OnMaintenance,
273
+ },
274
+ 'exact': {
275
+ # err-code
276
+ 'bad-request': BadRequest,
277
+ 'base-date-limit-error': BadRequest, # {"status":"error","err-code":"base-date-limit-error","err-msg":"date less than system limit","data":null}
278
+ 'api-not-support-temp-addr': PermissionDenied, # {"status":"error","err-code":"api-not-support-temp-addr","err-msg":"API withdrawal does not support temporary addresses","data":null}
279
+ 'timeout': RequestTimeout, # {"ts":1571653730865,"status":"error","err-code":"timeout","err-msg":"Request Timeout"}
280
+ 'gateway-internal-error': ExchangeNotAvailable, # {"status":"error","err-code":"gateway-internal-error","err-msg":"Failed to load data. Try again later.","data":null}
281
+ 'account-frozen-balance-insufficient-error': InsufficientFunds, # {"status":"error","err-code":"account-frozen-balance-insufficient-error","err-msg":"trade account balance is not enough, left: `0.0027`","data":null}
282
+ 'invalid-amount': InvalidOrder, # eg "Paramemter `amount` is invalid."
283
+ 'order-limitorder-amount-min-error': InvalidOrder, # limit order amount error, min: `0.001`
284
+ 'order-limitorder-amount-max-error': InvalidOrder, # market order amount error, max: `1000000`
285
+ 'order-marketorder-amount-min-error': InvalidOrder, # market order amount error, min: `0.01`
286
+ 'order-limitorder-price-min-error': InvalidOrder, # limit order price error
287
+ 'order-limitorder-price-max-error': InvalidOrder, # limit order price error
288
+ 'order-holding-limit-failed': InvalidOrder, # {"status":"error","err-code":"order-holding-limit-failed","err-msg":"Order failed, exceeded the holding limit of self currency","data":null}
289
+ 'order-orderprice-precision-error': InvalidOrder, # {"status":"error","err-code":"order-orderprice-precision-error","err-msg":"order price precision error, scale: `4`","data":null}
290
+ 'order-etp-nav-price-max-error': InvalidOrder, # {"status":"error","err-code":"order-etp-nav-price-max-error","err-msg":"Order price cannot be higher than 5% of NAV","data":null}
291
+ 'order-orderstate-error': OrderNotFound, # canceling an already canceled order
292
+ 'order-queryorder-invalid': OrderNotFound, # querying a non-existent order
293
+ 'order-update-error': ExchangeNotAvailable, # undocumented error
294
+ 'api-signature-check-failed': AuthenticationError,
295
+ 'api-signature-not-valid': AuthenticationError, # {"status":"error","err-code":"api-signature-not-valid","err-msg":"Signature not valid: Incorrect Access key [Access key错误]","data":null}
296
+ 'base-record-invalid': OrderNotFound, # https://github.com/ccxt/ccxt/issues/5750
297
+ 'base-symbol-trade-disabled': BadSymbol, # {"status":"error","err-code":"base-symbol-trade-disabled","err-msg":"Trading is disabled for self symbol","data":null}
298
+ 'base-symbol-error': BadSymbol, # {"status":"error","err-code":"base-symbol-error","err-msg":"The symbol is invalid","data":null}
299
+ 'system-maintenance': OnMaintenance, # {"status": "error", "err-code": "system-maintenance", "err-msg": "System is in maintenance!", "data": null}
300
+ # err-msg
301
+ 'invalid symbol': BadSymbol, # {"ts":1568813334794,"status":"error","err-code":"invalid-parameter","err-msg":"invalid symbol"}
302
+ 'symbol trade not open now': BadSymbol, # {"ts":1576210479343,"status":"error","err-code":"invalid-parameter","err-msg":"symbol trade not open now"},
303
+ 'invalid-address': BadRequest, # {"status":"error","err-code":"invalid-address","err-msg":"Invalid address.","data":null},
304
+ 'base-currency-chain-error': BadRequest, # {"status":"error","err-code":"base-currency-chain-error","err-msg":"The current currency chain does not exist","data":null},
305
+ 'dw-insufficient-balance': InsufficientFunds, # {"status":"error","err-code":"dw-insufficient-balance","err-msg":"Insufficient balance. You can only transfer `12.3456` at most.","data":null}
306
+ },
307
+ },
308
+ 'options': {
309
+ 'defaultNetwork': 'ERC20',
310
+ 'networks': {
311
+ 'ETH': 'erc20',
312
+ 'TRX': 'trc20',
313
+ 'HRC20': 'hrc20',
314
+ 'HECO': 'hrc20',
315
+ 'HT': 'hrc20',
316
+ 'ALGO': 'algo',
317
+ 'OMNI': '',
318
+ },
319
+ # https://github.com/ccxt/ccxt/issues/5376
320
+ 'fetchOrdersByStatesMethod': 'private_get_order_orders', # 'private_get_order_history' # https://github.com/ccxt/ccxt/pull/5392
321
+ 'fetchOpenOrdersMethod': 'fetch_open_orders_v1', # 'fetch_open_orders_v2' # https://github.com/ccxt/ccxt/issues/5388
322
+ 'createMarketBuyOrderRequiresPrice': True,
323
+ 'fetchMarketsMethod': 'publicGetCommonSymbols',
324
+ 'fetchBalanceMethod': 'privateGetAccountAccountsIdBalance',
325
+ 'createOrderMethod': 'privatePostOrderOrdersPlace',
326
+ 'language': 'en-US',
327
+ 'broker': {
328
+ 'id': 'AA03022abc',
329
+ },
330
+ },
331
+ 'commonCurrencies': {
332
+ # https://github.com/ccxt/ccxt/issues/6081
333
+ # https://github.com/ccxt/ccxt/issues/3365
334
+ # https://github.com/ccxt/ccxt/issues/2873
335
+ 'GET': 'Themis', # conflict with GET(Guaranteed Entrance Token, GET Protocol)
336
+ 'GTC': 'Game.com', # conflict with Gitcoin and Gastrocoin
337
+ 'HIT': 'HitChain',
338
+ # https://github.com/ccxt/ccxt/issues/7399
339
+ # https://coinmarketcap.com/currencies/pnetwork/
340
+ # https://coinmarketcap.com/currencies/penta/markets/
341
+ # https://en.cryptonomist.ch/blog/eidoo/the-edo-to-pnt-upgrade-what-you-need-to-know-updated/
342
+ 'PNT': 'Penta',
343
+ 'SBTC': 'Super Bitcoin',
344
+ 'BIFI': 'Bitcoin File', # conflict with Beefy.Finance https://github.com/ccxt/ccxt/issues/8706
345
+ },
346
+ })
347
+
348
+ def fetch_time(self, params={}):
349
+ """
350
+ fetches the current integer timestamp in milliseconds from the exchange server
351
+ :param dict [params]: extra parameters specific to the exchange API endpoint
352
+ :returns int: the current integer timestamp in milliseconds from the exchange server
353
+ """
354
+ response = self.publicGetCommonTimestamp(params)
355
+ return self.safe_integer(response, 'data')
356
+
357
+ def fetch_trading_limits(self, symbols: Strings = None, params={}):
358
+ # self method should not be called directly, use loadTradingLimits() instead
359
+ # by default it will try load withdrawal fees of all currencies(with separate requests)
360
+ # however if you define symbols = ['ETH/BTC', 'LTC/BTC'] in args it will only load those
361
+ self.load_markets()
362
+ if symbols is None:
363
+ symbols = self.symbols
364
+ result: dict = {}
365
+ for i in range(0, len(symbols)):
366
+ symbol = symbols[i]
367
+ result[symbol] = self.fetch_trading_limits_by_id(self.market_id(symbol), params)
368
+ return result
369
+
370
+ def fetch_trading_limits_by_id(self, id: str, params={}):
371
+ request: dict = {
372
+ 'symbol': id,
373
+ }
374
+ response = self.publicGetCommonExchange(self.extend(request, params))
375
+ #
376
+ # {status: "ok",
377
+ # "data": { symbol: "aidocbtc",
378
+ # "buy-limit-must-less-than": 1.1,
379
+ # "sell-limit-must-greater-than": 0.9,
380
+ # "limit-order-must-greater-than": 1,
381
+ # "limit-order-must-less-than": 5000000,
382
+ # "market-buy-order-must-greater-than": 0.0001,
383
+ # "market-buy-order-must-less-than": 100,
384
+ # "market-sell-order-must-greater-than": 1,
385
+ # "market-sell-order-must-less-than": 500000,
386
+ # "circuit-break-when-greater-than": 10000,
387
+ # "circuit-break-when-less-than": 10,
388
+ # "market-sell-order-rate-must-less-than": 0.1,
389
+ # "market-buy-order-rate-must-less-than": 0.1 }}
390
+ #
391
+ return self.parse_trading_limits(self.safe_value(response, 'data', {}))
392
+
393
+ def parse_trading_limits(self, limits, symbol: Str = None, params={}):
394
+ #
395
+ # { symbol: "aidocbtc",
396
+ # "buy-limit-must-less-than": 1.1,
397
+ # "sell-limit-must-greater-than": 0.9,
398
+ # "limit-order-must-greater-than": 1,
399
+ # "limit-order-must-less-than": 5000000,
400
+ # "market-buy-order-must-greater-than": 0.0001,
401
+ # "market-buy-order-must-less-than": 100,
402
+ # "market-sell-order-must-greater-than": 1,
403
+ # "market-sell-order-must-less-than": 500000,
404
+ # "circuit-break-when-greater-than": 10000,
405
+ # "circuit-break-when-less-than": 10,
406
+ # "market-sell-order-rate-must-less-than": 0.1,
407
+ # "market-buy-order-rate-must-less-than": 0.1 }
408
+ #
409
+ return {
410
+ 'info': limits,
411
+ 'limits': {
412
+ 'amount': {
413
+ 'min': self.safe_number(limits, 'limit-order-must-greater-than'),
414
+ 'max': self.safe_number(limits, 'limit-order-must-less-than'),
415
+ },
416
+ },
417
+ }
418
+
419
+ def cost_to_precision(self, symbol, cost):
420
+ return self.decimal_to_precision(cost, TRUNCATE, self.markets[symbol]['precision']['cost'], self.precisionMode)
421
+
422
+ def fetch_markets(self, params={}) -> List[Market]:
423
+ """
424
+ retrieves data on all markets for huobijp
425
+ :param dict [params]: extra parameters specific to the exchange API endpoint
426
+ :returns dict[]: an array of objects representing market data
427
+ """
428
+ method = self.options['fetchMarketsMethod']
429
+ response = getattr(self, method)(params)
430
+ #
431
+ # {
432
+ # "status": "ok",
433
+ # "data": [
434
+ # {
435
+ # "base-currency": "xrp",
436
+ # "quote-currency": "btc",
437
+ # "price-precision": 9,
438
+ # "amount-precision": 2,
439
+ # "symbol-partition": "default",
440
+ # "symbol": "xrpbtc",
441
+ # "state": "online",
442
+ # "value-precision": 8,
443
+ # "min-order-amt": 1,
444
+ # "max-order-amt": 5000000,
445
+ # "min-order-value": 0.0001,
446
+ # "limit-order-min-order-amt": 1,
447
+ # "limit-order-max-order-amt": 5000000,
448
+ # "limit-order-max-buy-amt": 5000000,
449
+ # "limit-order-max-sell-amt": 5000000,
450
+ # "sell-market-min-order-amt": 1,
451
+ # "sell-market-max-order-amt": 500000,
452
+ # "buy-market-max-order-value": 100,
453
+ # "leverage-ratio": 5,
454
+ # "super-margin-leverage-ratio": 3,
455
+ # "api-trading": "enabled",
456
+ # "tags": ""
457
+ # }
458
+ # ...
459
+ # ]
460
+ # }
461
+ #
462
+ markets = self.safe_value(response, 'data', [])
463
+ numMarkets = len(markets)
464
+ if numMarkets < 1:
465
+ raise NetworkError(self.id + ' fetchMarkets() returned empty response: ' + self.json(markets))
466
+ result = []
467
+ for i in range(0, len(markets)):
468
+ market = markets[i]
469
+ baseId = self.safe_string(market, 'base-currency')
470
+ quoteId = self.safe_string(market, 'quote-currency')
471
+ base = self.safe_currency_code(baseId)
472
+ quote = self.safe_currency_code(quoteId)
473
+ state = self.safe_string(market, 'state')
474
+ leverageRatio = self.safe_string(market, 'leverage-ratio', '1')
475
+ superLeverageRatio = self.safe_string(market, 'super-margin-leverage-ratio', '1')
476
+ margin = Precise.string_gt(leverageRatio, '1') or Precise.string_gt(superLeverageRatio, '1')
477
+ fee = self.parse_number('0') if (base == 'OMG') else self.parse_number('0.002')
478
+ result.append({
479
+ 'id': baseId + quoteId,
480
+ 'symbol': base + '/' + quote,
481
+ 'base': base,
482
+ 'quote': quote,
483
+ 'settle': None,
484
+ 'baseId': baseId,
485
+ 'quoteId': quoteId,
486
+ 'settleId': None,
487
+ 'type': 'spot',
488
+ 'spot': True,
489
+ 'margin': margin,
490
+ 'swap': False,
491
+ 'future': False,
492
+ 'option': False,
493
+ 'active': (state == 'online'),
494
+ 'contract': False,
495
+ 'linear': None,
496
+ 'inverse': None,
497
+ 'taker': fee,
498
+ 'maker': fee,
499
+ 'contractSize': None,
500
+ 'expiry': None,
501
+ 'expiryDatetime': None,
502
+ 'strike': None,
503
+ 'optionType': None,
504
+ 'precision': {
505
+ 'price': self.parse_number(self.parse_precision(self.safe_string(market, 'price-precision'))),
506
+ 'amount': self.parse_number(self.parse_precision(self.safe_string(market, 'amount-precision'))),
507
+ 'cost': self.parse_number(self.parse_precision(self.safe_string(market, 'value-precision'))),
508
+ },
509
+ 'limits': {
510
+ 'leverage': {
511
+ 'min': self.parse_number('1'),
512
+ 'max': self.parse_number(leverageRatio),
513
+ 'superMax': self.parse_number(superLeverageRatio),
514
+ },
515
+ 'amount': {
516
+ 'min': self.safe_number(market, 'min-order-amt'),
517
+ 'max': self.safe_number(market, 'max-order-amt'),
518
+ },
519
+ 'price': {
520
+ 'min': None,
521
+ 'max': None,
522
+ },
523
+ 'cost': {
524
+ 'min': self.safe_number(market, 'min-order-value'),
525
+ 'max': None,
526
+ },
527
+ },
528
+ 'created': None,
529
+ 'info': market,
530
+ })
531
+ return result
532
+
533
+ def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
534
+ #
535
+ # fetchTicker
536
+ #
537
+ # {
538
+ # "amount": 26228.672978342216,
539
+ # "open": 9078.95,
540
+ # "close": 9146.86,
541
+ # "high": 9155.41,
542
+ # "id": 209988544334,
543
+ # "count": 265846,
544
+ # "low": 8988.0,
545
+ # "version": 209988544334,
546
+ # "ask": [9146.87, 0.156134],
547
+ # "vol": 2.3822168242201668E8,
548
+ # "bid": [9146.86, 0.080758],
549
+ # }
550
+ #
551
+ # fetchTickers
552
+ # {
553
+ # "symbol": "bhdht",
554
+ # "open": 2.3938,
555
+ # "high": 2.4151,
556
+ # "low": 2.3323,
557
+ # "close": 2.3909,
558
+ # "amount": 628.992,
559
+ # "vol": 1493.71841095,
560
+ # "count": 2088,
561
+ # "bid": 2.3643,
562
+ # "bidSize": 0.7136,
563
+ # "ask": 2.4061,
564
+ # "askSize": 0.4156
565
+ # }
566
+ #
567
+ symbol = self.safe_symbol(None, market)
568
+ timestamp = self.safe_integer(ticker, 'ts')
569
+ bid = None
570
+ bidVolume = None
571
+ ask = None
572
+ askVolume = None
573
+ if 'bid' in ticker:
574
+ if isinstance(ticker['bid'], list):
575
+ bid = self.safe_string(ticker['bid'], 0)
576
+ bidVolume = self.safe_string(ticker['bid'], 1)
577
+ else:
578
+ bid = self.safe_string(ticker, 'bid')
579
+ bidVolume = self.safe_string(ticker, 'bidSize')
580
+ if 'ask' in ticker:
581
+ if isinstance(ticker['ask'], list):
582
+ ask = self.safe_string(ticker['ask'], 0)
583
+ askVolume = self.safe_string(ticker['ask'], 1)
584
+ else:
585
+ ask = self.safe_string(ticker, 'ask')
586
+ askVolume = self.safe_string(ticker, 'askSize')
587
+ open = self.safe_string(ticker, 'open')
588
+ close = self.safe_string(ticker, 'close')
589
+ baseVolume = self.safe_string(ticker, 'amount')
590
+ quoteVolume = self.safe_string(ticker, 'vol')
591
+ return self.safe_ticker({
592
+ 'symbol': symbol,
593
+ 'timestamp': timestamp,
594
+ 'datetime': self.iso8601(timestamp),
595
+ 'high': self.safe_string(ticker, 'high'),
596
+ 'low': self.safe_string(ticker, 'low'),
597
+ 'bid': bid,
598
+ 'bidVolume': bidVolume,
599
+ 'ask': ask,
600
+ 'askVolume': askVolume,
601
+ 'vwap': None,
602
+ 'open': open,
603
+ 'close': close,
604
+ 'last': close,
605
+ 'previousClose': None,
606
+ 'change': None,
607
+ 'percentage': None,
608
+ 'average': None,
609
+ 'baseVolume': baseVolume,
610
+ 'quoteVolume': quoteVolume,
611
+ 'info': ticker,
612
+ }, market)
613
+
614
+ def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
615
+ """
616
+ fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
617
+ :param str symbol: unified symbol of the market to fetch the order book for
618
+ :param int [limit]: the maximum amount of order book entries to return
619
+ :param dict [params]: extra parameters specific to the exchange API endpoint
620
+ :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
621
+ """
622
+ self.load_markets()
623
+ market = self.market(symbol)
624
+ request: dict = {
625
+ 'symbol': market['id'],
626
+ 'type': 'step0',
627
+ }
628
+ response = self.marketGetDepth(self.extend(request, params))
629
+ #
630
+ # {
631
+ # "status": "ok",
632
+ # "ch": "market.btcusdt.depth.step0",
633
+ # "ts": 1583474832790,
634
+ # "tick": {
635
+ # "bids": [
636
+ # [9100.290000000000000000, 0.200000000000000000],
637
+ # [9099.820000000000000000, 0.200000000000000000],
638
+ # [9099.610000000000000000, 0.205000000000000000],
639
+ # ],
640
+ # "asks": [
641
+ # [9100.640000000000000000, 0.005904000000000000],
642
+ # [9101.010000000000000000, 0.287311000000000000],
643
+ # [9101.030000000000000000, 0.012121000000000000],
644
+ # ],
645
+ # "ts":1583474832008,
646
+ # "version":104999698780
647
+ # }
648
+ # }
649
+ #
650
+ if 'tick' in response:
651
+ if not response['tick']:
652
+ raise BadSymbol(self.id + ' fetchOrderBook() returned empty response: ' + self.json(response))
653
+ tick = self.safe_value(response, 'tick')
654
+ timestamp = self.safe_integer(tick, 'ts', self.safe_integer(response, 'ts'))
655
+ result = self.parse_order_book(tick, symbol, timestamp)
656
+ result['nonce'] = self.safe_integer(tick, 'version')
657
+ return result
658
+ raise ExchangeError(self.id + ' fetchOrderBook() returned unrecognized response: ' + self.json(response))
659
+
660
+ def fetch_ticker(self, symbol: str, params={}) -> Ticker:
661
+ """
662
+ fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
663
+ :param str symbol: unified symbol of the market to fetch the ticker for
664
+ :param dict [params]: extra parameters specific to the exchange API endpoint
665
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
666
+ """
667
+ self.load_markets()
668
+ market = self.market(symbol)
669
+ request: dict = {
670
+ 'symbol': market['id'],
671
+ }
672
+ response = self.marketGetDetailMerged(self.extend(request, params))
673
+ #
674
+ # {
675
+ # "status": "ok",
676
+ # "ch": "market.btcusdt.detail.merged",
677
+ # "ts": 1583494336669,
678
+ # "tick": {
679
+ # "amount": 26228.672978342216,
680
+ # "open": 9078.95,
681
+ # "close": 9146.86,
682
+ # "high": 9155.41,
683
+ # "id": 209988544334,
684
+ # "count": 265846,
685
+ # "low": 8988.0,
686
+ # "version": 209988544334,
687
+ # "ask": [9146.87, 0.156134],
688
+ # "vol": 2.3822168242201668E8,
689
+ # "bid": [9146.86, 0.080758],
690
+ # }
691
+ # }
692
+ #
693
+ ticker = self.parse_ticker(response['tick'], market)
694
+ timestamp = self.safe_integer(response, 'ts')
695
+ ticker['timestamp'] = timestamp
696
+ ticker['datetime'] = self.iso8601(timestamp)
697
+ return ticker
698
+
699
+ def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
700
+ """
701
+ fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
702
+ :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
703
+ :param dict [params]: extra parameters specific to the exchange API endpoint
704
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
705
+ """
706
+ self.load_markets()
707
+ symbols = self.market_symbols(symbols)
708
+ response = self.marketGetTickers(params)
709
+ tickers = self.safe_value(response, 'data', [])
710
+ timestamp = self.safe_integer(response, 'ts')
711
+ result: dict = {}
712
+ for i in range(0, len(tickers)):
713
+ marketId = self.safe_string(tickers[i], 'symbol')
714
+ market = self.safe_market(marketId)
715
+ symbol = market['symbol']
716
+ ticker = self.parse_ticker(tickers[i], market)
717
+ ticker['timestamp'] = timestamp
718
+ ticker['datetime'] = self.iso8601(timestamp)
719
+ result[symbol] = ticker
720
+ return self.filter_by_array_tickers(result, 'symbol', symbols)
721
+
722
+ def parse_trade(self, trade: dict, market: Market = None) -> Trade:
723
+ #
724
+ # fetchTrades(public)
725
+ #
726
+ # {
727
+ # "amount": 0.010411000000000000,
728
+ # "trade-id": 102090736910,
729
+ # "ts": 1583497692182,
730
+ # "id": 10500517034273194594947,
731
+ # "price": 9096.050000000000000000,
732
+ # "direction": "sell"
733
+ # }
734
+ #
735
+ # fetchMyTrades(private)
736
+ #
737
+ # {
738
+ # "symbol": "swftcbtc",
739
+ # "fee-currency": "swftc",
740
+ # "filled-fees": "0",
741
+ # "source": "spot-api",
742
+ # "id": 83789509854000,
743
+ # "type": "buy-limit",
744
+ # "order-id": 83711103204909,
745
+ # 'filled-points': "0.005826843283532154",
746
+ # "fee-deduct-currency": "ht",
747
+ # 'filled-amount': "45941.53",
748
+ # "price": "0.0000001401",
749
+ # "created-at": 1597933260729,
750
+ # "match-id": 100087455560,
751
+ # "role": "maker",
752
+ # "trade-id": 100050305348
753
+ # },
754
+ #
755
+ marketId = self.safe_string(trade, 'symbol')
756
+ symbol = self.safe_symbol(marketId, market)
757
+ timestamp = self.safe_integer_2(trade, 'ts', 'created-at')
758
+ order = self.safe_string(trade, 'order-id')
759
+ side = self.safe_string(trade, 'direction')
760
+ type = self.safe_string(trade, 'type')
761
+ if type is not None:
762
+ typeParts = type.split('-')
763
+ side = typeParts[0]
764
+ type = typeParts[1]
765
+ takerOrMaker = self.safe_string(trade, 'role')
766
+ price = self.safe_string(trade, 'price')
767
+ amount = self.safe_string_2(trade, 'filled-amount', 'amount')
768
+ cost = Precise.string_mul(price, amount)
769
+ fee = None
770
+ feeCost = self.safe_string(trade, 'filled-fees')
771
+ feeCurrency = self.safe_currency_code(self.safe_string(trade, 'fee-currency'))
772
+ filledPoints = self.safe_string(trade, 'filled-points')
773
+ if filledPoints is not None:
774
+ if (feeCost is None) or (Precise.string_eq(feeCost, '0.0')):
775
+ feeCost = filledPoints
776
+ feeCurrency = self.safe_currency_code(self.safe_string(trade, 'fee-deduct-currency'))
777
+ if feeCost is not None:
778
+ fee = {
779
+ 'cost': feeCost,
780
+ 'currency': feeCurrency,
781
+ }
782
+ tradeId = self.safe_string_2(trade, 'trade-id', 'tradeId')
783
+ id = self.safe_string(trade, 'id', tradeId)
784
+ return self.safe_trade({
785
+ 'info': trade,
786
+ 'id': id,
787
+ 'symbol': symbol,
788
+ 'order': order,
789
+ 'timestamp': timestamp,
790
+ 'datetime': self.iso8601(timestamp),
791
+ 'type': type,
792
+ 'side': side,
793
+ 'takerOrMaker': takerOrMaker,
794
+ 'price': price,
795
+ 'amount': amount,
796
+ 'cost': cost,
797
+ 'fee': fee,
798
+ })
799
+
800
+ def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
801
+ """
802
+ fetch all the trades made from a single order
803
+ :param str id: order id
804
+ :param str symbol: unified market symbol
805
+ :param int [since]: the earliest time in ms to fetch trades for
806
+ :param int [limit]: the maximum number of trades to retrieve
807
+ :param dict [params]: extra parameters specific to the exchange API endpoint
808
+ :returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
809
+ """
810
+ self.load_markets()
811
+ request: dict = {
812
+ 'id': id,
813
+ }
814
+ response = self.privateGetOrderOrdersIdMatchresults(self.extend(request, params))
815
+ return self.parse_trades(response['data'], None, since, limit)
816
+
817
+ def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
818
+ """
819
+ fetch all trades made by the user
820
+ :param str symbol: unified market symbol
821
+ :param int [since]: the earliest time in ms to fetch trades for
822
+ :param int [limit]: the maximum number of trades structures to retrieve
823
+ :param dict [params]: extra parameters specific to the exchange API endpoint
824
+ :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
825
+ """
826
+ self.load_markets()
827
+ market = None
828
+ request: dict = {}
829
+ if symbol is not None:
830
+ market = self.market(symbol)
831
+ request['symbol'] = market['id']
832
+ if limit is not None:
833
+ request['size'] = limit # 1-100 orders, default is 100
834
+ if since is not None:
835
+ request['start-time'] = since # a date within 120 days from today
836
+ # request['end-time'] = self.sum(since, 172800000) # 48 hours window
837
+ response = self.privateGetOrderMatchresults(self.extend(request, params))
838
+ return self.parse_trades(response['data'], market, since, limit)
839
+
840
+ def fetch_trades(self, symbol: str, since: Int = None, limit: Int = 1000, params={}) -> List[Trade]:
841
+ """
842
+ get the list of most recent trades for a particular symbol
843
+ :param str symbol: unified symbol of the market to fetch trades for
844
+ :param int [since]: timestamp in ms of the earliest trade to fetch
845
+ :param int [limit]: the maximum amount of trades to fetch
846
+ :param dict [params]: extra parameters specific to the exchange API endpoint
847
+ :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
848
+ """
849
+ self.load_markets()
850
+ market = self.market(symbol)
851
+ request: dict = {
852
+ 'symbol': market['id'],
853
+ }
854
+ if limit is not None:
855
+ request['size'] = min(limit, 2000)
856
+ response = self.marketGetHistoryTrade(self.extend(request, params))
857
+ #
858
+ # {
859
+ # "status": "ok",
860
+ # "ch": "market.btcusdt.trade.detail",
861
+ # "ts": 1583497692365,
862
+ # "data": [
863
+ # {
864
+ # "id": 105005170342,
865
+ # "ts": 1583497692182,
866
+ # "data": [
867
+ # {
868
+ # "amount": 0.010411000000000000,
869
+ # "trade-id": 102090736910,
870
+ # "ts": 1583497692182,
871
+ # "id": 10500517034273194594947,
872
+ # "price": 9096.050000000000000000,
873
+ # "direction": "sell"
874
+ # }
875
+ # ]
876
+ # },
877
+ # # ...
878
+ # ]
879
+ # }
880
+ #
881
+ data = self.safe_value(response, 'data', [])
882
+ result = []
883
+ for i in range(0, len(data)):
884
+ trades = self.safe_value(data[i], 'data', [])
885
+ for j in range(0, len(trades)):
886
+ trade = self.parse_trade(trades[j], market)
887
+ result.append(trade)
888
+ result = self.sort_by(result, 'timestamp')
889
+ return self.filter_by_symbol_since_limit(result, market['symbol'], since, limit)
890
+
891
+ def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
892
+ #
893
+ # {
894
+ # "amount":1.2082,
895
+ # "open":0.025096,
896
+ # "close":0.025095,
897
+ # "high":0.025096,
898
+ # "id":1591515300,
899
+ # "count":6,
900
+ # "low":0.025095,
901
+ # "vol":0.0303205097
902
+ # }
903
+ #
904
+ return [
905
+ self.safe_timestamp(ohlcv, 'id'),
906
+ self.safe_number(ohlcv, 'open'),
907
+ self.safe_number(ohlcv, 'high'),
908
+ self.safe_number(ohlcv, 'low'),
909
+ self.safe_number(ohlcv, 'close'),
910
+ self.safe_number(ohlcv, 'amount'),
911
+ ]
912
+
913
+ def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = 1000, params={}) -> List[list]:
914
+ """
915
+ fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
916
+ :param str symbol: unified symbol of the market to fetch OHLCV data for
917
+ :param str timeframe: the length of time each candle represents
918
+ :param int [since]: timestamp in ms of the earliest candle to fetch
919
+ :param int [limit]: the maximum amount of candles to fetch
920
+ :param dict [params]: extra parameters specific to the exchange API endpoint
921
+ :returns int[][]: A list of candles ordered, open, high, low, close, volume
922
+ """
923
+ self.load_markets()
924
+ market = self.market(symbol)
925
+ request: dict = {
926
+ 'symbol': market['id'],
927
+ 'period': self.safe_string(self.timeframes, timeframe, timeframe),
928
+ }
929
+ if limit is not None:
930
+ request['size'] = min(limit, 2000)
931
+ response = self.marketGetHistoryKline(self.extend(request, params))
932
+ #
933
+ # {
934
+ # "status":"ok",
935
+ # "ch":"market.ethbtc.kline.1min",
936
+ # "ts":1591515374371,
937
+ # "data":[
938
+ # {"amount":0.0,"open":0.025095,"close":0.025095,"high":0.025095,"id":1591515360,"count":0,"low":0.025095,"vol":0.0},
939
+ # {"amount":1.2082,"open":0.025096,"close":0.025095,"high":0.025096,"id":1591515300,"count":6,"low":0.025095,"vol":0.0303205097},
940
+ # {"amount":0.0648,"open":0.025096,"close":0.025096,"high":0.025096,"id":1591515240,"count":2,"low":0.025096,"vol":0.0016262208},
941
+ # ]
942
+ # }
943
+ #
944
+ data = self.safe_list(response, 'data', [])
945
+ return self.parse_ohlcvs(data, market, timeframe, since, limit)
946
+
947
+ def fetch_accounts(self, params={}) -> List[Account]:
948
+ """
949
+ fetch all the accounts associated with a profile
950
+ :param dict [params]: extra parameters specific to the exchange API endpoint
951
+ :returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
952
+ """
953
+ self.load_markets()
954
+ response = self.privateGetAccountAccounts(params)
955
+ return response['data']
956
+
957
+ def fetch_currencies(self, params={}) -> Currencies:
958
+ """
959
+ fetches all available currencies on an exchange
960
+ :param dict [params]: extra parameters specific to the exchange API endpoint
961
+ :returns dict: an associative dictionary of currencies
962
+ """
963
+ request: dict = {
964
+ 'language': self.options['language'],
965
+ }
966
+ response = self.publicGetSettingsCurrencys(self.extend(request, params))
967
+ #
968
+ # {
969
+ # "status":"ok",
970
+ # "data":[
971
+ # {
972
+ # "currency-addr-with-tag":false,
973
+ # "fast-confirms":12,
974
+ # "safe-confirms":12,
975
+ # "currency-type":"eth",
976
+ # "quote-currency":true,
977
+ # "withdraw-enable-timestamp":1609430400000,
978
+ # "deposit-enable-timestamp":1609430400000,
979
+ # "currency-partition":"all",
980
+ # "support-sites":["OTC","INSTITUTION","MINEPOOL"],
981
+ # "withdraw-precision":6,
982
+ # "visible-assets-timestamp":1508839200000,
983
+ # "deposit-min-amount":"1",
984
+ # "withdraw-min-amount":"10",
985
+ # "show-precision":"8",
986
+ # "tags":"",
987
+ # "weight":23,
988
+ # "full-name":"Tether USDT",
989
+ # "otc-enable":1,
990
+ # "visible":true,
991
+ # "white-enabled":false,
992
+ # "country-disabled":false,
993
+ # "deposit-enabled":true,
994
+ # "withdraw-enabled":true,
995
+ # "name":"usdt",
996
+ # "state":"online",
997
+ # "display-name":"USDT",
998
+ # "suspend-withdraw-desc":null,
999
+ # "withdraw-desc":"Minimum withdrawal amount: 10 USDT(ERC20). not >_<not To ensure the safety of your funds, your withdrawal request will be manually reviewed if your security strategy or password is changed. Please wait for phone calls or emails from our staff.not >_<not Please make sure that your computer and browser are secure and your information is protected from being tampered or leaked.",
1000
+ # "suspend-deposit-desc":null,
1001
+ # "deposit-desc":"Please don’t deposit any other digital assets except USDT to the above address. Otherwise, you may lose your assets permanently. not >_<not Depositing to the above address requires confirmations of the entire network. It will arrive after 12 confirmations, and it will be available to withdraw after 12 confirmations. not >_<not Minimum deposit amount: 1 USDT. Any deposits less than the minimum will not be credited or refunded.not >_<not Your deposit address won’t change often. If there are any changes, we will notify you via announcement or email.not >_<not Please make sure that your computer and browser are secure and your information is protected from being tampered or leaked.",
1002
+ # "suspend-visible-desc":null
1003
+ # }
1004
+ # ]
1005
+ # }
1006
+ #
1007
+ currencies = self.safe_value(response, 'data', [])
1008
+ result: dict = {}
1009
+ for i in range(0, len(currencies)):
1010
+ currency = currencies[i]
1011
+ id = self.safe_value(currency, 'name')
1012
+ code = self.safe_currency_code(id)
1013
+ depositEnabled = self.safe_value(currency, 'deposit-enabled')
1014
+ withdrawEnabled = self.safe_value(currency, 'withdraw-enabled')
1015
+ countryDisabled = self.safe_value(currency, 'country-disabled')
1016
+ visible = self.safe_bool(currency, 'visible', False)
1017
+ state = self.safe_string(currency, 'state')
1018
+ active = visible and depositEnabled and withdrawEnabled and (state == 'online') and not countryDisabled
1019
+ name = self.safe_string(currency, 'display-name')
1020
+ precision = self.parse_number(self.parse_precision(self.safe_string(currency, 'withdraw-precision')))
1021
+ result[code] = {
1022
+ 'id': id,
1023
+ 'code': code,
1024
+ 'type': 'crypto',
1025
+ # 'payin': currency['deposit-enabled'],
1026
+ # 'payout': currency['withdraw-enabled'],
1027
+ # 'transfer': None,
1028
+ 'name': name,
1029
+ 'active': active,
1030
+ 'deposit': depositEnabled,
1031
+ 'withdraw': withdrawEnabled,
1032
+ 'fee': None, # todo need to fetch from fee endpoint
1033
+ 'precision': precision,
1034
+ 'limits': {
1035
+ 'amount': {
1036
+ 'min': precision,
1037
+ 'max': None,
1038
+ },
1039
+ 'deposit': {
1040
+ 'min': self.safe_number(currency, 'deposit-min-amount'),
1041
+ 'max': None,
1042
+ },
1043
+ 'withdraw': {
1044
+ 'min': self.safe_number(currency, 'withdraw-min-amount'),
1045
+ 'max': None,
1046
+ },
1047
+ },
1048
+ 'info': currency,
1049
+ }
1050
+ return result
1051
+
1052
+ def parse_balance(self, response) -> Balances:
1053
+ balances = self.safe_value(response['data'], 'list', [])
1054
+ result: dict = {'info': response}
1055
+ for i in range(0, len(balances)):
1056
+ balance = balances[i]
1057
+ currencyId = self.safe_string(balance, 'currency')
1058
+ code = self.safe_currency_code(currencyId)
1059
+ account = None
1060
+ if code in result:
1061
+ account = result[code]
1062
+ else:
1063
+ account = self.account()
1064
+ if balance['type'] == 'trade':
1065
+ account['free'] = self.safe_string(balance, 'balance')
1066
+ if balance['type'] == 'frozen':
1067
+ account['used'] = self.safe_string(balance, 'balance')
1068
+ result[code] = account
1069
+ return self.safe_balance(result)
1070
+
1071
+ def fetch_balance(self, params={}) -> Balances:
1072
+ """
1073
+ query for balance and get the amount of funds available for trading or funds locked in orders
1074
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1075
+ :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
1076
+ """
1077
+ self.load_markets()
1078
+ self.load_accounts()
1079
+ method = self.options['fetchBalanceMethod']
1080
+ request: dict = {
1081
+ 'id': self.accounts[0]['id'],
1082
+ }
1083
+ response = getattr(self, method)(self.extend(request, params))
1084
+ return self.parse_balance(response)
1085
+
1086
+ def fetch_orders_by_states(self, states, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1087
+ self.load_markets()
1088
+ request: dict = {
1089
+ 'states': states,
1090
+ }
1091
+ market = None
1092
+ if symbol is not None:
1093
+ market = self.market(symbol)
1094
+ request['symbol'] = market['id']
1095
+ method = self.safe_string(self.options, 'fetchOrdersByStatesMethod', 'private_get_order_orders')
1096
+ response = getattr(self, method)(self.extend(request, params))
1097
+ #
1098
+ # {"status": "ok",
1099
+ # "data": [{ id: 13997833014,
1100
+ # "symbol": "ethbtc",
1101
+ # "account-id": 3398321,
1102
+ # "amount": "0.045000000000000000",
1103
+ # "price": "0.034014000000000000",
1104
+ # "created-at": 1545836976871,
1105
+ # "type": "sell-limit",
1106
+ # "field-amount": "0.045000000000000000",
1107
+ # "field-cash-amount": "0.001530630000000000",
1108
+ # "field-fees": "0.000003061260000000",
1109
+ # "finished-at": 1545837948214,
1110
+ # "source": "spot-api",
1111
+ # "state": "filled",
1112
+ # "canceled-at": 0 } ]}
1113
+ #
1114
+ return self.parse_orders(response['data'], market, since, limit)
1115
+
1116
+ def fetch_order(self, id: str, symbol: Str = None, params={}):
1117
+ """
1118
+ fetches information on an order made by the user
1119
+ :param str symbol: unified symbol of the market the order was made in
1120
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1121
+ :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1122
+ """
1123
+ self.load_markets()
1124
+ request: dict = {
1125
+ 'id': id,
1126
+ }
1127
+ response = self.privateGetOrderOrdersId(self.extend(request, params))
1128
+ order = self.safe_dict(response, 'data')
1129
+ return self.parse_order(order)
1130
+
1131
+ def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1132
+ """
1133
+ fetches information on multiple orders made by the user
1134
+ :param str symbol: unified market symbol of the market orders were made in
1135
+ :param int [since]: the earliest time in ms to fetch orders for
1136
+ :param int [limit]: the maximum number of order structures to retrieve
1137
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1138
+ :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1139
+ """
1140
+ return self.fetch_orders_by_states('pre-submitted,submitted,partial-filled,filled,partial-canceled,canceled', symbol, since, limit, params)
1141
+
1142
+ def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1143
+ """
1144
+ fetch all unfilled currently open orders
1145
+ :param str symbol: unified market symbol
1146
+ :param int [since]: the earliest time in ms to fetch open orders for
1147
+ :param int [limit]: the maximum number of open orders structures to retrieve
1148
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1149
+ :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1150
+ """
1151
+ method = self.safe_string(self.options, 'fetchOpenOrdersMethod', 'fetch_open_orders_v1')
1152
+ return getattr(self, method)(symbol, since, limit, params)
1153
+
1154
+ def fetch_open_orders_v1(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1155
+ if symbol is None:
1156
+ raise ArgumentsRequired(self.id + ' fetchOpenOrdersV1() requires a symbol argument')
1157
+ return self.fetch_orders_by_states('pre-submitted,submitted,partial-filled', symbol, since, limit, params)
1158
+
1159
+ def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1160
+ """
1161
+ fetches information on multiple closed orders made by the user
1162
+ :param str symbol: unified market symbol of the market orders were made in
1163
+ :param int [since]: the earliest time in ms to fetch orders for
1164
+ :param int [limit]: the maximum number of order structures to retrieve
1165
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1166
+ :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1167
+ """
1168
+ return self.fetch_orders_by_states('filled,partial-canceled,canceled', symbol, since, limit, params)
1169
+
1170
+ def fetch_open_orders_v2(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1171
+ self.load_markets()
1172
+ request: dict = {}
1173
+ market = None
1174
+ if symbol is not None:
1175
+ market = self.market(symbol)
1176
+ request['symbol'] = market['id']
1177
+ accountId = self.safe_string(params, 'account-id')
1178
+ if accountId is None:
1179
+ # pick the first account
1180
+ self.load_accounts()
1181
+ for i in range(0, len(self.accounts)):
1182
+ account = self.accounts[i]
1183
+ if account['type'] == 'spot':
1184
+ accountId = self.safe_string(account, 'id')
1185
+ if accountId is not None:
1186
+ break
1187
+ request['account-id'] = accountId
1188
+ if limit is not None:
1189
+ request['size'] = limit
1190
+ omitted = self.omit(params, 'account-id')
1191
+ response = self.privateGetOrderOpenOrders(self.extend(request, omitted))
1192
+ #
1193
+ # {
1194
+ # "status":"ok",
1195
+ # "data":[
1196
+ # {
1197
+ # "symbol":"ethusdt",
1198
+ # "source":"api",
1199
+ # "amount":"0.010000000000000000",
1200
+ # "account-id":1528640,
1201
+ # "created-at":1561597491963,
1202
+ # "price":"400.000000000000000000",
1203
+ # "filled-amount":"0.0",
1204
+ # "filled-cash-amount":"0.0",
1205
+ # "filled-fees":"0.0",
1206
+ # "id":38477101630,
1207
+ # "state":"submitted",
1208
+ # "type":"sell-limit"
1209
+ # }
1210
+ # ]
1211
+ # }
1212
+ #
1213
+ data = self.safe_list(response, 'data', [])
1214
+ return self.parse_orders(data, market, since, limit)
1215
+
1216
+ def parse_order_status(self, status: Str):
1217
+ statuses: dict = {
1218
+ 'partial-filled': 'open',
1219
+ 'partial-canceled': 'canceled',
1220
+ 'filled': 'closed',
1221
+ 'canceled': 'canceled',
1222
+ 'submitted': 'open',
1223
+ }
1224
+ return self.safe_string(statuses, status, status)
1225
+
1226
+ def parse_order(self, order: dict, market: Market = None) -> Order:
1227
+ #
1228
+ # { id: 13997833014,
1229
+ # "symbol": "ethbtc",
1230
+ # "account-id": 3398321,
1231
+ # "amount": "0.045000000000000000",
1232
+ # "price": "0.034014000000000000",
1233
+ # "created-at": 1545836976871,
1234
+ # "type": "sell-limit",
1235
+ # "field-amount": "0.045000000000000000", # they have fixed it for filled-amount
1236
+ # "field-cash-amount": "0.001530630000000000", # they have fixed it for filled-cash-amount
1237
+ # "field-fees": "0.000003061260000000", # they have fixed it for filled-fees
1238
+ # "finished-at": 1545837948214,
1239
+ # "source": "spot-api",
1240
+ # "state": "filled",
1241
+ # "canceled-at": 0 }
1242
+ #
1243
+ # { id: 20395337822,
1244
+ # "symbol": "ethbtc",
1245
+ # "account-id": 5685075,
1246
+ # "amount": "0.001000000000000000",
1247
+ # "price": "0.0",
1248
+ # "created-at": 1545831584023,
1249
+ # "type": "buy-market",
1250
+ # "field-amount": "0.029100000000000000", # they have fixed it for filled-amount
1251
+ # "field-cash-amount": "0.000999788700000000", # they have fixed it for filled-cash-amount
1252
+ # "field-fees": "0.000058200000000000", # they have fixed it for filled-fees
1253
+ # "finished-at": 1545831584181,
1254
+ # "source": "spot-api",
1255
+ # "state": "filled",
1256
+ # "canceled-at": 0 }
1257
+ #
1258
+ id = self.safe_string(order, 'id')
1259
+ side = None
1260
+ type = None
1261
+ status = None
1262
+ if 'type' in order:
1263
+ orderType = order['type'].split('-')
1264
+ side = orderType[0]
1265
+ type = orderType[1]
1266
+ status = self.parse_order_status(self.safe_string(order, 'state'))
1267
+ marketId = self.safe_string(order, 'symbol')
1268
+ market = self.safe_market(marketId, market)
1269
+ timestamp = self.safe_integer(order, 'created-at')
1270
+ clientOrderId = self.safe_string(order, 'client-order-id')
1271
+ amount = self.safe_string(order, 'amount')
1272
+ filled = self.safe_string_2(order, 'filled-amount', 'field-amount') # typo in their API, filled amount
1273
+ price = self.safe_string(order, 'price')
1274
+ cost = self.safe_string_2(order, 'filled-cash-amount', 'field-cash-amount') # same typo
1275
+ feeCost = self.safe_string_2(order, 'filled-fees', 'field-fees') # typo in their API, filled fees
1276
+ fee = None
1277
+ if feeCost is not None:
1278
+ feeCurrency = market['quote'] if (side == 'sell') else market['base']
1279
+ fee = {
1280
+ 'cost': feeCost,
1281
+ 'currency': feeCurrency,
1282
+ }
1283
+ return self.safe_order({
1284
+ 'info': order,
1285
+ 'id': id,
1286
+ 'clientOrderId': clientOrderId,
1287
+ 'timestamp': timestamp,
1288
+ 'datetime': self.iso8601(timestamp),
1289
+ 'lastTradeTimestamp': None,
1290
+ 'symbol': market['symbol'],
1291
+ 'type': type,
1292
+ 'timeInForce': None,
1293
+ 'postOnly': None,
1294
+ 'side': side,
1295
+ 'price': price,
1296
+ 'stopPrice': None,
1297
+ 'triggerPrice': None,
1298
+ 'average': None,
1299
+ 'cost': cost,
1300
+ 'amount': amount,
1301
+ 'filled': filled,
1302
+ 'remaining': None,
1303
+ 'status': status,
1304
+ 'fee': fee,
1305
+ 'trades': None,
1306
+ }, market)
1307
+
1308
+ def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1309
+ """
1310
+ create a market buy order by providing the symbol and cost
1311
+ :param str symbol: unified symbol of the market to create an order in
1312
+ :param float cost: how much you want to trade in units of the quote currency
1313
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1314
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1315
+ """
1316
+ self.load_markets()
1317
+ market = self.market(symbol)
1318
+ if not market['spot']:
1319
+ raise NotSupported(self.id + ' createMarketBuyOrderWithCost() supports spot orders only')
1320
+ params['createMarketBuyOrderRequiresPrice'] = False
1321
+ return self.create_order(symbol, 'market', 'buy', cost, None, params)
1322
+
1323
+ def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1324
+ """
1325
+ create a trade order
1326
+ :param str symbol: unified symbol of the market to create an order in
1327
+ :param str type: 'market' or 'limit'
1328
+ :param str side: 'buy' or 'sell'
1329
+ :param float amount: how much of currency you want to trade in units of base currency
1330
+ :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1331
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1332
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1333
+ """
1334
+ self.load_markets()
1335
+ self.load_accounts()
1336
+ market = self.market(symbol)
1337
+ request: dict = {
1338
+ 'account-id': self.accounts[0]['id'],
1339
+ 'symbol': market['id'],
1340
+ 'type': side + '-' + type,
1341
+ }
1342
+ clientOrderId = self.safe_string_2(params, 'clientOrderId', 'client-order-id') # must be 64 chars max and unique within 24 hours
1343
+ if clientOrderId is None:
1344
+ broker = self.safe_value(self.options, 'broker', {})
1345
+ brokerId = self.safe_string(broker, 'id')
1346
+ request['client-order-id'] = brokerId + self.uuid()
1347
+ else:
1348
+ request['client-order-id'] = clientOrderId
1349
+ params = self.omit(params, ['clientOrderId', 'client-order-id'])
1350
+ if (type == 'market') and (side == 'buy'):
1351
+ quoteAmount = None
1352
+ createMarketBuyOrderRequiresPrice = True
1353
+ createMarketBuyOrderRequiresPrice, params = self.handle_option_and_params(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', True)
1354
+ cost = self.safe_number(params, 'cost')
1355
+ params = self.omit(params, 'cost')
1356
+ if cost is not None:
1357
+ quoteAmount = self.amount_to_precision(symbol, cost)
1358
+ elif createMarketBuyOrderRequiresPrice:
1359
+ if price is None:
1360
+ raise InvalidOrder(self.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend(amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to False and pass the cost to spend in the amount argument')
1361
+ else:
1362
+ # despite that cost = amount * price is in quote currency and should have quote precision
1363
+ # the exchange API requires the cost supplied in 'amount' to be of base precision
1364
+ # more about it here:
1365
+ # https://github.com/ccxt/ccxt/pull/4395
1366
+ # https://github.com/ccxt/ccxt/issues/7611
1367
+ # we use amountToPrecision here because the exchange requires cost in base precision
1368
+ amountString = self.number_to_string(amount)
1369
+ priceString = self.number_to_string(price)
1370
+ quoteAmount = self.amount_to_precision(symbol, Precise.string_mul(amountString, priceString))
1371
+ else:
1372
+ quoteAmount = self.amount_to_precision(symbol, amount)
1373
+ request['amount'] = quoteAmount
1374
+ else:
1375
+ request['amount'] = self.amount_to_precision(symbol, amount)
1376
+ if type == 'limit' or type == 'ioc' or type == 'limit-maker' or type == 'stop-limit' or type == 'stop-limit-fok':
1377
+ request['price'] = self.price_to_precision(symbol, price)
1378
+ method = self.options['createOrderMethod']
1379
+ response = getattr(self, method)(self.extend(request, params))
1380
+ id = self.safe_string(response, 'data')
1381
+ return self.safe_order({
1382
+ 'info': response,
1383
+ 'id': id,
1384
+ 'timestamp': None,
1385
+ 'datetime': None,
1386
+ 'lastTradeTimestamp': None,
1387
+ 'status': None,
1388
+ 'symbol': symbol,
1389
+ 'type': type,
1390
+ 'side': side,
1391
+ 'price': price,
1392
+ 'amount': amount,
1393
+ 'filled': None,
1394
+ 'remaining': None,
1395
+ 'cost': None,
1396
+ 'trades': None,
1397
+ 'fee': None,
1398
+ 'clientOrderId': None,
1399
+ 'average': None,
1400
+ }, market)
1401
+
1402
+ def cancel_order(self, id: str, symbol: Str = None, params={}):
1403
+ """
1404
+ cancels an open order
1405
+ :param str id: order id
1406
+ :param str symbol: not used by huobijp cancelOrder()
1407
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1408
+ :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1409
+ """
1410
+ response = self.privatePostOrderOrdersIdSubmitcancel({'id': id})
1411
+ #
1412
+ # {
1413
+ # "status": "ok",
1414
+ # "data": "10138899000",
1415
+ # }
1416
+ #
1417
+ return self.extend(self.parse_order(response), {
1418
+ 'id': id,
1419
+ 'status': 'canceled',
1420
+ })
1421
+
1422
+ def cancel_orders(self, ids, symbol: Str = None, params={}):
1423
+ """
1424
+ cancel multiple orders
1425
+ :param str[] ids: order ids
1426
+ :param str symbol: not used by huobijp cancelOrders()
1427
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1428
+ :returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1429
+ """
1430
+ self.load_markets()
1431
+ clientOrderIds = self.safe_value_2(params, 'clientOrderIds', 'client-order-ids')
1432
+ params = self.omit(params, ['clientOrderIds', 'client-order-ids'])
1433
+ request: dict = {}
1434
+ if clientOrderIds is None:
1435
+ request['order-ids'] = ids
1436
+ else:
1437
+ request['client-order-ids'] = clientOrderIds
1438
+ response = self.privatePostOrderOrdersBatchcancel(self.extend(request, params))
1439
+ #
1440
+ # {
1441
+ # "status": "ok",
1442
+ # "data": {
1443
+ # "success": [
1444
+ # "5983466"
1445
+ # ],
1446
+ # "failed": [
1447
+ # {
1448
+ # "err-msg": "Incorrect order state",
1449
+ # "order-state": 7,
1450
+ # "order-id": "",
1451
+ # "err-code": "order-orderstate-error",
1452
+ # "client-order-id": "first"
1453
+ # },
1454
+ # {
1455
+ # "err-msg": "Incorrect order state",
1456
+ # "order-state": 7,
1457
+ # "order-id": "",
1458
+ # "err-code": "order-orderstate-error",
1459
+ # "client-order-id": "second"
1460
+ # },
1461
+ # {
1462
+ # "err-msg": "The record is not found.",
1463
+ # "order-id": "",
1464
+ # "err-code": "base-not-found",
1465
+ # "client-order-id": "third"
1466
+ # }
1467
+ # ]
1468
+ # }
1469
+ # }
1470
+ #
1471
+ return response
1472
+
1473
+ def cancel_all_orders(self, symbol: Str = None, params={}):
1474
+ """
1475
+ cancel all open orders
1476
+ :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
1477
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1478
+ :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1479
+ """
1480
+ self.load_markets()
1481
+ request: dict = {
1482
+ # 'account-id' string False NA The account id used for self cancel Refer to GET /v1/account/accounts
1483
+ # 'symbol': market['id'], # a list of comma-separated symbols, all symbols by default
1484
+ # 'types' 'string', buy-market, sell-market, buy-limit, sell-limit, buy-ioc, sell-ioc, buy-stop-limit, sell-stop-limit, buy-limit-fok, sell-limit-fok, buy-stop-limit-fok, sell-stop-limit-fok
1485
+ # 'side': 'buy', # or 'sell'
1486
+ # 'size': 100, # the number of orders to cancel 1-100
1487
+ }
1488
+ market = None
1489
+ if symbol is not None:
1490
+ market = self.market(symbol)
1491
+ request['symbol'] = market['id']
1492
+ response = self.privatePostOrderOrdersBatchCancelOpenOrders(self.extend(request, params))
1493
+ #
1494
+ # {
1495
+ # "code": 200,
1496
+ # "data": {
1497
+ # "success-count": 2,
1498
+ # "failed-count": 0,
1499
+ # "next-id": 5454600
1500
+ # }
1501
+ # }
1502
+ #
1503
+ return response
1504
+
1505
+ def currency_to_precision(self, code, fee, networkCode=None):
1506
+ return self.decimal_to_precision(fee, 0, self.currencies[code]['precision'], self.precisionMode)
1507
+
1508
+ def safe_network(self, networkId):
1509
+ lastCharacterIndex = len(networkId) - 1
1510
+ lastCharacter = networkId[lastCharacterIndex]
1511
+ if lastCharacter == '1':
1512
+ networkId = networkId[0:lastCharacterIndex]
1513
+ networksById: dict = {}
1514
+ return self.safe_string(networksById, networkId, networkId)
1515
+
1516
+ def parse_deposit_address(self, depositAddress, currency: Currency = None):
1517
+ #
1518
+ # {
1519
+ # "currency": "usdt",
1520
+ # "address": "0xf7292eb9ba7bc50358e27f0e025a4d225a64127b",
1521
+ # "addressTag": "",
1522
+ # "chain": "usdterc20", # trc20usdt, hrc20usdt, usdt, algousdt
1523
+ # }
1524
+ #
1525
+ address = self.safe_string(depositAddress, 'address')
1526
+ tag = self.safe_string(depositAddress, 'addressTag')
1527
+ currencyId = self.safe_string(depositAddress, 'currency')
1528
+ currency = self.safe_currency(currencyId, currency)
1529
+ code = self.safe_currency_code(currencyId, currency)
1530
+ networkId = self.safe_string(depositAddress, 'chain')
1531
+ networks = self.safe_value(currency, 'networks', {})
1532
+ networksById = self.index_by(networks, 'id')
1533
+ networkValue = self.safe_value(networksById, networkId, networkId)
1534
+ network = self.safe_string(networkValue, 'network')
1535
+ self.check_address(address)
1536
+ return {
1537
+ 'currency': code,
1538
+ 'address': address,
1539
+ 'tag': tag,
1540
+ 'network': network,
1541
+ 'info': depositAddress,
1542
+ }
1543
+
1544
+ def fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1545
+ """
1546
+ fetch all deposits made to an account
1547
+ :param str code: unified currency code
1548
+ :param int [since]: the earliest time in ms to fetch deposits for
1549
+ :param int [limit]: the maximum number of deposits structures to retrieve
1550
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1551
+ :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
1552
+ """
1553
+ if limit is None or limit > 100:
1554
+ limit = 100
1555
+ self.load_markets()
1556
+ currency = None
1557
+ if code is not None:
1558
+ currency = self.currency(code)
1559
+ request: dict = {
1560
+ 'type': 'deposit',
1561
+ 'from': 0, # From 'id' ... if you want to get results after a particular transaction id, pass the id in params.from
1562
+ }
1563
+ if currency is not None:
1564
+ request['currency'] = currency['id']
1565
+ if limit is not None:
1566
+ request['size'] = limit # max 100
1567
+ response = self.privateGetQueryDepositWithdraw(self.extend(request, params))
1568
+ # return response
1569
+ return self.parse_transactions(response['data'], currency, since, limit)
1570
+
1571
+ def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1572
+ """
1573
+ fetch all withdrawals made from an account
1574
+ :param str code: unified currency code
1575
+ :param int [since]: the earliest time in ms to fetch withdrawals for
1576
+ :param int [limit]: the maximum number of withdrawals structures to retrieve
1577
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1578
+ :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
1579
+ """
1580
+ if limit is None or limit > 100:
1581
+ limit = 100
1582
+ self.load_markets()
1583
+ currency = None
1584
+ if code is not None:
1585
+ currency = self.currency(code)
1586
+ request: dict = {
1587
+ 'type': 'withdraw',
1588
+ 'from': 0, # From 'id' ... if you want to get results after a particular transaction id, pass the id in params.from
1589
+ }
1590
+ if currency is not None:
1591
+ request['currency'] = currency['id']
1592
+ if limit is not None:
1593
+ request['size'] = limit # max 100
1594
+ response = self.privateGetQueryDepositWithdraw(self.extend(request, params))
1595
+ # return response
1596
+ return self.parse_transactions(response['data'], currency, since, limit)
1597
+
1598
+ def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
1599
+ #
1600
+ # fetchDeposits
1601
+ #
1602
+ # {
1603
+ # "id": 8211029,
1604
+ # "type": "deposit",
1605
+ # "currency": "eth",
1606
+ # "chain": "eth",
1607
+ # 'tx-hash': "bd315....",
1608
+ # "amount": 0.81162421,
1609
+ # "address": "4b8b....",
1610
+ # 'address-tag": '",
1611
+ # "fee": 0,
1612
+ # "state": "safe",
1613
+ # "created-at": 1542180380965,
1614
+ # "updated-at": 1542180788077
1615
+ # }
1616
+ #
1617
+ # fetchWithdrawals
1618
+ #
1619
+ # {
1620
+ # "id": 6908275,
1621
+ # "type": "withdraw",
1622
+ # "currency": "btc",
1623
+ # "chain": "btc",
1624
+ # 'tx-hash': "c1a1a....",
1625
+ # "amount": 0.80257005,
1626
+ # "address": "1QR....",
1627
+ # 'address-tag": '",
1628
+ # "fee": 0.0005,
1629
+ # "state": "confirmed",
1630
+ # "created-at": 1552107295685,
1631
+ # "updated-at": 1552108032859
1632
+ # }
1633
+ #
1634
+ # withdraw
1635
+ #
1636
+ # {
1637
+ # "status": "ok",
1638
+ # "data": "99562054"
1639
+ # }
1640
+ #
1641
+ timestamp = self.safe_integer(transaction, 'created-at')
1642
+ code = self.safe_currency_code(self.safe_string(transaction, 'currency'))
1643
+ type = self.safe_string(transaction, 'type')
1644
+ if type == 'withdraw':
1645
+ type = 'withdrawal'
1646
+ feeCost = self.safe_string(transaction, 'fee')
1647
+ if feeCost is not None:
1648
+ feeCost = Precise.string_abs(feeCost)
1649
+ return {
1650
+ 'info': transaction,
1651
+ 'id': self.safe_string_2(transaction, 'id', 'data'),
1652
+ 'txid': self.safe_string(transaction, 'tx-hash'),
1653
+ 'timestamp': timestamp,
1654
+ 'datetime': self.iso8601(timestamp),
1655
+ 'network': self.safe_string_upper(transaction, 'chain'),
1656
+ 'address': self.safe_string(transaction, 'address'),
1657
+ 'addressTo': None,
1658
+ 'addressFrom': None,
1659
+ 'tag': self.safe_string(transaction, 'address-tag'),
1660
+ 'tagTo': None,
1661
+ 'tagFrom': None,
1662
+ 'type': type,
1663
+ 'amount': self.safe_number(transaction, 'amount'),
1664
+ 'currency': code,
1665
+ 'status': self.parse_transaction_status(self.safe_string(transaction, 'state')),
1666
+ 'updated': self.safe_integer(transaction, 'updated-at'),
1667
+ 'comment': None,
1668
+ 'internal': None,
1669
+ 'fee': {
1670
+ 'currency': code,
1671
+ 'cost': self.parse_number(feeCost),
1672
+ 'rate': None,
1673
+ },
1674
+ }
1675
+
1676
+ def parse_transaction_status(self, status: Str):
1677
+ statuses: dict = {
1678
+ # deposit statuses
1679
+ 'unknown': 'failed',
1680
+ 'confirming': 'pending',
1681
+ 'confirmed': 'ok',
1682
+ 'safe': 'ok',
1683
+ 'orphan': 'failed',
1684
+ # withdrawal statuses
1685
+ 'submitted': 'pending',
1686
+ 'canceled': 'canceled',
1687
+ 'reexamine': 'pending',
1688
+ 'reject': 'failed',
1689
+ 'pass': 'pending',
1690
+ 'wallet-reject': 'failed',
1691
+ # 'confirmed': 'ok', # present in deposit statuses
1692
+ 'confirm-error': 'failed',
1693
+ 'repealed': 'failed',
1694
+ 'wallet-transfer': 'pending',
1695
+ 'pre-transfer': 'pending',
1696
+ }
1697
+ return self.safe_string(statuses, status, status)
1698
+
1699
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
1700
+ """
1701
+ make a withdrawal
1702
+ :param str code: unified currency code
1703
+ :param float amount: the amount to withdraw
1704
+ :param str address: the address to withdraw to
1705
+ :param str tag:
1706
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1707
+ :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
1708
+ """
1709
+ tag, params = self.handle_withdraw_tag_and_params(tag, params)
1710
+ self.load_markets()
1711
+ self.check_address(address)
1712
+ currency = self.currency(code)
1713
+ request: dict = {
1714
+ 'address': address, # only supports existing addresses in your withdraw address list
1715
+ 'amount': amount,
1716
+ 'currency': currency['id'].lower(),
1717
+ }
1718
+ if tag is not None:
1719
+ request['addr-tag'] = tag # only for XRP?
1720
+ networks = self.safe_value(self.options, 'networks', {})
1721
+ network = self.safe_string_upper(params, 'network') # self line allows the user to specify either ERC20 or ETH
1722
+ network = self.safe_string_lower(networks, network, network) # handle ETH>ERC20 alias
1723
+ if network is not None:
1724
+ # possible chains - usdterc20, trc20usdt, hrc20usdt, usdt, algousdt
1725
+ if network == 'erc20':
1726
+ request['chain'] = currency['id'] + network
1727
+ else:
1728
+ request['chain'] = network + currency['id']
1729
+ params = self.omit(params, 'network')
1730
+ response = self.privatePostDwWithdrawApiCreate(self.extend(request, params))
1731
+ #
1732
+ # {
1733
+ # "status": "ok",
1734
+ # "data": "99562054"
1735
+ # }
1736
+ #
1737
+ return self.parse_transaction(response, currency)
1738
+
1739
+ def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
1740
+ url = '/'
1741
+ if api == 'market':
1742
+ url += api
1743
+ elif (api == 'public') or (api == 'private'):
1744
+ url += self.version
1745
+ elif (api == 'v2Public') or (api == 'v2Private'):
1746
+ url += 'v2'
1747
+ url += '/' + self.implode_params(path, params)
1748
+ query = self.omit(params, self.extract_params(path))
1749
+ if api == 'private' or api == 'v2Private':
1750
+ self.check_required_credentials()
1751
+ timestamp = self.ymdhms(self.milliseconds(), 'T')
1752
+ request: dict = {
1753
+ 'SignatureMethod': 'HmacSHA256',
1754
+ 'SignatureVersion': '2',
1755
+ 'AccessKeyId': self.apiKey,
1756
+ 'Timestamp': timestamp,
1757
+ }
1758
+ if method != 'POST':
1759
+ request = self.extend(request, query)
1760
+ requestSorted = self.keysort(request)
1761
+ auth = self.urlencode(requestSorted)
1762
+ # unfortunately, PHP demands double quotes for the escaped newline symbol
1763
+ # eslint-disable-next-line quotes
1764
+ payload = "\n".join([method, self.hostname, url, auth])
1765
+ signature = self.hmac(self.encode(payload), self.encode(self.secret), hashlib.sha256, 'base64')
1766
+ auth += '&' + self.urlencode({'Signature': signature})
1767
+ url += '?' + auth
1768
+ if method == 'POST':
1769
+ body = self.json(query)
1770
+ headers = {
1771
+ 'Content-Type': 'application/json',
1772
+ }
1773
+ else:
1774
+ headers = {
1775
+ 'Content-Type': 'application/x-www-form-urlencoded',
1776
+ }
1777
+ else:
1778
+ if params:
1779
+ url += '?' + self.urlencode(params)
1780
+ url = self.implode_params(self.urls['api'][api], {
1781
+ 'hostname': self.hostname,
1782
+ }) + url
1783
+ return {'url': url, 'method': method, 'body': body, 'headers': headers}
1784
+
1785
+ def handle_errors(self, httpCode: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
1786
+ if response is None:
1787
+ return None # fallback to default error handler
1788
+ if 'status' in response:
1789
+ #
1790
+ # {"status":"error","err-code":"order-limitorder-amount-min-error","err-msg":"limit order amount error, min: `0.001`","data":null}
1791
+ #
1792
+ status = self.safe_string(response, 'status')
1793
+ if status == 'error':
1794
+ code = self.safe_string(response, 'err-code')
1795
+ feedback = self.id + ' ' + body
1796
+ self.throw_broadly_matched_exception(self.exceptions['broad'], body, feedback)
1797
+ self.throw_exactly_matched_exception(self.exceptions['exact'], code, feedback)
1798
+ message = self.safe_string(response, 'err-msg')
1799
+ self.throw_exactly_matched_exception(self.exceptions['exact'], message, feedback)
1800
+ raise ExchangeError(feedback)
1801
+ return None