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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (772) hide show
  1. ccxt/__init__.py +358 -0
  2. ccxt/abantether.py +316 -0
  3. ccxt/abstract/__init__.py +0 -0
  4. ccxt/abstract/abantether.py +5 -0
  5. ccxt/abstract/ace.py +15 -0
  6. ccxt/abstract/afratether.py +6 -0
  7. ccxt/abstract/alpaca.py +70 -0
  8. ccxt/abstract/arzinja.py +5 -0
  9. ccxt/abstract/arzplus.py +7 -0
  10. ccxt/abstract/ascendex.py +77 -0
  11. ccxt/abstract/bequant.py +115 -0
  12. ccxt/abstract/bigone.py +45 -0
  13. ccxt/abstract/binance.py +712 -0
  14. ccxt/abstract/binancecoinm.py +712 -0
  15. ccxt/abstract/binanceus.py +764 -0
  16. ccxt/abstract/binanceusdm.py +712 -0
  17. ccxt/abstract/bingx.py +113 -0
  18. ccxt/abstract/bit2c.py +27 -0
  19. ccxt/abstract/bitbank.py +27 -0
  20. ccxt/abstract/bitbay.py +53 -0
  21. ccxt/abstract/bitbns.py +40 -0
  22. ccxt/abstract/bitcoincom.py +115 -0
  23. ccxt/abstract/bitfinex.py +69 -0
  24. ccxt/abstract/bitfinex2.py +139 -0
  25. ccxt/abstract/bitflyer.py +38 -0
  26. ccxt/abstract/bitget.py +508 -0
  27. ccxt/abstract/bithumb.py +32 -0
  28. ccxt/abstract/bitimen.py +7 -0
  29. ccxt/abstract/bitir.py +7 -0
  30. ccxt/abstract/bitmart.py +99 -0
  31. ccxt/abstract/bitmex.py +97 -0
  32. ccxt/abstract/bitopro.py +29 -0
  33. ccxt/abstract/bitpanda.py +35 -0
  34. ccxt/abstract/bitpin.py +7 -0
  35. ccxt/abstract/bitrue.py +72 -0
  36. ccxt/abstract/bitso.py +43 -0
  37. ccxt/abstract/bitstamp.py +258 -0
  38. ccxt/abstract/bitteam.py +29 -0
  39. ccxt/abstract/bitvavo.py +27 -0
  40. ccxt/abstract/bl3p.py +19 -0
  41. ccxt/abstract/blockchaincom.py +28 -0
  42. ccxt/abstract/blofin.py +37 -0
  43. ccxt/abstract/btcalpha.py +18 -0
  44. ccxt/abstract/btcbox.py +13 -0
  45. ccxt/abstract/btcmarkets.py +39 -0
  46. ccxt/abstract/btcturk.py +20 -0
  47. ccxt/abstract/bybit.py +298 -0
  48. ccxt/abstract/cex.py +33 -0
  49. ccxt/abstract/coinbase.py +94 -0
  50. ccxt/abstract/coinbaseadvanced.py +94 -0
  51. ccxt/abstract/coinbaseexchange.py +67 -0
  52. ccxt/abstract/coinbaseinternational.py +39 -0
  53. ccxt/abstract/coincatch.py +94 -0
  54. ccxt/abstract/coincheck.py +33 -0
  55. ccxt/abstract/coinex.py +237 -0
  56. ccxt/abstract/coinlist.py +54 -0
  57. ccxt/abstract/coinmate.py +62 -0
  58. ccxt/abstract/coinmetro.py +34 -0
  59. ccxt/abstract/coinone.py +67 -0
  60. ccxt/abstract/coinsph.py +54 -0
  61. ccxt/abstract/coinspot.py +28 -0
  62. ccxt/abstract/cryptocom.py +107 -0
  63. ccxt/abstract/currencycom.py +68 -0
  64. ccxt/abstract/delta.py +50 -0
  65. ccxt/abstract/deribit.py +125 -0
  66. ccxt/abstract/digifinex.py +91 -0
  67. ccxt/abstract/eterex.py +5 -0
  68. ccxt/abstract/excoino.py +7 -0
  69. ccxt/abstract/exir.py +8 -0
  70. ccxt/abstract/exmo.py +55 -0
  71. ccxt/abstract/exnovin.py +6 -0
  72. ccxt/abstract/farhadexchange.py +5 -0
  73. ccxt/abstract/fmfwio.py +115 -0
  74. ccxt/abstract/gate.py +265 -0
  75. ccxt/abstract/gateio.py +265 -0
  76. ccxt/abstract/gemini.py +58 -0
  77. ccxt/abstract/hashkey.py +67 -0
  78. ccxt/abstract/hitbtc.py +115 -0
  79. ccxt/abstract/hitbtc3.py +115 -0
  80. ccxt/abstract/hitobit.py +8 -0
  81. ccxt/abstract/hollaex.py +33 -0
  82. ccxt/abstract/htx.py +548 -0
  83. ccxt/abstract/huobi.py +548 -0
  84. ccxt/abstract/huobijp.py +114 -0
  85. ccxt/abstract/hyperliquid.py +6 -0
  86. ccxt/abstract/idex.py +26 -0
  87. ccxt/abstract/independentreserve.py +37 -0
  88. ccxt/abstract/indodax.py +26 -0
  89. ccxt/abstract/jibitex.py +7 -0
  90. ccxt/abstract/kraken.py +57 -0
  91. ccxt/abstract/krakenfutures.py +38 -0
  92. ccxt/abstract/kucoin.py +214 -0
  93. ccxt/abstract/kucoinfutures.py +233 -0
  94. ccxt/abstract/kuna.py +182 -0
  95. ccxt/abstract/latoken.py +56 -0
  96. ccxt/abstract/lbank.py +61 -0
  97. ccxt/abstract/luno.py +37 -0
  98. ccxt/abstract/lykke.py +29 -0
  99. ccxt/abstract/mercado.py +25 -0
  100. ccxt/abstract/mexc.py +178 -0
  101. ccxt/abstract/ndax.py +97 -0
  102. ccxt/abstract/nobitex.py +7 -0
  103. ccxt/abstract/novadax.py +29 -0
  104. ccxt/abstract/oceanex.py +22 -0
  105. ccxt/abstract/okcoin.py +74 -0
  106. ccxt/abstract/okexchange.py +8 -0
  107. ccxt/abstract/okx.py +324 -0
  108. ccxt/abstract/ompfinex.py +7 -0
  109. ccxt/abstract/onetrading.py +35 -0
  110. ccxt/abstract/oxfun.py +34 -0
  111. ccxt/abstract/p2b.py +22 -0
  112. ccxt/abstract/paradex.py +40 -0
  113. ccxt/abstract/paymium.py +28 -0
  114. ccxt/abstract/phemex.py +115 -0
  115. ccxt/abstract/poloniex.py +69 -0
  116. ccxt/abstract/poloniexfutures.py +48 -0
  117. ccxt/abstract/probit.py +23 -0
  118. ccxt/abstract/ramzinex.py +7 -0
  119. ccxt/abstract/sarmayex.py +5 -0
  120. ccxt/abstract/sarrafex.py +7 -0
  121. ccxt/abstract/tabdeal.py +7 -0
  122. ccxt/abstract/tetherland.py +5 -0
  123. ccxt/abstract/timex.py +62 -0
  124. ccxt/abstract/tokocrypto.py +37 -0
  125. ccxt/abstract/tradeogre.py +16 -0
  126. ccxt/abstract/twox.py +5 -0
  127. ccxt/abstract/ubitex.py +7 -0
  128. ccxt/abstract/upbit.py +38 -0
  129. ccxt/abstract/vertex.py +19 -0
  130. ccxt/abstract/wallex.py +8 -0
  131. ccxt/abstract/wavesexchange.py +154 -0
  132. ccxt/abstract/wazirx.py +30 -0
  133. ccxt/abstract/whitebit.py +98 -0
  134. ccxt/abstract/woo.py +83 -0
  135. ccxt/abstract/woofipro.py +119 -0
  136. ccxt/abstract/xt.py +152 -0
  137. ccxt/abstract/yobit.py +16 -0
  138. ccxt/abstract/zaif.py +38 -0
  139. ccxt/abstract/zonda.py +53 -0
  140. ccxt/ace.py +1012 -0
  141. ccxt/afratether.py +293 -0
  142. ccxt/alpaca.py +1083 -0
  143. ccxt/arzinja.py +285 -0
  144. ccxt/arzplus.py +412 -0
  145. ccxt/ascendex.py +3330 -0
  146. ccxt/async_support/__init__.py +337 -0
  147. ccxt/async_support/abantether.py +316 -0
  148. ccxt/async_support/ace.py +1012 -0
  149. ccxt/async_support/afratether.py +293 -0
  150. ccxt/async_support/alpaca.py +1083 -0
  151. ccxt/async_support/arzinja.py +285 -0
  152. ccxt/async_support/arzplus.py +412 -0
  153. ccxt/async_support/ascendex.py +3330 -0
  154. ccxt/async_support/base/__init__.py +1 -0
  155. ccxt/async_support/base/exchange.py +1966 -0
  156. ccxt/async_support/base/throttler.py +50 -0
  157. ccxt/async_support/base/ws/__init__.py +38 -0
  158. ccxt/async_support/base/ws/aiohttp_client.py +125 -0
  159. ccxt/async_support/base/ws/cache.py +212 -0
  160. ccxt/async_support/base/ws/client.py +193 -0
  161. ccxt/async_support/base/ws/fast_client.py +96 -0
  162. ccxt/async_support/base/ws/functions.py +59 -0
  163. ccxt/async_support/base/ws/future.py +58 -0
  164. ccxt/async_support/base/ws/order_book.py +78 -0
  165. ccxt/async_support/base/ws/order_book_side.py +174 -0
  166. ccxt/async_support/bequant.py +33 -0
  167. ccxt/async_support/bigone.py +2113 -0
  168. ccxt/async_support/binance.py +12234 -0
  169. ccxt/async_support/binancecoinm.py +45 -0
  170. ccxt/async_support/binanceus.py +211 -0
  171. ccxt/async_support/binanceusdm.py +58 -0
  172. ccxt/async_support/bingx.py +4325 -0
  173. ccxt/async_support/bit2c.py +866 -0
  174. ccxt/async_support/bitbank.py +1001 -0
  175. ccxt/async_support/bitbay.py +17 -0
  176. ccxt/async_support/bitbns.py +1154 -0
  177. ccxt/async_support/bitcoincom.py +17 -0
  178. ccxt/async_support/bitfinex.py +1617 -0
  179. ccxt/async_support/bitfinex2.py +3552 -0
  180. ccxt/async_support/bitflyer.py +995 -0
  181. ccxt/async_support/bitget.py +8273 -0
  182. ccxt/async_support/bithumb.py +1061 -0
  183. ccxt/async_support/bitimen.py +401 -0
  184. ccxt/async_support/bitir.py +490 -0
  185. ccxt/async_support/bitmart.py +4415 -0
  186. ccxt/async_support/bitmex.py +2756 -0
  187. ccxt/async_support/bitopro.py +1630 -0
  188. ccxt/async_support/bitpanda.py +16 -0
  189. ccxt/async_support/bitpin.py +454 -0
  190. ccxt/async_support/bitrue.py +3027 -0
  191. ccxt/async_support/bitso.py +1670 -0
  192. ccxt/async_support/bitstamp.py +2203 -0
  193. ccxt/async_support/bitteam.py +2239 -0
  194. ccxt/async_support/bitvavo.py +1968 -0
  195. ccxt/async_support/bl3p.py +485 -0
  196. ccxt/async_support/blockchaincom.py +1104 -0
  197. ccxt/async_support/blofin.py +2066 -0
  198. ccxt/async_support/btcalpha.py +891 -0
  199. ccxt/async_support/btcbox.py +544 -0
  200. ccxt/async_support/btcmarkets.py +1221 -0
  201. ccxt/async_support/btcturk.py +911 -0
  202. ccxt/async_support/bybit.py +8159 -0
  203. ccxt/async_support/cex.py +1605 -0
  204. ccxt/async_support/coinbase.py +4475 -0
  205. ccxt/async_support/coinbaseadvanced.py +17 -0
  206. ccxt/async_support/coinbaseexchange.py +1734 -0
  207. ccxt/async_support/coinbaseinternational.py +1899 -0
  208. ccxt/async_support/coincatch.py +5069 -0
  209. ccxt/async_support/coincheck.py +815 -0
  210. ccxt/async_support/coinex.py +5526 -0
  211. ccxt/async_support/coinlist.py +2243 -0
  212. ccxt/async_support/coinmate.py +1067 -0
  213. ccxt/async_support/coinmetro.py +1797 -0
  214. ccxt/async_support/coinone.py +1127 -0
  215. ccxt/async_support/coinsph.py +1850 -0
  216. ccxt/async_support/coinspot.py +534 -0
  217. ccxt/async_support/cryptocom.py +2822 -0
  218. ccxt/async_support/currencycom.py +1950 -0
  219. ccxt/async_support/delta.py +3376 -0
  220. ccxt/async_support/deribit.py +3437 -0
  221. ccxt/async_support/digifinex.py +3960 -0
  222. ccxt/async_support/eterex.py +286 -0
  223. ccxt/async_support/excoino.py +399 -0
  224. ccxt/async_support/exir.py +375 -0
  225. ccxt/async_support/exmo.py +2462 -0
  226. ccxt/async_support/exnovin.py +360 -0
  227. ccxt/async_support/farhadexchange.py +266 -0
  228. ccxt/async_support/fmfwio.py +34 -0
  229. ccxt/async_support/gate.py +6976 -0
  230. ccxt/async_support/gateio.py +16 -0
  231. ccxt/async_support/gemini.py +1825 -0
  232. ccxt/async_support/hashkey.py +4150 -0
  233. ccxt/async_support/hitbtc.py +3423 -0
  234. ccxt/async_support/hitbtc3.py +16 -0
  235. ccxt/async_support/hitobit.py +391 -0
  236. ccxt/async_support/hollaex.py +1813 -0
  237. ccxt/async_support/htx.py +8506 -0
  238. ccxt/async_support/huobi.py +16 -0
  239. ccxt/async_support/huobijp.py +1801 -0
  240. ccxt/async_support/hyperliquid.py +2431 -0
  241. ccxt/async_support/idex.py +1766 -0
  242. ccxt/async_support/independentreserve.py +784 -0
  243. ccxt/async_support/indodax.py +1247 -0
  244. ccxt/async_support/jibitex.py +395 -0
  245. ccxt/async_support/kraken.py +2894 -0
  246. ccxt/async_support/krakenfutures.py +2601 -0
  247. ccxt/async_support/kucoin.py +4602 -0
  248. ccxt/async_support/kucoinfutures.py +2698 -0
  249. ccxt/async_support/kuna.py +1841 -0
  250. ccxt/async_support/latoken.py +1664 -0
  251. ccxt/async_support/lbank.py +2683 -0
  252. ccxt/async_support/luno.py +1067 -0
  253. ccxt/async_support/lykke.py +1270 -0
  254. ccxt/async_support/mercado.py +842 -0
  255. ccxt/async_support/mexc.py +5369 -0
  256. ccxt/async_support/ndax.py +2354 -0
  257. ccxt/async_support/nobitex.py +419 -0
  258. ccxt/async_support/novadax.py +1484 -0
  259. ccxt/async_support/oceanex.py +903 -0
  260. ccxt/async_support/okcoin.py +2936 -0
  261. ccxt/async_support/okexchange.py +349 -0
  262. ccxt/async_support/okx.py +7827 -0
  263. ccxt/async_support/ompfinex.py +472 -0
  264. ccxt/async_support/onetrading.py +1911 -0
  265. ccxt/async_support/oxfun.py +2773 -0
  266. ccxt/async_support/p2b.py +1194 -0
  267. ccxt/async_support/paradex.py +2015 -0
  268. ccxt/async_support/paymium.py +564 -0
  269. ccxt/async_support/phemex.py +4473 -0
  270. ccxt/async_support/poloniex.py +2232 -0
  271. ccxt/async_support/poloniexfutures.py +1717 -0
  272. ccxt/async_support/probit.py +1734 -0
  273. ccxt/async_support/ramzinex.py +476 -0
  274. ccxt/async_support/sarmayex.py +357 -0
  275. ccxt/async_support/sarrafex.py +478 -0
  276. ccxt/async_support/tabdeal.py +364 -0
  277. ccxt/async_support/tetherland.py +349 -0
  278. ccxt/async_support/timex.py +1593 -0
  279. ccxt/async_support/tokocrypto.py +2405 -0
  280. ccxt/async_support/tradeogre.py +608 -0
  281. ccxt/async_support/twox.py +326 -0
  282. ccxt/async_support/ubitex.py +409 -0
  283. ccxt/async_support/upbit.py +1833 -0
  284. ccxt/async_support/vertex.py +2922 -0
  285. ccxt/async_support/wallex.py +445 -0
  286. ccxt/async_support/wavesexchange.py +2473 -0
  287. ccxt/async_support/wazirx.py +1224 -0
  288. ccxt/async_support/whitebit.py +2469 -0
  289. ccxt/async_support/woo.py +3114 -0
  290. ccxt/async_support/woofipro.py +2533 -0
  291. ccxt/async_support/xt.py +4454 -0
  292. ccxt/async_support/yobit.py +1283 -0
  293. ccxt/async_support/zaif.py +725 -0
  294. ccxt/async_support/zonda.py +1828 -0
  295. ccxt/base/__init__.py +27 -0
  296. ccxt/base/decimal_to_precision.py +174 -0
  297. ccxt/base/errors.py +242 -0
  298. ccxt/base/exchange.py +5941 -0
  299. ccxt/base/precise.py +287 -0
  300. ccxt/base/types.py +502 -0
  301. ccxt/bequant.py +33 -0
  302. ccxt/bigone.py +2112 -0
  303. ccxt/binance.py +12233 -0
  304. ccxt/binancecoinm.py +45 -0
  305. ccxt/binanceus.py +211 -0
  306. ccxt/binanceusdm.py +58 -0
  307. ccxt/bingx.py +4324 -0
  308. ccxt/bit2c.py +866 -0
  309. ccxt/bitbank.py +1001 -0
  310. ccxt/bitbay.py +17 -0
  311. ccxt/bitbns.py +1154 -0
  312. ccxt/bitcoincom.py +17 -0
  313. ccxt/bitfinex.py +1617 -0
  314. ccxt/bitfinex2.py +3552 -0
  315. ccxt/bitflyer.py +995 -0
  316. ccxt/bitget.py +8272 -0
  317. ccxt/bithumb.py +1061 -0
  318. ccxt/bitimen.py +401 -0
  319. ccxt/bitir.py +490 -0
  320. ccxt/bitmart.py +4415 -0
  321. ccxt/bitmex.py +2756 -0
  322. ccxt/bitopro.py +1630 -0
  323. ccxt/bitpanda.py +16 -0
  324. ccxt/bitpin.py +454 -0
  325. ccxt/bitrue.py +3026 -0
  326. ccxt/bitso.py +1670 -0
  327. ccxt/bitstamp.py +2203 -0
  328. ccxt/bitteam.py +2239 -0
  329. ccxt/bitvavo.py +1968 -0
  330. ccxt/bl3p.py +485 -0
  331. ccxt/blockchaincom.py +1104 -0
  332. ccxt/blofin.py +2066 -0
  333. ccxt/btcalpha.py +891 -0
  334. ccxt/btcbox.py +544 -0
  335. ccxt/btcmarkets.py +1221 -0
  336. ccxt/btcturk.py +911 -0
  337. ccxt/bybit.py +8158 -0
  338. ccxt/cex.py +1605 -0
  339. ccxt/coinbase.py +4474 -0
  340. ccxt/coinbaseadvanced.py +17 -0
  341. ccxt/coinbaseexchange.py +1734 -0
  342. ccxt/coinbaseinternational.py +1899 -0
  343. ccxt/coincatch.py +5069 -0
  344. ccxt/coincheck.py +815 -0
  345. ccxt/coinex.py +5525 -0
  346. ccxt/coinlist.py +2243 -0
  347. ccxt/coinmate.py +1067 -0
  348. ccxt/coinmetro.py +1797 -0
  349. ccxt/coinone.py +1127 -0
  350. ccxt/coinsph.py +1850 -0
  351. ccxt/coinspot.py +534 -0
  352. ccxt/cryptocom.py +2822 -0
  353. ccxt/currencycom.py +1950 -0
  354. ccxt/delta.py +3376 -0
  355. ccxt/deribit.py +3437 -0
  356. ccxt/digifinex.py +3959 -0
  357. ccxt/eterex.py +286 -0
  358. ccxt/excoino.py +399 -0
  359. ccxt/exir.py +375 -0
  360. ccxt/exmo.py +2462 -0
  361. ccxt/exnovin.py +360 -0
  362. ccxt/farhadexchange.py +266 -0
  363. ccxt/fmfwio.py +34 -0
  364. ccxt/gate.py +6975 -0
  365. ccxt/gateio.py +16 -0
  366. ccxt/gemini.py +1824 -0
  367. ccxt/hashkey.py +4150 -0
  368. ccxt/hitbtc.py +3423 -0
  369. ccxt/hitbtc3.py +16 -0
  370. ccxt/hitobit.py +391 -0
  371. ccxt/hollaex.py +1813 -0
  372. ccxt/htx.py +8505 -0
  373. ccxt/huobi.py +16 -0
  374. ccxt/huobijp.py +1801 -0
  375. ccxt/hyperliquid.py +2430 -0
  376. ccxt/idex.py +1766 -0
  377. ccxt/independentreserve.py +784 -0
  378. ccxt/indodax.py +1247 -0
  379. ccxt/jibitex.py +395 -0
  380. ccxt/kraken.py +2894 -0
  381. ccxt/krakenfutures.py +2601 -0
  382. ccxt/kucoin.py +4601 -0
  383. ccxt/kucoinfutures.py +2698 -0
  384. ccxt/kuna.py +1841 -0
  385. ccxt/latoken.py +1664 -0
  386. ccxt/lbank.py +2682 -0
  387. ccxt/luno.py +1067 -0
  388. ccxt/lykke.py +1270 -0
  389. ccxt/mercado.py +842 -0
  390. ccxt/mexc.py +5369 -0
  391. ccxt/ndax.py +2354 -0
  392. ccxt/nobitex.py +419 -0
  393. ccxt/novadax.py +1484 -0
  394. ccxt/oceanex.py +903 -0
  395. ccxt/okcoin.py +2936 -0
  396. ccxt/okexchange.py +349 -0
  397. ccxt/okx.py +7826 -0
  398. ccxt/ompfinex.py +472 -0
  399. ccxt/onetrading.py +1911 -0
  400. ccxt/oxfun.py +2772 -0
  401. ccxt/p2b.py +1194 -0
  402. ccxt/paradex.py +2015 -0
  403. ccxt/paymium.py +564 -0
  404. ccxt/phemex.py +4473 -0
  405. ccxt/poloniex.py +2232 -0
  406. ccxt/poloniexfutures.py +1717 -0
  407. ccxt/pro/__init__.py +149 -0
  408. ccxt/pro/alpaca.py +685 -0
  409. ccxt/pro/ascendex.py +916 -0
  410. ccxt/pro/bequant.py +38 -0
  411. ccxt/pro/binance.py +3488 -0
  412. ccxt/pro/binancecoinm.py +28 -0
  413. ccxt/pro/binanceus.py +48 -0
  414. ccxt/pro/binanceusdm.py +31 -0
  415. ccxt/pro/bingx.py +1264 -0
  416. ccxt/pro/bitcoincom.py +34 -0
  417. ccxt/pro/bitfinex.py +621 -0
  418. ccxt/pro/bitfinex2.py +1083 -0
  419. ccxt/pro/bitget.py +1692 -0
  420. ccxt/pro/bithumb.py +368 -0
  421. ccxt/pro/bitmart.py +1449 -0
  422. ccxt/pro/bitmex.py +1656 -0
  423. ccxt/pro/bitopro.py +445 -0
  424. ccxt/pro/bitpanda.py +15 -0
  425. ccxt/pro/bitrue.py +447 -0
  426. ccxt/pro/bitstamp.py +522 -0
  427. ccxt/pro/bitvavo.py +1270 -0
  428. ccxt/pro/blockchaincom.py +738 -0
  429. ccxt/pro/blofin.py +692 -0
  430. ccxt/pro/bybit.py +2000 -0
  431. ccxt/pro/cex.py +1440 -0
  432. ccxt/pro/coinbase.py +678 -0
  433. ccxt/pro/coinbaseadvanced.py +16 -0
  434. ccxt/pro/coinbaseexchange.py +895 -0
  435. ccxt/pro/coinbaseinternational.py +620 -0
  436. ccxt/pro/coincatch.py +1464 -0
  437. ccxt/pro/coincheck.py +199 -0
  438. ccxt/pro/coinex.py +1061 -0
  439. ccxt/pro/coinone.py +395 -0
  440. ccxt/pro/cryptocom.py +947 -0
  441. ccxt/pro/currencycom.py +536 -0
  442. ccxt/pro/deribit.py +892 -0
  443. ccxt/pro/exmo.py +629 -0
  444. ccxt/pro/gate.py +1416 -0
  445. ccxt/pro/gateio.py +15 -0
  446. ccxt/pro/gemini.py +865 -0
  447. ccxt/pro/hashkey.py +802 -0
  448. ccxt/pro/hitbtc.py +1216 -0
  449. ccxt/pro/hollaex.py +563 -0
  450. ccxt/pro/htx.py +2215 -0
  451. ccxt/pro/huobi.py +15 -0
  452. ccxt/pro/huobijp.py +570 -0
  453. ccxt/pro/hyperliquid.py +525 -0
  454. ccxt/pro/idex.py +672 -0
  455. ccxt/pro/independentreserve.py +270 -0
  456. ccxt/pro/kraken.py +1356 -0
  457. ccxt/pro/krakenfutures.py +1492 -0
  458. ccxt/pro/kucoin.py +1133 -0
  459. ccxt/pro/kucoinfutures.py +1081 -0
  460. ccxt/pro/lbank.py +843 -0
  461. ccxt/pro/luno.py +303 -0
  462. ccxt/pro/mexc.py +1122 -0
  463. ccxt/pro/ndax.py +506 -0
  464. ccxt/pro/okcoin.py +698 -0
  465. ccxt/pro/okx.py +1851 -0
  466. ccxt/pro/onetrading.py +1275 -0
  467. ccxt/pro/oxfun.py +950 -0
  468. ccxt/pro/p2b.py +419 -0
  469. ccxt/pro/paradex.py +352 -0
  470. ccxt/pro/phemex.py +1441 -0
  471. ccxt/pro/poloniex.py +1166 -0
  472. ccxt/pro/poloniexfutures.py +990 -0
  473. ccxt/pro/probit.py +551 -0
  474. ccxt/pro/upbit.py +520 -0
  475. ccxt/pro/vertex.py +943 -0
  476. ccxt/pro/wazirx.py +749 -0
  477. ccxt/pro/whitebit.py +864 -0
  478. ccxt/pro/woo.py +1078 -0
  479. ccxt/pro/woofipro.py +1183 -0
  480. ccxt/pro/xt.py +1067 -0
  481. ccxt/probit.py +1734 -0
  482. ccxt/ramzinex.py +476 -0
  483. ccxt/sarmayex.py +357 -0
  484. ccxt/sarrafex.py +478 -0
  485. ccxt/static_dependencies/__init__.py +1 -0
  486. ccxt/static_dependencies/ecdsa/__init__.py +14 -0
  487. ccxt/static_dependencies/ecdsa/_version.py +520 -0
  488. ccxt/static_dependencies/ecdsa/curves.py +56 -0
  489. ccxt/static_dependencies/ecdsa/der.py +221 -0
  490. ccxt/static_dependencies/ecdsa/ecdsa.py +310 -0
  491. ccxt/static_dependencies/ecdsa/ellipticcurve.py +197 -0
  492. ccxt/static_dependencies/ecdsa/keys.py +332 -0
  493. ccxt/static_dependencies/ecdsa/numbertheory.py +531 -0
  494. ccxt/static_dependencies/ecdsa/rfc6979.py +100 -0
  495. ccxt/static_dependencies/ecdsa/util.py +266 -0
  496. ccxt/static_dependencies/ethereum/__init__.py +7 -0
  497. ccxt/static_dependencies/ethereum/abi/__init__.py +16 -0
  498. ccxt/static_dependencies/ethereum/abi/abi.py +19 -0
  499. ccxt/static_dependencies/ethereum/abi/base.py +152 -0
  500. ccxt/static_dependencies/ethereum/abi/codec.py +217 -0
  501. ccxt/static_dependencies/ethereum/abi/constants.py +3 -0
  502. ccxt/static_dependencies/ethereum/abi/decoding.py +565 -0
  503. ccxt/static_dependencies/ethereum/abi/encoding.py +720 -0
  504. ccxt/static_dependencies/ethereum/abi/exceptions.py +139 -0
  505. ccxt/static_dependencies/ethereum/abi/grammar.py +443 -0
  506. ccxt/static_dependencies/ethereum/abi/packed.py +13 -0
  507. ccxt/static_dependencies/ethereum/abi/py.typed +0 -0
  508. ccxt/static_dependencies/ethereum/abi/registry.py +643 -0
  509. ccxt/static_dependencies/ethereum/abi/tools/__init__.py +3 -0
  510. ccxt/static_dependencies/ethereum/abi/tools/_strategies.py +230 -0
  511. ccxt/static_dependencies/ethereum/abi/utils/__init__.py +0 -0
  512. ccxt/static_dependencies/ethereum/abi/utils/numeric.py +83 -0
  513. ccxt/static_dependencies/ethereum/abi/utils/padding.py +27 -0
  514. ccxt/static_dependencies/ethereum/abi/utils/string.py +19 -0
  515. ccxt/static_dependencies/ethereum/account/__init__.py +3 -0
  516. ccxt/static_dependencies/ethereum/account/encode_typed_data/__init__.py +4 -0
  517. ccxt/static_dependencies/ethereum/account/encode_typed_data/encoding_and_hashing.py +239 -0
  518. ccxt/static_dependencies/ethereum/account/encode_typed_data/helpers.py +40 -0
  519. ccxt/static_dependencies/ethereum/account/messages.py +263 -0
  520. ccxt/static_dependencies/ethereum/account/py.typed +0 -0
  521. ccxt/static_dependencies/ethereum/hexbytes/__init__.py +5 -0
  522. ccxt/static_dependencies/ethereum/hexbytes/_utils.py +54 -0
  523. ccxt/static_dependencies/ethereum/hexbytes/main.py +65 -0
  524. ccxt/static_dependencies/ethereum/hexbytes/py.typed +0 -0
  525. ccxt/static_dependencies/ethereum/typing/__init__.py +63 -0
  526. ccxt/static_dependencies/ethereum/typing/abi.py +6 -0
  527. ccxt/static_dependencies/ethereum/typing/bls.py +7 -0
  528. ccxt/static_dependencies/ethereum/typing/discovery.py +5 -0
  529. ccxt/static_dependencies/ethereum/typing/encoding.py +7 -0
  530. ccxt/static_dependencies/ethereum/typing/enums.py +17 -0
  531. ccxt/static_dependencies/ethereum/typing/ethpm.py +9 -0
  532. ccxt/static_dependencies/ethereum/typing/evm.py +20 -0
  533. ccxt/static_dependencies/ethereum/typing/networks.py +1122 -0
  534. ccxt/static_dependencies/ethereum/typing/py.typed +0 -0
  535. ccxt/static_dependencies/ethereum/utils/__init__.py +115 -0
  536. ccxt/static_dependencies/ethereum/utils/abi.py +72 -0
  537. ccxt/static_dependencies/ethereum/utils/address.py +171 -0
  538. ccxt/static_dependencies/ethereum/utils/applicators.py +151 -0
  539. ccxt/static_dependencies/ethereum/utils/conversions.py +190 -0
  540. ccxt/static_dependencies/ethereum/utils/currency.py +107 -0
  541. ccxt/static_dependencies/ethereum/utils/curried/__init__.py +269 -0
  542. ccxt/static_dependencies/ethereum/utils/debug.py +20 -0
  543. ccxt/static_dependencies/ethereum/utils/decorators.py +132 -0
  544. ccxt/static_dependencies/ethereum/utils/encoding.py +6 -0
  545. ccxt/static_dependencies/ethereum/utils/exceptions.py +4 -0
  546. ccxt/static_dependencies/ethereum/utils/functional.py +75 -0
  547. ccxt/static_dependencies/ethereum/utils/hexadecimal.py +74 -0
  548. ccxt/static_dependencies/ethereum/utils/humanize.py +188 -0
  549. ccxt/static_dependencies/ethereum/utils/logging.py +159 -0
  550. ccxt/static_dependencies/ethereum/utils/module_loading.py +31 -0
  551. ccxt/static_dependencies/ethereum/utils/numeric.py +43 -0
  552. ccxt/static_dependencies/ethereum/utils/py.typed +0 -0
  553. ccxt/static_dependencies/ethereum/utils/toolz.py +76 -0
  554. ccxt/static_dependencies/ethereum/utils/types.py +54 -0
  555. ccxt/static_dependencies/ethereum/utils/typing/__init__.py +18 -0
  556. ccxt/static_dependencies/ethereum/utils/typing/misc.py +14 -0
  557. ccxt/static_dependencies/ethereum/utils/units.py +31 -0
  558. ccxt/static_dependencies/keccak/__init__.py +3 -0
  559. ccxt/static_dependencies/keccak/keccak.py +197 -0
  560. ccxt/static_dependencies/lark/__init__.py +38 -0
  561. ccxt/static_dependencies/lark/__pyinstaller/__init__.py +6 -0
  562. ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +14 -0
  563. ccxt/static_dependencies/lark/ast_utils.py +59 -0
  564. ccxt/static_dependencies/lark/common.py +86 -0
  565. ccxt/static_dependencies/lark/exceptions.py +292 -0
  566. ccxt/static_dependencies/lark/grammar.py +130 -0
  567. ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
  568. ccxt/static_dependencies/lark/indenter.py +143 -0
  569. ccxt/static_dependencies/lark/lark.py +658 -0
  570. ccxt/static_dependencies/lark/lexer.py +678 -0
  571. ccxt/static_dependencies/lark/load_grammar.py +1428 -0
  572. ccxt/static_dependencies/lark/parse_tree_builder.py +391 -0
  573. ccxt/static_dependencies/lark/parser_frontends.py +257 -0
  574. ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
  575. ccxt/static_dependencies/lark/parsers/cyk.py +340 -0
  576. ccxt/static_dependencies/lark/parsers/earley.py +314 -0
  577. ccxt/static_dependencies/lark/parsers/earley_common.py +42 -0
  578. ccxt/static_dependencies/lark/parsers/earley_forest.py +801 -0
  579. ccxt/static_dependencies/lark/parsers/grammar_analysis.py +203 -0
  580. ccxt/static_dependencies/lark/parsers/lalr_analysis.py +332 -0
  581. ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +158 -0
  582. ccxt/static_dependencies/lark/parsers/lalr_parser.py +122 -0
  583. ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +110 -0
  584. ccxt/static_dependencies/lark/parsers/xearley.py +165 -0
  585. ccxt/static_dependencies/lark/reconstruct.py +107 -0
  586. ccxt/static_dependencies/lark/tools/__init__.py +70 -0
  587. ccxt/static_dependencies/lark/tools/nearley.py +202 -0
  588. ccxt/static_dependencies/lark/tools/serialize.py +32 -0
  589. ccxt/static_dependencies/lark/tools/standalone.py +196 -0
  590. ccxt/static_dependencies/lark/tree.py +267 -0
  591. ccxt/static_dependencies/lark/tree_matcher.py +186 -0
  592. ccxt/static_dependencies/lark/tree_templates.py +180 -0
  593. ccxt/static_dependencies/lark/utils.py +343 -0
  594. ccxt/static_dependencies/lark/visitors.py +596 -0
  595. ccxt/static_dependencies/marshmallow/__init__.py +81 -0
  596. ccxt/static_dependencies/marshmallow/base.py +65 -0
  597. ccxt/static_dependencies/marshmallow/class_registry.py +94 -0
  598. ccxt/static_dependencies/marshmallow/decorators.py +231 -0
  599. ccxt/static_dependencies/marshmallow/error_store.py +60 -0
  600. ccxt/static_dependencies/marshmallow/exceptions.py +71 -0
  601. ccxt/static_dependencies/marshmallow/fields.py +2114 -0
  602. ccxt/static_dependencies/marshmallow/orderedset.py +89 -0
  603. ccxt/static_dependencies/marshmallow/schema.py +1228 -0
  604. ccxt/static_dependencies/marshmallow/types.py +12 -0
  605. ccxt/static_dependencies/marshmallow/utils.py +378 -0
  606. ccxt/static_dependencies/marshmallow/validate.py +678 -0
  607. ccxt/static_dependencies/marshmallow/warnings.py +2 -0
  608. ccxt/static_dependencies/marshmallow_dataclass/__init__.py +1047 -0
  609. ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +51 -0
  610. ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +45 -0
  611. ccxt/static_dependencies/marshmallow_dataclass/mypy.py +71 -0
  612. ccxt/static_dependencies/marshmallow_dataclass/typing.py +14 -0
  613. ccxt/static_dependencies/marshmallow_dataclass/union_field.py +82 -0
  614. ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +1 -0
  615. ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +193 -0
  616. ccxt/static_dependencies/msgpack/__init__.py +55 -0
  617. ccxt/static_dependencies/msgpack/exceptions.py +48 -0
  618. ccxt/static_dependencies/msgpack/ext.py +168 -0
  619. ccxt/static_dependencies/msgpack/fallback.py +951 -0
  620. ccxt/static_dependencies/parsimonious/__init__.py +10 -0
  621. ccxt/static_dependencies/parsimonious/exceptions.py +105 -0
  622. ccxt/static_dependencies/parsimonious/expressions.py +479 -0
  623. ccxt/static_dependencies/parsimonious/grammar.py +487 -0
  624. ccxt/static_dependencies/parsimonious/nodes.py +325 -0
  625. ccxt/static_dependencies/parsimonious/utils.py +40 -0
  626. ccxt/static_dependencies/starknet/__init__.py +0 -0
  627. ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
  628. ccxt/static_dependencies/starknet/cairo/data_types.py +123 -0
  629. ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
  630. ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +77 -0
  631. ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +46 -0
  632. ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +138 -0
  633. ccxt/static_dependencies/starknet/cairo/felt.py +64 -0
  634. ccxt/static_dependencies/starknet/cairo/type_parser.py +121 -0
  635. ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
  636. ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +59 -0
  637. ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
  638. ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +77 -0
  639. ccxt/static_dependencies/starknet/ccxt_utils.py +7 -0
  640. ccxt/static_dependencies/starknet/common.py +15 -0
  641. ccxt/static_dependencies/starknet/constants.py +39 -0
  642. ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
  643. ccxt/static_dependencies/starknet/hash/address.py +79 -0
  644. ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +111 -0
  645. ccxt/static_dependencies/starknet/hash/selector.py +16 -0
  646. ccxt/static_dependencies/starknet/hash/storage.py +12 -0
  647. ccxt/static_dependencies/starknet/hash/utils.py +78 -0
  648. ccxt/static_dependencies/starknet/models/__init__.py +0 -0
  649. ccxt/static_dependencies/starknet/models/typed_data.py +45 -0
  650. ccxt/static_dependencies/starknet/serialization/__init__.py +24 -0
  651. ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +40 -0
  652. ccxt/static_dependencies/starknet/serialization/_context.py +142 -0
  653. ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +10 -0
  654. ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +82 -0
  655. ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +43 -0
  656. ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +37 -0
  657. ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +66 -0
  658. ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +71 -0
  659. ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +71 -0
  660. ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +50 -0
  661. ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +58 -0
  662. ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +43 -0
  663. ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +40 -0
  664. ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +72 -0
  665. ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +36 -0
  666. ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +36 -0
  667. ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +76 -0
  668. ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +100 -0
  669. ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +32 -0
  670. ccxt/static_dependencies/starknet/serialization/errors.py +10 -0
  671. ccxt/static_dependencies/starknet/serialization/factory.py +229 -0
  672. ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +110 -0
  673. ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +59 -0
  674. ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
  675. ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +86 -0
  676. ccxt/static_dependencies/starknet/utils/iterable.py +13 -0
  677. ccxt/static_dependencies/starknet/utils/schema.py +13 -0
  678. ccxt/static_dependencies/starknet/utils/typed_data.py +182 -0
  679. ccxt/static_dependencies/starkware/__init__.py +0 -0
  680. ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
  681. ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +50 -0
  682. ccxt/static_dependencies/starkware/crypto/math_utils.py +78 -0
  683. ccxt/static_dependencies/starkware/crypto/signature.py +2344 -0
  684. ccxt/static_dependencies/starkware/crypto/utils.py +63 -0
  685. ccxt/static_dependencies/sympy/__init__.py +0 -0
  686. ccxt/static_dependencies/sympy/core/__init__.py +0 -0
  687. ccxt/static_dependencies/sympy/core/intfunc.py +35 -0
  688. ccxt/static_dependencies/sympy/external/__init__.py +0 -0
  689. ccxt/static_dependencies/sympy/external/gmpy.py +345 -0
  690. ccxt/static_dependencies/sympy/external/importtools.py +187 -0
  691. ccxt/static_dependencies/sympy/external/ntheory.py +637 -0
  692. ccxt/static_dependencies/sympy/external/pythonmpq.py +341 -0
  693. ccxt/static_dependencies/toolz/__init__.py +26 -0
  694. ccxt/static_dependencies/toolz/_signatures.py +784 -0
  695. ccxt/static_dependencies/toolz/_version.py +520 -0
  696. ccxt/static_dependencies/toolz/compatibility.py +30 -0
  697. ccxt/static_dependencies/toolz/curried/__init__.py +101 -0
  698. ccxt/static_dependencies/toolz/curried/exceptions.py +22 -0
  699. ccxt/static_dependencies/toolz/curried/operator.py +22 -0
  700. ccxt/static_dependencies/toolz/dicttoolz.py +339 -0
  701. ccxt/static_dependencies/toolz/functoolz.py +1049 -0
  702. ccxt/static_dependencies/toolz/itertoolz.py +1057 -0
  703. ccxt/static_dependencies/toolz/recipes.py +46 -0
  704. ccxt/static_dependencies/toolz/utils.py +9 -0
  705. ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
  706. ccxt/static_dependencies/typing_inspect/typing_inspect.py +851 -0
  707. ccxt/tabdeal.py +364 -0
  708. ccxt/test/__init__.py +3 -0
  709. ccxt/test/base/__init__.py +29 -0
  710. ccxt/test/base/test_account.py +26 -0
  711. ccxt/test/base/test_balance.py +56 -0
  712. ccxt/test/base/test_borrow_interest.py +35 -0
  713. ccxt/test/base/test_borrow_rate.py +32 -0
  714. ccxt/test/base/test_calculate_fee.py +51 -0
  715. ccxt/test/base/test_crypto.py +127 -0
  716. ccxt/test/base/test_currency.py +76 -0
  717. ccxt/test/base/test_datetime.py +109 -0
  718. ccxt/test/base/test_decimal_to_precision.py +392 -0
  719. ccxt/test/base/test_deep_extend.py +68 -0
  720. ccxt/test/base/test_deposit_withdrawal.py +50 -0
  721. ccxt/test/base/test_exchange_datetime_functions.py +76 -0
  722. ccxt/test/base/test_funding_rate_history.py +29 -0
  723. ccxt/test/base/test_last_price.py +31 -0
  724. ccxt/test/base/test_ledger_entry.py +45 -0
  725. ccxt/test/base/test_ledger_item.py +48 -0
  726. ccxt/test/base/test_leverage_tier.py +33 -0
  727. ccxt/test/base/test_liquidation.py +50 -0
  728. ccxt/test/base/test_margin_mode.py +24 -0
  729. ccxt/test/base/test_margin_modification.py +35 -0
  730. ccxt/test/base/test_market.py +193 -0
  731. ccxt/test/base/test_number.py +411 -0
  732. ccxt/test/base/test_ohlcv.py +33 -0
  733. ccxt/test/base/test_open_interest.py +32 -0
  734. ccxt/test/base/test_order.py +64 -0
  735. ccxt/test/base/test_order_book.py +69 -0
  736. ccxt/test/base/test_position.py +60 -0
  737. ccxt/test/base/test_shared_methods.py +353 -0
  738. ccxt/test/base/test_status.py +24 -0
  739. ccxt/test/base/test_throttle.py +126 -0
  740. ccxt/test/base/test_ticker.py +92 -0
  741. ccxt/test/base/test_trade.py +47 -0
  742. ccxt/test/base/test_trading_fee.py +26 -0
  743. ccxt/test/base/test_transaction.py +39 -0
  744. ccxt/test/test_async.py +1649 -0
  745. ccxt/test/test_sync.py +1648 -0
  746. ccxt/test/tests_async.py +1558 -0
  747. ccxt/test/tests_helpers.py +287 -0
  748. ccxt/test/tests_init.py +39 -0
  749. ccxt/test/tests_sync.py +1555 -0
  750. ccxt/tetherland.py +349 -0
  751. ccxt/timex.py +1593 -0
  752. ccxt/tokocrypto.py +2405 -0
  753. ccxt/tradeogre.py +608 -0
  754. ccxt/twox.py +326 -0
  755. ccxt/ubitex.py +409 -0
  756. ccxt/upbit.py +1833 -0
  757. ccxt/vertex.py +2922 -0
  758. ccxt/wallex.py +445 -0
  759. ccxt/wavesexchange.py +2472 -0
  760. ccxt/wazirx.py +1224 -0
  761. ccxt/whitebit.py +2469 -0
  762. ccxt/woo.py +3114 -0
  763. ccxt/woofipro.py +2533 -0
  764. ccxt/xt.py +4453 -0
  765. ccxt/yobit.py +1283 -0
  766. ccxt/zaif.py +725 -0
  767. ccxt/zonda.py +1828 -0
  768. ccxt_ir-4.3.46.0.1.dist-info/LICENSE.txt +21 -0
  769. ccxt_ir-4.3.46.0.1.dist-info/METADATA +655 -0
  770. ccxt_ir-4.3.46.0.1.dist-info/RECORD +772 -0
  771. ccxt_ir-4.3.46.0.1.dist-info/WHEEL +6 -0
  772. ccxt_ir-4.3.46.0.1.dist-info/top_level.txt +1 -0
