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
@@ -0,0 +1,1966 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # -----------------------------------------------------------------------------
4
+
5
+ __version__ = '4.3.46-0.1'
6
+
7
+ # -----------------------------------------------------------------------------
8
+
9
+ import asyncio
10
+ import concurrent.futures
11
+ import socket
12
+ import certifi
13
+ import aiohttp
14
+ import ssl
15
+ import sys
16
+ import yarl
17
+ import math
18
+ from typing import Any, List
19
+ from ccxt.base.types import Int, Str, Num, Strings
20
+
21
+ # -----------------------------------------------------------------------------
22
+
23
+ from ccxt.async_support.base.throttler import Throttler
24
+
25
+ # -----------------------------------------------------------------------------
26
+
27
+ from ccxt.base.errors import BaseError, BadSymbol, BadRequest, BadResponse, ExchangeError, ExchangeNotAvailable, RequestTimeout, NotSupported, NullResponse, InvalidAddress, RateLimitExceeded
28
+ from ccxt.base.types import OrderType, OrderSide, OrderRequest, CancellationRequest
29
+
30
+ # -----------------------------------------------------------------------------
31
+
32
+ from ccxt.base.exchange import Exchange as BaseExchange, ArgumentsRequired
33
+
34
+ # -----------------------------------------------------------------------------
35
+
36
+ from ccxt.async_support.base.ws.functions import inflate, inflate64, gunzip
37
+ from ccxt.async_support.base.ws.fast_client import FastClient
38
+ from ccxt.async_support.base.ws.future import Future
39
+ from ccxt.async_support.base.ws.order_book import OrderBook, IndexedOrderBook, CountedOrderBook
40
+
41
+
42
+ # -----------------------------------------------------------------------------
43
+
44
+ try:
45
+ from aiohttp_socks import ProxyConnector
46
+ except ImportError:
47
+ ProxyConnector = None
48
+
49
+ # -----------------------------------------------------------------------------
50
+
51
+ __all__ = [
52
+ 'BaseExchange',
53
+ 'Exchange',
54
+ ]
55
+
56
+ # -----------------------------------------------------------------------------
57
+
58
+
59
+ class Exchange(BaseExchange):
60
+ synchronous = False
61
+ streaming = {
62
+ 'maxPingPongMisses': 2,
63
+ 'keepAlive': 30000
64
+ }
65
+ ping = None
66
+ newUpdates = True
67
+ clients = {}
68
+
69
+ def __init__(self, config={}):
70
+ if 'asyncio_loop' in config:
71
+ self.asyncio_loop = config['asyncio_loop']
72
+ self.aiohttp_trust_env = config.get('aiohttp_trust_env', self.aiohttp_trust_env)
73
+ self.verify = config.get('verify', self.verify)
74
+ self.own_session = 'session' not in config
75
+ self.cafile = config.get('cafile', certifi.where())
76
+ super(Exchange, self).__init__(config)
77
+ self.throttle = None
78
+ self.init_rest_rate_limiter()
79
+ self.markets_loading = None
80
+ self.reloading_markets = False
81
+
82
+ def init_rest_rate_limiter(self):
83
+ self.throttle = Throttler(self.tokenBucket, self.asyncio_loop)
84
+
85
+ def get_event_loop(self):
86
+ return self.asyncio_loop
87
+
88
+ def get_session(self):
89
+ return self.session
90
+
91
+ def __del__(self):
92
+ if self.session is not None or self.socks_proxy_sessions is not None:
93
+ self.logger.warning(self.id + " requires to release all resources with an explicit call to the .close() coroutine. If you are using the exchange instance with async coroutines, add `await exchange.close()` to your code into a place when you're done with the exchange and don't need the exchange instance anymore (at the end of your async coroutine).")
94
+
95
+ if sys.version_info >= (3, 5):
96
+ async def __aenter__(self):
97
+ self.open()
98
+ return self
99
+
100
+ async def __aexit__(self, exc_type, exc, tb):
101
+ await self.close()
102
+
103
+ def open(self):
104
+ if self.asyncio_loop is None:
105
+ if sys.version_info >= (3, 7):
106
+ self.asyncio_loop = asyncio.get_running_loop()
107
+ else:
108
+ self.asyncio_loop = asyncio.get_event_loop()
109
+ self.throttle.loop = self.asyncio_loop
110
+
111
+ if self.ssl_context is None:
112
+ # Create our SSL context object with our CA cert file
113
+ self.ssl_context = ssl.create_default_context(cafile=self.cafile) if self.verify else self.verify
114
+
115
+ if self.own_session and self.session is None:
116
+ # Pass this SSL context to aiohttp and create a TCPConnector
117
+ connector = aiohttp.TCPConnector(ssl=self.ssl_context, loop=self.asyncio_loop, enable_cleanup_closed=True)
118
+ self.session = aiohttp.ClientSession(loop=self.asyncio_loop, connector=connector, trust_env=self.aiohttp_trust_env)
119
+
120
+ async def close(self):
121
+ await self.ws_close()
122
+ if self.session is not None:
123
+ if self.own_session:
124
+ await self.session.close()
125
+ self.session = None
126
+ await self.close_proxy_sessions()
127
+
128
+ async def close_proxy_sessions(self):
129
+ if self.socks_proxy_sessions is not None:
130
+ for url in self.socks_proxy_sessions:
131
+ await self.socks_proxy_sessions[url].close()
132
+ self.socks_proxy_sessions = None
133
+
134
+ async def fetch(self, url, method='GET', headers=None, body=None):
135
+ """Perform a HTTP request and return decoded JSON data"""
136
+
137
+ # ##### PROXY & HEADERS #####
138
+ request_headers = self.prepare_request_headers(headers)
139
+ self.last_request_headers = request_headers
140
+ # proxy-url
141
+ proxyUrl = self.check_proxy_url_settings(url, method, headers, body)
142
+ if proxyUrl is not None:
143
+ request_headers.update({'Origin': self.origin})
144
+ url = proxyUrl + url
145
+ # proxy agents
146
+ final_proxy = None # set default
147
+ proxy_session = None
148
+ httpProxy, httpsProxy, socksProxy = self.check_proxy_settings(url, method, headers, body)
149
+ if httpProxy:
150
+ final_proxy = httpProxy
151
+ elif httpsProxy:
152
+ final_proxy = httpsProxy
153
+ elif socksProxy:
154
+ if ProxyConnector is None:
155
+ raise NotSupported(self.id + ' - to use SOCKS proxy with ccxt, you need "aiohttp_socks" module that can be installed by "pip install aiohttp_socks"')
156
+ # Create our SSL context object with our CA cert file
157
+ self.open() # ensure `asyncio_loop` is set
158
+ connector = ProxyConnector.from_url(
159
+ socksProxy,
160
+ # extra args copied from self.open()
161
+ ssl=self.ssl_context,
162
+ loop=self.asyncio_loop,
163
+ enable_cleanup_closed=True
164
+ )
165
+ # override session
166
+ if (self.socks_proxy_sessions is None):
167
+ self.socks_proxy_sessions = {}
168
+ if (socksProxy not in self.socks_proxy_sessions):
169
+ self.socks_proxy_sessions[socksProxy] = aiohttp.ClientSession(loop=self.asyncio_loop, connector=connector, trust_env=self.aiohttp_trust_env)
170
+ proxy_session = self.socks_proxy_sessions[socksProxy]
171
+ # add aiohttp_proxy for python as exclusion
172
+ elif self.aiohttp_proxy:
173
+ final_proxy = self.aiohttp_proxy
174
+
175
+ proxyAgentSet = final_proxy is not None or socksProxy is not None
176
+ self.checkConflictingProxies(proxyAgentSet, proxyUrl)
177
+
178
+ # avoid old proxies mixing
179
+ if (self.aiohttp_proxy is not None) and (proxyUrl is not None or httpProxy is not None or httpsProxy is not None or socksProxy is not None):
180
+ raise NotSupported(self.id + ' you have set multiple proxies, please use one or another')
181
+
182
+ # log
183
+ if self.verbose:
184
+ self.log("\nfetch Request:", self.id, method, url, "RequestHeaders:", request_headers, "RequestBody:", body)
185
+ self.logger.debug("%s %s, Request: %s %s", method, url, headers, body)
186
+ # end of proxies & headers
187
+
188
+ request_body = body
189
+ encoded_body = body.encode() if body else None
190
+ self.open()
191
+ final_session = proxy_session if proxy_session is not None else self.session
192
+ session_method = getattr(final_session, method.lower())
193
+
194
+ http_response = None
195
+ http_status_code = None
196
+ http_status_text = None
197
+ json_response = None
198
+ try:
199
+ async with session_method(yarl.URL(url, encoded=True),
200
+ data=encoded_body,
201
+ headers=request_headers,
202
+ timeout=(self.timeout / 1000),
203
+ proxy=final_proxy) as response:
204
+ http_response = await response.text(errors='replace')
205
+ # CIMultiDictProxy
206
+ raw_headers = response.headers
207
+ headers = {}
208
+ for header in raw_headers:
209
+ if header in headers:
210
+ headers[header] = headers[header] + ', ' + raw_headers[header]
211
+ else:
212
+ headers[header] = raw_headers[header]
213
+ http_status_code = response.status
214
+ http_status_text = response.reason
215
+ http_response = self.on_rest_response(http_status_code, http_status_text, url, method, headers, http_response, request_headers, request_body)
216
+ json_response = self.parse_json(http_response)
217
+ if self.enableLastHttpResponse:
218
+ self.last_http_response = http_response
219
+ if self.enableLastResponseHeaders:
220
+ self.last_response_headers = headers
221
+ if self.enableLastJsonResponse:
222
+ self.last_json_response = json_response
223
+ if self.verbose:
224
+ self.log("\nfetch Response:", self.id, method, url, http_status_code, "ResponseHeaders:", headers, "ResponseBody:", http_response)
225
+ self.logger.debug("%s %s, Response: %s %s %s", method, url, http_status_code, headers, http_response)
226
+
227
+ except socket.gaierror as e:
228
+ details = ' '.join([self.id, method, url])
229
+ raise ExchangeNotAvailable(details) from e
230
+
231
+ except (concurrent.futures.TimeoutError, asyncio.TimeoutError) as e:
232
+ details = ' '.join([self.id, method, url])
233
+ raise RequestTimeout(details) from e
234
+
235
+ except aiohttp.ClientConnectionError as e:
236
+ details = ' '.join([self.id, method, url])
237
+ raise ExchangeNotAvailable(details) from e
238
+
239
+ except aiohttp.ClientError as e: # base exception class
240
+ details = ' '.join([self.id, method, url])
241
+ raise ExchangeError(details) from e
242
+
243
+ self.handle_errors(http_status_code, http_status_text, url, method, headers, http_response, json_response, request_headers, request_body)
244
+ self.handle_http_status_code(http_status_code, http_status_text, url, method, http_response)
245
+ if json_response is not None:
246
+ return json_response
247
+ if self.is_text_response(headers):
248
+ return http_response
249
+ if http_response == '' or http_response is None:
250
+ return http_response
251
+ return response.content
252
+
253
+ async def load_markets_helper(self, reload=False, params={}):
254
+ if not reload:
255
+ if self.markets:
256
+ if not self.markets_by_id:
257
+ return self.set_markets(self.markets)
258
+ return self.markets
259
+ currencies = None
260
+ if self.has['fetchCurrencies'] is True:
261
+ currencies = await self.fetch_currencies()
262
+ markets = await self.fetch_markets(params)
263
+ return self.set_markets(markets, currencies)
264
+
265
+ async def load_markets(self, reload=False, params={}):
266
+ if (reload and not self.reloading_markets) or not self.markets_loading:
267
+ self.reloading_markets = True
268
+ coroutine = self.load_markets_helper(reload, params)
269
+ # coroutines can only be awaited once so we wrap it in a task
270
+ self.markets_loading = asyncio.ensure_future(coroutine)
271
+ try:
272
+ result = await self.markets_loading
273
+ except Exception as e:
274
+ self.reloading_markets = False
275
+ self.markets_loading = None
276
+ raise e
277
+ self.reloading_markets = False
278
+ return result
279
+
280
+ async def load_fees(self, reload=False):
281
+ if not reload:
282
+ if self.loaded_fees != Exchange.loaded_fees:
283
+ return self.loaded_fees
284
+ self.loaded_fees = self.deep_extend(self.loaded_fees, await self.fetch_fees())
285
+ return self.loaded_fees
286
+
287
+ async def fetch_markets(self, params={}):
288
+ # markets are returned as a list
289
+ # currencies are returned as a dict
290
+ # this is for historical reasons
291
+ # and may be changed for consistency later
292
+ return self.to_array(self.markets)
293
+
294
+ async def fetch_currencies(self, params={}):
295
+ # markets are returned as a list
296
+ # currencies are returned as a dict
297
+ # this is for historical reasons
298
+ # and may be changed for consistency later
299
+ return self.currencies
300
+
301
+ async def fetchOHLCVC(self, symbol, timeframe='1m', since=None, limit=None, params={}):
302
+ return await self.fetch_ohlcvc(symbol, timeframe, since, limit, params)
303
+
304
+ async def fetch_full_tickers(self, symbols=None, params={}):
305
+ return await self.fetch_tickers(symbols, params)
306
+
307
+ async def sleep(self, milliseconds):
308
+ return await asyncio.sleep(milliseconds / 1000)
309
+
310
+ async def spawn_async(self, method, *args):
311
+ try:
312
+ await method(*args)
313
+ except Exception:
314
+ # todo: handle spawned errors
315
+ pass
316
+
317
+ def spawn(self, method, *args):
318
+ def callback(asyncio_future):
319
+ exception = asyncio_future.exception()
320
+ if exception is None:
321
+ future.resolve(asyncio_future.result())
322
+ else:
323
+ future.reject(exception)
324
+ future = Future()
325
+ task = self.asyncio_loop.create_task(method(*args))
326
+ task.add_done_callback(callback)
327
+ return future
328
+
329
+ # -----------------------------------------------------------------------
330
+ # WS/PRO code
331
+
332
+ @staticmethod
333
+ def inflate(data):
334
+ return inflate(data)
335
+
336
+ @staticmethod
337
+ def inflate64(data):
338
+ return inflate64(data)
339
+
340
+ @staticmethod
341
+ def gunzip(data):
342
+ return gunzip(data)
343
+
344
+ def order_book(self, snapshot={}, depth=None):
345
+ return OrderBook(snapshot, depth)
346
+
347
+ def indexed_order_book(self, snapshot={}, depth=None):
348
+ return IndexedOrderBook(snapshot, depth)
349
+
350
+ def counted_order_book(self, snapshot={}, depth=None):
351
+ return CountedOrderBook(snapshot, depth)
352
+
353
+ def client(self, url):
354
+ self.clients = self.clients or {}
355
+ if url not in self.clients:
356
+ on_message = self.handle_message
357
+ on_error = self.on_error
358
+ on_close = self.on_close
359
+ on_connected = self.on_connected
360
+ # decide client type here: aiohttp ws / websockets / signalr / socketio
361
+ ws_options = self.safe_value(self.options, 'ws', {})
362
+ options = self.extend(self.streaming, {
363
+ 'log': getattr(self, 'log'),
364
+ 'ping': getattr(self, 'ping', None),
365
+ 'verbose': self.verbose,
366
+ 'throttle': Throttler(self.tokenBucket, self.asyncio_loop),
367
+ 'asyncio_loop': self.asyncio_loop,
368
+ }, ws_options)
369
+ self.clients[url] = FastClient(url, on_message, on_error, on_close, on_connected, options)
370
+ self.clients[url].proxy = self.get_ws_proxy()
371
+ return self.clients[url]
372
+
373
+ def get_ws_proxy(self):
374
+ httpProxy, httpsProxy, socksProxy = self.check_ws_proxy_settings()
375
+ if httpProxy:
376
+ return httpProxy
377
+ elif httpsProxy:
378
+ return httpsProxy
379
+ elif socksProxy:
380
+ return socksProxy
381
+ return None
382
+
383
+ def delay(self, timeout, method, *args):
384
+ return self.asyncio_loop.call_later(timeout / 1000, self.spawn, method, *args)
385
+
386
+ def handle_message(self, client, message):
387
+ always = True
388
+ if always:
389
+ raise NotSupported(self.id + '.handle_message() not implemented yet')
390
+ return {}
391
+
392
+ def watch_multiple(self, url, message_hashes, message=None, subscribe_hashes=None, subscription=None):
393
+ # base exchange self.open starts the aiohttp Session in an async context
394
+ self.open()
395
+ backoff_delay = 0
396
+ client = self.client(url)
397
+
398
+ future = Future.race([client.future(message_hash) for message_hash in message_hashes])
399
+
400
+ missing_subscriptions = []
401
+ if subscribe_hashes is not None:
402
+ for subscribe_hash in subscribe_hashes:
403
+ if subscribe_hash not in client.subscriptions:
404
+ missing_subscriptions.append(subscribe_hash)
405
+ client.subscriptions[subscribe_hash] = subscription or True
406
+
407
+ connected = client.connected if client.connected.done() \
408
+ else asyncio.ensure_future(client.connect(self.session, backoff_delay))
409
+
410
+ def after(fut):
411
+ # todo: decouple signing from subscriptions
412
+ options = self.safe_value(self.options, 'ws')
413
+ cost = self.safe_value(options, 'cost', 1)
414
+ if message:
415
+ async def send_message():
416
+ if self.enableRateLimit:
417
+ await client.throttle(cost)
418
+ try:
419
+ await client.send(message)
420
+ except ConnectionError as e:
421
+ client.on_error(e)
422
+ except Exception as e:
423
+ client.on_error(e)
424
+ asyncio.ensure_future(send_message())
425
+
426
+ if missing_subscriptions:
427
+ connected.add_done_callback(after)
428
+
429
+ return future
430
+
431
+ def watch(self, url, message_hash, message=None, subscribe_hash=None, subscription=None):
432
+ # base exchange self.open starts the aiohttp Session in an async context
433
+ self.open()
434
+ backoff_delay = 0
435
+ client = self.client(url)
436
+ if subscribe_hash is None and message_hash in client.futures:
437
+ return client.futures[message_hash]
438
+ future = client.future(message_hash)
439
+
440
+ subscribed = client.subscriptions.get(subscribe_hash)
441
+
442
+ if not subscribed:
443
+ client.subscriptions[subscribe_hash] = subscription or True
444
+
445
+ connected = client.connected if client.connected.done() \
446
+ else asyncio.ensure_future(client.connect(self.session, backoff_delay))
447
+
448
+ def after(fut):
449
+ # todo: decouple signing from subscriptions
450
+ options = self.safe_value(self.options, 'ws')
451
+ cost = self.safe_value(options, 'cost', 1)
452
+ if message:
453
+ async def send_message():
454
+ if self.enableRateLimit:
455
+ await client.throttle(cost)
456
+ try:
457
+ await client.send(message)
458
+ except ConnectionError as e:
459
+ client.on_error(e)
460
+ except Exception as e:
461
+ client.on_error(e)
462
+ asyncio.ensure_future(send_message())
463
+
464
+ if not subscribed:
465
+ connected.add_done_callback(after)
466
+
467
+ return future
468
+
469
+ def on_connected(self, client, message=None):
470
+ # for user hooks
471
+ # print('Connected to', client.url)
472
+ pass
473
+
474
+ def on_error(self, client, error):
475
+ if client.url in self.clients and self.clients[client.url].error:
476
+ del self.clients[client.url]
477
+
478
+ def on_close(self, client, error):
479
+ if client.error:
480
+ # connection closed by the user or due to an error
481
+ pass
482
+ else:
483
+ # server disconnected a working connection
484
+ if client.url in self.clients:
485
+ del self.clients[client.url]
486
+
487
+ async def ws_close(self):
488
+ if self.clients:
489
+ await asyncio.wait([asyncio.create_task(client.close()) for client in self.clients.values()], return_when=asyncio.ALL_COMPLETED)
490
+ for url in self.clients.copy():
491
+ del self.clients[url]
492
+
493
+ async def load_order_book(self, client, messageHash, symbol, limit=None, params={}):
494
+ if symbol not in self.orderbooks:
495
+ client.reject(ExchangeError(self.id + ' loadOrderBook() orderbook is not initiated'), messageHash)
496
+ return
497
+ try:
498
+ maxRetries = self.handle_option('watchOrderBook', 'maxRetries', 3)
499
+ tries = 0
500
+ stored = self.orderbooks[symbol]
501
+ while tries < maxRetries:
502
+ cache = stored.cache
503
+ order_book = await self.fetch_order_book(symbol, limit, params)
504
+ index = self.get_cache_index(order_book, cache)
505
+ if index >= 0:
506
+ stored.reset(order_book)
507
+ self.handle_deltas(stored, cache[index:])
508
+ cache.clear()
509
+ client.resolve(stored, messageHash)
510
+ return
511
+ tries += 1
512
+ client.reject(ExchangeError(self.id + ' nonce is behind cache after ' + str(maxRetries) + ' tries.'), messageHash)
513
+ del self.clients[client.url]
514
+ except BaseError as e:
515
+ client.reject(e, messageHash)
516
+ await self.load_order_book(client, messageHash, symbol, limit, params)
517
+
518
+ def format_scientific_notation_ftx(self, n):
519
+ if n == 0:
520
+ return '0e-00'
521
+ return format(n, 'g')
522
+
523
+ # ########################################################################
524
+ # ########################################################################
525
+ # ########################################################################
526
+ # ########################################################################
527
+ # ######## ######## ########
528
+ # ######## ######## ########
529
+ # ######## ######## ########
530
+ # ######## ######## ########
531
+ # ######## ######################## ########################
532
+ # ######## ######################## ########################
533
+ # ######## ######################## ########################
534
+ # ######## ######################## ########################
535
+ # ######## ######## ########
536
+ # ######## ######## ########
537
+ # ######## ######## ########
538
+ # ######## ######## ########
539
+ # ########################################################################
540
+ # ########################################################################
541
+ # ########################################################################
542
+ # ########################################################################
543
+ # ######## ######## ######## ########
544
+ # ######## ######## ######## ########
545
+ # ######## ######## ######## ########
546
+ # ######## ######## ######## ########
547
+ # ################ ######################## ################
548
+ # ################ ######################## ################
549
+ # ################ ######################## ################
550
+ # ################ ######################## ################
551
+ # ######## ######## ################ ################
552
+ # ######## ######## ################ ################
553
+ # ######## ######## ################ ################
554
+ # ######## ######## ################ ################
555
+ # ########################################################################
556
+ # ########################################################################
557
+ # ########################################################################
558
+ # ########################################################################
559
+
560
+ # METHODS BELOW THIS LINE ARE TRANSPILED FROM JAVASCRIPT TO PYTHON AND PHP
561
+
562
+ async def fetch_accounts(self, params={}):
563
+ raise NotSupported(self.id + ' fetchAccounts() is not supported yet')
564
+
565
+ async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}):
566
+ raise NotSupported(self.id + ' fetchTrades() is not supported yet')
567
+
568
+ async def fetch_trades_ws(self, symbol: str, since: Int = None, limit: Int = None, params={}):
569
+ raise NotSupported(self.id + ' fetchTradesWs() is not supported yet')
570
+
571
+ async def watch_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
572
+ if self.has['watchLiquidationsForSymbols']:
573
+ return self.watch_liquidations_for_symbols([symbol], since, limit, params)
574
+ raise NotSupported(self.id + ' watchLiquidations() is not supported yet')
575
+
576
+ async def watch_liquidations_for_symbols(self, symbols: List[str], since: Int = None, limit: Int = None, params={}):
577
+ raise NotSupported(self.id + ' watchLiquidationsForSymbols() is not supported yet')
578
+
579
+ async def watch_my_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
580
+ if self.has['watchMyLiquidationsForSymbols']:
581
+ return self.watch_my_liquidations_for_symbols([symbol], since, limit, params)
582
+ raise NotSupported(self.id + ' watchMyLiquidations() is not supported yet')
583
+
584
+ async def watch_my_liquidations_for_symbols(self, symbols: List[str], since: Int = None, limit: Int = None, params={}):
585
+ raise NotSupported(self.id + ' watchMyLiquidationsForSymbols() is not supported yet')
586
+
587
+ async def watch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}):
588
+ raise NotSupported(self.id + ' watchTrades() is not supported yet')
589
+
590
+ async def watch_trades_for_symbols(self, symbols: List[str], since: Int = None, limit: Int = None, params={}):
591
+ raise NotSupported(self.id + ' watchTradesForSymbols() is not supported yet')
592
+
593
+ async def watch_my_trades_for_symbols(self, symbols: List[str], since: Int = None, limit: Int = None, params={}):
594
+ raise NotSupported(self.id + ' watchMyTradesForSymbols() is not supported yet')
595
+
596
+ async def watch_orders_for_symbols(self, symbols: List[str], since: Int = None, limit: Int = None, params={}):
597
+ raise NotSupported(self.id + ' watchOrdersForSymbols() is not supported yet')
598
+
599
+ async def watch_ohlcv_for_symbols(self, symbolsAndTimeframes: List[List[str]], since: Int = None, limit: Int = None, params={}):
600
+ raise NotSupported(self.id + ' watchOHLCVForSymbols() is not supported yet')
601
+
602
+ async def watch_order_book_for_symbols(self, symbols: List[str], limit: Int = None, params={}):
603
+ raise NotSupported(self.id + ' watchOrderBookForSymbols() is not supported yet')
604
+
605
+ async def fetch_deposit_addresses(self, codes: Strings = None, params={}):
606
+ raise NotSupported(self.id + ' fetchDepositAddresses() is not supported yet')
607
+
608
+ async def fetch_order_book(self, symbol: str, limit: Int = None, params={}):
609
+ raise NotSupported(self.id + ' fetchOrderBook() is not supported yet')
610
+
611
+ async def fetch_margin_mode(self, symbol: str, params={}):
612
+ if self.has['fetchMarginModes']:
613
+ marginModes = await self.fetch_margin_modes([symbol], params)
614
+ return self.safe_dict(marginModes, symbol)
615
+ else:
616
+ raise NotSupported(self.id + ' fetchMarginMode() is not supported yet')
617
+
618
+ async def fetch_margin_modes(self, symbols: Strings = None, params={}):
619
+ raise NotSupported(self.id + ' fetchMarginModes() is not supported yet')
620
+
621
+ async def fetch_rest_order_book_safe(self, symbol, limit=None, params={}):
622
+ fetchSnapshotMaxRetries = self.handle_option('watchOrderBook', 'maxRetries', 3)
623
+ for i in range(0, fetchSnapshotMaxRetries):
624
+ try:
625
+ orderBook = await self.fetch_order_book(symbol, limit, params)
626
+ return orderBook
627
+ except Exception as e:
628
+ if (i + 1) == fetchSnapshotMaxRetries:
629
+ raise e
630
+ return None
631
+
632
+ async def watch_order_book(self, symbol: str, limit: Int = None, params={}):
633
+ raise NotSupported(self.id + ' watchOrderBook() is not supported yet')
634
+
635
+ async def fetch_time(self, params={}):
636
+ raise NotSupported(self.id + ' fetchTime() is not supported yet')
637
+
638
+ async def fetch_trading_limits(self, symbols: Strings = None, params={}):
639
+ raise NotSupported(self.id + ' fetchTradingLimits() is not supported yet')
640
+
641
+ async def fetch_cross_borrow_rates(self, params={}):
642
+ raise NotSupported(self.id + ' fetchCrossBorrowRates() is not supported yet')
643
+
644
+ async def fetch_isolated_borrow_rates(self, params={}):
645
+ raise NotSupported(self.id + ' fetchIsolatedBorrowRates() is not supported yet')
646
+
647
+ async def fetch_leverage_tiers(self, symbols: Strings = None, params={}):
648
+ raise NotSupported(self.id + ' fetchLeverageTiers() is not supported yet')
649
+
650
+ async def fetch_funding_rates(self, symbols: Strings = None, params={}):
651
+ raise NotSupported(self.id + ' fetchFundingRates() is not supported yet')
652
+
653
+ async def watch_funding_rate(self, symbol: str, params={}):
654
+ raise NotSupported(self.id + ' watchFundingRate() is not supported yet')
655
+
656
+ async def watch_funding_rates(self, symbols: List[str], params={}):
657
+ raise NotSupported(self.id + ' watchFundingRates() is not supported yet')
658
+
659
+ async def watch_funding_rates_for_symbols(self, symbols: List[str], params={}):
660
+ return await self.watch_funding_rates(symbols, params)
661
+
662
+ async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}):
663
+ raise NotSupported(self.id + ' transfer() is not supported yet')
664
+
665
+ async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
666
+ raise NotSupported(self.id + ' withdraw() is not supported yet')
667
+
668
+ async def create_deposit_address(self, code: str, params={}):
669
+ raise NotSupported(self.id + ' createDepositAddress() is not supported yet')
670
+
671
+ async def set_leverage(self, leverage: Int, symbol: Str = None, params={}):
672
+ raise NotSupported(self.id + ' setLeverage() is not supported yet')
673
+
674
+ async def fetch_leverage(self, symbol: str, params={}):
675
+ if self.has['fetchLeverages']:
676
+ leverages = await self.fetch_leverages([symbol], params)
677
+ return self.safe_dict(leverages, symbol)
678
+ else:
679
+ raise NotSupported(self.id + ' fetchLeverage() is not supported yet')
680
+
681
+ async def fetch_leverages(self, symbols: Strings = None, params={}):
682
+ raise NotSupported(self.id + ' fetchLeverages() is not supported yet')
683
+
684
+ async def set_position_mode(self, hedged: bool, symbol: Str = None, params={}):
685
+ raise NotSupported(self.id + ' setPositionMode() is not supported yet')
686
+
687
+ async def add_margin(self, symbol: str, amount: float, params={}):
688
+ raise NotSupported(self.id + ' addMargin() is not supported yet')
689
+
690
+ async def reduce_margin(self, symbol: str, amount: float, params={}):
691
+ raise NotSupported(self.id + ' reduceMargin() is not supported yet')
692
+
693
+ async def set_margin(self, symbol: str, amount: float, params={}):
694
+ raise NotSupported(self.id + ' setMargin() is not supported yet')
695
+
696
+ async def fetch_margin_adjustment_history(self, symbol: Str = None, type: Str = None, since: Num = None, limit: Num = None, params={}):
697
+ """
698
+ fetches the history of margin added or reduced from contract isolated positions
699
+ :param str [symbol]: unified market symbol
700
+ :param str [type]: "add" or "reduce"
701
+ :param int [since]: timestamp in ms of the earliest change to fetch
702
+ :param int [limit]: the maximum amount of changes to fetch
703
+ :param dict params: extra parameters specific to the exchange api endpoint
704
+ :returns dict[]: a list of `margin structures <https://docs.ccxt.com/#/?id=margin-loan-structure>`
705
+ """
706
+ raise NotSupported(self.id + ' fetchMarginAdjustmentHistory() is not supported yet')
707
+
708
+ async def set_margin_mode(self, marginMode: str, symbol: Str = None, params={}):
709
+ raise NotSupported(self.id + ' setMarginMode() is not supported yet')
710
+
711
+ async def fetch_deposit_addresses_by_network(self, code: str, params={}):
712
+ raise NotSupported(self.id + ' fetchDepositAddressesByNetwork() is not supported yet')
713
+
714
+ async def fetch_open_interest_history(self, symbol: str, timeframe='1h', since: Int = None, limit: Int = None, params={}):
715
+ raise NotSupported(self.id + ' fetchOpenInterestHistory() is not supported yet')
716
+
717
+ async def fetch_open_interest(self, symbol: str, params={}):
718
+ raise NotSupported(self.id + ' fetchOpenInterest() is not supported yet')
719
+
720
+ async def sign_in(self, params={}):
721
+ raise NotSupported(self.id + ' signIn() is not supported yet')
722
+
723
+ async def fetch_payment_methods(self, params={}):
724
+ raise NotSupported(self.id + ' fetchPaymentMethods() is not supported yet')
725
+
726
+ async def fetch_borrow_rate(self, code: str, amount, params={}):
727
+ raise NotSupported(self.id + ' fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead')
728
+
729
+ async def repay_cross_margin(self, code: str, amount, params={}):
730
+ raise NotSupported(self.id + ' repayCrossMargin is not support yet')
731
+
732
+ async def repay_isolated_margin(self, symbol: str, code: str, amount, params={}):
733
+ raise NotSupported(self.id + ' repayIsolatedMargin is not support yet')
734
+
735
+ async def borrow_cross_margin(self, code: str, amount: float, params={}):
736
+ raise NotSupported(self.id + ' borrowCrossMargin is not support yet')
737
+
738
+ async def borrow_isolated_margin(self, symbol: str, code: str, amount: float, params={}):
739
+ raise NotSupported(self.id + ' borrowIsolatedMargin is not support yet')
740
+
741
+ async def borrow_margin(self, code: str, amount, symbol: Str = None, params={}):
742
+ raise NotSupported(self.id + ' borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead')
743
+
744
+ async def repay_margin(self, code: str, amount, symbol: Str = None, params={}):
745
+ raise NotSupported(self.id + ' repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead')
746
+
747
+ async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
748
+ message = ''
749
+ if self.has['fetchTrades']:
750
+ message = '. If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see "build-ohlcv-bars" file'
751
+ raise NotSupported(self.id + ' fetchOHLCV() is not supported yet' + message)
752
+
753
+ async def fetch_ohlcv_ws(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
754
+ message = ''
755
+ if self.has['fetchTradesWs']:
756
+ message = '. If you want to build OHLCV candles from trade executions data, visit https://github.com/ccxt/ccxt/tree/master/examples/ and see "build-ohlcv-bars" file'
757
+ raise NotSupported(self.id + ' fetchOHLCVWs() is not supported yet. Try using fetchOHLCV instead.' + message)
758
+
759
+ async def watch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
760
+ raise NotSupported(self.id + ' watchOHLCV() is not supported yet')
761
+
762
+ async def fetch_web_endpoint(self, method, endpointMethod, returnAsJson, startRegex=None, endRegex=None):
763
+ errorMessage = ''
764
+ options = self.safe_value(self.options, method, {})
765
+ muteOnFailure = self.safe_bool(options, 'webApiMuteFailure', True)
766
+ try:
767
+ # if it was not explicitly disabled, then don't fetch
768
+ if self.safe_bool(options, 'webApiEnable', True) is not True:
769
+ return None
770
+ maxRetries = self.safe_value(options, 'webApiRetries', 10)
771
+ response = None
772
+ retry = 0
773
+ while(retry < maxRetries):
774
+ try:
775
+ response = await getattr(self, endpointMethod)({})
776
+ break
777
+ except Exception as e:
778
+ retry = retry + 1
779
+ if retry == maxRetries:
780
+ raise e
781
+ content = response
782
+ if startRegex is not None:
783
+ splitted_by_start = content.split(startRegex)
784
+ content = splitted_by_start[1] # we need second part after start
785
+ if endRegex is not None:
786
+ splitted_by_end = content.split(endRegex)
787
+ content = splitted_by_end[0] # we need first part after start
788
+ if returnAsJson and (isinstance(content, str)):
789
+ jsoned = self.parse_json(content.strip()) # content should be trimmed before json parsing
790
+ if jsoned:
791
+ return jsoned # if parsing was not successfull, exception should be thrown
792
+ else:
793
+ raise BadResponse('could not parse the response into json')
794
+ else:
795
+ return content
796
+ except Exception as e:
797
+ errorMessage = self.id + ' ' + method + '() failed to fetch correct data from website. Probably webpage markup has been changed, breaking the page custom parser.'
798
+ if muteOnFailure:
799
+ return None
800
+ else:
801
+ raise BadResponse(errorMessage)
802
+
803
+ async def fetch_l2_order_book(self, symbol: str, limit: Int = None, params={}):
804
+ orderbook = await self.fetch_order_book(symbol, limit, params)
805
+ return self.extend(orderbook, {
806
+ 'asks': self.sort_by(self.aggregate(orderbook['asks']), 0),
807
+ 'bids': self.sort_by(self.aggregate(orderbook['bids']), 0, True),
808
+ })
809
+
810
+ async def load_trading_limits(self, symbols: Strings = None, reload=False, params={}):
811
+ if self.has['fetchTradingLimits']:
812
+ if reload or not ('limitsLoaded' in self.options):
813
+ response = await self.fetch_trading_limits(symbols)
814
+ for i in range(0, len(symbols)):
815
+ symbol = symbols[i]
816
+ self.markets[symbol] = self.deep_extend(self.markets[symbol], response[symbol])
817
+ self.options['limitsLoaded'] = self.milliseconds()
818
+ return self.markets
819
+
820
+ async def fetch2(self, path, api: Any = 'public', method='GET', params={}, headers: Any = None, body: Any = None, config={}):
821
+ if self.enableRateLimit:
822
+ cost = self.calculate_rate_limiter_cost(api, method, path, params, config)
823
+ await self.throttle(cost)
824
+ self.lastRestRequestTimestamp = self.milliseconds()
825
+ request = self.sign(path, api, method, params, headers, body)
826
+ self.last_request_headers = request['headers']
827
+ self.last_request_body = request['body']
828
+ self.last_request_url = request['url']
829
+ return await self.fetch(request['url'], request['method'], request['headers'], request['body'])
830
+
831
+ async def request(self, path, api: Any = 'public', method='GET', params={}, headers: Any = None, body: Any = None, config={}):
832
+ return await self.fetch2(path, api, method, params, headers, body, config)
833
+
834
+ async def load_accounts(self, reload=False, params={}):
835
+ if reload:
836
+ self.accounts = await self.fetch_accounts(params)
837
+ else:
838
+ if self.accounts:
839
+ return self.accounts
840
+ else:
841
+ self.accounts = await self.fetch_accounts(params)
842
+ self.accountsById = self.index_by(self.accounts, 'id')
843
+ return self.accounts
844
+
845
+ async def edit_limit_buy_order(self, id: str, symbol: str, amount: float, price: Num = None, params={}):
846
+ return await self.edit_limit_order(id, symbol, 'buy', amount, price, params)
847
+
848
+ async def edit_limit_sell_order(self, id: str, symbol: str, amount: float, price: Num = None, params={}):
849
+ return await self.edit_limit_order(id, symbol, 'sell', amount, price, params)
850
+
851
+ async def edit_limit_order(self, id: str, symbol: str, side: OrderSide, amount: float, price: Num = None, params={}):
852
+ return await self.edit_order(id, symbol, 'limit', side, amount, price, params)
853
+
854
+ async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
855
+ await self.cancel_order(id, symbol)
856
+ return await self.create_order(symbol, type, side, amount, price, params)
857
+
858
+ async def edit_order_ws(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
859
+ await self.cancel_order_ws(id, symbol)
860
+ return await self.create_order_ws(symbol, type, side, amount, price, params)
861
+
862
+ async def fetch_permissions(self, params={}):
863
+ raise NotSupported(self.id + ' fetchPermissions() is not supported yet')
864
+
865
+ async def fetch_position(self, symbol: str, params={}):
866
+ raise NotSupported(self.id + ' fetchPosition() is not supported yet')
867
+
868
+ async def fetch_position_ws(self, symbol: str, params={}):
869
+ raise NotSupported(self.id + ' fetchPositionWs() is not supported yet')
870
+
871
+ async def watch_position(self, symbol: Str = None, params={}):
872
+ raise NotSupported(self.id + ' watchPosition() is not supported yet')
873
+
874
+ async def watch_positions(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}):
875
+ raise NotSupported(self.id + ' watchPositions() is not supported yet')
876
+
877
+ async def watch_position_for_symbols(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}):
878
+ return await self.watch_positions(symbols, since, limit, params)
879
+
880
+ async def fetch_positions_for_symbol(self, symbol: str, params={}):
881
+ """
882
+ fetches all open positions for specific symbol, unlike fetchPositions(which is designed to work with multiple symbols) so self method might be preffered for one-market position, because of less rate-limit consumption and speed
883
+ :param str symbol: unified market symbol
884
+ :param dict params: extra parameters specific to the endpoint
885
+ :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>` with maximum 3 items - possible one position for "one-way" mode, and possible two positions(long & short) for "two-way"(a.k.a. hedge) mode
886
+ """
887
+ raise NotSupported(self.id + ' fetchPositionsForSymbol() is not supported yet')
888
+
889
+ async def fetch_positions_for_symbol_ws(self, symbol: str, params={}):
890
+ """
891
+ fetches all open positions for specific symbol, unlike fetchPositions(which is designed to work with multiple symbols) so self method might be preffered for one-market position, because of less rate-limit consumption and speed
892
+ :param str symbol: unified market symbol
893
+ :param dict params: extra parameters specific to the endpoint
894
+ :returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>` with maximum 3 items - possible one position for "one-way" mode, and possible two positions(long & short) for "two-way"(a.k.a. hedge) mode
895
+ """
896
+ raise NotSupported(self.id + ' fetchPositionsForSymbol() is not supported yet')
897
+
898
+ async def fetch_positions(self, symbols: Strings = None, params={}):
899
+ raise NotSupported(self.id + ' fetchPositions() is not supported yet')
900
+
901
+ async def fetch_positions_ws(self, symbols: Strings = None, params={}):
902
+ raise NotSupported(self.id + ' fetchPositions() is not supported yet')
903
+
904
+ async def fetch_positions_risk(self, symbols: Strings = None, params={}):
905
+ raise NotSupported(self.id + ' fetchPositionsRisk() is not supported yet')
906
+
907
+ async def fetch_bids_asks(self, symbols: Strings = None, params={}):
908
+ raise NotSupported(self.id + ' fetchBidsAsks() is not supported yet')
909
+
910
+ async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
911
+ raise NotSupported(self.id + ' fetchBorrowInterest() is not supported yet')
912
+
913
+ async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
914
+ raise NotSupported(self.id + ' fetchLedger() is not supported yet')
915
+
916
+ async def fetch_ledger_entry(self, id: str, code: Str = None, params={}):
917
+ raise NotSupported(self.id + ' fetchLedgerEntry() is not supported yet')
918
+
919
+ async def fetch_balance(self, params={}):
920
+ raise NotSupported(self.id + ' fetchBalance() is not supported yet')
921
+
922
+ async def fetch_balance_ws(self, params={}):
923
+ raise NotSupported(self.id + ' fetchBalanceWs() is not supported yet')
924
+
925
+ async def watch_balance(self, params={}):
926
+ raise NotSupported(self.id + ' watchBalance() is not supported yet')
927
+
928
+ async def fetch_partial_balance(self, part, params={}):
929
+ balance = await self.fetch_balance(params)
930
+ return balance[part]
931
+
932
+ async def fetch_free_balance(self, params={}):
933
+ return await self.fetch_partial_balance('free', params)
934
+
935
+ async def fetch_used_balance(self, params={}):
936
+ return await self.fetch_partial_balance('used', params)
937
+
938
+ async def fetch_total_balance(self, params={}):
939
+ return await self.fetch_partial_balance('total', params)
940
+
941
+ async def fetch_status(self, params={}):
942
+ raise NotSupported(self.id + ' fetchStatus() is not supported yet')
943
+
944
+ async def fetch_transaction_fee(self, code: str, params={}):
945
+ if not self.has['fetchTransactionFees']:
946
+ raise NotSupported(self.id + ' fetchTransactionFee() is not supported yet')
947
+ return await self.fetch_transaction_fees([code], params)
948
+
949
+ async def fetch_transaction_fees(self, codes: Strings = None, params={}):
950
+ raise NotSupported(self.id + ' fetchTransactionFees() is not supported yet')
951
+
952
+ async def fetch_deposit_withdraw_fees(self, codes: Strings = None, params={}):
953
+ raise NotSupported(self.id + ' fetchDepositWithdrawFees() is not supported yet')
954
+
955
+ async def fetch_deposit_withdraw_fee(self, code: str, params={}):
956
+ if not self.has['fetchDepositWithdrawFees']:
957
+ raise NotSupported(self.id + ' fetchDepositWithdrawFee() is not supported yet')
958
+ fees = await self.fetch_deposit_withdraw_fees([code], params)
959
+ return self.safe_value(fees, code)
960
+
961
+ async def fetch_cross_borrow_rate(self, code: str, params={}):
962
+ await self.load_markets()
963
+ if not self.has['fetchBorrowRates']:
964
+ raise NotSupported(self.id + ' fetchCrossBorrowRate() is not supported yet')
965
+ borrowRates = await self.fetch_cross_borrow_rates(params)
966
+ rate = self.safe_value(borrowRates, code)
967
+ if rate is None:
968
+ raise ExchangeError(self.id + ' fetchCrossBorrowRate() could not find the borrow rate for currency code ' + code)
969
+ return rate
970
+
971
+ async def fetch_isolated_borrow_rate(self, symbol: str, params={}):
972
+ await self.load_markets()
973
+ if not self.has['fetchBorrowRates']:
974
+ raise NotSupported(self.id + ' fetchIsolatedBorrowRate() is not supported yet')
975
+ borrowRates = await self.fetch_isolated_borrow_rates(params)
976
+ rate = self.safe_dict(borrowRates, symbol)
977
+ if rate is None:
978
+ raise ExchangeError(self.id + ' fetchIsolatedBorrowRate() could not find the borrow rate for market symbol ' + symbol)
979
+ return rate
980
+
981
+ async def fetch_ticker(self, symbol: str, params={}):
982
+ if self.has['fetchTickers']:
983
+ await self.load_markets()
984
+ market = self.market(symbol)
985
+ symbol = market['symbol']
986
+ tickers = await self.fetch_tickers([symbol], params)
987
+ ticker = self.safe_dict(tickers, symbol)
988
+ if ticker is None:
989
+ raise NullResponse(self.id + ' fetchTickers() could not find a ticker for ' + symbol)
990
+ else:
991
+ return ticker
992
+ else:
993
+ raise NotSupported(self.id + ' fetchTicker() is not supported yet')
994
+
995
+ async def fetch_ticker_ws(self, symbol: str, params={}):
996
+ if self.has['fetchTickersWs']:
997
+ await self.load_markets()
998
+ market = self.market(symbol)
999
+ symbol = market['symbol']
1000
+ tickers = await self.fetch_ticker_ws(symbol, params)
1001
+ ticker = self.safe_dict(tickers, symbol)
1002
+ if ticker is None:
1003
+ raise NullResponse(self.id + ' fetchTickers() could not find a ticker for ' + symbol)
1004
+ else:
1005
+ return ticker
1006
+ else:
1007
+ raise NotSupported(self.id + ' fetchTicker() is not supported yet')
1008
+
1009
+ async def watch_ticker(self, symbol: str, params={}):
1010
+ raise NotSupported(self.id + ' watchTicker() is not supported yet')
1011
+
1012
+ async def fetch_tickers(self, symbols: Strings = None, params={}):
1013
+ raise NotSupported(self.id + ' fetchTickers() is not supported yet')
1014
+
1015
+ async def fetch_tickers_ws(self, symbols: Strings = None, params={}):
1016
+ raise NotSupported(self.id + ' fetchTickers() is not supported yet')
1017
+
1018
+ async def fetch_order_books(self, symbols: Strings = None, limit: Int = None, params={}):
1019
+ raise NotSupported(self.id + ' fetchOrderBooks() is not supported yet')
1020
+
1021
+ async def watch_bids_asks(self, symbols: Strings = None, params={}):
1022
+ raise NotSupported(self.id + ' watchBidsAsks() is not supported yet')
1023
+
1024
+ async def watch_tickers(self, symbols: Strings = None, params={}):
1025
+ raise NotSupported(self.id + ' watchTickers() is not supported yet')
1026
+
1027
+ async def fetch_order(self, id: str, symbol: Str = None, params={}):
1028
+ raise NotSupported(self.id + ' fetchOrder() is not supported yet')
1029
+
1030
+ async def fetch_order_ws(self, id: str, symbol: Str = None, params={}):
1031
+ raise NotSupported(self.id + ' fetchOrderWs() is not supported yet')
1032
+
1033
+ async def fetch_order_status(self, id: str, symbol: Str = None, params={}):
1034
+ # TODO: TypeScript: change method signature by replacing
1035
+ # Promise<string> with Promise<Order['status']>.
1036
+ order = await self.fetch_order(id, symbol, params)
1037
+ return order['status']
1038
+
1039
+ async def fetch_unified_order(self, order, params={}):
1040
+ return await self.fetch_order(self.safe_string(order, 'id'), self.safe_string(order, 'symbol'), params)
1041
+
1042
+ async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1043
+ raise NotSupported(self.id + ' createOrder() is not supported yet')
1044
+
1045
+ async def create_trailing_amount_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingAmount=None, trailingTriggerPrice=None, params={}):
1046
+ """
1047
+ create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
1048
+ :param str symbol: unified symbol of the market to create an order in
1049
+ :param str type: 'market' or 'limit'
1050
+ :param str side: 'buy' or 'sell'
1051
+ :param float amount: how much you want to trade in units of the base currency, or number of contracts
1052
+ :param float [price]: the price for the order to be filled at, in units of the quote currency, ignored in market orders
1053
+ :param float trailingAmount: the quote amount to trail away from the current market price
1054
+ :param float [trailingTriggerPrice]: the price to activate a trailing order, default uses the price argument
1055
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1056
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1057
+ """
1058
+ if trailingAmount is None:
1059
+ raise ArgumentsRequired(self.id + ' createTrailingAmountOrder() requires a trailingAmount argument')
1060
+ params['trailingAmount'] = trailingAmount
1061
+ if trailingTriggerPrice is not None:
1062
+ params['trailingTriggerPrice'] = trailingTriggerPrice
1063
+ if self.has['createTrailingAmountOrder']:
1064
+ return await self.create_order(symbol, type, side, amount, price, params)
1065
+ raise NotSupported(self.id + ' createTrailingAmountOrder() is not supported yet')
1066
+
1067
+ async def create_trailing_amount_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingAmount=None, trailingTriggerPrice=None, params={}):
1068
+ """
1069
+ create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
1070
+ :param str symbol: unified symbol of the market to create an order in
1071
+ :param str type: 'market' or 'limit'
1072
+ :param str side: 'buy' or 'sell'
1073
+ :param float amount: how much you want to trade in units of the base currency, or number of contracts
1074
+ :param float [price]: the price for the order to be filled at, in units of the quote currency, ignored in market orders
1075
+ :param float trailingAmount: the quote amount to trail away from the current market price
1076
+ :param float [trailingTriggerPrice]: the price to activate a trailing order, default uses the price argument
1077
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1078
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1079
+ """
1080
+ if trailingAmount is None:
1081
+ raise ArgumentsRequired(self.id + ' createTrailingAmountOrderWs() requires a trailingAmount argument')
1082
+ params['trailingAmount'] = trailingAmount
1083
+ if trailingTriggerPrice is not None:
1084
+ params['trailingTriggerPrice'] = trailingTriggerPrice
1085
+ if self.has['createTrailingAmountOrderWs']:
1086
+ return await self.create_order_ws(symbol, type, side, amount, price, params)
1087
+ raise NotSupported(self.id + ' createTrailingAmountOrderWs() is not supported yet')
1088
+
1089
+ async def create_trailing_percent_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingPercent=None, trailingTriggerPrice=None, params={}):
1090
+ """
1091
+ create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
1092
+ :param str symbol: unified symbol of the market to create an order in
1093
+ :param str type: 'market' or 'limit'
1094
+ :param str side: 'buy' or 'sell'
1095
+ :param float amount: how much you want to trade in units of the base currency, or number of contracts
1096
+ :param float [price]: the price for the order to be filled at, in units of the quote currency, ignored in market orders
1097
+ :param float trailingPercent: the percent to trail away from the current market price
1098
+ :param float [trailingTriggerPrice]: the price to activate a trailing order, default uses the price argument
1099
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1100
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1101
+ """
1102
+ if trailingPercent is None:
1103
+ raise ArgumentsRequired(self.id + ' createTrailingPercentOrder() requires a trailingPercent argument')
1104
+ params['trailingPercent'] = trailingPercent
1105
+ if trailingTriggerPrice is not None:
1106
+ params['trailingTriggerPrice'] = trailingTriggerPrice
1107
+ if self.has['createTrailingPercentOrder']:
1108
+ return await self.create_order(symbol, type, side, amount, price, params)
1109
+ raise NotSupported(self.id + ' createTrailingPercentOrder() is not supported yet')
1110
+
1111
+ async def create_trailing_percent_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, trailingPercent=None, trailingTriggerPrice=None, params={}):
1112
+ """
1113
+ create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
1114
+ :param str symbol: unified symbol of the market to create an order in
1115
+ :param str type: 'market' or 'limit'
1116
+ :param str side: 'buy' or 'sell'
1117
+ :param float amount: how much you want to trade in units of the base currency, or number of contracts
1118
+ :param float [price]: the price for the order to be filled at, in units of the quote currency, ignored in market orders
1119
+ :param float trailingPercent: the percent to trail away from the current market price
1120
+ :param float [trailingTriggerPrice]: the price to activate a trailing order, default uses the price argument
1121
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1122
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1123
+ """
1124
+ if trailingPercent is None:
1125
+ raise ArgumentsRequired(self.id + ' createTrailingPercentOrderWs() requires a trailingPercent argument')
1126
+ params['trailingPercent'] = trailingPercent
1127
+ if trailingTriggerPrice is not None:
1128
+ params['trailingTriggerPrice'] = trailingTriggerPrice
1129
+ if self.has['createTrailingPercentOrderWs']:
1130
+ return await self.create_order_ws(symbol, type, side, amount, price, params)
1131
+ raise NotSupported(self.id + ' createTrailingPercentOrderWs() is not supported yet')
1132
+
1133
+ async def create_market_order_with_cost(self, symbol: str, side: OrderSide, cost: float, params={}):
1134
+ """
1135
+ create a market order by providing the symbol, side and cost
1136
+ :param str symbol: unified symbol of the market to create an order in
1137
+ :param str side: 'buy' or 'sell'
1138
+ :param float cost: how much you want to trade in units of the quote currency
1139
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1140
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1141
+ """
1142
+ if self.has['createMarketOrderWithCost'] or (self.has['createMarketBuyOrderWithCost'] and self.has['createMarketSellOrderWithCost']):
1143
+ return await self.create_order(symbol, 'market', side, cost, 1, params)
1144
+ raise NotSupported(self.id + ' createMarketOrderWithCost() is not supported yet')
1145
+
1146
+ async def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
1147
+ """
1148
+ create a market buy order by providing the symbol and cost
1149
+ :param str symbol: unified symbol of the market to create an order in
1150
+ :param float cost: how much you want to trade in units of the quote currency
1151
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1152
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1153
+ """
1154
+ if self.options['createMarketBuyOrderRequiresPrice'] or self.has['createMarketBuyOrderWithCost']:
1155
+ return await self.create_order(symbol, 'market', 'buy', cost, 1, params)
1156
+ raise NotSupported(self.id + ' createMarketBuyOrderWithCost() is not supported yet')
1157
+
1158
+ async def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
1159
+ """
1160
+ create a market sell order by providing the symbol and cost
1161
+ :param str symbol: unified symbol of the market to create an order in
1162
+ :param float cost: how much you want to trade in units of the quote currency
1163
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1164
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1165
+ """
1166
+ if self.options['createMarketSellOrderRequiresPrice'] or self.has['createMarketSellOrderWithCost']:
1167
+ return await self.create_order(symbol, 'market', 'sell', cost, 1, params)
1168
+ raise NotSupported(self.id + ' createMarketSellOrderWithCost() is not supported yet')
1169
+
1170
+ async def create_market_order_with_cost_ws(self, symbol: str, side: OrderSide, cost: float, params={}):
1171
+ """
1172
+ create a market order by providing the symbol, side and cost
1173
+ :param str symbol: unified symbol of the market to create an order in
1174
+ :param str side: 'buy' or 'sell'
1175
+ :param float cost: how much you want to trade in units of the quote currency
1176
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1177
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1178
+ """
1179
+ if self.has['createMarketOrderWithCostWs'] or (self.has['createMarketBuyOrderWithCostWs'] and self.has['createMarketSellOrderWithCostWs']):
1180
+ return await self.create_order_ws(symbol, 'market', side, cost, 1, params)
1181
+ raise NotSupported(self.id + ' createMarketOrderWithCostWs() is not supported yet')
1182
+
1183
+ async def create_trigger_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, triggerPrice: Num = None, params={}):
1184
+ """
1185
+ create a trigger stop order(type 1)
1186
+ :param str symbol: unified symbol of the market to create an order in
1187
+ :param str type: 'market' or 'limit'
1188
+ :param str side: 'buy' or 'sell'
1189
+ :param float amount: how much you want to trade in units of the base currency or the number of contracts
1190
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
1191
+ :param float triggerPrice: the price to trigger the stop order, in units of the quote currency
1192
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1193
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1194
+ """
1195
+ if triggerPrice is None:
1196
+ raise ArgumentsRequired(self.id + ' createTriggerOrder() requires a triggerPrice argument')
1197
+ params['triggerPrice'] = triggerPrice
1198
+ if self.has['createTriggerOrder']:
1199
+ return await self.create_order(symbol, type, side, amount, price, params)
1200
+ raise NotSupported(self.id + ' createTriggerOrder() is not supported yet')
1201
+
1202
+ async def create_trigger_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, triggerPrice: Num = None, params={}):
1203
+ """
1204
+ create a trigger stop order(type 1)
1205
+ :param str symbol: unified symbol of the market to create an order in
1206
+ :param str type: 'market' or 'limit'
1207
+ :param str side: 'buy' or 'sell'
1208
+ :param float amount: how much you want to trade in units of the base currency or the number of contracts
1209
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
1210
+ :param float triggerPrice: the price to trigger the stop order, in units of the quote currency
1211
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1212
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1213
+ """
1214
+ if triggerPrice is None:
1215
+ raise ArgumentsRequired(self.id + ' createTriggerOrderWs() requires a triggerPrice argument')
1216
+ params['triggerPrice'] = triggerPrice
1217
+ if self.has['createTriggerOrderWs']:
1218
+ return await self.create_order_ws(symbol, type, side, amount, price, params)
1219
+ raise NotSupported(self.id + ' createTriggerOrderWs() is not supported yet')
1220
+
1221
+ async def create_stop_loss_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, stopLossPrice: Num = None, params={}):
1222
+ """
1223
+ create a trigger stop loss order(type 2)
1224
+ :param str symbol: unified symbol of the market to create an order in
1225
+ :param str type: 'market' or 'limit'
1226
+ :param str side: 'buy' or 'sell'
1227
+ :param float amount: how much you want to trade in units of the base currency or the number of contracts
1228
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
1229
+ :param float stopLossPrice: the price to trigger the stop loss order, in units of the quote currency
1230
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1231
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1232
+ """
1233
+ if stopLossPrice is None:
1234
+ raise ArgumentsRequired(self.id + ' createStopLossOrder() requires a stopLossPrice argument')
1235
+ params['stopLossPrice'] = stopLossPrice
1236
+ if self.has['createStopLossOrder']:
1237
+ return await self.create_order(symbol, type, side, amount, price, params)
1238
+ raise NotSupported(self.id + ' createStopLossOrder() is not supported yet')
1239
+
1240
+ async def create_stop_loss_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, stopLossPrice: Num = None, params={}):
1241
+ """
1242
+ create a trigger stop loss order(type 2)
1243
+ :param str symbol: unified symbol of the market to create an order in
1244
+ :param str type: 'market' or 'limit'
1245
+ :param str side: 'buy' or 'sell'
1246
+ :param float amount: how much you want to trade in units of the base currency or the number of contracts
1247
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
1248
+ :param float stopLossPrice: the price to trigger the stop loss order, in units of the quote currency
1249
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1250
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1251
+ """
1252
+ if stopLossPrice is None:
1253
+ raise ArgumentsRequired(self.id + ' createStopLossOrderWs() requires a stopLossPrice argument')
1254
+ params['stopLossPrice'] = stopLossPrice
1255
+ if self.has['createStopLossOrderWs']:
1256
+ return await self.create_order_ws(symbol, type, side, amount, price, params)
1257
+ raise NotSupported(self.id + ' createStopLossOrderWs() is not supported yet')
1258
+
1259
+ async def create_take_profit_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, takeProfitPrice: Num = None, params={}):
1260
+ """
1261
+ create a trigger take profit order(type 2)
1262
+ :param str symbol: unified symbol of the market to create an order in
1263
+ :param str type: 'market' or 'limit'
1264
+ :param str side: 'buy' or 'sell'
1265
+ :param float amount: how much you want to trade in units of the base currency or the number of contracts
1266
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
1267
+ :param float takeProfitPrice: the price to trigger the take profit order, in units of the quote currency
1268
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1269
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1270
+ """
1271
+ if takeProfitPrice is None:
1272
+ raise ArgumentsRequired(self.id + ' createTakeProfitOrder() requires a takeProfitPrice argument')
1273
+ params['takeProfitPrice'] = takeProfitPrice
1274
+ if self.has['createTakeProfitOrder']:
1275
+ return await self.create_order(symbol, type, side, amount, price, params)
1276
+ raise NotSupported(self.id + ' createTakeProfitOrder() is not supported yet')
1277
+
1278
+ async def create_take_profit_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, takeProfitPrice: Num = None, params={}):
1279
+ """
1280
+ create a trigger take profit order(type 2)
1281
+ :param str symbol: unified symbol of the market to create an order in
1282
+ :param str type: 'market' or 'limit'
1283
+ :param str side: 'buy' or 'sell'
1284
+ :param float amount: how much you want to trade in units of the base currency or the number of contracts
1285
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
1286
+ :param float takeProfitPrice: the price to trigger the take profit order, in units of the quote currency
1287
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1288
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1289
+ """
1290
+ if takeProfitPrice is None:
1291
+ raise ArgumentsRequired(self.id + ' createTakeProfitOrderWs() requires a takeProfitPrice argument')
1292
+ params['takeProfitPrice'] = takeProfitPrice
1293
+ if self.has['createTakeProfitOrderWs']:
1294
+ return await self.create_order_ws(symbol, type, side, amount, price, params)
1295
+ raise NotSupported(self.id + ' createTakeProfitOrderWs() is not supported yet')
1296
+
1297
+ async def create_order_with_take_profit_and_stop_loss(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, takeProfit: Num = None, stopLoss: Num = None, params={}):
1298
+ """
1299
+ create an order with a stop loss or take profit attached(type 3)
1300
+ :param str symbol: unified symbol of the market to create an order in
1301
+ :param str type: 'market' or 'limit'
1302
+ :param str side: 'buy' or 'sell'
1303
+ :param float amount: how much you want to trade in units of the base currency or the number of contracts
1304
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
1305
+ :param float [takeProfit]: the take profit price, in units of the quote currency
1306
+ :param float [stopLoss]: the stop loss price, in units of the quote currency
1307
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1308
+ :param str [params.takeProfitType]: *not available on all exchanges* 'limit' or 'market'
1309
+ :param str [params.stopLossType]: *not available on all exchanges* 'limit' or 'market'
1310
+ :param str [params.takeProfitPriceType]: *not available on all exchanges* 'last', 'mark' or 'index'
1311
+ :param str [params.stopLossPriceType]: *not available on all exchanges* 'last', 'mark' or 'index'
1312
+ :param float [params.takeProfitLimitPrice]: *not available on all exchanges* limit price for a limit take profit order
1313
+ :param float [params.stopLossLimitPrice]: *not available on all exchanges* stop loss for a limit stop loss order
1314
+ :param float [params.takeProfitAmount]: *not available on all exchanges* the amount for a take profit
1315
+ :param float [params.stopLossAmount]: *not available on all exchanges* the amount for a stop loss
1316
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1317
+ """
1318
+ params = self.set_take_profit_and_stop_loss_params(symbol, type, side, amount, price, takeProfit, stopLoss, params)
1319
+ if self.has['createOrderWithTakeProfitAndStopLoss']:
1320
+ return await self.create_order(symbol, type, side, amount, price, params)
1321
+ raise NotSupported(self.id + ' createOrderWithTakeProfitAndStopLoss() is not supported yet')
1322
+
1323
+ async def create_order_with_take_profit_and_stop_loss_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, takeProfit: Num = None, stopLoss: Num = None, params={}):
1324
+ """
1325
+ create an order with a stop loss or take profit attached(type 3)
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 you want to trade in units of the base currency or the number of contracts
1330
+ :param float [price]: the price to fulfill the order, in units of the quote currency, ignored in market orders
1331
+ :param float [takeProfit]: the take profit price, in units of the quote currency
1332
+ :param float [stopLoss]: the stop loss price, in units of the quote currency
1333
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1334
+ :param str [params.takeProfitType]: *not available on all exchanges* 'limit' or 'market'
1335
+ :param str [params.stopLossType]: *not available on all exchanges* 'limit' or 'market'
1336
+ :param str [params.takeProfitPriceType]: *not available on all exchanges* 'last', 'mark' or 'index'
1337
+ :param str [params.stopLossPriceType]: *not available on all exchanges* 'last', 'mark' or 'index'
1338
+ :param float [params.takeProfitLimitPrice]: *not available on all exchanges* limit price for a limit take profit order
1339
+ :param float [params.stopLossLimitPrice]: *not available on all exchanges* stop loss for a limit stop loss order
1340
+ :param float [params.takeProfitAmount]: *not available on all exchanges* the amount for a take profit
1341
+ :param float [params.stopLossAmount]: *not available on all exchanges* the amount for a stop loss
1342
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1343
+ """
1344
+ params = self.set_take_profit_and_stop_loss_params(symbol, type, side, amount, price, takeProfit, stopLoss, params)
1345
+ if self.has['createOrderWithTakeProfitAndStopLossWs']:
1346
+ return await self.create_order_ws(symbol, type, side, amount, price, params)
1347
+ raise NotSupported(self.id + ' createOrderWithTakeProfitAndStopLossWs() is not supported yet')
1348
+
1349
+ async def create_orders(self, orders: List[OrderRequest], params={}):
1350
+ raise NotSupported(self.id + ' createOrders() is not supported yet')
1351
+
1352
+ async def create_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1353
+ raise NotSupported(self.id + ' createOrderWs() is not supported yet')
1354
+
1355
+ async def cancel_order(self, id: str, symbol: Str = None, params={}):
1356
+ raise NotSupported(self.id + ' cancelOrder() is not supported yet')
1357
+
1358
+ async def cancel_order_ws(self, id: str, symbol: Str = None, params={}):
1359
+ raise NotSupported(self.id + ' cancelOrderWs() is not supported yet')
1360
+
1361
+ async def cancel_orders_ws(self, ids: List[str], symbol: Str = None, params={}):
1362
+ raise NotSupported(self.id + ' cancelOrdersWs() is not supported yet')
1363
+
1364
+ async def cancel_all_orders(self, symbol: Str = None, params={}):
1365
+ raise NotSupported(self.id + ' cancelAllOrders() is not supported yet')
1366
+
1367
+ async def cancel_all_orders_after(self, timeout: Int, params={}):
1368
+ raise NotSupported(self.id + ' cancelAllOrdersAfter() is not supported yet')
1369
+
1370
+ async def cancel_orders_for_symbols(self, orders: List[CancellationRequest], params={}):
1371
+ raise NotSupported(self.id + ' cancelOrdersForSymbols() is not supported yet')
1372
+
1373
+ async def cancel_all_orders_ws(self, symbol: Str = None, params={}):
1374
+ raise NotSupported(self.id + ' cancelAllOrdersWs() is not supported yet')
1375
+
1376
+ async def cancel_unified_order(self, order, params={}):
1377
+ return self.cancel_order(self.safe_string(order, 'id'), self.safe_string(order, 'symbol'), params)
1378
+
1379
+ async def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1380
+ if self.has['fetchOpenOrders'] and self.has['fetchClosedOrders']:
1381
+ raise NotSupported(self.id + ' fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead')
1382
+ raise NotSupported(self.id + ' fetchOrders() is not supported yet')
1383
+
1384
+ async def fetch_orders_ws(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1385
+ raise NotSupported(self.id + ' fetchOrdersWs() is not supported yet')
1386
+
1387
+ async def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1388
+ raise NotSupported(self.id + ' fetchOrderTrades() is not supported yet')
1389
+
1390
+ async def watch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1391
+ raise NotSupported(self.id + ' watchOrders() is not supported yet')
1392
+
1393
+ async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1394
+ if self.has['fetchOrders']:
1395
+ orders = await self.fetch_orders(symbol, since, limit, params)
1396
+ return self.filter_by(orders, 'status', 'open')
1397
+ raise NotSupported(self.id + ' fetchOpenOrders() is not supported yet')
1398
+
1399
+ async def fetch_open_orders_ws(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1400
+ if self.has['fetchOrdersWs']:
1401
+ orders = await self.fetch_orders_ws(symbol, since, limit, params)
1402
+ return self.filter_by(orders, 'status', 'open')
1403
+ raise NotSupported(self.id + ' fetchOpenOrdersWs() is not supported yet')
1404
+
1405
+ async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1406
+ if self.has['fetchOrders']:
1407
+ orders = await self.fetch_orders(symbol, since, limit, params)
1408
+ return self.filter_by(orders, 'status', 'closed')
1409
+ raise NotSupported(self.id + ' fetchClosedOrders() is not supported yet')
1410
+
1411
+ async def fetch_canceled_and_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1412
+ raise NotSupported(self.id + ' fetchCanceledAndClosedOrders() is not supported yet')
1413
+
1414
+ async def fetch_closed_orders_ws(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1415
+ if self.has['fetchOrdersWs']:
1416
+ orders = await self.fetch_orders_ws(symbol, since, limit, params)
1417
+ return self.filter_by(orders, 'status', 'closed')
1418
+ raise NotSupported(self.id + ' fetchClosedOrdersWs() is not supported yet')
1419
+
1420
+ async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1421
+ raise NotSupported(self.id + ' fetchMyTrades() is not supported yet')
1422
+
1423
+ async def fetch_my_liquidations(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1424
+ raise NotSupported(self.id + ' fetchMyLiquidations() is not supported yet')
1425
+
1426
+ async def fetch_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
1427
+ raise NotSupported(self.id + ' fetchLiquidations() is not supported yet')
1428
+
1429
+ async def fetch_my_trades_ws(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1430
+ raise NotSupported(self.id + ' fetchMyTradesWs() is not supported yet')
1431
+
1432
+ async def watch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1433
+ raise NotSupported(self.id + ' watchMyTrades() is not supported yet')
1434
+
1435
+ async def fetch_greeks(self, symbol: str, params={}):
1436
+ raise NotSupported(self.id + ' fetchGreeks() is not supported yet')
1437
+
1438
+ async def fetch_option_chain(self, code: str, params={}):
1439
+ raise NotSupported(self.id + ' fetchOptionChain() is not supported yet')
1440
+
1441
+ async def fetch_option(self, symbol: str, params={}):
1442
+ raise NotSupported(self.id + ' fetchOption() is not supported yet')
1443
+
1444
+ async def fetch_convert_quote(self, fromCode: str, toCode: str, amount: Num = None, params={}):
1445
+ raise NotSupported(self.id + ' fetchConvertQuote() is not supported yet')
1446
+
1447
+ async def fetch_deposits_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1448
+ """
1449
+ fetch history of deposits and withdrawals
1450
+ :param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
1451
+ :param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
1452
+ :param int [limit]: max number of deposit/withdrawals to return, default is None
1453
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1454
+ :returns dict: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
1455
+ """
1456
+ raise NotSupported(self.id + ' fetchDepositsWithdrawals() is not supported yet')
1457
+
1458
+ async def fetch_deposits(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1459
+ raise NotSupported(self.id + ' fetchDeposits() is not supported yet')
1460
+
1461
+ async def fetch_withdrawals(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1462
+ raise NotSupported(self.id + ' fetchWithdrawals() is not supported yet')
1463
+
1464
+ async def fetch_deposits_ws(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1465
+ raise NotSupported(self.id + ' fetchDepositsWs() is not supported yet')
1466
+
1467
+ async def fetch_withdrawals_ws(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1468
+ raise NotSupported(self.id + ' fetchWithdrawalsWs() is not supported yet')
1469
+
1470
+ async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1471
+ raise NotSupported(self.id + ' fetchFundingRateHistory() is not supported yet')
1472
+
1473
+ async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1474
+ raise NotSupported(self.id + ' fetchFundingHistory() is not supported yet')
1475
+
1476
+ async def close_position(self, symbol: str, side: OrderSide = None, params={}):
1477
+ raise NotSupported(self.id + ' closePosition() is not supported yet')
1478
+
1479
+ async def close_all_positions(self, params={}):
1480
+ raise NotSupported(self.id + ' closeAllPositions() is not supported yet')
1481
+
1482
+ async def fetch_l3_order_book(self, symbol: str, limit: Int = None, params={}):
1483
+ raise BadRequest(self.id + ' fetchL3OrderBook() is not supported yet')
1484
+
1485
+ async def fetch_deposit_address(self, code: str, params={}):
1486
+ if self.has['fetchDepositAddresses']:
1487
+ depositAddresses = await self.fetch_deposit_addresses([code], params)
1488
+ depositAddress = self.safe_value(depositAddresses, code)
1489
+ if depositAddress is None:
1490
+ raise InvalidAddress(self.id + ' fetchDepositAddress() could not find a deposit address for ' + code + ', make sure you have created a corresponding deposit address in your wallet on the exchange website')
1491
+ else:
1492
+ return depositAddress
1493
+ elif self.has['fetchDepositAddressesByNetwork']:
1494
+ network = self.safe_string(params, 'network')
1495
+ params = self.omit(params, 'network')
1496
+ addressStructures = await self.fetch_deposit_addresses_by_network(code, params)
1497
+ if network is not None:
1498
+ return self.safe_dict(addressStructures, network)
1499
+ else:
1500
+ keys = list(addressStructures.keys())
1501
+ key = self.safe_string(keys, 0)
1502
+ return self.safe_dict(addressStructures, key)
1503
+ else:
1504
+ raise NotSupported(self.id + ' fetchDepositAddress() is not supported yet')
1505
+
1506
+ async def create_limit_order(self, symbol: str, side: OrderSide, amount: float, price: float, params={}):
1507
+ return await self.create_order(symbol, 'limit', side, amount, price, params)
1508
+
1509
+ async def create_limit_order_ws(self, symbol: str, side: OrderSide, amount: float, price: float, params={}):
1510
+ return await self.create_order_ws(symbol, 'limit', side, amount, price, params)
1511
+
1512
+ async def create_market_order(self, symbol: str, side: OrderSide, amount: float, price: Num = None, params={}):
1513
+ return await self.create_order(symbol, 'market', side, amount, price, params)
1514
+
1515
+ async def create_market_order_ws(self, symbol: str, side: OrderSide, amount: float, price: Num = None, params={}):
1516
+ return await self.create_order_ws(symbol, 'market', side, amount, price, params)
1517
+
1518
+ async def create_limit_buy_order(self, symbol: str, amount: float, price: float, params={}):
1519
+ return await self.create_order(symbol, 'limit', 'buy', amount, price, params)
1520
+
1521
+ async def create_limit_buy_order_ws(self, symbol: str, amount: float, price: float, params={}):
1522
+ return await self.create_order_ws(symbol, 'limit', 'buy', amount, price, params)
1523
+
1524
+ async def create_limit_sell_order(self, symbol: str, amount: float, price: float, params={}):
1525
+ return await self.create_order(symbol, 'limit', 'sell', amount, price, params)
1526
+
1527
+ async def create_limit_sell_order_ws(self, symbol: str, amount: float, price: float, params={}):
1528
+ return await self.create_order_ws(symbol, 'limit', 'sell', amount, price, params)
1529
+
1530
+ async def create_market_buy_order(self, symbol: str, amount: float, params={}):
1531
+ return await self.create_order(symbol, 'market', 'buy', amount, None, params)
1532
+
1533
+ async def create_market_buy_order_ws(self, symbol: str, amount: float, params={}):
1534
+ return await self.create_order_ws(symbol, 'market', 'buy', amount, None, params)
1535
+
1536
+ async def create_market_sell_order(self, symbol: str, amount: float, params={}):
1537
+ return await self.create_order(symbol, 'market', 'sell', amount, None, params)
1538
+
1539
+ async def create_market_sell_order_ws(self, symbol: str, amount: float, params={}):
1540
+ return await self.create_order_ws(symbol, 'market', 'sell', amount, None, params)
1541
+
1542
+ async def load_time_difference(self, params={}):
1543
+ serverTime = await self.fetch_time(params)
1544
+ after = self.milliseconds()
1545
+ self.options['timeDifference'] = after - serverTime
1546
+ return self.options['timeDifference']
1547
+
1548
+ async def fetch_market_leverage_tiers(self, symbol: str, params={}):
1549
+ if self.has['fetchLeverageTiers']:
1550
+ market = self.market(symbol)
1551
+ if not market['contract']:
1552
+ raise BadSymbol(self.id + ' fetchMarketLeverageTiers() supports contract markets only')
1553
+ tiers = await self.fetch_leverage_tiers([symbol])
1554
+ return self.safe_value(tiers, symbol)
1555
+ else:
1556
+ raise NotSupported(self.id + ' fetchMarketLeverageTiers() is not supported yet')
1557
+
1558
+ async def create_post_only_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1559
+ if not self.has['createPostOnlyOrder']:
1560
+ raise NotSupported(self.id + 'createPostOnlyOrder() is not supported yet')
1561
+ query = self.extend(params, {'postOnly': True})
1562
+ return await self.create_order(symbol, type, side, amount, price, query)
1563
+
1564
+ async def create_post_only_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1565
+ if not self.has['createPostOnlyOrderWs']:
1566
+ raise NotSupported(self.id + 'createPostOnlyOrderWs() is not supported yet')
1567
+ query = self.extend(params, {'postOnly': True})
1568
+ return await self.create_order_ws(symbol, type, side, amount, price, query)
1569
+
1570
+ async def create_reduce_only_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1571
+ if not self.has['createReduceOnlyOrder']:
1572
+ raise NotSupported(self.id + 'createReduceOnlyOrder() is not supported yet')
1573
+ query = self.extend(params, {'reduceOnly': True})
1574
+ return await self.create_order(symbol, type, side, amount, price, query)
1575
+
1576
+ async def create_reduce_only_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1577
+ if not self.has['createReduceOnlyOrderWs']:
1578
+ raise NotSupported(self.id + 'createReduceOnlyOrderWs() is not supported yet')
1579
+ query = self.extend(params, {'reduceOnly': True})
1580
+ return await self.create_order_ws(symbol, type, side, amount, price, query)
1581
+
1582
+ async def create_stop_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, stopPrice: Num = None, params={}):
1583
+ if not self.has['createStopOrder']:
1584
+ raise NotSupported(self.id + ' createStopOrder() is not supported yet')
1585
+ if stopPrice is None:
1586
+ raise ArgumentsRequired(self.id + ' create_stop_order() requires a stopPrice argument')
1587
+ query = self.extend(params, {'stopPrice': stopPrice})
1588
+ return await self.create_order(symbol, type, side, amount, price, query)
1589
+
1590
+ async def create_stop_order_ws(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, stopPrice: Num = None, params={}):
1591
+ if not self.has['createStopOrderWs']:
1592
+ raise NotSupported(self.id + ' createStopOrderWs() is not supported yet')
1593
+ if stopPrice is None:
1594
+ raise ArgumentsRequired(self.id + ' createStopOrderWs() requires a stopPrice argument')
1595
+ query = self.extend(params, {'stopPrice': stopPrice})
1596
+ return await self.create_order_ws(symbol, type, side, amount, price, query)
1597
+
1598
+ async def create_stop_limit_order(self, symbol: str, side: OrderSide, amount: float, price: float, stopPrice: float, params={}):
1599
+ if not self.has['createStopLimitOrder']:
1600
+ raise NotSupported(self.id + ' createStopLimitOrder() is not supported yet')
1601
+ query = self.extend(params, {'stopPrice': stopPrice})
1602
+ return await self.create_order(symbol, 'limit', side, amount, price, query)
1603
+
1604
+ async def create_stop_limit_order_ws(self, symbol: str, side: OrderSide, amount: float, price: float, stopPrice: float, params={}):
1605
+ if not self.has['createStopLimitOrderWs']:
1606
+ raise NotSupported(self.id + ' createStopLimitOrderWs() is not supported yet')
1607
+ query = self.extend(params, {'stopPrice': stopPrice})
1608
+ return await self.create_order_ws(symbol, 'limit', side, amount, price, query)
1609
+
1610
+ async def create_stop_market_order(self, symbol: str, side: OrderSide, amount: float, stopPrice: float, params={}):
1611
+ if not self.has['createStopMarketOrder']:
1612
+ raise NotSupported(self.id + ' createStopMarketOrder() is not supported yet')
1613
+ query = self.extend(params, {'stopPrice': stopPrice})
1614
+ return await self.create_order(symbol, 'market', side, amount, None, query)
1615
+
1616
+ async def create_stop_market_order_ws(self, symbol: str, side: OrderSide, amount: float, stopPrice: float, params={}):
1617
+ if not self.has['createStopMarketOrderWs']:
1618
+ raise NotSupported(self.id + ' createStopMarketOrderWs() is not supported yet')
1619
+ query = self.extend(params, {'stopPrice': stopPrice})
1620
+ return await self.create_order_ws(symbol, 'market', side, amount, None, query)
1621
+
1622
+ async def fetch_last_prices(self, symbols: Strings = None, params={}):
1623
+ raise NotSupported(self.id + ' fetchLastPrices() is not supported yet')
1624
+
1625
+ async def fetch_trading_fees(self, params={}):
1626
+ raise NotSupported(self.id + ' fetchTradingFees() is not supported yet')
1627
+
1628
+ async def fetch_trading_fees_ws(self, params={}):
1629
+ raise NotSupported(self.id + ' fetchTradingFeesWs() is not supported yet')
1630
+
1631
+ async def fetch_trading_fee(self, symbol: str, params={}):
1632
+ if not self.has['fetchTradingFees']:
1633
+ raise NotSupported(self.id + ' fetchTradingFee() is not supported yet')
1634
+ fees = await self.fetch_trading_fees(params)
1635
+ return self.safe_dict(fees, symbol)
1636
+
1637
+ async def fetch_convert_currencies(self, params={}):
1638
+ raise NotSupported(self.id + ' fetchConvertCurrencies() is not supported yet')
1639
+
1640
+ async def fetch_funding_rate(self, symbol: str, params={}):
1641
+ if self.has['fetchFundingRates']:
1642
+ await self.load_markets()
1643
+ market = self.market(symbol)
1644
+ symbol = market['symbol']
1645
+ if not market['contract']:
1646
+ raise BadSymbol(self.id + ' fetchFundingRate() supports contract markets only')
1647
+ rates = await self.fetch_funding_rates([symbol], params)
1648
+ rate = self.safe_value(rates, symbol)
1649
+ if rate is None:
1650
+ raise NullResponse(self.id + ' fetchFundingRate() returned no data for ' + symbol)
1651
+ else:
1652
+ return rate
1653
+ else:
1654
+ raise NotSupported(self.id + ' fetchFundingRate() is not supported yet')
1655
+
1656
+ async def fetch_mark_ohlcv(self, symbol, timeframe='1m', since: Int = None, limit: Int = None, params={}):
1657
+ """
1658
+ fetches historical mark price candlestick data containing the open, high, low, and close price of a market
1659
+ :param str symbol: unified symbol of the market to fetch OHLCV data for
1660
+ :param str timeframe: the length of time each candle represents
1661
+ :param int [since]: timestamp in ms of the earliest candle to fetch
1662
+ :param int [limit]: the maximum amount of candles to fetch
1663
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1664
+ :returns float[][]: A list of candles ordered, open, high, low, close, None
1665
+ """
1666
+ if self.has['fetchMarkOHLCV']:
1667
+ request: dict = {
1668
+ 'price': 'mark',
1669
+ }
1670
+ return await self.fetch_ohlcv(symbol, timeframe, since, limit, self.extend(request, params))
1671
+ else:
1672
+ raise NotSupported(self.id + ' fetchMarkOHLCV() is not supported yet')
1673
+
1674
+ async def fetch_index_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
1675
+ """
1676
+ fetches historical index price candlestick data containing the open, high, low, and close price of a market
1677
+ :param str symbol: unified symbol of the market to fetch OHLCV data for
1678
+ :param str timeframe: the length of time each candle represents
1679
+ :param int [since]: timestamp in ms of the earliest candle to fetch
1680
+ :param int [limit]: the maximum amount of candles to fetch
1681
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1682
+ * @returns {} A list of candles ordered, open, high, low, close, None
1683
+ """
1684
+ if self.has['fetchIndexOHLCV']:
1685
+ request: dict = {
1686
+ 'price': 'index',
1687
+ }
1688
+ return await self.fetch_ohlcv(symbol, timeframe, since, limit, self.extend(request, params))
1689
+ else:
1690
+ raise NotSupported(self.id + ' fetchIndexOHLCV() is not supported yet')
1691
+
1692
+ async def fetch_premium_index_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}):
1693
+ """
1694
+ fetches historical premium index price candlestick data containing the open, high, low, and close price of a market
1695
+ :param str symbol: unified symbol of the market to fetch OHLCV data for
1696
+ :param str timeframe: the length of time each candle represents
1697
+ :param int [since]: timestamp in ms of the earliest candle to fetch
1698
+ :param int [limit]: the maximum amount of candles to fetch
1699
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1700
+ :returns float[][]: A list of candles ordered, open, high, low, close, None
1701
+ """
1702
+ if self.has['fetchPremiumIndexOHLCV']:
1703
+ request: dict = {
1704
+ 'price': 'premiumIndex',
1705
+ }
1706
+ return await self.fetch_ohlcv(symbol, timeframe, since, limit, self.extend(request, params))
1707
+ else:
1708
+ raise NotSupported(self.id + ' fetchPremiumIndexOHLCV() is not supported yet')
1709
+
1710
+ async def fetch_transactions(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1711
+ """
1712
+ * @deprecated
1713
+ *DEPRECATED* use fetchDepositsWithdrawals instead
1714
+ :param str code: unified currency code for the currency of the deposit/withdrawals, default is None
1715
+ :param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
1716
+ :param int [limit]: max number of deposit/withdrawals to return, default is None
1717
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1718
+ :returns dict: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
1719
+ """
1720
+ if self.has['fetchDepositsWithdrawals']:
1721
+ return await self.fetch_deposits_withdrawals(code, since, limit, params)
1722
+ else:
1723
+ raise NotSupported(self.id + ' fetchTransactions() is not supported yet')
1724
+
1725
+ async def fetch_paginated_call_dynamic(self, method: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}, maxEntriesPerRequest: Int = None):
1726
+ maxCalls = None
1727
+ maxCalls, params = self.handle_option_and_params(params, method, 'paginationCalls', 10)
1728
+ maxRetries = None
1729
+ maxRetries, params = self.handle_option_and_params(params, method, 'maxRetries', 3)
1730
+ paginationDirection = None
1731
+ paginationDirection, params = self.handle_option_and_params(params, method, 'paginationDirection', 'backward')
1732
+ paginationTimestamp = None
1733
+ calls = 0
1734
+ result = []
1735
+ errors = 0
1736
+ until = self.safe_integer_2(params, 'untill', 'till') # do not omit it from params here
1737
+ maxEntriesPerRequest, params = self.handle_max_entries_per_request_and_params(method, maxEntriesPerRequest, params)
1738
+ if (paginationDirection == 'forward'):
1739
+ if since is None:
1740
+ raise ArgumentsRequired(self.id + ' pagination requires a since argument when paginationDirection set to forward')
1741
+ paginationTimestamp = since
1742
+ while((calls < maxCalls)):
1743
+ calls += 1
1744
+ try:
1745
+ if paginationDirection == 'backward':
1746
+ # do it backwards, starting from the last
1747
+ # UNTIL filtering is required in order to work
1748
+ if paginationTimestamp is not None:
1749
+ params['until'] = paginationTimestamp - 1
1750
+ response = await getattr(self, method)(symbol, None, maxEntriesPerRequest, params)
1751
+ responseLength = len(response)
1752
+ if self.verbose:
1753
+ backwardMessage = 'Dynamic pagination call ' + self.number_to_string(calls) + ' method ' + method + ' response length ' + self.number_to_string(responseLength)
1754
+ if paginationTimestamp is not None:
1755
+ backwardMessage += ' timestamp ' + self.number_to_string(paginationTimestamp)
1756
+ self.log(backwardMessage)
1757
+ if responseLength == 0:
1758
+ break
1759
+ errors = 0
1760
+ result = self.array_concat(result, response)
1761
+ firstElement = self.safe_value(response, 0)
1762
+ paginationTimestamp = self.safe_integer_2(firstElement, 'timestamp', 0)
1763
+ if (since is not None) and (paginationTimestamp <= since):
1764
+ break
1765
+ else:
1766
+ # do it forwards, starting from the since
1767
+ response = await getattr(self, method)(symbol, paginationTimestamp, maxEntriesPerRequest, params)
1768
+ responseLength = len(response)
1769
+ if self.verbose:
1770
+ forwardMessage = 'Dynamic pagination call ' + self.number_to_string(calls) + ' method ' + method + ' response length ' + self.number_to_string(responseLength)
1771
+ if paginationTimestamp is not None:
1772
+ forwardMessage += ' timestamp ' + self.number_to_string(paginationTimestamp)
1773
+ self.log(forwardMessage)
1774
+ if responseLength == 0:
1775
+ break
1776
+ errors = 0
1777
+ result = self.array_concat(result, response)
1778
+ last = self.safe_value(response, responseLength - 1)
1779
+ paginationTimestamp = self.safe_integer(last, 'timestamp') - 1
1780
+ if (until is not None) and (paginationTimestamp >= until):
1781
+ break
1782
+ except Exception as e:
1783
+ errors += 1
1784
+ if errors > maxRetries:
1785
+ raise e
1786
+ uniqueResults = self.remove_repeated_elements_from_array(result)
1787
+ key = 0 if (method == 'fetchOHLCV') else 'timestamp'
1788
+ return self.filter_by_since_limit(uniqueResults, since, limit, key)
1789
+
1790
+ async def safe_deterministic_call(self, method: str, symbol: Str = None, since: Int = None, limit: Int = None, timeframe: Str = None, params={}):
1791
+ maxRetries = None
1792
+ maxRetries, params = self.handle_option_and_params(params, method, 'maxRetries', 3)
1793
+ errors = 0
1794
+ while(errors <= maxRetries):
1795
+ try:
1796
+ if timeframe and method != 'fetchFundingRateHistory':
1797
+ return await getattr(self, method)(symbol, timeframe, since, limit, params)
1798
+ else:
1799
+ return await getattr(self, method)(symbol, since, limit, params)
1800
+ except Exception as e:
1801
+ if isinstance(e, RateLimitExceeded):
1802
+ raise e # if we are rate limited, we should not retry and fail fast
1803
+ errors += 1
1804
+ if errors > maxRetries:
1805
+ raise e
1806
+ return []
1807
+
1808
+ async def fetch_paginated_call_deterministic(self, method: str, symbol: Str = None, since: Int = None, limit: Int = None, timeframe: Str = None, params={}, maxEntriesPerRequest=None):
1809
+ maxCalls = None
1810
+ maxCalls, params = self.handle_option_and_params(params, method, 'paginationCalls', 10)
1811
+ maxEntriesPerRequest, params = self.handle_max_entries_per_request_and_params(method, maxEntriesPerRequest, params)
1812
+ current = self.milliseconds()
1813
+ tasks = []
1814
+ time = self.parse_timeframe(timeframe) * 1000
1815
+ step = time * maxEntriesPerRequest
1816
+ currentSince = current - (maxCalls * step) - 1
1817
+ if since is not None:
1818
+ currentSince = max(currentSince, since)
1819
+ else:
1820
+ currentSince = max(currentSince, 1241440531000) # avoid timestamps older than 2009
1821
+ until = self.safe_integer_2(params, 'until', 'till') # do not omit it here
1822
+ if until is not None:
1823
+ requiredCalls = int(math.ceil((until - since)) / step)
1824
+ if requiredCalls > maxCalls:
1825
+ raise BadRequest(self.id + ' the number of required calls is greater than the max number of calls allowed, either increase the paginationCalls or decrease the since-until gap. Current paginationCalls limit is ' + str(maxCalls) + ' required calls is ' + str(requiredCalls))
1826
+ for i in range(0, maxCalls):
1827
+ if (until is not None) and (currentSince >= until):
1828
+ break
1829
+ if currentSince >= current:
1830
+ break
1831
+ tasks.append(self.safe_deterministic_call(method, symbol, currentSince, maxEntriesPerRequest, timeframe, params))
1832
+ currentSince = self.sum(currentSince, step) - 1
1833
+ results = await asyncio.gather(*tasks)
1834
+ result = []
1835
+ for i in range(0, len(results)):
1836
+ result = self.array_concat(result, results[i])
1837
+ uniqueResults = self.remove_repeated_elements_from_array(result)
1838
+ key = 0 if (method == 'fetchOHLCV') else 'timestamp'
1839
+ return self.filter_by_since_limit(uniqueResults, since, limit, key)
1840
+
1841
+ async def fetch_paginated_call_cursor(self, method: str, symbol: Str = None, since=None, limit=None, params={}, cursorReceived=None, cursorSent=None, cursorIncrement=None, maxEntriesPerRequest=None):
1842
+ maxCalls = None
1843
+ maxCalls, params = self.handle_option_and_params(params, method, 'paginationCalls', 10)
1844
+ maxRetries = None
1845
+ maxRetries, params = self.handle_option_and_params(params, method, 'maxRetries', 3)
1846
+ maxEntriesPerRequest, params = self.handle_max_entries_per_request_and_params(method, maxEntriesPerRequest, params)
1847
+ cursorValue = None
1848
+ i = 0
1849
+ errors = 0
1850
+ result = []
1851
+ while(i < maxCalls):
1852
+ try:
1853
+ if cursorValue is not None:
1854
+ if cursorIncrement is not None:
1855
+ cursorValue = self.parse_to_int(cursorValue) + cursorIncrement
1856
+ params[cursorSent] = cursorValue
1857
+ response = None
1858
+ if method == 'fetchAccounts':
1859
+ response = await getattr(self, method)(params)
1860
+ elif method == 'getLeverageTiersPaginated':
1861
+ response = await getattr(self, method)(symbol, params)
1862
+ else:
1863
+ response = await getattr(self, method)(symbol, since, maxEntriesPerRequest, params)
1864
+ errors = 0
1865
+ responseLength = len(response)
1866
+ if self.verbose:
1867
+ cursorString = '' if (cursorValue is None) else cursorValue
1868
+ iteration = (i + 1)
1869
+ cursorMessage = 'Cursor pagination call ' + str(iteration) + ' method ' + method + ' response length ' + str(responseLength) + ' cursor ' + cursorString
1870
+ self.log(cursorMessage)
1871
+ if responseLength == 0:
1872
+ break
1873
+ result = self.array_concat(result, response)
1874
+ last = self.safe_value(response, responseLength - 1)
1875
+ cursorValue = self.safe_value(last['info'], cursorReceived)
1876
+ if cursorValue is None:
1877
+ break
1878
+ lastTimestamp = self.safe_integer(last, 'timestamp')
1879
+ if lastTimestamp is not None and lastTimestamp < since:
1880
+ break
1881
+ except Exception as e:
1882
+ errors += 1
1883
+ if errors > maxRetries:
1884
+ raise e
1885
+ i += 1
1886
+ sorted = self.sort_cursor_paginated_result(result)
1887
+ key = 0 if (method == 'fetchOHLCV') else 'timestamp'
1888
+ return self.filter_by_since_limit(sorted, since, limit, key)
1889
+
1890
+ async def fetch_paginated_call_incremental(self, method: str, symbol: Str = None, since=None, limit=None, params={}, pageKey=None, maxEntriesPerRequest=None):
1891
+ maxCalls = None
1892
+ maxCalls, params = self.handle_option_and_params(params, method, 'paginationCalls', 10)
1893
+ maxRetries = None
1894
+ maxRetries, params = self.handle_option_and_params(params, method, 'maxRetries', 3)
1895
+ maxEntriesPerRequest, params = self.handle_max_entries_per_request_and_params(method, maxEntriesPerRequest, params)
1896
+ i = 0
1897
+ errors = 0
1898
+ result = []
1899
+ while(i < maxCalls):
1900
+ try:
1901
+ params[pageKey] = i + 1
1902
+ response = await getattr(self, method)(symbol, since, maxEntriesPerRequest, params)
1903
+ errors = 0
1904
+ responseLength = len(response)
1905
+ if self.verbose:
1906
+ iteration = (i + str(1))
1907
+ incrementalMessage = 'Incremental pagination call ' + iteration + ' method ' + method + ' response length ' + str(responseLength)
1908
+ self.log(incrementalMessage)
1909
+ if responseLength == 0:
1910
+ break
1911
+ result = self.array_concat(result, response)
1912
+ except Exception as e:
1913
+ errors += 1
1914
+ if errors > maxRetries:
1915
+ raise e
1916
+ i += 1
1917
+ sorted = self.sort_cursor_paginated_result(result)
1918
+ key = 0 if (method == 'fetchOHLCV') else 'timestamp'
1919
+ return self.filter_by_since_limit(sorted, since, limit, key)
1920
+
1921
+ async def fetch_position_history(self, symbol: str, since: Int = None, limit: Int = None, params={}):
1922
+ """
1923
+ fetches the history of margin added or reduced from contract isolated positions
1924
+ :param str [symbol]: unified market symbol
1925
+ :param int [since]: timestamp in ms of the position
1926
+ :param int [limit]: the maximum amount of candles to fetch, default=1000
1927
+ :param dict params: extra parameters specific to the exchange api endpoint
1928
+ :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
1929
+ """
1930
+ if self.has['fetchPositionsHistory']:
1931
+ positions = await self.fetch_positions_history([symbol], since, limit, params)
1932
+ return self.safe_dict(positions, 0)
1933
+ else:
1934
+ raise NotSupported(self.id + ' fetchPositionHistory() is not supported yet')
1935
+
1936
+ async def fetch_positions_history(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}):
1937
+ """
1938
+ fetches the history of margin added or reduced from contract isolated positions
1939
+ :param str [symbol]: unified market symbol
1940
+ :param int [since]: timestamp in ms of the position
1941
+ :param int [limit]: the maximum amount of candles to fetch, default=1000
1942
+ :param dict params: extra parameters specific to the exchange api endpoint
1943
+ :returns dict[]: a list of `position structures <https://docs.ccxt.com/#/?id=position-structure>`
1944
+ """
1945
+ raise NotSupported(self.id + ' fetchPositionsHistory() is not supported yet')
1946
+
1947
+ async def fetch_transfer(self, id: str, code: Str = None, params={}):
1948
+ """
1949
+ fetches a transfer
1950
+ :param str id: transfer id
1951
+ :param [str] code: unified currency code
1952
+ :param dict params: extra parameters specific to the exchange api endpoint
1953
+ :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
1954
+ """
1955
+ raise NotSupported(self.id + ' fetchTransfer() is not supported yet')
1956
+
1957
+ async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1958
+ """
1959
+ fetches a transfer
1960
+ :param str id: transfer id
1961
+ :param int [since]: timestamp in ms of the earliest transfer to fetch
1962
+ :param int [limit]: the maximum amount of transfers to fetch
1963
+ :param dict params: extra parameters specific to the exchange api endpoint
1964
+ :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
1965
+ """
1966
+ raise NotSupported(self.id + ' fetchTransfers() is not supported yet')