ccxt/bitstamp.py ADDED
@@ -0,0 +1,2203 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ # https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+
6
+ from ccxt.base.exchange import Exchange
7
+ from ccxt.abstract.bitstamp import ImplicitAPI
8
+ import hashlib
9
+ from ccxt.base.types import Balances, Currencies, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
10
+ from typing import List
11
+ from ccxt.base.errors import ExchangeError
12
+ from ccxt.base.errors import AuthenticationError
13
+ from ccxt.base.errors import PermissionDenied
14
+ from ccxt.base.errors import BadRequest
15
+ from ccxt.base.errors import InsufficientFunds
16
+ from ccxt.base.errors import InvalidAddress
17
+ from ccxt.base.errors import InvalidOrder
18
+ from ccxt.base.errors import OrderNotFound
19
+ from ccxt.base.errors import NotSupported
20
+ from ccxt.base.errors import ExchangeNotAvailable
21
+ from ccxt.base.errors import OnMaintenance
22
+ from ccxt.base.errors import InvalidNonce
23
+ from ccxt.base.decimal_to_precision import TICK_SIZE
24
+ from ccxt.base.precise import Precise
25
+
26
+
27
+ class bitstamp(Exchange, ImplicitAPI):
28
+
29
+ def describe(self):
30
+ return self.deep_extend(super(bitstamp, self).describe(), {
31
+ 'id': 'bitstamp',
32
+ 'name': 'Bitstamp',
33
+ 'countries': ['GB'],
34
+ # 8000 requests per 10 minutes = 8000 / 600 = 13.33333333 requests per second => 1000ms / 13.33333333 = 75ms between requests on average
35
+ 'rateLimit': 75,
36
+ 'version': 'v2',
37
+ 'userAgent': self.userAgents['chrome'],
38
+ 'pro': True,
39
+ 'has': {
40
+ 'CORS': True,
41
+ 'spot': True,
42
+ 'margin': False,
43
+ 'swap': False,
44
+ 'future': False,
45
+ 'option': False,
46
+ 'addMargin': False,
47
+ 'cancelAllOrders': True,
48
+ 'cancelOrder': True,
49
+ 'closeAllPositions': False,
50
+ 'closePosition': False,
51
+ 'createOrder': True,
52
+ 'createReduceOnlyOrder': False,
53
+ 'createStopLimitOrder': False,
54
+ 'createStopMarketOrder': False,
55
+ 'createStopOrder': False,
56
+ 'fetchBalance': True,
57
+ 'fetchBorrowRateHistories': False,
58
+ 'fetchBorrowRateHistory': False,
59
+ 'fetchCrossBorrowRate': False,
60
+ 'fetchCrossBorrowRates': False,
61
+ 'fetchCurrencies': True,
62
+ 'fetchDepositAddress': True,
63
+ 'fetchDepositsWithdrawals': True,
64
+ 'fetchDepositWithdrawFee': 'emulated',
65
+ 'fetchDepositWithdrawFees': True,
66
+ 'fetchFundingHistory': False,
67
+ 'fetchFundingRate': False,
68
+ 'fetchFundingRateHistory': False,
69
+ 'fetchFundingRates': False,
70
+ 'fetchIndexOHLCV': False,
71
+ 'fetchIsolatedBorrowRate': False,
72
+ 'fetchIsolatedBorrowRates': False,
73
+ 'fetchLedger': True,
74
+ 'fetchLeverage': False,
75
+ 'fetchMarginMode': False,
76
+ 'fetchMarkets': True,
77
+ 'fetchMarkOHLCV': False,
78
+ 'fetchMyTrades': True,
79
+ 'fetchOHLCV': True,
80
+ 'fetchOpenInterestHistory': False,
81
+ 'fetchOpenOrders': True,
82
+ 'fetchOrder': True,
83
+ 'fetchOrderBook': True,
84
+ 'fetchPosition': False,
85
+ 'fetchPositionHistory': False,
86
+ 'fetchPositionMode': False,
87
+ 'fetchPositions': False,
88
+ 'fetchPositionsForSymbol': False,
89
+ 'fetchPositionsHistory': False,
90
+ 'fetchPositionsRisk': False,
91
+ 'fetchPremiumIndexOHLCV': False,
92
+ 'fetchTicker': True,
93
+ 'fetchTickers': True,
94
+ 'fetchTrades': True,
95
+ 'fetchTradingFee': True,
96
+ 'fetchTradingFees': True,
97
+ 'fetchTransactionFees': True,
98
+ 'fetchTransactions': 'emulated',
99
+ 'fetchWithdrawals': True,
100
+ 'reduceMargin': False,
101
+ 'setLeverage': False,
102
+ 'setMarginMode': False,
103
+ 'setPositionMode': False,
104
+ 'transfer': True,
105
+ 'withdraw': True,
106
+ },
107
+ 'urls': {
108
+ 'logo': 'https://user-images.githubusercontent.com/1294454/27786377-8c8ab57e-5fe9-11e7-8ea4-2b05b6bcceec.jpg',
109
+ 'api': {
110
+ 'public': 'https://www.bitstamp.net/api',
111
+ 'private': 'https://www.bitstamp.net/api',
112
+ },
113
+ 'www': 'https://www.bitstamp.net',
114
+ 'doc': 'https://www.bitstamp.net/api',
115
+ },
116
+ 'timeframes': {
117
+ '1m': '60',
118
+ '3m': '180',
119
+ '5m': '300',
120
+ '15m': '900',
121
+ '30m': '1800',
122
+ '1h': '3600',
123
+ '2h': '7200',
124
+ '4h': '14400',
125
+ '6h': '21600',
126
+ '12h': '43200',
127
+ '1d': '86400',
128
+ '1w': '259200',
129
+ },
130
+ 'requiredCredentials': {
131
+ 'apiKey': True,
132
+ 'secret': True,
133
+ },
134
+ 'api': {
135
+ 'public': {
136
+ 'get': {
137
+ 'ohlc/{pair}/': 1,
138
+ 'order_book/{pair}/': 1,
139
+ 'ticker/': 1,
140
+ 'ticker_hour/{pair}/': 1,
141
+ 'ticker/{pair}/': 1,
142
+ 'transactions/{pair}/': 1,
143
+ 'trading-pairs-info/': 1,
144
+ 'currencies/': 1,
145
+ 'eur_usd/': 1,
146
+ 'travel_rule/vasps/': 1,
147
+ },
148
+ },
149
+ 'private': {
150
+ 'get': {
151
+ 'travel_rule/contacts/': 1,
152
+ 'contacts/{contact_uuid}/': 1,
153
+ 'earn/subscriptions/': 1,
154
+ 'earn/transactions/': 1,
155
+ },
156
+ 'post': {
157
+ 'account_balances/': 1,
158
+ 'account_balances/{currency}/': 1,
159
+ 'balance/': 1,
160
+ 'balance/{pair}/': 1,
161
+ 'bch_withdrawal/': 1,
162
+ 'bch_address/': 1,
163
+ 'user_transactions/': 1,
164
+ 'user_transactions/{pair}/': 1,
165
+ 'crypto-transactions/': 1,
166
+ 'open_orders/all/': 1,
167
+ 'open_orders/{pair}/': 1,
168
+ 'order_status/': 1,
169
+ 'cancel_order/': 1,
170
+ 'cancel_all_orders/': 1,
171
+ 'cancel_all_orders/{pair}/': 1,
172
+ 'buy/{pair}/': 1,
173
+ 'buy/market/{pair}/': 1,
174
+ 'buy/instant/{pair}/': 1,
175
+ 'sell/{pair}/': 1,
176
+ 'sell/market/{pair}/': 1,
177
+ 'sell/instant/{pair}/': 1,
178
+ 'transfer-to-main/': 1,
179
+ 'transfer-from-main/': 1,
180
+ 'my_trading_pairs/': 1,
181
+ 'fees/trading/': 1,
182
+ 'fees/trading/{market_symbol}': 1,
183
+ 'fees/withdrawal/': 1,
184
+ 'fees/withdrawal/{currency}/': 1,
185
+ 'withdrawal-requests/': 1,
186
+ 'withdrawal/open/': 1,
187
+ 'withdrawal/status/': 1,
188
+ 'withdrawal/cancel/': 1,
189
+ 'liquidation_address/new/': 1,
190
+ 'liquidation_address/info/': 1,
191
+ 'btc_unconfirmed/': 1,
192
+ 'websockets_token/': 1,
193
+ # individual coins
194
+ 'btc_withdrawal/': 1,
195
+ 'btc_address/': 1,
196
+ 'ripple_withdrawal/': 1,
197
+ 'ripple_address/': 1,
198
+ 'ltc_withdrawal/': 1,
199
+ 'ltc_address/': 1,
200
+ 'eth_withdrawal/': 1,
201
+ 'eth_address/': 1,
202
+ 'xrp_withdrawal/': 1,
203
+ 'xrp_address/': 1,
204
+ 'xlm_withdrawal/': 1,
205
+ 'xlm_address/': 1,
206
+ 'pax_withdrawal/': 1,
207
+ 'pax_address/': 1,
208
+ 'link_withdrawal/': 1,
209
+ 'link_address/': 1,
210
+ 'usdc_withdrawal/': 1,
211
+ 'usdc_address/': 1,
212
+ 'omg_withdrawal/': 1,
213
+ 'omg_address/': 1,
214
+ 'dai_withdrawal/': 1,
215
+ 'dai_address/': 1,
216
+ 'knc_withdrawal/': 1,
217
+ 'knc_address/': 1,
218
+ 'mkr_withdrawal/': 1,
219
+ 'mkr_address/': 1,
220
+ 'zrx_withdrawal/': 1,
221
+ 'zrx_address/': 1,
222
+ 'gusd_withdrawal/': 1,
223
+ 'gusd_address/': 1,
224
+ 'aave_withdrawal/': 1,
225
+ 'aave_address/': 1,
226
+ 'bat_withdrawal/': 1,
227
+ 'bat_address/': 1,
228
+ 'uma_withdrawal/': 1,
229
+ 'uma_address/': 1,
230
+ 'snx_withdrawal/': 1,
231
+ 'snx_address/': 1,
232
+ 'uni_withdrawal/': 1,
233
+ 'uni_address/': 1,
234
+ 'yfi_withdrawal/': 1,
235
+ 'yfi_address/': 1,
236
+ 'audio_withdrawal/': 1,
237
+ 'audio_address/': 1,
238
+ 'crv_withdrawal/': 1,
239
+ 'crv_address/': 1,
240
+ 'algo_withdrawal/': 1,
241
+ 'algo_address/': 1,
242
+ 'comp_withdrawal/': 1,
243
+ 'comp_address/': 1,
244
+ 'grt_withdrawal/': 1,
245
+ 'grt_address/': 1,
246
+ 'usdt_withdrawal/': 1,
247
+ 'usdt_address/': 1,
248
+ 'eurt_withdrawal/': 1,
249
+ 'eurt_address/': 1,
250
+ 'matic_withdrawal/': 1,
251
+ 'matic_address/': 1,
252
+ 'sushi_withdrawal/': 1,
253
+ 'sushi_address/': 1,
254
+ 'chz_withdrawal/': 1,
255
+ 'chz_address/': 1,
256
+ 'enj_withdrawal/': 1,
257
+ 'enj_address/': 1,
258
+ 'alpha_withdrawal/': 1,
259
+ 'alpha_address/': 1,
260
+ 'ftt_withdrawal/': 1,
261
+ 'ftt_address/': 1,
262
+ 'storj_withdrawal/': 1,
263
+ 'storj_address/': 1,
264
+ 'axs_withdrawal/': 1,
265
+ 'axs_address/': 1,
266
+ 'sand_withdrawal/': 1,
267
+ 'sand_address/': 1,
268
+ 'hbar_withdrawal/': 1,
269
+ 'hbar_address/': 1,
270
+ 'rgt_withdrawal/': 1,
271
+ 'rgt_address/': 1,
272
+ 'fet_withdrawal/': 1,
273
+ 'fet_address/': 1,
274
+ 'skl_withdrawal/': 1,
275
+ 'skl_address/': 1,
276
+ 'cel_withdrawal/': 1,
277
+ 'cel_address/': 1,
278
+ 'sxp_withdrawal/': 1,
279
+ 'sxp_address/': 1,
280
+ 'ada_withdrawal/': 1,
281
+ 'ada_address/': 1,
282
+ 'slp_withdrawal/': 1,
283
+ 'slp_address/': 1,
284
+ 'ftm_withdrawal/': 1,
285
+ 'ftm_address/': 1,
286
+ 'perp_withdrawal/': 1,
287
+ 'perp_address/': 1,
288
+ 'dydx_withdrawal/': 1,
289
+ 'dydx_address/': 1,
290
+ 'gala_withdrawal/': 1,
291
+ 'gala_address/': 1,
292
+ 'shib_withdrawal/': 1,
293
+ 'shib_address/': 1,
294
+ 'amp_withdrawal/': 1,
295
+ 'amp_address/': 1,
296
+ 'sgb_withdrawal/': 1,
297
+ 'sgb_address/': 1,
298
+ 'avax_withdrawal/': 1,
299
+ 'avax_address/': 1,
300
+ 'wbtc_withdrawal/': 1,
301
+ 'wbtc_address/': 1,
302
+ 'ctsi_withdrawal/': 1,
303
+ 'ctsi_address/': 1,
304
+ 'cvx_withdrawal/': 1,
305
+ 'cvx_address/': 1,
306
+ 'imx_withdrawal/': 1,
307
+ 'imx_address/': 1,
308
+ 'nexo_withdrawal/': 1,
309
+ 'nexo_address/': 1,
310
+ 'ust_withdrawal/': 1,
311
+ 'ust_address/': 1,
312
+ 'ant_withdrawal/': 1,
313
+ 'ant_address/': 1,
314
+ 'gods_withdrawal/': 1,
315
+ 'gods_address/': 1,
316
+ 'rad_withdrawal/': 1,
317
+ 'rad_address/': 1,
318
+ 'band_withdrawal/': 1,
319
+ 'band_address/': 1,
320
+ 'inj_withdrawal/': 1,
321
+ 'inj_address/': 1,
322
+ 'rly_withdrawal/': 1,
323
+ 'rly_address/': 1,
324
+ 'rndr_withdrawal/': 1,
325
+ 'rndr_address/': 1,
326
+ 'vega_withdrawal/': 1,
327
+ 'vega_address/': 1,
328
+ '1inch_withdrawal/': 1,
329
+ '1inch_address/': 1,
330
+ 'ens_withdrawal/': 1,
331
+ 'ens_address/': 1,
332
+ 'mana_withdrawal/': 1,
333
+ 'mana_address/': 1,
334
+ 'lrc_withdrawal/': 1,
335
+ 'lrc_address/': 1,
336
+ 'ape_withdrawal/': 1,
337
+ 'ape_address/': 1,
338
+ 'mpl_withdrawal/': 1,
339
+ 'mpl_address/': 1,
340
+ 'euroc_withdrawal/': 1,
341
+ 'euroc_address/': 1,
342
+ 'sol_withdrawal/': 1,
343
+ 'sol_address/': 1,
344
+ 'dot_withdrawal/': 1,
345
+ 'dot_address/': 1,
346
+ 'near_withdrawal/': 1,
347
+ 'near_address/': 1,
348
+ 'doge_withdrawal/': 1,
349
+ 'doge_address/': 1,
350
+ 'flr_withdrawal/': 1,
351
+ 'flr_address/': 1,
352
+ 'dgld_withdrawal/': 1,
353
+ 'dgld_address/': 1,
354
+ 'ldo_withdrawal/': 1,
355
+ 'ldo_address/': 1,
356
+ 'travel_rule/contacts/': 1,
357
+ 'earn/subscribe/': 1,
358
+ 'earn/subscriptions/setting/': 1,
359
+ 'earn/unsubscribe': 1,
360
+ 'wecan_withdrawal/': 1,
361
+ 'wecan_address/': 1,
362
+ 'trac_withdrawal/': 1,
363
+ 'trac_address/': 1,
364
+ 'eurcv_withdrawal/': 1,
365
+ 'eurcv_address/': 1,
366
+ 'pyusd_withdrawal/': 1,
367
+ 'pyusd_address/': 1,
368
+ 'lmwr_withdrawal/': 1,
369
+ 'lmwr_address/': 1,
370
+ 'pepe_withdrawal/': 1,
371
+ 'pepe_address/': 1,
372
+ 'blur_withdrawal/': 1,
373
+ 'blur_address/': 1,
374
+ 'vext_withdrawal/': 1,
375
+ 'vext_address/': 1,
376
+ 'cspr_withdrawal/': 1,
377
+ 'cspr_address/': 1,
378
+ 'vchf_withdrawal/': 1,
379
+ 'vchf_address/': 1,
380
+ 'veur_withdrawal/': 1,
381
+ 'veur_address/': 1,
382
+ 'truf_withdrawal/': 1,
383
+ 'truf_address/': 1,
384
+ 'wif_withdrawal/': 1,
385
+ 'wif_address/': 1,
386
+ 'smt_withdrawal/': 1,
387
+ 'smt_address/': 1,
388
+ 'sui_withdrawal/': 1,
389
+ 'sui_address/': 1,
390
+ 'jup_withdrawal/': 1,
391
+ 'jup_address/': 1,
392
+ 'ondo_withdrawal/': 1,
393
+ 'ondo_address/': 1,
394
+ 'boba_withdrawal/': 1,
395
+ 'boba_address/': 1,
396
+ 'pyth_withdrawal/': 1,
397
+ 'pyth_address/': 1,
398
+ },
399
+ },
400
+ },
401
+ 'fees': {
402
+ 'trading': {
403
+ 'tierBased': True,
404
+ 'percentage': True,
405
+ 'taker': self.parse_number('0.005'),
406
+ 'maker': self.parse_number('0.005'),
407
+ 'tiers': {
408
+ 'taker': [
409
+ [self.parse_number('0'), self.parse_number('0.005')],
410
+ [self.parse_number('20000'), self.parse_number('0.0025')],
411
+ [self.parse_number('100000'), self.parse_number('0.0024')],
412
+ [self.parse_number('200000'), self.parse_number('0.0022')],
413
+ [self.parse_number('400000'), self.parse_number('0.0020')],
414
+ [self.parse_number('600000'), self.parse_number('0.0015')],
415
+ [self.parse_number('1000000'), self.parse_number('0.0014')],
416
+ [self.parse_number('2000000'), self.parse_number('0.0013')],
417
+ [self.parse_number('4000000'), self.parse_number('0.0012')],
418
+ [self.parse_number('20000000'), self.parse_number('0.0011')],
419
+ [self.parse_number('50000000'), self.parse_number('0.0010')],
420
+ [self.parse_number('100000000'), self.parse_number('0.0007')],
421
+ [self.parse_number('500000000'), self.parse_number('0.0005')],
422
+ [self.parse_number('2000000000'), self.parse_number('0.0003')],
423
+ [self.parse_number('6000000000'), self.parse_number('0.0001')],
424
+ [self.parse_number('20000000000'), self.parse_number('0.00005')],
425
+ [self.parse_number('20000000001'), self.parse_number('0')],
426
+ ],
427
+ 'maker': [
428
+ [self.parse_number('0'), self.parse_number('0.005')],
429
+ [self.parse_number('20000'), self.parse_number('0.0025')],
430
+ [self.parse_number('100000'), self.parse_number('0.0024')],
431
+ [self.parse_number('200000'), self.parse_number('0.0022')],
432
+ [self.parse_number('400000'), self.parse_number('0.0020')],
433
+ [self.parse_number('600000'), self.parse_number('0.0015')],
434
+ [self.parse_number('1000000'), self.parse_number('0.0014')],
435
+ [self.parse_number('2000000'), self.parse_number('0.0013')],
436
+ [self.parse_number('4000000'), self.parse_number('0.0012')],
437
+ [self.parse_number('20000000'), self.parse_number('0.0011')],
438
+ [self.parse_number('50000000'), self.parse_number('0.0010')],
439
+ [self.parse_number('100000000'), self.parse_number('0.0007')],
440
+ [self.parse_number('500000000'), self.parse_number('0.0005')],
441
+ [self.parse_number('2000000000'), self.parse_number('0.0003')],
442
+ [self.parse_number('6000000000'), self.parse_number('0.0001')],
443
+ [self.parse_number('20000000000'), self.parse_number('0.00005')],
444
+ [self.parse_number('20000000001'), self.parse_number('0')],
445
+ ],
446
+ },
447
+ },
448
+ 'funding': {
449
+ 'tierBased': False,
450
+ 'percentage': False,
451
+ 'withdraw': {},
452
+ 'deposit': {
453
+ 'BTC': 0,
454
+ 'BCH': 0,
455
+ 'LTC': 0,
456
+ 'ETH': 0,
457
+ 'XRP': 0,
458
+ 'XLM': 0,
459
+ 'PAX': 0,
460
+ 'USD': 7.5,
461
+ 'EUR': 0,
462
+ },
463
+ },
464
+ },
465
+ 'precisionMode': TICK_SIZE,
466
+ 'commonCurrencies': {
467
+ 'UST': 'USTC',
468
+ },
469
+ # exchange-specific options
470
+ 'options': {
471
+ 'networksById': {
472
+ 'bitcoin-cash': 'BCH',
473
+ 'bitcoin': 'BTC',
474
+ 'ethereum': 'ERC20',
475
+ 'litecoin': 'LTC',
476
+ 'stellar': 'XLM',
477
+ 'xrpl': 'XRP',
478
+ 'tron': 'TRC20',
479
+ 'algorand': 'ALGO',
480
+ 'flare': 'FLR',
481
+ 'hedera': 'HBAR',
482
+ 'cardana': 'ADA',
483
+ 'songbird': 'FLR',
484
+ 'avalanche-c-chain': 'AVAX',
485
+ 'solana': 'SOL',
486
+ 'polkadot': 'DOT',
487
+ 'near': 'NEAR',
488
+ 'doge': 'DOGE',
489
+ 'sui': 'SUI',
490
+ 'casper': 'CSRP',
491
+ },
492
+ },
493
+ 'exceptions': {
494
+ 'exact': {
495
+ 'No permission found': PermissionDenied,
496
+ 'API key not found': AuthenticationError,
497
+ 'IP address not allowed': PermissionDenied,
498
+ 'Invalid nonce': InvalidNonce,
499
+ 'Invalid signature': AuthenticationError,
500
+ 'Authentication failed': AuthenticationError,
501
+ 'Missing key, signature and nonce parameters': AuthenticationError,
502
+ 'Wrong API key format': AuthenticationError,
503
+ 'Your account is frozen': PermissionDenied,
504
+ 'Please update your profile with your FATCA information, before using API.': PermissionDenied,
505
+ 'Order not found.': OrderNotFound,
506
+ 'Price is more than 20% below market price.': InvalidOrder,
507
+ "Bitstamp.net is under scheduled maintenance. We'll be back soon.": OnMaintenance, # {"error": "Bitstamp.net is under scheduled maintenance. We'll be back soon."}
508
+ 'Order could not be placed.': ExchangeNotAvailable, # Order could not be placed(perhaps due to internal error or trade halt). Please retry placing order.
509
+ 'Invalid offset.': BadRequest,
510
+ },
511
+ 'broad': {
512
+ 'Minimum order size is': InvalidOrder, # Minimum order size is 5.0 EUR.
513
+ 'Check your account balance for details.': InsufficientFunds, # You have only 0.00100000 BTC available. Check your account balance for details.
514
+ 'Ensure self value has at least': InvalidAddress, # Ensure self value has at least 25 characters(it has 4).
515
+ 'Ensure that there are no more than': InvalidOrder, # {"status": "error", "reason": {"amount": ["Ensure that there are no more than 0 decimal places."], "__all__": [""]}}
516
+ },
517
+ },
518
+ })
519
+
520
+ def fetch_markets(self, params={}) -> List[Market]:
521
+ """
522
+ retrieves data on all markets for bitstamp
523
+ :see: https://www.bitstamp.net/api/#tag/Market-info/operation/GetTradingPairsInfo
524
+ :param dict [params]: extra parameters specific to the exchange API endpoint
525
+ :returns dict[]: an array of objects representing market data
526
+ """
527
+ response = self.fetch_markets_from_cache(params)
528
+ #
529
+ # [
530
+ # {
531
+ # "trading": "Enabled",
532
+ # "base_decimals": 8,
533
+ # "url_symbol": "btcusd",
534
+ # "name": "BTC/USD",
535
+ # "instant_and_market_orders": "Enabled",
536
+ # "minimum_order": "20.0 USD",
537
+ # "counter_decimals": 2,
538
+ # "description": "Bitcoin / U.S. dollar"
539
+ # }
540
+ # ]
541
+ #
542
+ result = []
543
+ for i in range(0, len(response)):
544
+ market = response[i]
545
+ name = self.safe_string(market, 'name')
546
+ base, quote = name.split('/')
547
+ baseId = base.lower()
548
+ quoteId = quote.lower()
549
+ base = self.safe_currency_code(base)
550
+ quote = self.safe_currency_code(quote)
551
+ minimumOrder = self.safe_string(market, 'minimum_order')
552
+ parts = minimumOrder.split(' ')
553
+ status = self.safe_string(market, 'trading')
554
+ result.append({
555
+ 'id': self.safe_string(market, 'url_symbol'),
556
+ 'marketId': baseId + '_' + quoteId,
557
+ 'symbol': base + '/' + quote,
558
+ 'base': base,
559
+ 'quote': quote,
560
+ 'settle': None,
561
+ 'baseId': baseId,
562
+ 'quoteId': quoteId,
563
+ 'settleId': None,
564
+ 'type': 'spot',
565
+ 'spot': True,
566
+ 'margin': False,
567
+ 'future': False,
568
+ 'swap': False,
569
+ 'option': False,
570
+ 'active': (status == 'Enabled'),
571
+ 'contract': False,
572
+ 'linear': None,
573
+ 'inverse': None,
574
+ 'contractSize': None,
575
+ 'expiry': None,
576
+ 'expiryDatetime': None,
577
+ 'strike': None,
578
+ 'optionType': None,
579
+ 'precision': {
580
+ 'amount': self.parse_number(self.parse_precision(self.safe_string(market, 'base_decimals'))),
581
+ 'price': self.parse_number(self.parse_precision(self.safe_string(market, 'counter_decimals'))),
582
+ },
583
+ 'limits': {
584
+ 'leverage': {
585
+ 'min': None,
586
+ 'max': None,
587
+ },
588
+ 'amount': {
589
+ 'min': None,
590
+ 'max': None,
591
+ },
592
+ 'price': {
593
+ 'min': None,
594
+ 'max': None,
595
+ },
596
+ 'cost': {
597
+ 'min': self.safe_number(parts, 0),
598
+ 'max': None,
599
+ },
600
+ },
601
+ 'created': None,
602
+ 'info': market,
603
+ })
604
+ return result
605
+
606
+ def construct_currency_object(self, id, code, name, precision, minCost, originalPayload):
607
+ currencyType = 'crypto'
608
+ description = self.describe()
609
+ if self.is_fiat(code):
610
+ currencyType = 'fiat'
611
+ tickSize = self.parse_number(self.parse_precision(self.number_to_string(precision)))
612
+ return {
613
+ 'id': id,
614
+ 'code': code,
615
+ 'info': originalPayload, # the original payload
616
+ 'type': currencyType,
617
+ 'name': name,
618
+ 'active': True,
619
+ 'deposit': None,
620
+ 'withdraw': None,
621
+ 'fee': self.safe_number(description['fees']['funding']['withdraw'], code),
622
+ 'precision': tickSize,
623
+ 'limits': {
624
+ 'amount': {
625
+ 'min': tickSize,
626
+ 'max': None,
627
+ },
628
+ 'price': {
629
+ 'min': tickSize,
630
+ 'max': None,
631
+ },
632
+ 'cost': {
633
+ 'min': minCost,
634
+ 'max': None,
635
+ },
636
+ 'withdraw': {
637
+ 'min': None,
638
+ 'max': None,
639
+ },
640
+ },
641
+ 'networks': {},
642
+ }
643
+
644
+ def fetch_markets_from_cache(self, params={}):
645
+ # self method is now redundant
646
+ # currencies are now fetched before markets
647
+ options = self.safe_value(self.options, 'fetchMarkets', {})
648
+ timestamp = self.safe_integer(options, 'timestamp')
649
+ expires = self.safe_integer(options, 'expires', 1000)
650
+ now = self.milliseconds()
651
+ if (timestamp is None) or ((now - timestamp) > expires):
652
+ response = self.publicGetTradingPairsInfo(params)
653
+ self.options['fetchMarkets'] = self.extend(options, {
654
+ 'response': response,
655
+ 'timestamp': now,
656
+ })
657
+ return self.safe_value(self.options['fetchMarkets'], 'response')
658
+
659
+ def fetch_currencies(self, params={}) -> Currencies:
660
+ """
661
+ fetches all available currencies on an exchange
662
+ :see: https://www.bitstamp.net/api/#tag/Market-info/operation/GetTradingPairsInfo
663
+ :param dict [params]: extra parameters specific to the exchange API endpoint
664
+ :returns dict: an associative dictionary of currencies
665
+ """
666
+ response = self.fetch_markets_from_cache(params)
667
+ #
668
+ # [
669
+ # {
670
+ # "trading": "Enabled",
671
+ # "base_decimals": 8,
672
+ # "url_symbol": "btcusd",
673
+ # "name": "BTC/USD",
674
+ # "instant_and_market_orders": "Enabled",
675
+ # "minimum_order": "20.0 USD",
676
+ # "counter_decimals": 2,
677
+ # "description": "Bitcoin / U.S. dollar"
678
+ # },
679
+ # ]
680
+ #
681
+ result: dict = {}
682
+ for i in range(0, len(response)):
683
+ market = response[i]
684
+ name = self.safe_string(market, 'name')
685
+ base, quote = name.split('/')
686
+ baseId = base.lower()
687
+ quoteId = quote.lower()
688
+ base = self.safe_currency_code(base)
689
+ quote = self.safe_currency_code(quote)
690
+ description = self.safe_string(market, 'description')
691
+ baseDescription, quoteDescription = description.split(' / ')
692
+ minimumOrder = self.safe_string(market, 'minimum_order')
693
+ parts = minimumOrder.split(' ')
694
+ cost = parts[0]
695
+ if not (base in result):
696
+ baseDecimals = self.safe_integer(market, 'base_decimals')
697
+ result[base] = self.construct_currency_object(baseId, base, baseDescription, baseDecimals, None, market)
698
+ if not (quote in result):
699
+ counterDecimals = self.safe_integer(market, 'counter_decimals')
700
+ result[quote] = self.construct_currency_object(quoteId, quote, quoteDescription, counterDecimals, self.parse_number(cost), market)
701
+ return result
702
+
703
+ def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
704
+ """
705
+ fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
706
+ :see: https://www.bitstamp.net/api/#tag/Order-book/operation/GetOrderBook
707
+ :param str symbol: unified symbol of the market to fetch the order book for
708
+ :param int [limit]: the maximum amount of order book entries to return
709
+ :param dict [params]: extra parameters specific to the exchange API endpoint
710
+ :returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
711
+ """
712
+ self.load_markets()
713
+ market = self.market(symbol)
714
+ request: dict = {
715
+ 'pair': market['id'],
716
+ }
717
+ response = self.publicGetOrderBookPair(self.extend(request, params))
718
+ #
719
+ # {
720
+ # "timestamp": "1583652948",
721
+ # "microtimestamp": "1583652948955826",
722
+ # "bids": [
723
+ # ["8750.00", "1.33685271"],
724
+ # ["8749.39", "0.07700000"],
725
+ # ["8746.98", "0.07400000"],
726
+ # ]
727
+ # "asks": [
728
+ # ["8754.10", "1.51995636"],
729
+ # ["8754.71", "1.40000000"],
730
+ # ["8754.72", "2.50000000"],
731
+ # ]
732
+ # }
733
+ #
734
+ microtimestamp = self.safe_integer(response, 'microtimestamp')
735
+ timestamp = self.parse_to_int(microtimestamp / 1000)
736
+ orderbook = self.parse_order_book(response, market['symbol'], timestamp)
737
+ orderbook['nonce'] = microtimestamp
738
+ return orderbook
739
+
740
+ def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
741
+ #
742
+ # {
743
+ # "timestamp": "1686068944",
744
+ # "high": "26252",
745
+ # "last": "26216",
746
+ # "bid": "26208",
747
+ # "vwap": "25681",
748
+ # "volume": "3563.13819902",
749
+ # "low": "25350",
750
+ # "ask": "26211",
751
+ # "open": "25730",
752
+ # "open_24": "25895",
753
+ # "percent_change_24": "1.24",
754
+ # "pair": "BTC/USD"
755
+ # }
756
+ #
757
+ marketId = self.safe_string(ticker, 'pair')
758
+ symbol = self.safe_symbol(marketId, market, None)
759
+ timestamp = self.safe_timestamp(ticker, 'timestamp')
760
+ vwap = self.safe_string(ticker, 'vwap')
761
+ baseVolume = self.safe_string(ticker, 'volume')
762
+ quoteVolume = Precise.string_mul(baseVolume, vwap)
763
+ last = self.safe_string(ticker, 'last')
764
+ return self.safe_ticker({
765
+ 'symbol': symbol,
766
+ 'timestamp': timestamp,
767
+ 'datetime': self.iso8601(timestamp),
768
+ 'high': self.safe_string(ticker, 'high'),
769
+ 'low': self.safe_string(ticker, 'low'),
770
+ 'bid': self.safe_string(ticker, 'bid'),
771
+ 'bidVolume': None,
772
+ 'ask': self.safe_string(ticker, 'ask'),
773
+ 'askVolume': None,
774
+ 'vwap': vwap,
775
+ 'open': self.safe_string(ticker, 'open'),
776
+ 'close': last,
777
+ 'last': last,
778
+ 'previousClose': None,
779
+ 'change': None,
780
+ 'percentage': None,
781
+ 'average': None,
782
+ 'baseVolume': baseVolume,
783
+ 'quoteVolume': quoteVolume,
784
+ 'info': ticker,
785
+ }, market)
786
+
787
+ def fetch_ticker(self, symbol: str, params={}) -> Ticker:
788
+ """
789
+ fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
790
+ :see: https://www.bitstamp.net/api/#tag/Tickers/operation/GetMarketTicker
791
+ :param str symbol: unified symbol of the market to fetch the ticker for
792
+ :param dict [params]: extra parameters specific to the exchange API endpoint
793
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
794
+ """
795
+ self.load_markets()
796
+ market = self.market(symbol)
797
+ request: dict = {
798
+ 'pair': market['id'],
799
+ }
800
+ ticker = self.publicGetTickerPair(self.extend(request, params))
801
+ #
802
+ # {
803
+ # "timestamp": "1686068944",
804
+ # "high": "26252",
805
+ # "last": "26216",
806
+ # "bid": "26208",
807
+ # "vwap": "25681",
808
+ # "volume": "3563.13819902",
809
+ # "low": "25350",
810
+ # "ask": "26211",
811
+ # "open": "25730",
812
+ # "open_24": "25895",
813
+ # "percent_change_24": "1.24"
814
+ # }
815
+ #
816
+ return self.parse_ticker(ticker, market)
817
+
818
+ def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
819
+ """
820
+ fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
821
+ :see: https://www.bitstamp.net/api/#tag/Tickers/operation/GetCurrencyPairTickers
822
+ :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
823
+ :param dict [params]: extra parameters specific to the exchange API endpoint
824
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
825
+ """
826
+ self.load_markets()
827
+ response = self.publicGetTicker(params)
828
+ #
829
+ # {
830
+ # "timestamp": "1686068944",
831
+ # "high": "26252",
832
+ # "last": "26216",
833
+ # "bid": "26208",
834
+ # "vwap": "25681",
835
+ # "volume": "3563.13819902",
836
+ # "low": "25350",
837
+ # "ask": "26211",
838
+ # "open": "25730",
839
+ # "open_24": "25895",
840
+ # "percent_change_24": "1.24",
841
+ # "pair": "BTC/USD"
842
+ # }
843
+ #
844
+ return self.parse_tickers(response, symbols)
845
+
846
+ def get_currency_id_from_transaction(self, transaction):
847
+ #
848
+ # {
849
+ # "fee": "0.00000000",
850
+ # "btc_usd": "0.00",
851
+ # "datetime": XXX,
852
+ # "usd": 0.0,
853
+ # "btc": 0.0,
854
+ # "eth": "0.05000000",
855
+ # "type": "0",
856
+ # "id": XXX,
857
+ # "eur": 0.0
858
+ # }
859
+ #
860
+ currencyId = self.safe_string_lower(transaction, 'currency')
861
+ if currencyId is not None:
862
+ return currencyId
863
+ transaction = self.omit(transaction, [
864
+ 'fee',
865
+ 'price',
866
+ 'datetime',
867
+ 'type',
868
+ 'status',
869
+ 'id',
870
+ ])
871
+ ids = list(transaction.keys())
872
+ for i in range(0, len(ids)):
873
+ id = ids[i]
874
+ if id.find('_') < 0:
875
+ value = self.safe_integer(transaction, id)
876
+ if (value is not None) and (value != 0):
877
+ return id
878
+ return None
879
+
880
+ def get_market_from_trade(self, trade):
881
+ trade = self.omit(trade, [
882
+ 'fee',
883
+ 'price',
884
+ 'datetime',
885
+ 'tid',
886
+ 'type',
887
+ 'order_id',
888
+ 'side',
889
+ ])
890
+ currencyIds = list(trade.keys())
891
+ numCurrencyIds = len(currencyIds)
892
+ if numCurrencyIds > 2:
893
+ raise ExchangeError(self.id + ' getMarketFromTrade() too many keys: ' + self.json(currencyIds) + ' in the trade: ' + self.json(trade))
894
+ if numCurrencyIds == 2:
895
+ marketId = currencyIds[0] + currencyIds[1]
896
+ if marketId in self.markets_by_id:
897
+ return self.safe_market(marketId)
898
+ marketId = currencyIds[1] + currencyIds[0]
899
+ if marketId in self.markets_by_id:
900
+ return self.safe_market(marketId)
901
+ return None
902
+
903
+ def parse_trade(self, trade: dict, market: Market = None) -> Trade:
904
+ #
905
+ # fetchTrades(public)
906
+ #
907
+ # {
908
+ # "date": "1637845199",
909
+ # "tid": "209895701",
910
+ # "amount": "0.00500000",
911
+ # "type": "0", # Transaction type: 0 - buy; 1 - sell
912
+ # "price": "4451.25"
913
+ # }
914
+ #
915
+ # fetchMyTrades, trades returned within fetchOrder(private)
916
+ #
917
+ # {
918
+ # "fee": "0.11128",
919
+ # "eth_usdt": 4451.25,
920
+ # "datetime": "2021-11-25 12:59:59.322000",
921
+ # "usdt": "-22.26",
922
+ # "order_id": 1429545880227846,
923
+ # "usd": 0,
924
+ # "btc": 0,
925
+ # "eth": "0.00500000",
926
+ # "type": "2", # Transaction type: 0 - deposit; 1 - withdrawal; 2 - market trade; 14 - sub account transfer; 25 - credited with staked assets; 26 - sent assets to staking; 27 - staking reward; 32 - referral reward; 35 - inter account transfer.
927
+ # "id": 209895701,
928
+ # "eur": 0
929
+ # }
930
+ #
931
+ # from fetchOrder(private)
932
+ #
933
+ # {
934
+ # "fee": "0.11128",
935
+ # "price": "4451.25000000",
936
+ # "datetime": "2021-11-25 12:59:59.322000",
937
+ # "usdt": "22.25625000",
938
+ # "tid": 209895701,
939
+ # "eth": "0.00500000",
940
+ # "type": 2 # Transaction type: 0 - deposit; 1 - withdrawal; 2 - market trade
941
+ # }
942
+ #
943
+ id = self.safe_string_2(trade, 'id', 'tid')
944
+ symbol = None
945
+ side = None
946
+ priceString = self.safe_string(trade, 'price')
947
+ amountString = self.safe_string(trade, 'amount')
948
+ orderId = self.safe_string(trade, 'order_id')
949
+ type = None
950
+ costString = self.safe_string(trade, 'cost')
951
+ rawMarketId = None
952
+ if market is None:
953
+ keys = list(trade.keys())
954
+ for i in range(0, len(keys)):
955
+ currentKey = keys[i]
956
+ if currentKey != 'order_id' and currentKey.find('_') >= 0:
957
+ rawMarketId = currentKey
958
+ market = self.safe_market(rawMarketId, market, '_')
959
+ # if the market is still not defined
960
+ # try to deduce it from used keys
961
+ if market is None:
962
+ market = self.get_market_from_trade(trade)
963
+ feeCostString = self.safe_string(trade, 'fee')
964
+ feeCurrency = market['quote']
965
+ priceId = rawMarketId if (rawMarketId is not None) else market['marketId']
966
+ priceString = self.safe_string(trade, priceId, priceString)
967
+ amountString = self.safe_string(trade, market['baseId'], amountString)
968
+ costString = self.safe_string(trade, market['quoteId'], costString)
969
+ symbol = market['symbol']
970
+ datetimeString = self.safe_string_2(trade, 'date', 'datetime')
971
+ timestamp = None
972
+ if datetimeString is not None:
973
+ if datetimeString.find(' ') >= 0:
974
+ # iso8601
975
+ timestamp = self.parse8601(datetimeString)
976
+ else:
977
+ # string unix epoch in seconds
978
+ timestamp = int(datetimeString)
979
+ timestamp = timestamp * 1000
980
+ # if it is a private trade
981
+ if 'id' in trade:
982
+ if amountString is not None:
983
+ isAmountNeg = Precise.string_lt(amountString, '0')
984
+ if isAmountNeg:
985
+ side = 'sell'
986
+ amountString = Precise.string_neg(amountString)
987
+ else:
988
+ side = 'buy'
989
+ else:
990
+ side = self.safe_string(trade, 'type')
991
+ if side == '1':
992
+ side = 'sell'
993
+ elif side == '0':
994
+ side = 'buy'
995
+ else:
996
+ side = None
997
+ if costString is not None:
998
+ costString = Precise.string_abs(costString)
999
+ fee = None
1000
+ if feeCostString is not None:
1001
+ fee = {
1002
+ 'cost': feeCostString,
1003
+ 'currency': feeCurrency,
1004
+ }
1005
+ return self.safe_trade({
1006
+ 'id': id,
1007
+ 'info': trade,
1008
+ 'timestamp': timestamp,
1009
+ 'datetime': self.iso8601(timestamp),
1010
+ 'symbol': symbol,
1011
+ 'order': orderId,
1012
+ 'type': type,
1013
+ 'side': side,
1014
+ 'takerOrMaker': None,
1015
+ 'price': priceString,
1016
+ 'amount': amountString,
1017
+ 'cost': costString,
1018
+ 'fee': fee,
1019
+ }, market)
1020
+
1021
+ def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
1022
+ """
1023
+ get the list of most recent trades for a particular symbol
1024
+ :see: https://www.bitstamp.net/api/#tag/Transactions-public/operation/GetTransactions
1025
+ :param str symbol: unified symbol of the market to fetch trades for
1026
+ :param int [since]: timestamp in ms of the earliest trade to fetch
1027
+ :param int [limit]: the maximum amount of trades to fetch
1028
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1029
+ :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
1030
+ """
1031
+ self.load_markets()
1032
+ market = self.market(symbol)
1033
+ request: dict = {
1034
+ 'pair': market['id'],
1035
+ 'time': 'hour',
1036
+ }
1037
+ response = self.publicGetTransactionsPair(self.extend(request, params))
1038
+ #
1039
+ # [
1040
+ # {
1041
+ # "date": "1551814435",
1042
+ # "tid": "83581898",
1043
+ # "price": "0.03532850",
1044
+ # "type": "1",
1045
+ # "amount": "0.85945907"
1046
+ # },
1047
+ # {
1048
+ # "date": "1551814434",
1049
+ # "tid": "83581896",
1050
+ # "price": "0.03532851",
1051
+ # "type": "1",
1052
+ # "amount": "11.34130961"
1053
+ # },
1054
+ # ]
1055
+ #
1056
+ return self.parse_trades(response, market, since, limit)
1057
+
1058
+ def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
1059
+ #
1060
+ # {
1061
+ # "high": "9064.77",
1062
+ # "timestamp": "1593961440",
1063
+ # "volume": "18.49436608",
1064
+ # "low": "9040.87",
1065
+ # "close": "9064.77",
1066
+ # "open": "9040.87"
1067
+ # }
1068
+ #
1069
+ return [
1070
+ self.safe_timestamp(ohlcv, 'timestamp'),
1071
+ self.safe_number(ohlcv, 'open'),
1072
+ self.safe_number(ohlcv, 'high'),
1073
+ self.safe_number(ohlcv, 'low'),
1074
+ self.safe_number(ohlcv, 'close'),
1075
+ self.safe_number(ohlcv, 'volume'),
1076
+ ]
1077
+
1078
+ def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
1079
+ """
1080
+ fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1081
+ :see: https://www.bitstamp.net/api/#tag/Market-info/operation/GetOHLCData
1082
+ :param str symbol: unified symbol of the market to fetch OHLCV data for
1083
+ :param str timeframe: the length of time each candle represents
1084
+ :param int [since]: timestamp in ms of the earliest candle to fetch
1085
+ :param int [limit]: the maximum amount of candles to fetch
1086
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1087
+ :returns int[][]: A list of candles ordered, open, high, low, close, volume
1088
+ """
1089
+ self.load_markets()
1090
+ market = self.market(symbol)
1091
+ request: dict = {
1092
+ 'pair': market['id'],
1093
+ 'step': self.safe_string(self.timeframes, timeframe, timeframe),
1094
+ }
1095
+ duration = self.parse_timeframe(timeframe)
1096
+ if limit is None:
1097
+ if since is None:
1098
+ request['limit'] = 1000 # we need to specify an allowed amount of `limit` if no `since` is set and there is no default limit by exchange
1099
+ else:
1100
+ limit = 1000
1101
+ start = self.parse_to_int(since / 1000)
1102
+ request['start'] = start
1103
+ request['end'] = self.sum(start, duration * (limit - 1))
1104
+ request['limit'] = limit
1105
+ else:
1106
+ if since is not None:
1107
+ start = self.parse_to_int(since / 1000)
1108
+ request['start'] = start
1109
+ request['end'] = self.sum(start, duration * (limit - 1))
1110
+ request['limit'] = min(limit, 1000) # min 1, max 1000
1111
+ response = self.publicGetOhlcPair(self.extend(request, params))
1112
+ #
1113
+ # {
1114
+ # "data": {
1115
+ # "pair": "BTC/USD",
1116
+ # "ohlc": [
1117
+ # {"high": "9064.77", "timestamp": "1593961440", "volume": "18.49436608", "low": "9040.87", "close": "9064.77", "open": "9040.87"},
1118
+ # {"high": "9071.59", "timestamp": "1593961500", "volume": "3.48631711", "low": "9058.76", "close": "9061.07", "open": "9064.66"},
1119
+ # {"high": "9067.33", "timestamp": "1593961560", "volume": "0.04142833", "low": "9061.94", "close": "9061.94", "open": "9067.33"},
1120
+ # ],
1121
+ # }
1122
+ # }
1123
+ #
1124
+ data = self.safe_value(response, 'data', {})
1125
+ ohlc = self.safe_list(data, 'ohlc', [])
1126
+ return self.parse_ohlcvs(ohlc, market, timeframe, since, limit)
1127
+
1128
+ def parse_balance(self, response) -> Balances:
1129
+ result: dict = {
1130
+ 'info': response,
1131
+ 'timestamp': None,
1132
+ 'datetime': None,
1133
+ }
1134
+ if response is None:
1135
+ response = []
1136
+ for i in range(0, len(response)):
1137
+ currencyBalance = response[i]
1138
+ currencyId = self.safe_string(currencyBalance, 'currency')
1139
+ currencyCode = self.safe_currency_code(currencyId)
1140
+ account = self.account()
1141
+ account['free'] = self.safe_string(currencyBalance, 'available')
1142
+ account['used'] = self.safe_string(currencyBalance, 'reserved')
1143
+ account['total'] = self.safe_string(currencyBalance, 'total')
1144
+ result[currencyCode] = account
1145
+ return self.safe_balance(result)
1146
+
1147
+ def fetch_balance(self, params={}) -> Balances:
1148
+ """
1149
+ query for balance and get the amount of funds available for trading or funds locked in orders
1150
+ :see: https://www.bitstamp.net/api/#tag/Account-balances/operation/GetAccountBalances
1151
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1152
+ :returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
1153
+ """
1154
+ self.load_markets()
1155
+ response = self.privatePostAccountBalances(params)
1156
+ #
1157
+ # [
1158
+ # {
1159
+ # "currency": "usdt",
1160
+ # "total": "7.00000",
1161
+ # "available": "7.00000",
1162
+ # "reserved": "0.00000"
1163
+ # },
1164
+ # ...
1165
+ # ]
1166
+ #
1167
+ return self.parse_balance(response)
1168
+
1169
+ def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
1170
+ """
1171
+ fetch the trading fees for a market
1172
+ :see: https://www.bitstamp.net/api/#tag/Fees/operation/GetTradingFeesForCurrency
1173
+ :param str symbol: unified market symbol
1174
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1175
+ :returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
1176
+ """
1177
+ self.load_markets()
1178
+ market = self.market(symbol)
1179
+ request: dict = {
1180
+ 'market_symbol': market['id'],
1181
+ }
1182
+ response = self.privatePostFeesTrading(self.extend(request, params))
1183
+ #
1184
+ # [
1185
+ # {
1186
+ # "currency_pair": "btcusd",
1187
+ # "fees":
1188
+ # {
1189
+ # "maker": "0.15000",
1190
+ # "taker": "0.16000"
1191
+ # },
1192
+ # "market": "btcusd"
1193
+ # }
1194
+ # ...
1195
+ # ]
1196
+ #
1197
+ tradingFeesByMarketId = self.index_by(response, 'currency_pair')
1198
+ tradingFee = self.safe_dict(tradingFeesByMarketId, market['id'])
1199
+ return self.parse_trading_fee(tradingFee, market)
1200
+
1201
+ def parse_trading_fee(self, fee: dict, market: Market = None) -> TradingFeeInterface:
1202
+ marketId = self.safe_string(fee, 'market')
1203
+ fees = self.safe_dict(fee, 'fees', {})
1204
+ return {
1205
+ 'info': fee,
1206
+ 'symbol': self.safe_symbol(marketId, market),
1207
+ 'maker': self.safe_number(fees, 'maker'),
1208
+ 'taker': self.safe_number(fees, 'taker'),
1209
+ 'percentage': None,
1210
+ 'tierBased': None,
1211
+ }
1212
+
1213
+ def parse_trading_fees(self, fees):
1214
+ result: dict = {'info': fees}
1215
+ symbols = self.symbols
1216
+ for i in range(0, len(symbols)):
1217
+ symbol = symbols[i]
1218
+ fee = self.parse_trading_fee(fees[i])
1219
+ result[symbol] = fee
1220
+ return result
1221
+
1222
+ def fetch_trading_fees(self, params={}) -> TradingFees:
1223
+ """
1224
+ fetch the trading fees for multiple markets
1225
+ :see: https://www.bitstamp.net/api/#tag/Fees/operation/GetAllTradingFees
1226
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1227
+ :returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
1228
+ """
1229
+ self.load_markets()
1230
+ response = self.privatePostFeesTrading(params)
1231
+ #
1232
+ # [
1233
+ # {
1234
+ # "currency_pair": "btcusd",
1235
+ # "fees":
1236
+ # {
1237
+ # "maker": "0.15000",
1238
+ # "taker": "0.16000"
1239
+ # },
1240
+ # "market": "btcusd"
1241
+ # }
1242
+ # ...
1243
+ # ]
1244
+ #
1245
+ return self.parse_trading_fees(response)
1246
+
1247
+ def fetch_transaction_fees(self, codes: Strings = None, params={}):
1248
+ """
1249
+ * @deprecated
1250
+ please use fetchDepositWithdrawFees instead
1251
+ :see: https://www.bitstamp.net/api/#tag/Fees
1252
+ :param str[]|None codes: list of unified currency codes
1253
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1254
+ :returns dict[]: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
1255
+ """
1256
+ self.load_markets()
1257
+ response = self.privatePostFeesWithdrawal(params)
1258
+ #
1259
+ # [
1260
+ # {
1261
+ # "currency": "btc",
1262
+ # "fee": "0.00015000",
1263
+ # "network": "bitcoin"
1264
+ # }
1265
+ # ...
1266
+ # ]
1267
+ #
1268
+ return self.parse_transaction_fees(response)
1269
+
1270
+ def parse_transaction_fees(self, response, codes=None):
1271
+ result: dict = {}
1272
+ currencies = self.index_by(response, 'currency')
1273
+ ids = list(currencies.keys())
1274
+ for i in range(0, len(ids)):
1275
+ id = ids[i]
1276
+ fees = self.safe_value(response, i, {})
1277
+ code = self.safe_currency_code(id)
1278
+ if (codes is not None) and not self.in_array(code, codes):
1279
+ continue
1280
+ result[code] = {
1281
+ 'withdraw_fee': self.safe_number(fees, 'fee'),
1282
+ 'deposit': {},
1283
+ 'info': self.safe_dict(currencies, id),
1284
+ }
1285
+ return result
1286
+
1287
+ def fetch_deposit_withdraw_fees(self, codes=None, params={}):
1288
+ """
1289
+ fetch deposit and withdraw fees
1290
+ :see: https://www.bitstamp.net/api/#tag/Fees/operation/GetAllWithdrawalFees
1291
+ :param str[]|None codes: list of unified currency codes
1292
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1293
+ :returns dict[]: a list of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>`
1294
+ """
1295
+ self.load_markets()
1296
+ response = self.privatePostFeesWithdrawal(params)
1297
+ #
1298
+ # [
1299
+ # {
1300
+ # "currency": "btc",
1301
+ # "fee": "0.00015000",
1302
+ # "network": "bitcoin"
1303
+ # }
1304
+ # ...
1305
+ # ]
1306
+ #
1307
+ responseByCurrencyId = self.group_by(response, 'currency')
1308
+ return self.parse_deposit_withdraw_fees(responseByCurrencyId, codes)
1309
+
1310
+ def parse_deposit_withdraw_fee(self, fee, currency=None):
1311
+ result = self.deposit_withdraw_fee(fee)
1312
+ for j in range(0, len(fee)):
1313
+ networkEntry = fee[j]
1314
+ networkId = self.safe_string(networkEntry, 'network')
1315
+ networkCode = self.network_id_to_code(networkId)
1316
+ withdrawFee = self.safe_number(networkEntry, 'fee')
1317
+ result['withdraw'] = {
1318
+ 'fee': withdrawFee,
1319
+ 'percentage': None,
1320
+ }
1321
+ result['networks'][networkCode] = {
1322
+ 'withdraw': {
1323
+ 'fee': withdrawFee,
1324
+ 'percentage': None,
1325
+ },
1326
+ 'deposit': {
1327
+ 'fee': None,
1328
+ 'percentage': None,
1329
+ },
1330
+ }
1331
+ return result
1332
+
1333
+ def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1334
+ """
1335
+ create a trade order
1336
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/OpenInstantBuyOrder
1337
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/OpenMarketBuyOrder
1338
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/OpenLimitBuyOrder
1339
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/OpenInstantSellOrder
1340
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/OpenMarketSellOrder
1341
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/OpenLimitSellOrder
1342
+ :param str symbol: unified symbol of the market to create an order in
1343
+ :param str type: 'market' or 'limit'
1344
+ :param str side: 'buy' or 'sell'
1345
+ :param float amount: how much of currency you want to trade in units of base currency
1346
+ :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1347
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1348
+ :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1349
+ """
1350
+ self.load_markets()
1351
+ market = self.market(symbol)
1352
+ request: dict = {
1353
+ 'pair': market['id'],
1354
+ 'amount': self.amount_to_precision(symbol, amount),
1355
+ }
1356
+ clientOrderId = self.safe_string_2(params, 'client_order_id', 'clientOrderId')
1357
+ if clientOrderId is not None:
1358
+ request['client_order_id'] = clientOrderId
1359
+ params = self.omit(params, ['clientOrderId'])
1360
+ response = None
1361
+ capitalizedSide = self.capitalize(side)
1362
+ if type == 'market':
1363
+ if capitalizedSide == 'Buy':
1364
+ response = self.privatePostBuyMarketPair(self.extend(request, params))
1365
+ else:
1366
+ response = self.privatePostSellMarketPair(self.extend(request, params))
1367
+ elif type == 'instant':
1368
+ if capitalizedSide == 'Buy':
1369
+ response = self.privatePostBuyInstantPair(self.extend(request, params))
1370
+ else:
1371
+ response = self.privatePostSellInstantPair(self.extend(request, params))
1372
+ else:
1373
+ request['price'] = self.price_to_precision(symbol, price)
1374
+ if capitalizedSide == 'Buy':
1375
+ response = self.privatePostBuyPair(self.extend(request, params))
1376
+ else:
1377
+ response = self.privatePostSellPair(self.extend(request, params))
1378
+ order = self.parse_order(response, market)
1379
+ order['type'] = type
1380
+ return order
1381
+
1382
+ def cancel_order(self, id: str, symbol: Str = None, params={}):
1383
+ """
1384
+ cancels an open order
1385
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/CancelOrder
1386
+ :param str id: order id
1387
+ :param str symbol: unified symbol of the market the order was made in
1388
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1389
+ :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1390
+ """
1391
+ self.load_markets()
1392
+ request: dict = {
1393
+ 'id': id,
1394
+ }
1395
+ response = self.privatePostCancelOrder(self.extend(request, params))
1396
+ #
1397
+ # {
1398
+ # "id": 1453282316578816,
1399
+ # "amount": "0.02035278",
1400
+ # "price": "2100.45",
1401
+ # "type": 0,
1402
+ # "market": "BTC/USD"
1403
+ # }
1404
+ #
1405
+ return self.parse_order(response)
1406
+
1407
+ def cancel_all_orders(self, symbol: Str = None, params={}):
1408
+ """
1409
+ cancel all open orders
1410
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/CancelAllOrders
1411
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/CancelOrdersForMarket
1412
+ :param str symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
1413
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1414
+ :returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1415
+ """
1416
+ self.load_markets()
1417
+ market = None
1418
+ request: dict = {}
1419
+ response = None
1420
+ if symbol is not None:
1421
+ market = self.market(symbol)
1422
+ request['pair'] = market['id']
1423
+ response = self.privatePostCancelAllOrdersPair(self.extend(request, params))
1424
+ else:
1425
+ response = self.privatePostCancelAllOrders(self.extend(request, params))
1426
+ #
1427
+ # {
1428
+ # "canceled": [
1429
+ # {
1430
+ # "id": 1453282316578816,
1431
+ # "amount": "0.02035278",
1432
+ # "price": "2100.45",
1433
+ # "type": 0,
1434
+ # "currency_pair": "BTC/USD",
1435
+ # "market": "BTC/USD"
1436
+ # }
1437
+ # ],
1438
+ # "success": True
1439
+ # }
1440
+ #
1441
+ canceled = self.safe_list(response, 'canceled')
1442
+ return self.parse_orders(canceled)
1443
+
1444
+ def parse_order_status(self, status: Str):
1445
+ statuses: dict = {
1446
+ 'In Queue': 'open',
1447
+ 'Open': 'open',
1448
+ 'Finished': 'closed',
1449
+ 'Canceled': 'canceled',
1450
+ }
1451
+ return self.safe_string(statuses, status, status)
1452
+
1453
+ def fetch_order_status(self, id: str, symbol: Str = None, params={}):
1454
+ self.load_markets()
1455
+ clientOrderId = self.safe_value_2(params, 'client_order_id', 'clientOrderId')
1456
+ request: dict = {}
1457
+ if clientOrderId is not None:
1458
+ request['client_order_id'] = clientOrderId
1459
+ params = self.omit(params, ['client_order_id', 'clientOrderId'])
1460
+ else:
1461
+ request['id'] = id
1462
+ response = self.privatePostOrderStatus(self.extend(request, params))
1463
+ return self.parse_order_status(self.safe_string(response, 'status'))
1464
+
1465
+ def fetch_order(self, id: str, symbol: Str = None, params={}):
1466
+ """
1467
+ fetches information on an order made by the user
1468
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/GetOrderStatus
1469
+ :param str symbol: unified symbol of the market the order was made in
1470
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1471
+ :returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
1472
+ """
1473
+ self.load_markets()
1474
+ market = None
1475
+ if symbol is not None:
1476
+ market = self.market(symbol)
1477
+ clientOrderId = self.safe_value_2(params, 'client_order_id', 'clientOrderId')
1478
+ request: dict = {}
1479
+ if clientOrderId is not None:
1480
+ request['client_order_id'] = clientOrderId
1481
+ params = self.omit(params, ['client_order_id', 'clientOrderId'])
1482
+ else:
1483
+ request['id'] = id
1484
+ response = self.privatePostOrderStatus(self.extend(request, params))
1485
+ #
1486
+ # {
1487
+ # "status": "Finished",
1488
+ # "id": 1429545880227846,
1489
+ # "amount_remaining": "0.00000000",
1490
+ # "transactions": [
1491
+ # {
1492
+ # "fee": "0.11128",
1493
+ # "price": "4451.25000000",
1494
+ # "datetime": "2021-11-25 12:59:59.322000",
1495
+ # "usdt": "22.25625000",
1496
+ # "tid": 209895701,
1497
+ # "eth": "0.00500000",
1498
+ # "type": 2
1499
+ # }
1500
+ # ]
1501
+ # }
1502
+ #
1503
+ return self.parse_order(response, market)
1504
+
1505
+ def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
1506
+ """
1507
+ fetch all trades made by the user
1508
+ :see: https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactions
1509
+ :see: https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactionsForMarket
1510
+ :param str symbol: unified market symbol
1511
+ :param int [since]: the earliest time in ms to fetch trades for
1512
+ :param int [limit]: the maximum number of trades structures to retrieve
1513
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1514
+ :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
1515
+ """
1516
+ self.load_markets()
1517
+ request: dict = {}
1518
+ method = 'privatePostUserTransactions'
1519
+ market = None
1520
+ if symbol is not None:
1521
+ market = self.market(symbol)
1522
+ request['pair'] = market['id']
1523
+ method += 'Pair'
1524
+ if limit is not None:
1525
+ request['limit'] = limit
1526
+ response = getattr(self, method)(self.extend(request, params))
1527
+ result = self.filter_by(response, 'type', '2')
1528
+ return self.parse_trades(result, market, since, limit)
1529
+
1530
+ def fetch_deposits_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1531
+ """
1532
+ fetch history of deposits and withdrawals
1533
+ :see: https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactions
1534
+ :param str [code]: unified currency code for the currency of the deposit/withdrawals, default is None
1535
+ :param int [since]: timestamp in ms of the earliest deposit/withdrawal, default is None
1536
+ :param int [limit]: max number of deposit/withdrawals to return, default is None
1537
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1538
+ :returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
1539
+ """
1540
+ self.load_markets()
1541
+ request: dict = {}
1542
+ if limit is not None:
1543
+ request['limit'] = limit
1544
+ response = self.privatePostUserTransactions(self.extend(request, params))
1545
+ #
1546
+ # [
1547
+ # {
1548
+ # "fee": "0.00000000",
1549
+ # "btc_usd": "0.00",
1550
+ # "id": 1234567894,
1551
+ # "usd": 0,
1552
+ # "btc": 0,
1553
+ # "datetime": "2018-09-08 09:00:31",
1554
+ # "type": "1",
1555
+ # "xrp": "-20.00000000",
1556
+ # "eur": 0,
1557
+ # },
1558
+ # {
1559
+ # "fee": "0.00000000",
1560
+ # "btc_usd": "0.00",
1561
+ # "id": 1134567891,
1562
+ # "usd": 0,
1563
+ # "btc": 0,
1564
+ # "datetime": "2018-09-07 18:47:52",
1565
+ # "type": "0",
1566
+ # "xrp": "20.00000000",
1567
+ # "eur": 0,
1568
+ # },
1569
+ # ]
1570
+ #
1571
+ currency = None
1572
+ if code is not None:
1573
+ currency = self.currency(code)
1574
+ transactions = self.filter_by_array(response, 'type', ['0', '1'], False)
1575
+ return self.parse_transactions(transactions, currency, since, limit)
1576
+
1577
+ def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
1578
+ """
1579
+ fetch all withdrawals made from an account
1580
+ :see: https://www.bitstamp.net/api/#tag/Withdrawals/operation/GetWithdrawalRequests
1581
+ :param str code: unified currency code
1582
+ :param int [since]: the earliest time in ms to fetch withdrawals for
1583
+ :param int [limit]: the maximum number of withdrawals structures to retrieve
1584
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1585
+ :returns dict[]: a list of `transaction structures <https://docs.ccxt.com/#/?id=transaction-structure>`
1586
+ """
1587
+ self.load_markets()
1588
+ request: dict = {}
1589
+ if since is not None:
1590
+ request['timedelta'] = self.milliseconds() - since
1591
+ else:
1592
+ request['timedelta'] = 50000000 # use max bitstamp approved value
1593
+ response = self.privatePostWithdrawalRequests(self.extend(request, params))
1594
+ #
1595
+ # [
1596
+ # {
1597
+ # "status": 2,
1598
+ # "datetime": "2018-10-17 10:58:13",
1599
+ # "currency": "BTC",
1600
+ # "amount": "0.29669259",
1601
+ # "address": "aaaaa",
1602
+ # "type": 1,
1603
+ # "id": 111111,
1604
+ # "transaction_id": "xxxx",
1605
+ # },
1606
+ # {
1607
+ # "status": 2,
1608
+ # "datetime": "2018-10-17 10:55:17",
1609
+ # "currency": "ETH",
1610
+ # "amount": "1.11010664",
1611
+ # "address": "aaaa",
1612
+ # "type": 16,
1613
+ # "id": 222222,
1614
+ # "transaction_id": "xxxxx",
1615
+ # },
1616
+ # ]
1617
+ #
1618
+ return self.parse_transactions(response, None, since, limit)
1619
+
1620
+ def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
1621
+ #
1622
+ # fetchDepositsWithdrawals
1623
+ #
1624
+ # {
1625
+ # "fee": "0.00000000",
1626
+ # "btc_usd": "0.00",
1627
+ # "id": 1234567894,
1628
+ # "usd": 0,
1629
+ # "btc": 0,
1630
+ # "datetime": "2018-09-08 09:00:31",
1631
+ # "type": "1",
1632
+ # "xrp": "-20.00000000",
1633
+ # "eur": 0,
1634
+ # }
1635
+ #
1636
+ # fetchWithdrawals
1637
+ #
1638
+ # {
1639
+ # "status": 2,
1640
+ # "datetime": "2018-10-17 10:58:13",
1641
+ # "currency": "BTC",
1642
+ # "amount": "0.29669259",
1643
+ # "address": "aaaaa",
1644
+ # "type": 1,
1645
+ # "id": 111111,
1646
+ # "transaction_id": "xxxx",
1647
+ # }
1648
+ #
1649
+ # {
1650
+ # "id": 3386432,
1651
+ # "type": 14,
1652
+ # "amount": "863.21332500",
1653
+ # "status": 2,
1654
+ # "address": "rE1sdh25BJQ3qFwngiTBwaq3zPGGYcrjp1?dt=1455",
1655
+ # "currency": "XRP",
1656
+ # "datetime": "2018-01-05 15:27:55",
1657
+ # "transaction_id": "001743B03B0C79BA166A064AC0142917B050347B4CB23BA2AB4B91B3C5608F4C"
1658
+ # }
1659
+ #
1660
+ timestamp = self.parse8601(self.safe_string(transaction, 'datetime'))
1661
+ currencyId = self.get_currency_id_from_transaction(transaction)
1662
+ code = self.safe_currency_code(currencyId, currency)
1663
+ feeCost = self.safe_string(transaction, 'fee')
1664
+ feeCurrency = None
1665
+ amount = None
1666
+ if 'amount' in transaction:
1667
+ amount = self.safe_string(transaction, 'amount')
1668
+ elif currency is not None:
1669
+ amount = self.safe_string(transaction, currency['id'], amount)
1670
+ feeCurrency = currency['code']
1671
+ elif (code is not None) and (currencyId is not None):
1672
+ amount = self.safe_string(transaction, currencyId, amount)
1673
+ feeCurrency = code
1674
+ if amount is not None:
1675
+ # withdrawals have a negative amount
1676
+ amount = Precise.string_abs(amount)
1677
+ status = 'ok'
1678
+ if 'status' in transaction:
1679
+ status = self.parse_transaction_status(self.safe_string(transaction, 'status'))
1680
+ type = None
1681
+ if 'type' in transaction:
1682
+ # from fetchDepositsWithdrawals
1683
+ rawType = self.safe_string(transaction, 'type')
1684
+ if rawType == '0':
1685
+ type = 'deposit'
1686
+ elif rawType == '1':
1687
+ type = 'withdrawal'
1688
+ else:
1689
+ # from fetchWithdrawals
1690
+ type = 'withdrawal'
1691
+ tag = None
1692
+ address = self.safe_string(transaction, 'address')
1693
+ if address is not None:
1694
+ # dt(destination tag) is embedded into the address field
1695
+ addressParts = address.split('?dt=')
1696
+ numParts = len(addressParts)
1697
+ if numParts > 1:
1698
+ address = addressParts[0]
1699
+ tag = addressParts[1]
1700
+ fee = {
1701
+ 'currency': None,
1702
+ 'cost': None,
1703
+ 'rate': None,
1704
+ }
1705
+ if feeCost is not None:
1706
+ fee = {
1707
+ 'currency': feeCurrency,
1708
+ 'cost': feeCost,
1709
+ 'rate': None,
1710
+ }
1711
+ return {
1712
+ 'info': transaction,
1713
+ 'id': self.safe_string(transaction, 'id'),
1714
+ 'txid': self.safe_string(transaction, 'transaction_id'),
1715
+ 'type': type,
1716
+ 'currency': code,
1717
+ 'network': None,
1718
+ 'amount': self.parse_number(amount),
1719
+ 'status': status,
1720
+ 'timestamp': timestamp,
1721
+ 'datetime': self.iso8601(timestamp),
1722
+ 'address': address,
1723
+ 'addressFrom': None,
1724
+ 'addressTo': address,
1725
+ 'tag': tag,
1726
+ 'tagFrom': None,
1727
+ 'tagTo': tag,
1728
+ 'updated': None,
1729
+ 'comment': None,
1730
+ 'internal': None,
1731
+ 'fee': fee,
1732
+ }
1733
+
1734
+ def parse_transaction_status(self, status: Str):
1735
+ #
1736
+ # withdrawals:
1737
+ # 0(open), 1(in process), 2(finished), 3(canceled) or 4(failed).
1738
+ #
1739
+ statuses: dict = {
1740
+ '0': 'pending', # Open
1741
+ '1': 'pending', # In process
1742
+ '2': 'ok', # Finished
1743
+ '3': 'canceled', # Canceled
1744
+ '4': 'failed', # Failed
1745
+ }
1746
+ return self.safe_string(statuses, status, status)
1747
+
1748
+ def parse_order(self, order: dict, market: Market = None) -> Order:
1749
+ #
1750
+ # from fetch order:
1751
+ # {status: "Finished",
1752
+ # "id": 731693945,
1753
+ # "client_order_id": '',
1754
+ # "transactions":
1755
+ # [{fee: "0.000019",
1756
+ # "price": "0.00015803",
1757
+ # "datetime": "2018-01-07 10:45:34.132551",
1758
+ # "btc": "0.0079015000000000",
1759
+ # "tid": 42777395,
1760
+ # "type": 2,
1761
+ # "xrp": "50.00000000"}]}
1762
+ #
1763
+ # partially filled order:
1764
+ # {"id": 468646390,
1765
+ # "client_order_id": "",
1766
+ # "status": "Canceled",
1767
+ # "transactions": [{
1768
+ # "eth": "0.23000000",
1769
+ # "fee": "0.09",
1770
+ # "tid": 25810126,
1771
+ # "usd": "69.8947000000000000",
1772
+ # "type": 2,
1773
+ # "price": "303.89000000",
1774
+ # "datetime": "2017-11-11 07:22:20.710567"
1775
+ # }]}
1776
+ #
1777
+ # from create order response:
1778
+ # {
1779
+ # "price": "0.00008012",
1780
+ # "client_order_id": '',
1781
+ # "currency_pair": "XRP/BTC",
1782
+ # "datetime": "2019-01-31 21:23:36",
1783
+ # "amount": "15.00000000",
1784
+ # "type": "0",
1785
+ # "id": "2814205012"
1786
+ # }
1787
+ #
1788
+ # cancelOrder
1789
+ #
1790
+ # {
1791
+ # "id": 1453282316578816,
1792
+ # "amount": "0.02035278",
1793
+ # "price": "2100.45",
1794
+ # "type": 0,
1795
+ # "market": "BTC/USD"
1796
+ # }
1797
+ #
1798
+ id = self.safe_string(order, 'id')
1799
+ clientOrderId = self.safe_string(order, 'client_order_id')
1800
+ side = self.safe_string(order, 'type')
1801
+ if side is not None:
1802
+ side = 'sell' if (side == '1') else 'buy'
1803
+ # there is no timestamp from fetchOrder
1804
+ timestamp = self.parse8601(self.safe_string(order, 'datetime'))
1805
+ marketId = self.safe_string_lower(order, 'currency_pair')
1806
+ symbol = self.safe_symbol(marketId, market, '/')
1807
+ status = self.parse_order_status(self.safe_string(order, 'status'))
1808
+ amount = self.safe_string(order, 'amount')
1809
+ transactions = self.safe_value(order, 'transactions', [])
1810
+ price = self.safe_string(order, 'price')
1811
+ return self.safe_order({
1812
+ 'id': id,
1813
+ 'clientOrderId': clientOrderId,
1814
+ 'datetime': self.iso8601(timestamp),
1815
+ 'timestamp': timestamp,
1816
+ 'lastTradeTimestamp': None,
1817
+ 'status': status,
1818
+ 'symbol': symbol,
1819
+ 'type': None,
1820
+ 'timeInForce': None,
1821
+ 'postOnly': None,
1822
+ 'side': side,
1823
+ 'price': price,
1824
+ 'stopPrice': None,
1825
+ 'triggerPrice': None,
1826
+ 'cost': None,
1827
+ 'amount': amount,
1828
+ 'filled': None,
1829
+ 'remaining': None,
1830
+ 'trades': transactions,
1831
+ 'fee': None,
1832
+ 'info': order,
1833
+ 'average': None,
1834
+ }, market)
1835
+
1836
+ def parse_ledger_entry_type(self, type):
1837
+ types: dict = {
1838
+ '0': 'transaction',
1839
+ '1': 'transaction',
1840
+ '2': 'trade',
1841
+ '14': 'transfer',
1842
+ }
1843
+ return self.safe_string(types, type, type)
1844
+
1845
+ def parse_ledger_entry(self, item: dict, currency: Currency = None):
1846
+ #
1847
+ # [
1848
+ # {
1849
+ # "fee": "0.00000000",
1850
+ # "btc_usd": "0.00",
1851
+ # "id": 1234567894,
1852
+ # "usd": 0,
1853
+ # "btc": 0,
1854
+ # "datetime": "2018-09-08 09:00:31",
1855
+ # "type": "1",
1856
+ # "xrp": "-20.00000000",
1857
+ # "eur": 0,
1858
+ # },
1859
+ # {
1860
+ # "fee": "0.00000000",
1861
+ # "btc_usd": "0.00",
1862
+ # "id": 1134567891,
1863
+ # "usd": 0,
1864
+ # "btc": 0,
1865
+ # "datetime": "2018-09-07 18:47:52",
1866
+ # "type": "0",
1867
+ # "xrp": "20.00000000",
1868
+ # "eur": 0,
1869
+ # },
1870
+ # ]
1871
+ #
1872
+ type = self.parse_ledger_entry_type(self.safe_string(item, 'type'))
1873
+ if type == 'trade':
1874
+ parsedTrade = self.parse_trade(item)
1875
+ market = None
1876
+ keys = list(item.keys())
1877
+ for i in range(0, len(keys)):
1878
+ if keys[i].find('_') >= 0:
1879
+ marketId = keys[i].replace('_', '')
1880
+ market = self.safe_market(marketId, market)
1881
+ # if the market is still not defined
1882
+ # try to deduce it from used keys
1883
+ if market is None:
1884
+ market = self.get_market_from_trade(item)
1885
+ direction = 'in' if (parsedTrade['side'] == 'buy') else 'out'
1886
+ return {
1887
+ 'id': parsedTrade['id'],
1888
+ 'info': item,
1889
+ 'timestamp': parsedTrade['timestamp'],
1890
+ 'datetime': parsedTrade['datetime'],
1891
+ 'direction': direction,
1892
+ 'account': None,
1893
+ 'referenceId': parsedTrade['order'],
1894
+ 'referenceAccount': None,
1895
+ 'type': type,
1896
+ 'currency': market['base'],
1897
+ 'amount': parsedTrade['amount'],
1898
+ 'before': None,
1899
+ 'after': None,
1900
+ 'status': 'ok',
1901
+ 'fee': parsedTrade['fee'],
1902
+ }
1903
+ else:
1904
+ parsedTransaction = self.parse_transaction(item, currency)
1905
+ direction = None
1906
+ if 'amount' in item:
1907
+ amount = self.safe_string(item, 'amount')
1908
+ direction = 'in' if Precise.string_gt(amount, '0') else 'out'
1909
+ elif ('currency' in parsedTransaction) and parsedTransaction['currency'] is not None:
1910
+ currencyCode = self.safe_string(parsedTransaction, 'currency')
1911
+ currency = self.currency(currencyCode)
1912
+ amount = self.safe_string(item, currency['id'])
1913
+ direction = 'in' if Precise.string_gt(amount, '0') else 'out'
1914
+ return {
1915
+ 'id': parsedTransaction['id'],
1916
+ 'info': item,
1917
+ 'timestamp': parsedTransaction['timestamp'],
1918
+ 'datetime': parsedTransaction['datetime'],
1919
+ 'direction': direction,
1920
+ 'account': None,
1921
+ 'referenceId': parsedTransaction['txid'],
1922
+ 'referenceAccount': None,
1923
+ 'type': type,
1924
+ 'currency': parsedTransaction['currency'],
1925
+ 'amount': parsedTransaction['amount'],
1926
+ 'before': None,
1927
+ 'after': None,
1928
+ 'status': parsedTransaction['status'],
1929
+ 'fee': parsedTransaction['fee'],
1930
+ }
1931
+
1932
+ def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}):
1933
+ """
1934
+ fetch the history of changes, actions done by the user or operations that altered balance of the user
1935
+ :see: https://www.bitstamp.net/api/#tag/Transactions-private/operation/GetUserTransactions
1936
+ :param str code: unified currency code, default is None
1937
+ :param int [since]: timestamp in ms of the earliest ledger entry, default is None
1938
+ :param int [limit]: max number of ledger entrys to return, default is None
1939
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1940
+ :returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger-structure>`
1941
+ """
1942
+ self.load_markets()
1943
+ request: dict = {}
1944
+ if limit is not None:
1945
+ request['limit'] = limit
1946
+ response = self.privatePostUserTransactions(self.extend(request, params))
1947
+ currency = None
1948
+ if code is not None:
1949
+ currency = self.currency(code)
1950
+ return self.parse_ledger(response, currency, since, limit)
1951
+
1952
+ def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
1953
+ """
1954
+ fetch all unfilled currently open orders
1955
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/GetAllOpenOrders
1956
+ :see: https://www.bitstamp.net/api/#tag/Orders/operation/GetOpenOrdersForMarket
1957
+ :param str symbol: unified market symbol
1958
+ :param int [since]: the earliest time in ms to fetch open orders for
1959
+ :param int [limit]: the maximum number of open orders structures to retrieve
1960
+ :param dict [params]: extra parameters specific to the exchange API endpoint
1961
+ :returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
1962
+ """
1963
+ market = None
1964
+ self.load_markets()
1965
+ if symbol is not None:
1966
+ market = self.market(symbol)
1967
+ response = self.privatePostOpenOrdersAll(params)
1968
+ #
1969
+ # [
1970
+ # {
1971
+ # "price": "0.00008012",
1972
+ # "currency_pair": "XRP/BTC",
1973
+ # "client_order_id": '',
1974
+ # "datetime": "2019-01-31 21:23:36",
1975
+ # "amount": "15.00000000",
1976
+ # "type": "0",
1977
+ # "id": "2814205012",
1978
+ # }
1979
+ # ]
1980
+ #
1981
+ return self.parse_orders(response, market, since, limit, {
1982
+ 'status': 'open',
1983
+ 'type': 'limit',
1984
+ })
1985
+
1986
+ def get_currency_name(self, code):
1987
+ """
1988
+ * @ignore
1989
+ :param str code: Unified currency code
1990
+ :returns str: lowercase version of code
1991
+ """
1992
+ return code.lower()
1993
+
1994
+ def is_fiat(self, code):
1995
+ return code == 'USD' or code == 'EUR' or code == 'GBP'
1996
+
1997
+ def fetch_deposit_address(self, code: str, params={}):
1998
+ """
1999
+ fetch the deposit address for a currency associated with self account
2000
+ :see: https://www.bitstamp.net/api/#tag/Deposits/operation/GetCryptoDepositAddress
2001
+ :param str code: unified currency code
2002
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2003
+ :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
2004
+ """
2005
+ if self.is_fiat(code):
2006
+ raise NotSupported(self.id + ' fiat fetchDepositAddress() for ' + code + ' is not supported!')
2007
+ name = self.get_currency_name(code)
2008
+ method = 'privatePost' + self.capitalize(name) + 'Address'
2009
+ response = getattr(self, method)(params)
2010
+ address = self.safe_string(response, 'address')
2011
+ tag = self.safe_string_2(response, 'memo_id', 'destination_tag')
2012
+ self.check_address(address)
2013
+ return {
2014
+ 'currency': code,
2015
+ 'address': address,
2016
+ 'tag': tag,
2017
+ 'network': None,
2018
+ 'info': response,
2019
+ }
2020
+
2021
+ def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
2022
+ """
2023
+ make a withdrawal
2024
+ :see: https://www.bitstamp.net/api/#tag/Withdrawals/operation/RequestFiatWithdrawal
2025
+ :see: https://www.bitstamp.net/api/#tag/Withdrawals/operation/RequestCryptoWithdrawal
2026
+ :param str code: unified currency code
2027
+ :param float amount: the amount to withdraw
2028
+ :param str address: the address to withdraw to
2029
+ :param str tag:
2030
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2031
+ :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
2032
+ """
2033
+ # For fiat withdrawals please provide all required additional parameters in the 'params'
2034
+ # Check https://www.bitstamp.net/api/ under 'Open bank withdrawal' for list and description.
2035
+ tag, params = self.handle_withdraw_tag_and_params(tag, params)
2036
+ self.load_markets()
2037
+ self.check_address(address)
2038
+ request: dict = {
2039
+ 'amount': amount,
2040
+ }
2041
+ currency = None
2042
+ method = None
2043
+ if not self.is_fiat(code):
2044
+ name = self.get_currency_name(code)
2045
+ method = 'privatePost' + self.capitalize(name) + 'Withdrawal'
2046
+ if code == 'XRP':
2047
+ if tag is not None:
2048
+ request['destination_tag'] = tag
2049
+ elif code == 'XLM' or code == 'HBAR':
2050
+ if tag is not None:
2051
+ request['memo_id'] = tag
2052
+ request['address'] = address
2053
+ else:
2054
+ method = 'privatePostWithdrawalOpen'
2055
+ currency = self.currency(code)
2056
+ request['iban'] = address
2057
+ request['account_currency'] = currency['id']
2058
+ response = getattr(self, method)(self.extend(request, params))
2059
+ return self.parse_transaction(response, currency)
2060
+
2061
+ def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
2062
+ """
2063
+ transfer currency internally between wallets on the same account
2064
+ :see: https://www.bitstamp.net/api/#tag/Sub-account/operation/TransferFromMainToSub
2065
+ :see: https://www.bitstamp.net/api/#tag/Sub-account/operation/TransferFromSubToMain
2066
+ :param str code: unified currency code
2067
+ :param float amount: amount to transfer
2068
+ :param str fromAccount: account to transfer from
2069
+ :param str toAccount: account to transfer to
2070
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2071
+ :returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
2072
+ """
2073
+ self.load_markets()
2074
+ currency = self.currency(code)
2075
+ request: dict = {
2076
+ 'amount': self.parse_to_numeric(self.currency_to_precision(code, amount)),
2077
+ 'currency': currency['id'].upper(),
2078
+ }
2079
+ response = None
2080
+ if fromAccount == 'main':
2081
+ request['subAccount'] = toAccount
2082
+ response = self.privatePostTransferFromMain(self.extend(request, params))
2083
+ elif toAccount == 'main':
2084
+ request['subAccount'] = fromAccount
2085
+ response = self.privatePostTransferToMain(self.extend(request, params))
2086
+ else:
2087
+ raise BadRequest(self.id + ' transfer() only supports from or to main')
2088
+ #
2089
+ # {status: 'ok'}
2090
+ #
2091
+ transfer = self.parse_transfer(response, currency)
2092
+ transfer['amount'] = amount
2093
+ transfer['fromAccount'] = fromAccount
2094
+ transfer['toAccount'] = toAccount
2095
+ return transfer
2096
+
2097
+ def parse_transfer(self, transfer, currency=None):
2098
+ #
2099
+ # {status: 'ok'}
2100
+ #
2101
+ status = self.safe_string(transfer, 'status')
2102
+ return {
2103
+ 'info': transfer,
2104
+ 'id': None,
2105
+ 'timestamp': None,
2106
+ 'datetime': None,
2107
+ 'currency': currency['code'],
2108
+ 'amount': None,
2109
+ 'fromAccount': None,
2110
+ 'toAccount': None,
2111
+ 'status': self.parse_transfer_status(status),
2112
+ }
2113
+
2114
+ def parse_transfer_status(self, status: Str) -> Str:
2115
+ statuses: dict = {
2116
+ 'ok': 'ok',
2117
+ 'error': 'failed',
2118
+ }
2119
+ return self.safe_string(statuses, status, status)
2120
+
2121
+ def nonce(self):
2122
+ return self.milliseconds()
2123
+
2124
+ def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
2125
+ url = self.urls['api'][api] + '/'
2126
+ url += self.version + '/'
2127
+ url += self.implode_params(path, params)
2128
+ query = self.omit(params, self.extract_params(path))
2129
+ if api == 'public':
2130
+ if query:
2131
+ url += '?' + self.urlencode(query)
2132
+ else:
2133
+ self.check_required_credentials()
2134
+ xAuth = 'BITSTAMP ' + self.apiKey
2135
+ xAuthNonce = self.uuid()
2136
+ xAuthTimestamp = str(self.milliseconds())
2137
+ xAuthVersion = 'v2'
2138
+ contentType = ''
2139
+ headers = {
2140
+ 'X-Auth': xAuth,
2141
+ 'X-Auth-Nonce': xAuthNonce,
2142
+ 'X-Auth-Timestamp': xAuthTimestamp,
2143
+ 'X-Auth-Version': xAuthVersion,
2144
+ }
2145
+ if method == 'POST':
2146
+ if query:
2147
+ body = self.urlencode(query)
2148
+ contentType = 'application/x-www-form-urlencoded'
2149
+ headers['Content-Type'] = contentType
2150
+ else:
2151
+ # sending an empty POST request will trigger
2152
+ # an API0020 error returned by the exchange
2153
+ # therefore for empty requests we send a dummy object
2154
+ # https://github.com/ccxt/ccxt/issues/6846
2155
+ body = self.urlencode({'foo': 'bar'})
2156
+ contentType = 'application/x-www-form-urlencoded'
2157
+ headers['Content-Type'] = contentType
2158
+ authBody = body if body else ''
2159
+ auth = xAuth + method + url.replace('https://', '') + contentType + xAuthNonce + xAuthTimestamp + xAuthVersion + authBody
2160
+ signature = self.hmac(self.encode(auth), self.encode(self.secret), hashlib.sha256)
2161
+ headers['X-Auth-Signature'] = signature
2162
+ return {'url': url, 'method': method, 'body': body, 'headers': headers}
2163
+
2164
+ def handle_errors(self, httpCode: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
2165
+ if response is None:
2166
+ return None
2167
+ #
2168
+ # {"error": "No permission found"} # fetchDepositAddress returns self on apiKeys that don't have the permission required
2169
+ # {"status": "error", "reason": {"__all__": ["Minimum order size is 5.0 EUR."]}}
2170
+ # reuse of a nonce gives: {status: 'error', reason: 'Invalid nonce', code: 'API0004'}
2171
+ #
2172
+ status = self.safe_string(response, 'status')
2173
+ error = self.safe_value(response, 'error')
2174
+ if (status == 'error') or (error is not None):
2175
+ errors = []
2176
+ if isinstance(error, str):
2177
+ errors.append(error)
2178
+ elif error is not None:
2179
+ keys = list(error.keys())
2180
+ for i in range(0, len(keys)):
2181
+ key = keys[i]
2182
+ value = self.safe_value(error, key)
2183
+ if isinstance(value, list):
2184
+ errors = self.array_concat(errors, value)
2185
+ else:
2186
+ errors.append(value)
2187
+ reasonInner = self.safe_value(response, 'reason', {})
2188
+ if isinstance(reasonInner, str):
2189
+ errors.append(reasonInner)
2190
+ else:
2191
+ all = self.safe_value(reasonInner, '__all__', [])
2192
+ for i in range(0, len(all)):
2193
+ errors.append(all[i])
2194
+ code = self.safe_string(response, 'code')
2195
+ if code == 'API0005':
2196
+ raise AuthenticationError(self.id + ' invalid signature, use the uid for the main account if you have subaccounts')
2197
+ feedback = self.id + ' ' + body
2198
+ for i in range(0, len(errors)):
2199
+ value = errors[i]
2200
+ self.throw_exactly_matched_exception(self.exceptions['exact'], value, feedback)
2201
+ self.throw_broadly_matched_exception(self.exceptions['broad'], value, feedback)
2202
+ raise ExchangeError(feedback)
2203
+ return None