ccxt 4.2.18 → 4.2.19

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 (426) hide show
  1. package/README.md +8 -8
  2. package/dist/ccxt.browser.js +34202 -33193
  3. package/dist/ccxt.browser.min.js +2 -2
  4. package/dist/cjs/ccxt.js +12 -1
  5. package/dist/cjs/src/alpaca.js +18 -18
  6. package/dist/cjs/src/ascendex.js +13 -6
  7. package/dist/cjs/src/base/Exchange.js +266 -27
  8. package/dist/cjs/src/bigone.js +434 -168
  9. package/dist/cjs/src/binance.js +163 -34
  10. package/dist/cjs/src/binanceus.js +8 -0
  11. package/dist/cjs/src/bingx.js +183 -41
  12. package/dist/cjs/src/bitfinex.js +2 -3
  13. package/dist/cjs/src/bitget.js +59 -16
  14. package/dist/cjs/src/bitmart.js +5 -5
  15. package/dist/cjs/src/bitmex.js +4 -6
  16. package/dist/cjs/src/bitpanda.js +5 -1991
  17. package/dist/cjs/src/bitstamp.js +8 -0
  18. package/dist/cjs/src/bybit.js +27 -47
  19. package/dist/cjs/src/coinbase.js +176 -26
  20. package/dist/cjs/src/coincheck.js +1 -0
  21. package/dist/cjs/src/coinex.js +3 -0
  22. package/dist/cjs/src/coinlist.js +13 -6
  23. package/dist/cjs/src/coinone.js +2 -2
  24. package/dist/cjs/src/coinsph.js +4 -5
  25. package/dist/cjs/src/delta.js +7 -1
  26. package/dist/cjs/src/deribit.js +17 -4
  27. package/dist/cjs/src/gate.js +151 -169
  28. package/dist/cjs/src/gemini.js +1 -1
  29. package/dist/cjs/src/hitbtc.js +2 -3
  30. package/dist/cjs/src/htx.js +157 -7
  31. package/dist/cjs/src/huobijp.js +2 -3
  32. package/dist/cjs/src/independentreserve.js +7 -5
  33. package/dist/cjs/src/kraken.js +86 -54
  34. package/dist/cjs/src/kucoin.js +5 -0
  35. package/dist/cjs/src/kucoinfutures.js +131 -77
  36. package/dist/cjs/src/lbank.js +60 -33
  37. package/dist/cjs/src/luno.js +84 -2
  38. package/dist/cjs/src/mexc.js +3 -3
  39. package/dist/cjs/src/oceanex.js +1 -1
  40. package/dist/cjs/src/okx.js +23 -11
  41. package/dist/cjs/{js/src/bitpanda.js → src/onetrading.js} +39 -39
  42. package/dist/cjs/src/phemex.js +37 -27
  43. package/dist/cjs/src/poloniexfutures.js +1 -0
  44. package/dist/cjs/src/pro/binance.js +66 -25
  45. package/dist/cjs/src/pro/bitget.js +1 -1
  46. package/dist/cjs/src/pro/bitpanda.js +5 -1330
  47. package/dist/cjs/src/pro/coinbase.js +4 -1
  48. package/dist/cjs/src/pro/hitbtc.js +5 -4
  49. package/dist/cjs/src/pro/htx.js +6 -1
  50. package/dist/cjs/src/pro/kraken.js +1 -1
  51. package/dist/cjs/src/pro/krakenfutures.js +7 -1
  52. package/dist/cjs/src/pro/kucoin.js +46 -36
  53. package/dist/cjs/src/pro/kucoinfutures.js +45 -37
  54. package/dist/cjs/src/pro/lbank.js +881 -0
  55. package/dist/cjs/src/pro/okx.js +52 -2
  56. package/dist/cjs/{js/src/pro/bitpanda.js → src/pro/onetrading.js} +4 -7
  57. package/dist/cjs/src/pro/poloniex.js +2 -2
  58. package/dist/cjs/src/pro/poloniexfutures.js +43 -35
  59. package/dist/cjs/src/pro/woo.js +126 -0
  60. package/dist/cjs/src/probit.js +4 -2
  61. package/dist/cjs/src/upbit.js +12 -12
  62. package/dist/cjs/src/wavesexchange.js +1 -1
  63. package/dist/cjs/src/whitebit.js +1 -0
  64. package/dist/cjs/src/woo.js +56 -0
  65. package/js/ccxt.d.ts +11 -2
  66. package/js/ccxt.js +8 -2
  67. package/js/src/abstract/bitpanda.d.ts +4 -4
  68. package/js/src/abstract/bitstamp.d.ts +8 -0
  69. package/js/src/abstract/gate.d.ts +1 -0
  70. package/js/src/abstract/gateio.d.ts +1 -0
  71. package/js/src/abstract/htx.d.ts +3 -0
  72. package/js/src/abstract/huobi.d.ts +3 -0
  73. package/js/src/abstract/luno.d.ts +1 -0
  74. package/js/src/abstract/onetrading.d.ts +38 -0
  75. package/js/src/ascendex.js +2 -0
  76. package/js/src/bingx.js +1 -1
  77. package/js/src/bitget.js +22 -3
  78. package/js/src/bitpanda.d.ts +2 -72
  79. package/js/src/bitpanda.js +5 -1991
  80. package/js/src/bitstamp.js +8 -0
  81. package/js/src/deribit.js +11 -3
  82. package/js/src/gate.d.ts +1 -0
  83. package/js/src/gate.js +50 -110
  84. package/js/src/htx.js +3 -0
  85. package/js/src/kraken.d.ts +1 -0
  86. package/js/src/kraken.js +39 -38
  87. package/js/src/lbank.js +1 -0
  88. package/js/src/luno.d.ts +3 -1
  89. package/js/src/luno.js +84 -2
  90. package/js/src/mexc.js +1 -2
  91. package/js/src/onetrading.d.ts +74 -0
  92. package/js/src/onetrading.js +2003 -0
  93. package/js/src/poloniexfutures.js +1 -0
  94. package/js/src/pro/binance.js +6 -1
  95. package/js/src/pro/bitpanda.d.ts +2 -34
  96. package/js/src/pro/bitpanda.js +5 -1330
  97. package/js/src/pro/lbank.d.ts +29 -0
  98. package/js/src/pro/lbank.js +882 -0
  99. package/js/src/pro/onetrading.d.ts +36 -0
  100. package/js/src/pro/onetrading.js +1339 -0
  101. package/package.json +2 -2
  102. package/rollup.config.js +2 -0
  103. package/skip-tests.json +2 -1
  104. package/test-commonjs.cjs +25 -1
  105. package/dist/cjs/js/ccxt.js +0 -478
  106. package/dist/cjs/js/src/abstract/alpaca.js +0 -9
  107. package/dist/cjs/js/src/abstract/ascendex.js +0 -9
  108. package/dist/cjs/js/src/abstract/bigone.js +0 -9
  109. package/dist/cjs/js/src/abstract/binance.js +0 -9
  110. package/dist/cjs/js/src/abstract/bingx.js +0 -9
  111. package/dist/cjs/js/src/abstract/bit2c.js +0 -9
  112. package/dist/cjs/js/src/abstract/bitbank.js +0 -9
  113. package/dist/cjs/js/src/abstract/bitbns.js +0 -9
  114. package/dist/cjs/js/src/abstract/bitfinex.js +0 -9
  115. package/dist/cjs/js/src/abstract/bitfinex2.js +0 -9
  116. package/dist/cjs/js/src/abstract/bitflyer.js +0 -9
  117. package/dist/cjs/js/src/abstract/bitforex.js +0 -9
  118. package/dist/cjs/js/src/abstract/bitget.js +0 -9
  119. package/dist/cjs/js/src/abstract/bithumb.js +0 -9
  120. package/dist/cjs/js/src/abstract/bitmart.js +0 -9
  121. package/dist/cjs/js/src/abstract/bitmex.js +0 -9
  122. package/dist/cjs/js/src/abstract/bitopro.js +0 -9
  123. package/dist/cjs/js/src/abstract/bitpanda.js +0 -9
  124. package/dist/cjs/js/src/abstract/bitrue.js +0 -9
  125. package/dist/cjs/js/src/abstract/bitso.js +0 -9
  126. package/dist/cjs/js/src/abstract/bitstamp.js +0 -9
  127. package/dist/cjs/js/src/abstract/bitteam.js +0 -9
  128. package/dist/cjs/js/src/abstract/bitvavo.js +0 -9
  129. package/dist/cjs/js/src/abstract/bl3p.js +0 -9
  130. package/dist/cjs/js/src/abstract/blockchaincom.js +0 -9
  131. package/dist/cjs/js/src/abstract/btcalpha.js +0 -9
  132. package/dist/cjs/js/src/abstract/btcbox.js +0 -9
  133. package/dist/cjs/js/src/abstract/btcmarkets.js +0 -9
  134. package/dist/cjs/js/src/abstract/btcturk.js +0 -9
  135. package/dist/cjs/js/src/abstract/bybit.js +0 -9
  136. package/dist/cjs/js/src/abstract/cex.js +0 -9
  137. package/dist/cjs/js/src/abstract/coinbase.js +0 -9
  138. package/dist/cjs/js/src/abstract/coinbasepro.js +0 -9
  139. package/dist/cjs/js/src/abstract/coincheck.js +0 -9
  140. package/dist/cjs/js/src/abstract/coinex.js +0 -9
  141. package/dist/cjs/js/src/abstract/coinlist.js +0 -9
  142. package/dist/cjs/js/src/abstract/coinmate.js +0 -9
  143. package/dist/cjs/js/src/abstract/coinone.js +0 -9
  144. package/dist/cjs/js/src/abstract/coinsph.js +0 -9
  145. package/dist/cjs/js/src/abstract/coinspot.js +0 -9
  146. package/dist/cjs/js/src/abstract/cryptocom.js +0 -9
  147. package/dist/cjs/js/src/abstract/currencycom.js +0 -9
  148. package/dist/cjs/js/src/abstract/delta.js +0 -9
  149. package/dist/cjs/js/src/abstract/deribit.js +0 -9
  150. package/dist/cjs/js/src/abstract/digifinex.js +0 -9
  151. package/dist/cjs/js/src/abstract/exmo.js +0 -9
  152. package/dist/cjs/js/src/abstract/gate.js +0 -9
  153. package/dist/cjs/js/src/abstract/gemini.js +0 -9
  154. package/dist/cjs/js/src/abstract/hitbtc.js +0 -9
  155. package/dist/cjs/js/src/abstract/hollaex.js +0 -9
  156. package/dist/cjs/js/src/abstract/htx.js +0 -9
  157. package/dist/cjs/js/src/abstract/huobijp.js +0 -9
  158. package/dist/cjs/js/src/abstract/idex.js +0 -9
  159. package/dist/cjs/js/src/abstract/independentreserve.js +0 -9
  160. package/dist/cjs/js/src/abstract/indodax.js +0 -9
  161. package/dist/cjs/js/src/abstract/kraken.js +0 -9
  162. package/dist/cjs/js/src/abstract/krakenfutures.js +0 -9
  163. package/dist/cjs/js/src/abstract/kucoin.js +0 -9
  164. package/dist/cjs/js/src/abstract/kucoinfutures.js +0 -9
  165. package/dist/cjs/js/src/abstract/kuna.js +0 -9
  166. package/dist/cjs/js/src/abstract/latoken.js +0 -9
  167. package/dist/cjs/js/src/abstract/lbank.js +0 -9
  168. package/dist/cjs/js/src/abstract/luno.js +0 -9
  169. package/dist/cjs/js/src/abstract/lykke.js +0 -9
  170. package/dist/cjs/js/src/abstract/mercado.js +0 -9
  171. package/dist/cjs/js/src/abstract/mexc.js +0 -9
  172. package/dist/cjs/js/src/abstract/ndax.js +0 -9
  173. package/dist/cjs/js/src/abstract/novadax.js +0 -9
  174. package/dist/cjs/js/src/abstract/oceanex.js +0 -9
  175. package/dist/cjs/js/src/abstract/okcoin.js +0 -9
  176. package/dist/cjs/js/src/abstract/okx.js +0 -9
  177. package/dist/cjs/js/src/abstract/p2b.js +0 -9
  178. package/dist/cjs/js/src/abstract/paymium.js +0 -9
  179. package/dist/cjs/js/src/abstract/phemex.js +0 -9
  180. package/dist/cjs/js/src/abstract/poloniex.js +0 -9
  181. package/dist/cjs/js/src/abstract/poloniexfutures.js +0 -9
  182. package/dist/cjs/js/src/abstract/probit.js +0 -9
  183. package/dist/cjs/js/src/abstract/timex.js +0 -9
  184. package/dist/cjs/js/src/abstract/tokocrypto.js +0 -9
  185. package/dist/cjs/js/src/abstract/upbit.js +0 -9
  186. package/dist/cjs/js/src/abstract/wavesexchange.js +0 -9
  187. package/dist/cjs/js/src/abstract/wazirx.js +0 -9
  188. package/dist/cjs/js/src/abstract/whitebit.js +0 -9
  189. package/dist/cjs/js/src/abstract/woo.js +0 -9
  190. package/dist/cjs/js/src/abstract/yobit.js +0 -9
  191. package/dist/cjs/js/src/abstract/zaif.js +0 -9
  192. package/dist/cjs/js/src/abstract/zonda.js +0 -9
  193. package/dist/cjs/js/src/ace.js +0 -1058
  194. package/dist/cjs/js/src/alpaca.js +0 -1125
  195. package/dist/cjs/js/src/ascendex.js +0 -3365
  196. package/dist/cjs/js/src/base/Exchange.js +0 -5260
  197. package/dist/cjs/js/src/base/Precise.js +0 -263
  198. package/dist/cjs/js/src/base/errors.js +0 -299
  199. package/dist/cjs/js/src/base/functions/crypto.js +0 -78
  200. package/dist/cjs/js/src/base/functions/encode.js +0 -44
  201. package/dist/cjs/js/src/base/functions/generic.js +0 -193
  202. package/dist/cjs/js/src/base/functions/misc.js +0 -96
  203. package/dist/cjs/js/src/base/functions/number.js +0 -297
  204. package/dist/cjs/js/src/base/functions/platform.js +0 -28
  205. package/dist/cjs/js/src/base/functions/rsa.js +0 -34
  206. package/dist/cjs/js/src/base/functions/string.js +0 -48
  207. package/dist/cjs/js/src/base/functions/throttle.js +0 -66
  208. package/dist/cjs/js/src/base/functions/time.js +0 -187
  209. package/dist/cjs/js/src/base/functions/totp.js +0 -24
  210. package/dist/cjs/js/src/base/functions/type.js +0 -162
  211. package/dist/cjs/js/src/base/functions.js +0 -157
  212. package/dist/cjs/js/src/base/ws/Cache.js +0 -254
  213. package/dist/cjs/js/src/base/ws/Client.js +0 -299
  214. package/dist/cjs/js/src/base/ws/Future.js +0 -34
  215. package/dist/cjs/js/src/base/ws/OrderBook.js +0 -107
  216. package/dist/cjs/js/src/base/ws/OrderBookSide.js +0 -281
  217. package/dist/cjs/js/src/base/ws/WsClient.js +0 -69
  218. package/dist/cjs/js/src/bequant.js +0 -33
  219. package/dist/cjs/js/src/bigone.js +0 -2213
  220. package/dist/cjs/js/src/binance.js +0 -9851
  221. package/dist/cjs/js/src/binancecoinm.js +0 -45
  222. package/dist/cjs/js/src/binanceus.js +0 -92
  223. package/dist/cjs/js/src/binanceusdm.js +0 -58
  224. package/dist/cjs/js/src/bingx.js +0 -3872
  225. package/dist/cjs/js/src/bit2c.js +0 -916
  226. package/dist/cjs/js/src/bitbank.js +0 -1000
  227. package/dist/cjs/js/src/bitbay.js +0 -17
  228. package/dist/cjs/js/src/bitbns.js +0 -1220
  229. package/dist/cjs/js/src/bitcoincom.js +0 -17
  230. package/dist/cjs/js/src/bitfinex.js +0 -1670
  231. package/dist/cjs/js/src/bitfinex2.js +0 -2990
  232. package/dist/cjs/js/src/bitflyer.js +0 -1045
  233. package/dist/cjs/js/src/bitforex.js +0 -852
  234. package/dist/cjs/js/src/bitget.js +0 -8295
  235. package/dist/cjs/js/src/bithumb.js +0 -1090
  236. package/dist/cjs/js/src/bitmart.js +0 -4454
  237. package/dist/cjs/js/src/bitmex.js +0 -2881
  238. package/dist/cjs/js/src/bitopro.js +0 -1724
  239. package/dist/cjs/js/src/bitrue.js +0 -3253
  240. package/dist/cjs/js/src/bitso.js +0 -1753
  241. package/dist/cjs/js/src/bitstamp.js +0 -2188
  242. package/dist/cjs/js/src/bitteam.js +0 -2309
  243. package/dist/cjs/js/src/bitvavo.js +0 -1968
  244. package/dist/cjs/js/src/bl3p.js +0 -447
  245. package/dist/cjs/js/src/blockchaincom.js +0 -1160
  246. package/dist/cjs/js/src/btcalpha.js +0 -929
  247. package/dist/cjs/js/src/btcbox.js +0 -565
  248. package/dist/cjs/js/src/btcmarkets.js +0 -1237
  249. package/dist/cjs/js/src/btcturk.js +0 -929
  250. package/dist/cjs/js/src/bybit.js +0 -7624
  251. package/dist/cjs/js/src/cex.js +0 -1693
  252. package/dist/cjs/js/src/coinbase.js +0 -3424
  253. package/dist/cjs/js/src/coinbasepro.js +0 -1866
  254. package/dist/cjs/js/src/coincheck.js +0 -844
  255. package/dist/cjs/js/src/coinex.js +0 -5417
  256. package/dist/cjs/js/src/coinlist.js +0 -2337
  257. package/dist/cjs/js/src/coinmate.js +0 -989
  258. package/dist/cjs/js/src/coinone.js +0 -1185
  259. package/dist/cjs/js/src/coinsph.js +0 -1933
  260. package/dist/cjs/js/src/coinspot.js +0 -548
  261. package/dist/cjs/js/src/cryptocom.js +0 -3007
  262. package/dist/cjs/js/src/currencycom.js +0 -2015
  263. package/dist/cjs/js/src/delta.js +0 -3262
  264. package/dist/cjs/js/src/deribit.js +0 -3310
  265. package/dist/cjs/js/src/digifinex.js +0 -4307
  266. package/dist/cjs/js/src/exmo.js +0 -2645
  267. package/dist/cjs/js/src/fmfwio.js +0 -34
  268. package/dist/cjs/js/src/gate.js +0 -7077
  269. package/dist/cjs/js/src/gateio.js +0 -16
  270. package/dist/cjs/js/src/gemini.js +0 -1801
  271. package/dist/cjs/js/src/hitbtc.js +0 -3660
  272. package/dist/cjs/js/src/hitbtc3.js +0 -19
  273. package/dist/cjs/js/src/hollaex.js +0 -1882
  274. package/dist/cjs/js/src/htx.js +0 -9174
  275. package/dist/cjs/js/src/huobi.js +0 -16
  276. package/dist/cjs/js/src/huobijp.js +0 -1918
  277. package/dist/cjs/js/src/idex.js +0 -1770
  278. package/dist/cjs/js/src/independentreserve.js +0 -761
  279. package/dist/cjs/js/src/indodax.js +0 -1069
  280. package/dist/cjs/js/src/kraken.js +0 -2891
  281. package/dist/cjs/js/src/krakenfutures.js +0 -2407
  282. package/dist/cjs/js/src/kucoin.js +0 -4494
  283. package/dist/cjs/js/src/kucoinfutures.js +0 -2529
  284. package/dist/cjs/js/src/kuna.js +0 -1949
  285. package/dist/cjs/js/src/latoken.js +0 -1729
  286. package/dist/cjs/js/src/lbank.js +0 -2851
  287. package/dist/cjs/js/src/luno.js +0 -1044
  288. package/dist/cjs/js/src/lykke.js +0 -1303
  289. package/dist/cjs/js/src/mercado.js +0 -897
  290. package/dist/cjs/js/src/mexc.js +0 -5407
  291. package/dist/cjs/js/src/ndax.js +0 -2450
  292. package/dist/cjs/js/src/novadax.js +0 -1556
  293. package/dist/cjs/js/src/oceanex.js +0 -964
  294. package/dist/cjs/js/src/okcoin.js +0 -3115
  295. package/dist/cjs/js/src/okx.js +0 -7331
  296. package/dist/cjs/js/src/p2b.js +0 -1243
  297. package/dist/cjs/js/src/paymium.js +0 -597
  298. package/dist/cjs/js/src/phemex.js +0 -4725
  299. package/dist/cjs/js/src/poloniex.js +0 -2356
  300. package/dist/cjs/js/src/poloniexfutures.js +0 -1794
  301. package/dist/cjs/js/src/pro/alpaca.js +0 -714
  302. package/dist/cjs/js/src/pro/ascendex.js +0 -957
  303. package/dist/cjs/js/src/pro/bequant.js +0 -33
  304. package/dist/cjs/js/src/pro/binance.js +0 -2796
  305. package/dist/cjs/js/src/pro/binancecoinm.js +0 -23
  306. package/dist/cjs/js/src/pro/binanceus.js +0 -51
  307. package/dist/cjs/js/src/pro/binanceusdm.js +0 -32
  308. package/dist/cjs/js/src/pro/bingx.js +0 -944
  309. package/dist/cjs/js/src/pro/bitcoincom.js +0 -29
  310. package/dist/cjs/js/src/pro/bitfinex.js +0 -672
  311. package/dist/cjs/js/src/pro/bitfinex2.js +0 -1159
  312. package/dist/cjs/js/src/pro/bitget.js +0 -1733
  313. package/dist/cjs/js/src/pro/bitmart.js +0 -1486
  314. package/dist/cjs/js/src/pro/bitmex.js +0 -1576
  315. package/dist/cjs/js/src/pro/bitopro.js +0 -327
  316. package/dist/cjs/js/src/pro/bitrue.js +0 -462
  317. package/dist/cjs/js/src/pro/bitstamp.js +0 -547
  318. package/dist/cjs/js/src/pro/bitvavo.js +0 -704
  319. package/dist/cjs/js/src/pro/blockchaincom.js +0 -794
  320. package/dist/cjs/js/src/pro/bybit.js +0 -1843
  321. package/dist/cjs/js/src/pro/cex.js +0 -1510
  322. package/dist/cjs/js/src/pro/coinbase.js +0 -561
  323. package/dist/cjs/js/src/pro/coinbasepro.js +0 -968
  324. package/dist/cjs/js/src/pro/coinex.js +0 -1095
  325. package/dist/cjs/js/src/pro/cryptocom.js +0 -1020
  326. package/dist/cjs/js/src/pro/currencycom.js +0 -563
  327. package/dist/cjs/js/src/pro/deribit.js +0 -825
  328. package/dist/cjs/js/src/pro/exmo.js +0 -658
  329. package/dist/cjs/js/src/pro/gate.js +0 -1316
  330. package/dist/cjs/js/src/pro/gateio.js +0 -16
  331. package/dist/cjs/js/src/pro/gemini.js +0 -649
  332. package/dist/cjs/js/src/pro/hitbtc.js +0 -1294
  333. package/dist/cjs/js/src/pro/hollaex.js +0 -597
  334. package/dist/cjs/js/src/pro/htx.js +0 -2388
  335. package/dist/cjs/js/src/pro/huobi.js +0 -16
  336. package/dist/cjs/js/src/pro/huobijp.js +0 -606
  337. package/dist/cjs/js/src/pro/idex.js +0 -714
  338. package/dist/cjs/js/src/pro/independentreserve.js +0 -280
  339. package/dist/cjs/js/src/pro/kraken.js +0 -1364
  340. package/dist/cjs/js/src/pro/krakenfutures.js +0 -1506
  341. package/dist/cjs/js/src/pro/kucoin.js +0 -1062
  342. package/dist/cjs/js/src/pro/kucoinfutures.js +0 -989
  343. package/dist/cjs/js/src/pro/luno.js +0 -322
  344. package/dist/cjs/js/src/pro/mexc.js +0 -1170
  345. package/dist/cjs/js/src/pro/ndax.js +0 -545
  346. package/dist/cjs/js/src/pro/okcoin.js +0 -760
  347. package/dist/cjs/js/src/pro/okx.js +0 -1608
  348. package/dist/cjs/js/src/pro/phemex.js +0 -1511
  349. package/dist/cjs/js/src/pro/poloniex.js +0 -1253
  350. package/dist/cjs/js/src/pro/poloniexfutures.js +0 -1022
  351. package/dist/cjs/js/src/pro/probit.js +0 -586
  352. package/dist/cjs/js/src/pro/upbit.js +0 -234
  353. package/dist/cjs/js/src/pro/wazirx.js +0 -776
  354. package/dist/cjs/js/src/pro/whitebit.js +0 -927
  355. package/dist/cjs/js/src/pro/woo.js +0 -895
  356. package/dist/cjs/js/src/probit.js +0 -1867
  357. package/dist/cjs/js/src/static_dependencies/fflake/browser.js +0 -401
  358. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +0 -195
  359. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +0 -308
  360. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +0 -554
  361. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +0 -94
  362. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +0 -70
  363. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +0 -91
  364. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +0 -16
  365. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +0 -1760
  366. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +0 -52
  367. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +0 -81
  368. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +0 -376
  369. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +0 -70
  370. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +0 -1580
  371. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +0 -74
  372. package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +0 -24
  373. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +0 -158
  374. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +0 -429
  375. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +0 -176
  376. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +0 -324
  377. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +0 -163
  378. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +0 -245
  379. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +0 -1018
  380. package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +0 -383
  381. package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +0 -258
  382. package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +0 -53
  383. package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +0 -120
  384. package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +0 -69
  385. package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +0 -7
  386. package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +0 -83
  387. package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +0 -240
  388. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +0 -91
  389. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +0 -130
  390. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +0 -214
  391. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +0 -239
  392. package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +0 -93
  393. package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +0 -354
  394. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +0 -16
  395. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +0 -20
  396. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +0 -30
  397. package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +0 -239
  398. package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +0 -372
  399. package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +0 -273
  400. package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +0 -139
  401. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +0 -14
  402. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +0 -16
  403. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +0 -81
  404. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +0 -292
  405. package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +0 -103
  406. package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +0 -140
  407. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +0 -175
  408. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +0 -95
  409. package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +0 -7
  410. package/dist/cjs/js/src/static_dependencies/scure-base/index.js +0 -383
  411. package/dist/cjs/js/src/timex.js +0 -1562
  412. package/dist/cjs/js/src/tokocrypto.js +0 -2542
  413. package/dist/cjs/js/src/upbit.js +0 -1844
  414. package/dist/cjs/js/src/wavesexchange.js +0 -2607
  415. package/dist/cjs/js/src/wazirx.js +0 -953
  416. package/dist/cjs/js/src/whitebit.js +0 -2310
  417. package/dist/cjs/js/src/woo.js +0 -2769
  418. package/dist/cjs/js/src/yobit.js +0 -1314
  419. package/dist/cjs/js/src/zaif.js +0 -736
  420. package/dist/cjs/js/src/zonda.js +0 -1883
  421. package/dist/cjs/src/abstract/bitpanda.js +0 -9
  422. package/test.ts +0 -0
  423. /package/dist/cjs/{js/src/abstract/ace.js → src/abstract/onetrading.js} +0 -0
  424. /package/dist/cjs/{js/src → src}/pro/coincheck.js +0 -0
  425. /package/dist/cjs/{js/src → src}/pro/coinone.js +0 -0
  426. /package/js/src/abstract/{bitpanda.js → onetrading.js} +0 -0
@@ -1,2188 +0,0 @@
1
- 'use strict';
2
-
3
- var bitstamp$1 = require('./abstract/bitstamp.js');
4
- var errors = require('./base/errors.js');
5
- var Precise = require('./base/Precise.js');
6
- var number = require('./base/functions/number.js');
7
- var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
8
-
9
- // ---------------------------------------------------------------------------
10
- // ---------------------------------------------------------------------------
11
- /**
12
- * @class bitstamp
13
- * @augments Exchange
14
- */
15
- class bitstamp extends bitstamp$1 {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'bitstamp',
19
- 'name': 'Bitstamp',
20
- 'countries': ['GB'],
21
- // 8000 requests per 10 minutes = 8000 / 600 = 13.33333333 requests per second => 1000ms / 13.33333333 = 75ms between requests on average
22
- 'rateLimit': 75,
23
- 'version': 'v2',
24
- 'userAgent': this.userAgents['chrome'],
25
- 'pro': true,
26
- 'has': {
27
- 'CORS': true,
28
- 'spot': true,
29
- 'margin': false,
30
- 'swap': false,
31
- 'future': false,
32
- 'option': false,
33
- 'addMargin': false,
34
- 'cancelAllOrders': true,
35
- 'cancelOrder': true,
36
- 'closeAllPositions': false,
37
- 'closePosition': false,
38
- 'createOrder': true,
39
- 'createReduceOnlyOrder': false,
40
- 'createStopLimitOrder': false,
41
- 'createStopMarketOrder': false,
42
- 'createStopOrder': false,
43
- 'fetchBalance': true,
44
- 'fetchBorrowRateHistories': false,
45
- 'fetchBorrowRateHistory': false,
46
- 'fetchCrossBorrowRate': false,
47
- 'fetchCrossBorrowRates': false,
48
- 'fetchCurrencies': true,
49
- 'fetchDepositAddress': true,
50
- 'fetchDepositsWithdrawals': true,
51
- 'fetchDepositWithdrawFee': 'emulated',
52
- 'fetchDepositWithdrawFees': true,
53
- 'fetchFundingHistory': false,
54
- 'fetchFundingRate': false,
55
- 'fetchFundingRateHistory': false,
56
- 'fetchFundingRates': false,
57
- 'fetchIndexOHLCV': false,
58
- 'fetchIsolatedBorrowRate': false,
59
- 'fetchIsolatedBorrowRates': false,
60
- 'fetchLedger': true,
61
- 'fetchLeverage': false,
62
- 'fetchMarginMode': false,
63
- 'fetchMarkets': true,
64
- 'fetchMarkOHLCV': false,
65
- 'fetchMyTrades': true,
66
- 'fetchOHLCV': true,
67
- 'fetchOpenInterestHistory': false,
68
- 'fetchOpenOrders': true,
69
- 'fetchOrder': true,
70
- 'fetchOrderBook': true,
71
- 'fetchPosition': false,
72
- 'fetchPositionMode': false,
73
- 'fetchPositions': false,
74
- 'fetchPositionsRisk': false,
75
- 'fetchPremiumIndexOHLCV': false,
76
- 'fetchTicker': true,
77
- 'fetchTickers': true,
78
- 'fetchTrades': true,
79
- 'fetchTradingFee': true,
80
- 'fetchTradingFees': true,
81
- 'fetchTransactionFees': true,
82
- 'fetchTransactions': 'emulated',
83
- 'fetchWithdrawals': true,
84
- 'reduceMargin': false,
85
- 'setLeverage': false,
86
- 'setMarginMode': false,
87
- 'setPositionMode': false,
88
- 'withdraw': true,
89
- },
90
- 'urls': {
91
- 'logo': 'https://user-images.githubusercontent.com/1294454/27786377-8c8ab57e-5fe9-11e7-8ea4-2b05b6bcceec.jpg',
92
- 'api': {
93
- 'public': 'https://www.bitstamp.net/api',
94
- 'private': 'https://www.bitstamp.net/api',
95
- },
96
- 'www': 'https://www.bitstamp.net',
97
- 'doc': 'https://www.bitstamp.net/api',
98
- },
99
- 'timeframes': {
100
- '1m': '60',
101
- '3m': '180',
102
- '5m': '300',
103
- '15m': '900',
104
- '30m': '1800',
105
- '1h': '3600',
106
- '2h': '7200',
107
- '4h': '14400',
108
- '6h': '21600',
109
- '12h': '43200',
110
- '1d': '86400',
111
- '1w': '259200',
112
- },
113
- 'requiredCredentials': {
114
- 'apiKey': true,
115
- 'secret': true,
116
- },
117
- 'api': {
118
- 'public': {
119
- 'get': {
120
- 'ohlc/{pair}/': 1,
121
- 'order_book/{pair}/': 1,
122
- 'ticker/': 1,
123
- 'ticker_hour/{pair}/': 1,
124
- 'ticker/{pair}/': 1,
125
- 'transactions/{pair}/': 1,
126
- 'trading-pairs-info/': 1,
127
- 'currencies/': 1,
128
- 'eur_usd/': 1,
129
- 'travel_rule/vasps/': 1,
130
- },
131
- },
132
- 'private': {
133
- 'get': {
134
- 'travel_rule/contacts/': 1,
135
- 'contacts/{contact_uuid}/': 1,
136
- 'earn/subscriptions/': 1,
137
- 'earn/transactions/': 1,
138
- },
139
- 'post': {
140
- 'account_balances/': 1,
141
- 'account_balances/{currency}/': 1,
142
- 'balance/': 1,
143
- 'balance/{pair}/': 1,
144
- 'bch_withdrawal/': 1,
145
- 'bch_address/': 1,
146
- 'user_transactions/': 1,
147
- 'user_transactions/{pair}/': 1,
148
- 'crypto-transactions/': 1,
149
- 'open_orders/all/': 1,
150
- 'open_orders/{pair}/': 1,
151
- 'order_status/': 1,
152
- 'cancel_order/': 1,
153
- 'cancel_all_orders/': 1,
154
- 'cancel_all_orders/{pair}/': 1,
155
- 'buy/{pair}/': 1,
156
- 'buy/market/{pair}/': 1,
157
- 'buy/instant/{pair}/': 1,
158
- 'sell/{pair}/': 1,
159
- 'sell/market/{pair}/': 1,
160
- 'sell/instant/{pair}/': 1,
161
- 'transfer-to-main/': 1,
162
- 'transfer-from-main/': 1,
163
- 'my_trading_pairs/': 1,
164
- 'fees/trading/': 1,
165
- 'fees/trading/{pair}': 1,
166
- 'fees/withdrawal/': 1,
167
- 'fees/withdrawal/{currency}/': 1,
168
- 'withdrawal-requests/': 1,
169
- 'withdrawal/open/': 1,
170
- 'withdrawal/status/': 1,
171
- 'withdrawal/cancel/': 1,
172
- 'liquidation_address/new/': 1,
173
- 'liquidation_address/info/': 1,
174
- 'btc_unconfirmed/': 1,
175
- 'websockets_token/': 1,
176
- // individual coins
177
- 'btc_withdrawal/': 1,
178
- 'btc_address/': 1,
179
- 'ripple_withdrawal/': 1,
180
- 'ripple_address/': 1,
181
- 'ltc_withdrawal/': 1,
182
- 'ltc_address/': 1,
183
- 'eth_withdrawal/': 1,
184
- 'eth_address/': 1,
185
- 'xrp_withdrawal/': 1,
186
- 'xrp_address/': 1,
187
- 'xlm_withdrawal/': 1,
188
- 'xlm_address/': 1,
189
- 'pax_withdrawal/': 1,
190
- 'pax_address/': 1,
191
- 'link_withdrawal/': 1,
192
- 'link_address/': 1,
193
- 'usdc_withdrawal/': 1,
194
- 'usdc_address/': 1,
195
- 'omg_withdrawal/': 1,
196
- 'omg_address/': 1,
197
- 'dai_withdrawal/': 1,
198
- 'dai_address/': 1,
199
- 'knc_withdrawal/': 1,
200
- 'knc_address/': 1,
201
- 'mkr_withdrawal/': 1,
202
- 'mkr_address/': 1,
203
- 'zrx_withdrawal/': 1,
204
- 'zrx_address/': 1,
205
- 'gusd_withdrawal/': 1,
206
- 'gusd_address/': 1,
207
- 'aave_withdrawal/': 1,
208
- 'aave_address/': 1,
209
- 'bat_withdrawal/': 1,
210
- 'bat_address/': 1,
211
- 'uma_withdrawal/': 1,
212
- 'uma_address/': 1,
213
- 'snx_withdrawal/': 1,
214
- 'snx_address/': 1,
215
- 'uni_withdrawal/': 1,
216
- 'uni_address/': 1,
217
- 'yfi_withdrawal/': 1,
218
- 'yfi_address': 1,
219
- 'audio_withdrawal/': 1,
220
- 'audio_address/': 1,
221
- 'crv_withdrawal/': 1,
222
- 'crv_address/': 1,
223
- 'algo_withdrawal/': 1,
224
- 'algo_address/': 1,
225
- 'comp_withdrawal/': 1,
226
- 'comp_address/': 1,
227
- 'grt_withdrawal': 1,
228
- 'grt_address/': 1,
229
- 'usdt_withdrawal/': 1,
230
- 'usdt_address/': 1,
231
- 'eurt_withdrawal/': 1,
232
- 'eurt_address/': 1,
233
- 'matic_withdrawal/': 1,
234
- 'matic_address/': 1,
235
- 'sushi_withdrawal/': 1,
236
- 'sushi_address/': 1,
237
- 'chz_withdrawal/': 1,
238
- 'chz_address/': 1,
239
- 'enj_withdrawal/': 1,
240
- 'enj_address/': 1,
241
- 'alpha_withdrawal/': 1,
242
- 'alpha_address/': 1,
243
- 'ftt_withdrawal/': 1,
244
- 'ftt_address/': 1,
245
- 'storj_withdrawal/': 1,
246
- 'storj_address/': 1,
247
- 'axs_withdrawal/': 1,
248
- 'axs_address/': 1,
249
- 'sand_withdrawal/': 1,
250
- 'sand_address/': 1,
251
- 'hbar_withdrawal/': 1,
252
- 'hbar_address/': 1,
253
- 'rgt_withdrawal/': 1,
254
- 'rgt_address/': 1,
255
- 'fet_withdrawal/': 1,
256
- 'fet_address/': 1,
257
- 'skl_withdrawal/': 1,
258
- 'skl_address/': 1,
259
- 'cel_withdrawal/': 1,
260
- 'cel_address/': 1,
261
- 'sxp_withdrawal/': 1,
262
- 'sxp_address/': 1,
263
- 'ada_withdrawal/': 1,
264
- 'ada_address/': 1,
265
- 'slp_withdrawal/': 1,
266
- 'slp_address/': 1,
267
- 'ftm_withdrawal/': 1,
268
- 'ftm_address/': 1,
269
- 'perp_withdrawal/': 1,
270
- 'perp_address/': 1,
271
- 'dydx_withdrawal/': 1,
272
- 'dydx_address/': 1,
273
- 'gala_withdrawal/': 1,
274
- 'gala_address/': 1,
275
- 'shib_withdrawal/': 1,
276
- 'shib_address/': 1,
277
- 'amp_withdrawal/': 1,
278
- 'amp_address/': 1,
279
- 'sgb_withdrawal/': 1,
280
- 'sgb_address/': 1,
281
- 'avax_withdrawal/': 1,
282
- 'avax_address/': 1,
283
- 'wbtc_withdrawal/': 1,
284
- 'wbtc_address/': 1,
285
- 'ctsi_withdrawal/': 1,
286
- 'ctsi_address/': 1,
287
- 'cvx_withdrawal/': 1,
288
- 'cvx_address/': 1,
289
- 'imx_withdrawal/': 1,
290
- 'imx_address/': 1,
291
- 'nexo_withdrawal/': 1,
292
- 'nexo_address/': 1,
293
- 'ust_withdrawal/': 1,
294
- 'ust_address/': 1,
295
- 'ant_withdrawal/': 1,
296
- 'ant_address/': 1,
297
- 'gods_withdrawal/': 1,
298
- 'gods_address/': 1,
299
- 'rad_withdrawal/': 1,
300
- 'rad_address/': 1,
301
- 'band_withdrawal/': 1,
302
- 'band_address/': 1,
303
- 'inj_withdrawal/': 1,
304
- 'inj_address/': 1,
305
- 'rly_withdrawal/': 1,
306
- 'rly_address/': 1,
307
- 'rndr_withdrawal/': 1,
308
- 'rndr_address/': 1,
309
- 'vega_withdrawal/': 1,
310
- 'vega_address/': 1,
311
- '1inch_withdrawal/': 1,
312
- '1inch_address/': 1,
313
- 'ens_withdrawal/': 1,
314
- 'ens_address/': 1,
315
- 'mana_withdrawal/': 1,
316
- 'mana_address/': 1,
317
- 'lrc_withdrawal/': 1,
318
- 'lrc_address/': 1,
319
- 'ape_withdrawal/': 1,
320
- 'ape_address/': 1,
321
- 'mpl_withdrawal/': 1,
322
- 'mpl_address/': 1,
323
- 'euroc_withdrawal/': 1,
324
- 'euroc_address/': 1,
325
- 'sol_withdrawal/': 1,
326
- 'sol_address/': 1,
327
- 'dot_withdrawal/': 1,
328
- 'dot_address/': 1,
329
- 'near_withdrawal/': 1,
330
- 'near_address/': 1,
331
- 'doge_withdrawal/': 1,
332
- 'doge_address/': 1,
333
- 'flr_withdrawal/': 1,
334
- 'flr_address/': 1,
335
- 'dgld_withdrawal/': 1,
336
- 'dgld_address/': 1,
337
- 'ldo_withdrawal/': 1,
338
- 'ldo_address/': 1,
339
- 'travel_rule/contacts/': 1,
340
- 'earn/subscribe/': 1,
341
- 'earn/subscriptions/setting/': 1,
342
- 'earn/unsubscribe': 1,
343
- },
344
- },
345
- },
346
- 'fees': {
347
- 'trading': {
348
- 'tierBased': true,
349
- 'percentage': true,
350
- 'taker': this.parseNumber('0.005'),
351
- 'maker': this.parseNumber('0.005'),
352
- 'tiers': {
353
- 'taker': [
354
- [this.parseNumber('0'), this.parseNumber('0.005')],
355
- [this.parseNumber('20000'), this.parseNumber('0.0025')],
356
- [this.parseNumber('100000'), this.parseNumber('0.0024')],
357
- [this.parseNumber('200000'), this.parseNumber('0.0022')],
358
- [this.parseNumber('400000'), this.parseNumber('0.0020')],
359
- [this.parseNumber('600000'), this.parseNumber('0.0015')],
360
- [this.parseNumber('1000000'), this.parseNumber('0.0014')],
361
- [this.parseNumber('2000000'), this.parseNumber('0.0013')],
362
- [this.parseNumber('4000000'), this.parseNumber('0.0012')],
363
- [this.parseNumber('20000000'), this.parseNumber('0.0011')],
364
- [this.parseNumber('50000000'), this.parseNumber('0.0010')],
365
- [this.parseNumber('100000000'), this.parseNumber('0.0007')],
366
- [this.parseNumber('500000000'), this.parseNumber('0.0005')],
367
- [this.parseNumber('2000000000'), this.parseNumber('0.0003')],
368
- [this.parseNumber('6000000000'), this.parseNumber('0.0001')],
369
- [this.parseNumber('20000000000'), this.parseNumber('0.00005')],
370
- [this.parseNumber('20000000001'), this.parseNumber('0')],
371
- ],
372
- 'maker': [
373
- [this.parseNumber('0'), this.parseNumber('0.005')],
374
- [this.parseNumber('20000'), this.parseNumber('0.0025')],
375
- [this.parseNumber('100000'), this.parseNumber('0.0024')],
376
- [this.parseNumber('200000'), this.parseNumber('0.0022')],
377
- [this.parseNumber('400000'), this.parseNumber('0.0020')],
378
- [this.parseNumber('600000'), this.parseNumber('0.0015')],
379
- [this.parseNumber('1000000'), this.parseNumber('0.0014')],
380
- [this.parseNumber('2000000'), this.parseNumber('0.0013')],
381
- [this.parseNumber('4000000'), this.parseNumber('0.0012')],
382
- [this.parseNumber('20000000'), this.parseNumber('0.0011')],
383
- [this.parseNumber('50000000'), this.parseNumber('0.0010')],
384
- [this.parseNumber('100000000'), this.parseNumber('0.0007')],
385
- [this.parseNumber('500000000'), this.parseNumber('0.0005')],
386
- [this.parseNumber('2000000000'), this.parseNumber('0.0003')],
387
- [this.parseNumber('6000000000'), this.parseNumber('0.0001')],
388
- [this.parseNumber('20000000000'), this.parseNumber('0.00005')],
389
- [this.parseNumber('20000000001'), this.parseNumber('0')],
390
- ],
391
- },
392
- },
393
- 'funding': {
394
- 'tierBased': false,
395
- 'percentage': false,
396
- 'withdraw': {},
397
- 'deposit': {
398
- 'BTC': 0,
399
- 'BCH': 0,
400
- 'LTC': 0,
401
- 'ETH': 0,
402
- 'XRP': 0,
403
- 'XLM': 0,
404
- 'PAX': 0,
405
- 'USD': 7.5,
406
- 'EUR': 0,
407
- },
408
- },
409
- },
410
- 'precisionMode': number.TICK_SIZE,
411
- 'commonCurrencies': {
412
- 'UST': 'USTC',
413
- },
414
- 'exceptions': {
415
- 'exact': {
416
- 'No permission found': errors.PermissionDenied,
417
- 'API key not found': errors.AuthenticationError,
418
- 'IP address not allowed': errors.PermissionDenied,
419
- 'Invalid nonce': errors.InvalidNonce,
420
- 'Invalid signature': errors.AuthenticationError,
421
- 'Authentication failed': errors.AuthenticationError,
422
- 'Missing key, signature and nonce parameters': errors.AuthenticationError,
423
- 'Wrong API key format': errors.AuthenticationError,
424
- 'Your account is frozen': errors.PermissionDenied,
425
- 'Please update your profile with your FATCA information, before using API.': errors.PermissionDenied,
426
- 'Order not found.': errors.OrderNotFound,
427
- 'Price is more than 20% below market price.': errors.InvalidOrder,
428
- "Bitstamp.net is under scheduled maintenance. We'll be back soon.": errors.OnMaintenance,
429
- 'Order could not be placed.': errors.ExchangeNotAvailable,
430
- 'Invalid offset.': errors.BadRequest,
431
- },
432
- 'broad': {
433
- 'Minimum order size is': errors.InvalidOrder,
434
- 'Check your account balance for details.': errors.InsufficientFunds,
435
- 'Ensure this value has at least': errors.InvalidAddress,
436
- 'Ensure that there are no more than': errors.InvalidOrder, // {"status": "error", "reason": {"amount": ["Ensure that there are no more than 0 decimal places."], "__all__": [""]}}
437
- },
438
- },
439
- });
440
- }
441
- async fetchMarkets(params = {}) {
442
- /**
443
- * @method
444
- * @name bitstamp#fetchMarkets
445
- * @description retrieves data on all markets for bitstamp
446
- * @param {object} [params] extra parameters specific to the exchange API endpoint
447
- * @returns {object[]} an array of objects representing market data
448
- */
449
- const response = await this.fetchMarketsFromCache(params);
450
- //
451
- // [
452
- // {
453
- // "trading": "Enabled",
454
- // "base_decimals": 8,
455
- // "url_symbol": "btcusd",
456
- // "name": "BTC/USD",
457
- // "instant_and_market_orders": "Enabled",
458
- // "minimum_order": "20.0 USD",
459
- // "counter_decimals": 2,
460
- // "description": "Bitcoin / U.S. dollar"
461
- // }
462
- // ]
463
- //
464
- const result = [];
465
- for (let i = 0; i < response.length; i++) {
466
- const market = response[i];
467
- const name = this.safeString(market, 'name');
468
- let [base, quote] = name.split('/');
469
- const baseId = base.toLowerCase();
470
- const quoteId = quote.toLowerCase();
471
- base = this.safeCurrencyCode(base);
472
- quote = this.safeCurrencyCode(quote);
473
- const minimumOrder = this.safeString(market, 'minimum_order');
474
- const parts = minimumOrder.split(' ');
475
- const status = this.safeString(market, 'trading');
476
- result.push({
477
- 'id': this.safeString(market, 'url_symbol'),
478
- 'marketId': baseId + '_' + quoteId,
479
- 'symbol': base + '/' + quote,
480
- 'base': base,
481
- 'quote': quote,
482
- 'settle': undefined,
483
- 'baseId': baseId,
484
- 'quoteId': quoteId,
485
- 'settleId': undefined,
486
- 'type': 'spot',
487
- 'spot': true,
488
- 'margin': false,
489
- 'future': false,
490
- 'swap': false,
491
- 'option': false,
492
- 'active': (status === 'Enabled'),
493
- 'contract': false,
494
- 'linear': undefined,
495
- 'inverse': undefined,
496
- 'contractSize': undefined,
497
- 'expiry': undefined,
498
- 'expiryDatetime': undefined,
499
- 'strike': undefined,
500
- 'optionType': undefined,
501
- 'precision': {
502
- 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'base_decimals'))),
503
- 'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'counter_decimals'))),
504
- },
505
- 'limits': {
506
- 'leverage': {
507
- 'min': undefined,
508
- 'max': undefined,
509
- },
510
- 'amount': {
511
- 'min': undefined,
512
- 'max': undefined,
513
- },
514
- 'price': {
515
- 'min': undefined,
516
- 'max': undefined,
517
- },
518
- 'cost': {
519
- 'min': this.safeNumber(parts, 0),
520
- 'max': undefined,
521
- },
522
- },
523
- 'created': undefined,
524
- 'info': market,
525
- });
526
- }
527
- return result;
528
- }
529
- constructCurrencyObject(id, code, name, precision, minCost, originalPayload) {
530
- let currencyType = 'crypto';
531
- const description = this.describe();
532
- if (this.isFiat(code)) {
533
- currencyType = 'fiat';
534
- }
535
- const tickSize = this.parseNumber(this.parsePrecision(this.numberToString(precision)));
536
- return {
537
- 'id': id,
538
- 'code': code,
539
- 'info': originalPayload,
540
- 'type': currencyType,
541
- 'name': name,
542
- 'active': true,
543
- 'deposit': undefined,
544
- 'withdraw': undefined,
545
- 'fee': this.safeNumber(description['fees']['funding']['withdraw'], code),
546
- 'precision': tickSize,
547
- 'limits': {
548
- 'amount': {
549
- 'min': tickSize,
550
- 'max': undefined,
551
- },
552
- 'price': {
553
- 'min': tickSize,
554
- 'max': undefined,
555
- },
556
- 'cost': {
557
- 'min': minCost,
558
- 'max': undefined,
559
- },
560
- 'withdraw': {
561
- 'min': undefined,
562
- 'max': undefined,
563
- },
564
- },
565
- 'networks': {},
566
- };
567
- }
568
- async fetchMarketsFromCache(params = {}) {
569
- // this method is now redundant
570
- // currencies are now fetched before markets
571
- const options = this.safeValue(this.options, 'fetchMarkets', {});
572
- const timestamp = this.safeInteger(options, 'timestamp');
573
- const expires = this.safeInteger(options, 'expires', 1000);
574
- const now = this.milliseconds();
575
- if ((timestamp === undefined) || ((now - timestamp) > expires)) {
576
- const response = await this.publicGetTradingPairsInfo(params);
577
- this.options['fetchMarkets'] = this.extend(options, {
578
- 'response': response,
579
- 'timestamp': now,
580
- });
581
- }
582
- return this.safeValue(this.options['fetchMarkets'], 'response');
583
- }
584
- async fetchCurrencies(params = {}) {
585
- /**
586
- * @method
587
- * @name bitstamp#fetchCurrencies
588
- * @description fetches all available currencies on an exchange
589
- * @param {object} [params] extra parameters specific to the exchange API endpoint
590
- * @returns {object} an associative dictionary of currencies
591
- */
592
- const response = await this.fetchMarketsFromCache(params);
593
- //
594
- // [
595
- // {
596
- // "trading": "Enabled",
597
- // "base_decimals": 8,
598
- // "url_symbol": "btcusd",
599
- // "name": "BTC/USD",
600
- // "instant_and_market_orders": "Enabled",
601
- // "minimum_order": "20.0 USD",
602
- // "counter_decimals": 2,
603
- // "description": "Bitcoin / U.S. dollar"
604
- // },
605
- // ]
606
- //
607
- const result = {};
608
- for (let i = 0; i < response.length; i++) {
609
- const market = response[i];
610
- const name = this.safeString(market, 'name');
611
- let [base, quote] = name.split('/');
612
- const baseId = base.toLowerCase();
613
- const quoteId = quote.toLowerCase();
614
- base = this.safeCurrencyCode(base);
615
- quote = this.safeCurrencyCode(quote);
616
- const description = this.safeString(market, 'description');
617
- const [baseDescription, quoteDescription] = description.split(' / ');
618
- const minimumOrder = this.safeString(market, 'minimum_order');
619
- const parts = minimumOrder.split(' ');
620
- const cost = parts[0];
621
- if (!(base in result)) {
622
- const baseDecimals = this.safeInteger(market, 'base_decimals');
623
- result[base] = this.constructCurrencyObject(baseId, base, baseDescription, baseDecimals, undefined, market);
624
- }
625
- if (!(quote in result)) {
626
- const counterDecimals = this.safeInteger(market, 'counter_decimals');
627
- result[quote] = this.constructCurrencyObject(quoteId, quote, quoteDescription, counterDecimals, this.parseNumber(cost), market);
628
- }
629
- }
630
- return result;
631
- }
632
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
633
- /**
634
- * @method
635
- * @name bitstamp#fetchOrderBook
636
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
637
- * @param {string} symbol unified symbol of the market to fetch the order book for
638
- * @param {int} [limit] the maximum amount of order book entries to return
639
- * @param {object} [params] extra parameters specific to the exchange API endpoint
640
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
641
- */
642
- await this.loadMarkets();
643
- const market = this.market(symbol);
644
- const request = {
645
- 'pair': market['id'],
646
- };
647
- const response = await this.publicGetOrderBookPair(this.extend(request, params));
648
- //
649
- // {
650
- // "timestamp": "1583652948",
651
- // "microtimestamp": "1583652948955826",
652
- // "bids": [
653
- // [ "8750.00", "1.33685271" ],
654
- // [ "8749.39", "0.07700000" ],
655
- // [ "8746.98", "0.07400000" ],
656
- // ]
657
- // "asks": [
658
- // [ "8754.10", "1.51995636" ],
659
- // [ "8754.71", "1.40000000" ],
660
- // [ "8754.72", "2.50000000" ],
661
- // ]
662
- // }
663
- //
664
- const microtimestamp = this.safeInteger(response, 'microtimestamp');
665
- const timestamp = this.parseToInt(microtimestamp / 1000);
666
- const orderbook = this.parseOrderBook(response, market['symbol'], timestamp);
667
- orderbook['nonce'] = microtimestamp;
668
- return orderbook;
669
- }
670
- parseTicker(ticker, market = undefined) {
671
- //
672
- // {
673
- // "timestamp": "1686068944",
674
- // "high": "26252",
675
- // "last": "26216",
676
- // "bid": "26208",
677
- // "vwap": "25681",
678
- // "volume": "3563.13819902",
679
- // "low": "25350",
680
- // "ask": "26211",
681
- // "open": "25730",
682
- // "open_24": "25895",
683
- // "percent_change_24": "1.24",
684
- // "pair": "BTC/USD"
685
- // }
686
- //
687
- const marketId = this.safeString(ticker, 'pair');
688
- const symbol = this.safeSymbol(marketId, market, undefined);
689
- const timestamp = this.safeTimestamp(ticker, 'timestamp');
690
- const vwap = this.safeString(ticker, 'vwap');
691
- const baseVolume = this.safeString(ticker, 'volume');
692
- const quoteVolume = Precise["default"].stringMul(baseVolume, vwap);
693
- const last = this.safeString(ticker, 'last');
694
- return this.safeTicker({
695
- 'symbol': symbol,
696
- 'timestamp': timestamp,
697
- 'datetime': this.iso8601(timestamp),
698
- 'high': this.safeString(ticker, 'high'),
699
- 'low': this.safeString(ticker, 'low'),
700
- 'bid': this.safeString(ticker, 'bid'),
701
- 'bidVolume': undefined,
702
- 'ask': this.safeString(ticker, 'ask'),
703
- 'askVolume': undefined,
704
- 'vwap': vwap,
705
- 'open': this.safeString(ticker, 'open'),
706
- 'close': last,
707
- 'last': last,
708
- 'previousClose': undefined,
709
- 'change': undefined,
710
- 'percentage': undefined,
711
- 'average': undefined,
712
- 'baseVolume': baseVolume,
713
- 'quoteVolume': quoteVolume,
714
- 'info': ticker,
715
- }, market);
716
- }
717
- async fetchTicker(symbol, params = {}) {
718
- /**
719
- * @method
720
- * @name bitstamp#fetchTicker
721
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
722
- * @param {string} symbol unified symbol of the market to fetch the ticker for
723
- * @param {object} [params] extra parameters specific to the exchange API endpoint
724
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
725
- */
726
- await this.loadMarkets();
727
- const market = this.market(symbol);
728
- const request = {
729
- 'pair': market['id'],
730
- };
731
- const ticker = await this.publicGetTickerPair(this.extend(request, params));
732
- //
733
- // {
734
- // "timestamp": "1686068944",
735
- // "high": "26252",
736
- // "last": "26216",
737
- // "bid": "26208",
738
- // "vwap": "25681",
739
- // "volume": "3563.13819902",
740
- // "low": "25350",
741
- // "ask": "26211",
742
- // "open": "25730",
743
- // "open_24": "25895",
744
- // "percent_change_24": "1.24"
745
- // }
746
- //
747
- return this.parseTicker(ticker, market);
748
- }
749
- async fetchTickers(symbols = undefined, params = {}) {
750
- /**
751
- * @method
752
- * @name bitstamp#fetchTickers
753
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
754
- * @see https://www.bitstamp.net/api/#all-tickers
755
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
756
- * @param {object} [params] extra parameters specific to the exchange API endpoint
757
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
758
- */
759
- await this.loadMarkets();
760
- const response = await this.publicGetTicker(params);
761
- //
762
- // {
763
- // "timestamp": "1686068944",
764
- // "high": "26252",
765
- // "last": "26216",
766
- // "bid": "26208",
767
- // "vwap": "25681",
768
- // "volume": "3563.13819902",
769
- // "low": "25350",
770
- // "ask": "26211",
771
- // "open": "25730",
772
- // "open_24": "25895",
773
- // "percent_change_24": "1.24",
774
- // "pair": "BTC/USD"
775
- // }
776
- //
777
- return this.parseTickers(response, symbols);
778
- }
779
- getCurrencyIdFromTransaction(transaction) {
780
- //
781
- // {
782
- // "fee": "0.00000000",
783
- // "btc_usd": "0.00",
784
- // "datetime": XXX,
785
- // "usd": 0.0,
786
- // "btc": 0.0,
787
- // "eth": "0.05000000",
788
- // "type": "0",
789
- // "id": XXX,
790
- // "eur": 0.0
791
- // }
792
- //
793
- const currencyId = this.safeStringLower(transaction, 'currency');
794
- if (currencyId !== undefined) {
795
- return currencyId;
796
- }
797
- transaction = this.omit(transaction, [
798
- 'fee',
799
- 'price',
800
- 'datetime',
801
- 'type',
802
- 'status',
803
- 'id',
804
- ]);
805
- const ids = Object.keys(transaction);
806
- for (let i = 0; i < ids.length; i++) {
807
- const id = ids[i];
808
- if (id.indexOf('_') < 0) {
809
- const value = this.safeNumber(transaction, id);
810
- if ((value !== undefined) && (value !== 0)) {
811
- return id;
812
- }
813
- }
814
- }
815
- return undefined;
816
- }
817
- getMarketFromTrade(trade) {
818
- trade = this.omit(trade, [
819
- 'fee',
820
- 'price',
821
- 'datetime',
822
- 'tid',
823
- 'type',
824
- 'order_id',
825
- 'side',
826
- ]);
827
- const currencyIds = Object.keys(trade);
828
- const numCurrencyIds = currencyIds.length;
829
- if (numCurrencyIds > 2) {
830
- throw new errors.ExchangeError(this.id + ' getMarketFromTrade() too many keys: ' + this.json(currencyIds) + ' in the trade: ' + this.json(trade));
831
- }
832
- if (numCurrencyIds === 2) {
833
- let marketId = currencyIds[0] + currencyIds[1];
834
- if (marketId in this.markets_by_id) {
835
- return this.safeMarket(marketId);
836
- }
837
- marketId = currencyIds[1] + currencyIds[0];
838
- if (marketId in this.markets_by_id) {
839
- return this.safeMarket(marketId);
840
- }
841
- }
842
- return undefined;
843
- }
844
- parseTrade(trade, market = undefined) {
845
- //
846
- // fetchTrades (public)
847
- //
848
- // {
849
- // "date": "1637845199",
850
- // "tid": "209895701",
851
- // "amount": "0.00500000",
852
- // "type": "0", // Transaction type: 0 - buy; 1 - sell
853
- // "price": "4451.25"
854
- // }
855
- //
856
- // fetchMyTrades, trades returned within fetchOrder (private)
857
- //
858
- // {
859
- // "fee": "0.11128",
860
- // "eth_usdt": 4451.25,
861
- // "datetime": "2021-11-25 12:59:59.322000",
862
- // "usdt": "-22.26",
863
- // "order_id": 1429545880227846,
864
- // "usd": 0,
865
- // "btc": 0,
866
- // "eth": "0.00500000",
867
- // "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.
868
- // "id": 209895701,
869
- // "eur": 0
870
- // }
871
- //
872
- // from fetchOrder (private)
873
- //
874
- // {
875
- // "fee": "0.11128",
876
- // "price": "4451.25000000",
877
- // "datetime": "2021-11-25 12:59:59.322000",
878
- // "usdt": "22.25625000",
879
- // "tid": 209895701,
880
- // "eth": "0.00500000",
881
- // "type": 2 // Transaction type: 0 - deposit; 1 - withdrawal; 2 - market trade
882
- // }
883
- //
884
- const id = this.safeString2(trade, 'id', 'tid');
885
- let symbol = undefined;
886
- let side = undefined;
887
- let priceString = this.safeString(trade, 'price');
888
- let amountString = this.safeString(trade, 'amount');
889
- const orderId = this.safeString(trade, 'order_id');
890
- const type = undefined;
891
- let costString = this.safeString(trade, 'cost');
892
- let rawMarketId = undefined;
893
- if (market === undefined) {
894
- const keys = Object.keys(trade);
895
- for (let i = 0; i < keys.length; i++) {
896
- const currentKey = keys[i];
897
- if (currentKey !== 'order_id' && currentKey.indexOf('_') >= 0) {
898
- rawMarketId = currentKey;
899
- market = this.safeMarket(rawMarketId, market, '_');
900
- }
901
- }
902
- }
903
- // if the market is still not defined
904
- // try to deduce it from used keys
905
- if (market === undefined) {
906
- market = this.getMarketFromTrade(trade);
907
- }
908
- const feeCostString = this.safeString(trade, 'fee');
909
- const feeCurrency = market['quote'];
910
- const priceId = (rawMarketId !== undefined) ? rawMarketId : market['marketId'];
911
- priceString = this.safeString(trade, priceId, priceString);
912
- amountString = this.safeString(trade, market['baseId'], amountString);
913
- costString = this.safeString(trade, market['quoteId'], costString);
914
- symbol = market['symbol'];
915
- const datetimeString = this.safeString2(trade, 'date', 'datetime');
916
- let timestamp = undefined;
917
- if (datetimeString !== undefined) {
918
- if (datetimeString.indexOf(' ') >= 0) {
919
- // iso8601
920
- timestamp = this.parse8601(datetimeString);
921
- }
922
- else {
923
- // string unix epoch in seconds
924
- timestamp = parseInt(datetimeString);
925
- timestamp = timestamp * 1000;
926
- }
927
- }
928
- // if it is a private trade
929
- if ('id' in trade) {
930
- if (amountString !== undefined) {
931
- const isAmountNeg = Precise["default"].stringLt(amountString, '0');
932
- if (isAmountNeg) {
933
- side = 'sell';
934
- amountString = Precise["default"].stringNeg(amountString);
935
- }
936
- else {
937
- side = 'buy';
938
- }
939
- }
940
- }
941
- else {
942
- side = this.safeString(trade, 'type');
943
- if (side === '1') {
944
- side = 'sell';
945
- }
946
- else if (side === '0') {
947
- side = 'buy';
948
- }
949
- else {
950
- side = undefined;
951
- }
952
- }
953
- if (costString !== undefined) {
954
- costString = Precise["default"].stringAbs(costString);
955
- }
956
- let fee = undefined;
957
- if (feeCostString !== undefined) {
958
- fee = {
959
- 'cost': feeCostString,
960
- 'currency': feeCurrency,
961
- };
962
- }
963
- return this.safeTrade({
964
- 'id': id,
965
- 'info': trade,
966
- 'timestamp': timestamp,
967
- 'datetime': this.iso8601(timestamp),
968
- 'symbol': symbol,
969
- 'order': orderId,
970
- 'type': type,
971
- 'side': side,
972
- 'takerOrMaker': undefined,
973
- 'price': priceString,
974
- 'amount': amountString,
975
- 'cost': costString,
976
- 'fee': fee,
977
- }, market);
978
- }
979
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
980
- /**
981
- * @method
982
- * @name bitstamp#fetchTrades
983
- * @description get the list of most recent trades for a particular symbol
984
- * @param {string} symbol unified symbol of the market to fetch trades for
985
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
986
- * @param {int} [limit] the maximum amount of trades to fetch
987
- * @param {object} [params] extra parameters specific to the exchange API endpoint
988
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
989
- */
990
- await this.loadMarkets();
991
- const market = this.market(symbol);
992
- const request = {
993
- 'pair': market['id'],
994
- 'time': 'hour',
995
- };
996
- const response = await this.publicGetTransactionsPair(this.extend(request, params));
997
- //
998
- // [
999
- // {
1000
- // "date": "1551814435",
1001
- // "tid": "83581898",
1002
- // "price": "0.03532850",
1003
- // "type": "1",
1004
- // "amount": "0.85945907"
1005
- // },
1006
- // {
1007
- // "date": "1551814434",
1008
- // "tid": "83581896",
1009
- // "price": "0.03532851",
1010
- // "type": "1",
1011
- // "amount": "11.34130961"
1012
- // },
1013
- // ]
1014
- //
1015
- return this.parseTrades(response, market, since, limit);
1016
- }
1017
- parseOHLCV(ohlcv, market = undefined) {
1018
- //
1019
- // {
1020
- // "high": "9064.77",
1021
- // "timestamp": "1593961440",
1022
- // "volume": "18.49436608",
1023
- // "low": "9040.87",
1024
- // "close": "9064.77",
1025
- // "open": "9040.87"
1026
- // }
1027
- //
1028
- return [
1029
- this.safeTimestamp(ohlcv, 'timestamp'),
1030
- this.safeNumber(ohlcv, 'open'),
1031
- this.safeNumber(ohlcv, 'high'),
1032
- this.safeNumber(ohlcv, 'low'),
1033
- this.safeNumber(ohlcv, 'close'),
1034
- this.safeNumber(ohlcv, 'volume'),
1035
- ];
1036
- }
1037
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1038
- /**
1039
- * @method
1040
- * @name bitstamp#fetchOHLCV
1041
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1042
- * @see https://www.bitstamp.net/api/#tag/Market-info/operation/GetOHLCData
1043
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1044
- * @param {string} timeframe the length of time each candle represents
1045
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
1046
- * @param {int} [limit] the maximum amount of candles to fetch
1047
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1048
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1049
- */
1050
- await this.loadMarkets();
1051
- const market = this.market(symbol);
1052
- const request = {
1053
- 'pair': market['id'],
1054
- 'step': this.safeString(this.timeframes, timeframe, timeframe),
1055
- };
1056
- const duration = this.parseTimeframe(timeframe);
1057
- if (limit === undefined) {
1058
- if (since === undefined) {
1059
- 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
1060
- }
1061
- else {
1062
- limit = 1000;
1063
- const start = this.parseToInt(since / 1000);
1064
- request['start'] = start;
1065
- request['end'] = this.sum(start, duration * (limit - 1));
1066
- request['limit'] = limit;
1067
- }
1068
- }
1069
- else {
1070
- if (since !== undefined) {
1071
- const start = this.parseToInt(since / 1000);
1072
- request['start'] = start;
1073
- request['end'] = this.sum(start, duration * (limit - 1));
1074
- }
1075
- request['limit'] = Math.min(limit, 1000); // min 1, max 1000
1076
- }
1077
- const response = await this.publicGetOhlcPair(this.extend(request, params));
1078
- //
1079
- // {
1080
- // "data": {
1081
- // "pair": "BTC/USD",
1082
- // "ohlc": [
1083
- // {"high": "9064.77", "timestamp": "1593961440", "volume": "18.49436608", "low": "9040.87", "close": "9064.77", "open": "9040.87"},
1084
- // {"high": "9071.59", "timestamp": "1593961500", "volume": "3.48631711", "low": "9058.76", "close": "9061.07", "open": "9064.66"},
1085
- // {"high": "9067.33", "timestamp": "1593961560", "volume": "0.04142833", "low": "9061.94", "close": "9061.94", "open": "9067.33"},
1086
- // ],
1087
- // }
1088
- // }
1089
- //
1090
- const data = this.safeValue(response, 'data', {});
1091
- const ohlc = this.safeValue(data, 'ohlc', []);
1092
- return this.parseOHLCVs(ohlc, market, timeframe, since, limit);
1093
- }
1094
- parseBalance(response) {
1095
- const result = {
1096
- 'info': response,
1097
- 'timestamp': undefined,
1098
- 'datetime': undefined,
1099
- };
1100
- const codes = Object.keys(this.currencies);
1101
- for (let i = 0; i < codes.length; i++) {
1102
- const code = codes[i];
1103
- const currency = this.currency(code);
1104
- const currencyId = currency['id'];
1105
- const account = this.account();
1106
- account['free'] = this.safeString(response, currencyId + '_available');
1107
- account['used'] = this.safeString(response, currencyId + '_reserved');
1108
- account['total'] = this.safeString(response, currencyId + '_balance');
1109
- result[code] = account;
1110
- }
1111
- return this.safeBalance(result);
1112
- }
1113
- async fetchBalance(params = {}) {
1114
- /**
1115
- * @method
1116
- * @name bitstamp#fetchBalance
1117
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
1118
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1119
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1120
- */
1121
- await this.loadMarkets();
1122
- const response = await this.privatePostBalance(params);
1123
- //
1124
- // {
1125
- // "aave_available": "0.00000000",
1126
- // "aave_balance": "0.00000000",
1127
- // "aave_reserved": "0.00000000",
1128
- // "aave_withdrawal_fee": "0.07000000",
1129
- // "aavebtc_fee": "0.000",
1130
- // "aaveeur_fee": "0.000",
1131
- // "aaveusd_fee": "0.000",
1132
- // "bat_available": "0.00000000",
1133
- // "bat_balance": "0.00000000",
1134
- // "bat_reserved": "0.00000000",
1135
- // "bat_withdrawal_fee": "5.00000000",
1136
- // "batbtc_fee": "0.000",
1137
- // "bateur_fee": "0.000",
1138
- // "batusd_fee": "0.000",
1139
- // }
1140
- //
1141
- return this.parseBalance(response);
1142
- }
1143
- async fetchTradingFee(symbol, params = {}) {
1144
- /**
1145
- * @method
1146
- * @name bitstamp#fetchTradingFee
1147
- * @description fetch the trading fees for a market
1148
- * @param {string} symbol unified market symbol
1149
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1150
- * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
1151
- */
1152
- await this.loadMarkets();
1153
- const market = this.market(symbol);
1154
- const request = {
1155
- 'pair': market['id'],
1156
- };
1157
- const response = await this.privatePostBalancePair(this.extend(request, params));
1158
- return this.parseTradingFee(response, market);
1159
- }
1160
- parseTradingFee(fee, market = undefined) {
1161
- market = this.safeMarket(undefined, market);
1162
- const feeString = this.safeString(fee, market['id'] + '_fee');
1163
- const dividedFeeString = Precise["default"].stringDiv(feeString, '100');
1164
- const tradeFee = this.parseNumber(dividedFeeString);
1165
- return {
1166
- 'info': fee,
1167
- 'symbol': market['symbol'],
1168
- 'maker': tradeFee,
1169
- 'taker': tradeFee,
1170
- };
1171
- }
1172
- parseTradingFees(fees) {
1173
- const result = { 'info': fees };
1174
- const symbols = this.symbols;
1175
- for (let i = 0; i < symbols.length; i++) {
1176
- const symbol = symbols[i];
1177
- const market = this.market(symbol);
1178
- const fee = this.parseTradingFee(fees, market);
1179
- result[symbol] = fee;
1180
- }
1181
- return result;
1182
- }
1183
- async fetchTradingFees(params = {}) {
1184
- /**
1185
- * @method
1186
- * @name bitstamp#fetchTradingFees
1187
- * @description fetch the trading fees for multiple markets
1188
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1189
- * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
1190
- */
1191
- await this.loadMarkets();
1192
- const response = await this.privatePostBalance(params);
1193
- return this.parseTradingFees(response);
1194
- }
1195
- async fetchTransactionFees(codes = undefined, params = {}) {
1196
- /**
1197
- * @method
1198
- * @name bitstamp#fetchTransactionFees
1199
- * @deprecated
1200
- * @description please use fetchDepositWithdrawFees instead
1201
- * @see https://www.bitstamp.net/api/#balance
1202
- * @param {string[]|undefined} codes list of unified currency codes
1203
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1204
- * @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
1205
- */
1206
- await this.loadMarkets();
1207
- const balance = await this.privatePostBalance(params);
1208
- return this.parseTransactionFees(balance);
1209
- }
1210
- parseTransactionFees(response, codes = undefined) {
1211
- //
1212
- // {
1213
- // "yfi_available": "0.00000000",
1214
- // "yfi_balance": "0.00000000",
1215
- // "yfi_reserved": "0.00000000",
1216
- // "yfi_withdrawal_fee": "0.00070000",
1217
- // "yfieur_fee": "0.000",
1218
- // "yfiusd_fee": "0.000",
1219
- // "zrx_available": "0.00000000",
1220
- // "zrx_balance": "0.00000000",
1221
- // "zrx_reserved": "0.00000000",
1222
- // "zrx_withdrawal_fee": "12.00000000",
1223
- // "zrxeur_fee": "0.000",
1224
- // "zrxusd_fee": "0.000",
1225
- // ...
1226
- // }
1227
- //
1228
- if (codes === undefined) {
1229
- codes = Object.keys(this.currencies);
1230
- }
1231
- const result = {};
1232
- let mainCurrencyId = undefined;
1233
- const ids = Object.keys(response);
1234
- for (let i = 0; i < ids.length; i++) {
1235
- const id = ids[i];
1236
- const currencyId = id.split('_')[0];
1237
- const code = this.safeCurrencyCode(currencyId);
1238
- if (codes !== undefined && !this.inArray(code, codes)) {
1239
- continue;
1240
- }
1241
- if (id.indexOf('_available') >= 0) {
1242
- mainCurrencyId = currencyId;
1243
- result[code] = {
1244
- 'deposit': undefined,
1245
- 'withdraw': undefined,
1246
- 'info': {},
1247
- };
1248
- }
1249
- if (currencyId === mainCurrencyId) {
1250
- result[code]['info'][id] = this.safeNumber(response, id);
1251
- }
1252
- if (id.indexOf('_withdrawal_fee') >= 0) {
1253
- result[code]['withdraw'] = this.safeNumber(response, id);
1254
- }
1255
- }
1256
- return result;
1257
- }
1258
- async fetchDepositWithdrawFees(codes = undefined, params = {}) {
1259
- /**
1260
- * @method
1261
- * @name bitstamp#fetchDepositWithdrawFees
1262
- * @description fetch deposit and withdraw fees
1263
- * @see https://www.bitstamp.net/api/#balance
1264
- * @param {string[]|undefined} codes list of unified currency codes
1265
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1266
- * @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
1267
- */
1268
- await this.loadMarkets();
1269
- const response = await this.privatePostBalance(params);
1270
- //
1271
- // {
1272
- // "yfi_available": "0.00000000",
1273
- // "yfi_balance": "0.00000000",
1274
- // "yfi_reserved": "0.00000000",
1275
- // "yfi_withdrawal_fee": "0.00070000",
1276
- // "yfieur_fee": "0.000",
1277
- // "yfiusd_fee": "0.000",
1278
- // "zrx_available": "0.00000000",
1279
- // "zrx_balance": "0.00000000",
1280
- // "zrx_reserved": "0.00000000",
1281
- // "zrx_withdrawal_fee": "12.00000000",
1282
- // "zrxeur_fee": "0.000",
1283
- // "zrxusd_fee": "0.000",
1284
- // ...
1285
- // }
1286
- //
1287
- return this.parseDepositWithdrawFees(response, codes);
1288
- }
1289
- parseDepositWithdrawFees(response, codes = undefined, currencyIdKey = undefined) {
1290
- //
1291
- // {
1292
- // "yfi_available": "0.00000000",
1293
- // "yfi_balance": "0.00000000",
1294
- // "yfi_reserved": "0.00000000",
1295
- // "yfi_withdrawal_fee": "0.00070000",
1296
- // "yfieur_fee": "0.000",
1297
- // "yfiusd_fee": "0.000",
1298
- // "zrx_available": "0.00000000",
1299
- // "zrx_balance": "0.00000000",
1300
- // "zrx_reserved": "0.00000000",
1301
- // "zrx_withdrawal_fee": "12.00000000",
1302
- // "zrxeur_fee": "0.000",
1303
- // "zrxusd_fee": "0.000",
1304
- // ...
1305
- // }
1306
- //
1307
- const result = {};
1308
- const ids = Object.keys(response);
1309
- for (let i = 0; i < ids.length; i++) {
1310
- const id = ids[i];
1311
- const currencyId = id.split('_')[0];
1312
- const code = this.safeCurrencyCode(currencyId);
1313
- const dictValue = this.safeNumber(response, id);
1314
- if (codes !== undefined && !this.inArray(code, codes)) {
1315
- continue;
1316
- }
1317
- if (id.indexOf('_available') >= 0) {
1318
- result[code] = this.depositWithdrawFee({});
1319
- }
1320
- if (id.indexOf('_withdrawal_fee') >= 0) {
1321
- result[code]['withdraw']['fee'] = dictValue;
1322
- }
1323
- const resultValue = this.safeValue(result, code);
1324
- if (resultValue !== undefined) {
1325
- result[code]['info'][id] = dictValue;
1326
- }
1327
- }
1328
- return result;
1329
- }
1330
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1331
- /**
1332
- * @method
1333
- * @name bitstamp#createOrder
1334
- * @description create a trade order
1335
- * @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenInstantBuyOrder
1336
- * @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenMarketBuyOrder
1337
- * @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenLimitBuyOrder
1338
- * @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenInstantSellOrder
1339
- * @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenMarketSellOrder
1340
- * @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenLimitSellOrder
1341
- * @param {string} symbol unified symbol of the market to create an order in
1342
- * @param {string} type 'market' or 'limit'
1343
- * @param {string} side 'buy' or 'sell'
1344
- * @param {float} amount how much of currency you want to trade in units of base currency
1345
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1346
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1347
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1348
- */
1349
- await this.loadMarkets();
1350
- const market = this.market(symbol);
1351
- const request = {
1352
- 'pair': market['id'],
1353
- 'amount': this.amountToPrecision(symbol, amount),
1354
- };
1355
- const clientOrderId = this.safeString2(params, 'client_order_id', 'clientOrderId');
1356
- if (clientOrderId !== undefined) {
1357
- request['client_order_id'] = clientOrderId;
1358
- params = this.omit(params, ['clientOrderId']);
1359
- }
1360
- let response = undefined;
1361
- const capitalizedSide = this.capitalize(side);
1362
- if (type === 'market') {
1363
- if (capitalizedSide === 'Buy') {
1364
- response = await this.privatePostBuyMarketPair(this.extend(request, params));
1365
- }
1366
- else {
1367
- response = await this.privatePostSellMarketPair(this.extend(request, params));
1368
- }
1369
- }
1370
- else if (type === 'instant') {
1371
- if (capitalizedSide === 'Buy') {
1372
- response = await this.privatePostBuyInstantPair(this.extend(request, params));
1373
- }
1374
- else {
1375
- response = await this.privatePostSellInstantPair(this.extend(request, params));
1376
- }
1377
- }
1378
- else {
1379
- request['price'] = this.priceToPrecision(symbol, price);
1380
- if (capitalizedSide === 'Buy') {
1381
- response = await this.privatePostBuyPair(this.extend(request, params));
1382
- }
1383
- else {
1384
- response = await this.privatePostSellPair(this.extend(request, params));
1385
- }
1386
- }
1387
- const order = this.parseOrder(response, market);
1388
- order['type'] = type;
1389
- return order;
1390
- }
1391
- async cancelOrder(id, symbol = undefined, params = {}) {
1392
- /**
1393
- * @method
1394
- * @name bitstamp#cancelOrder
1395
- * @description cancels an open order
1396
- * @param {string} id order id
1397
- * @param {string} symbol unified symbol of the market the order was made in
1398
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1399
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1400
- */
1401
- await this.loadMarkets();
1402
- const request = {
1403
- 'id': id,
1404
- };
1405
- return await this.privatePostCancelOrder(this.extend(request, params));
1406
- }
1407
- async cancelAllOrders(symbol = undefined, params = {}) {
1408
- /**
1409
- * @method
1410
- * @name bitstamp#cancelAllOrders
1411
- * @description cancel all open orders
1412
- * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
1413
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1414
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1415
- */
1416
- await this.loadMarkets();
1417
- let market = undefined;
1418
- const request = {};
1419
- let response = undefined;
1420
- if (symbol !== undefined) {
1421
- market = this.market(symbol);
1422
- request['pair'] = market['id'];
1423
- response = await this.privatePostCancelAllOrdersPair(this.extend(request, params));
1424
- }
1425
- else {
1426
- response = await this.privatePostCancelAllOrders(this.extend(request, params));
1427
- }
1428
- return response;
1429
- }
1430
- parseOrderStatus(status) {
1431
- const statuses = {
1432
- 'In Queue': 'open',
1433
- 'Open': 'open',
1434
- 'Finished': 'closed',
1435
- 'Canceled': 'canceled',
1436
- };
1437
- return this.safeString(statuses, status, status);
1438
- }
1439
- async fetchOrderStatus(id, symbol = undefined, params = {}) {
1440
- await this.loadMarkets();
1441
- const clientOrderId = this.safeValue2(params, 'client_order_id', 'clientOrderId');
1442
- const request = {};
1443
- if (clientOrderId !== undefined) {
1444
- request['client_order_id'] = clientOrderId;
1445
- params = this.omit(params, ['client_order_id', 'clientOrderId']);
1446
- }
1447
- else {
1448
- request['id'] = id;
1449
- }
1450
- const response = await this.privatePostOrderStatus(this.extend(request, params));
1451
- return this.parseOrderStatus(this.safeString(response, 'status'));
1452
- }
1453
- async fetchOrder(id, symbol = undefined, params = {}) {
1454
- /**
1455
- * @method
1456
- * @name bitstamp#fetchOrder
1457
- * @description fetches information on an order made by the user
1458
- * @param {string} symbol unified symbol of the market the order was made in
1459
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1460
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1461
- */
1462
- await this.loadMarkets();
1463
- let market = undefined;
1464
- if (symbol !== undefined) {
1465
- market = this.market(symbol);
1466
- }
1467
- const clientOrderId = this.safeValue2(params, 'client_order_id', 'clientOrderId');
1468
- const request = {};
1469
- if (clientOrderId !== undefined) {
1470
- request['client_order_id'] = clientOrderId;
1471
- params = this.omit(params, ['client_order_id', 'clientOrderId']);
1472
- }
1473
- else {
1474
- request['id'] = id;
1475
- }
1476
- const response = await this.privatePostOrderStatus(this.extend(request, params));
1477
- //
1478
- // {
1479
- // "status": "Finished",
1480
- // "id": 1429545880227846,
1481
- // "amount_remaining": "0.00000000",
1482
- // "transactions": [
1483
- // {
1484
- // "fee": "0.11128",
1485
- // "price": "4451.25000000",
1486
- // "datetime": "2021-11-25 12:59:59.322000",
1487
- // "usdt": "22.25625000",
1488
- // "tid": 209895701,
1489
- // "eth": "0.00500000",
1490
- // "type": 2
1491
- // }
1492
- // ]
1493
- // }
1494
- //
1495
- return this.parseOrder(response, market);
1496
- }
1497
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1498
- /**
1499
- * @method
1500
- * @name bitstamp#fetchMyTrades
1501
- * @description fetch all trades made by the user
1502
- * @param {string} symbol unified market symbol
1503
- * @param {int} [since] the earliest time in ms to fetch trades for
1504
- * @param {int} [limit] the maximum number of trades structures to retrieve
1505
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1506
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1507
- */
1508
- await this.loadMarkets();
1509
- const request = {};
1510
- let method = 'privatePostUserTransactions';
1511
- let market = undefined;
1512
- if (symbol !== undefined) {
1513
- market = this.market(symbol);
1514
- request['pair'] = market['id'];
1515
- method += 'Pair';
1516
- }
1517
- if (limit !== undefined) {
1518
- request['limit'] = limit;
1519
- }
1520
- const response = await this[method](this.extend(request, params));
1521
- const result = this.filterBy(response, 'type', '2');
1522
- return this.parseTrades(result, market, since, limit);
1523
- }
1524
- async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1525
- /**
1526
- * @method
1527
- * @name bitstamp#fetchDepositsWithdrawals
1528
- * @description fetch history of deposits and withdrawals
1529
- * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
1530
- * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
1531
- * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
1532
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1533
- * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1534
- */
1535
- await this.loadMarkets();
1536
- const request = {};
1537
- if (limit !== undefined) {
1538
- request['limit'] = limit;
1539
- }
1540
- const response = await this.privatePostUserTransactions(this.extend(request, params));
1541
- //
1542
- // [
1543
- // {
1544
- // "fee": "0.00000000",
1545
- // "btc_usd": "0.00",
1546
- // "id": 1234567894,
1547
- // "usd": 0,
1548
- // "btc": 0,
1549
- // "datetime": "2018-09-08 09:00:31",
1550
- // "type": "1",
1551
- // "xrp": "-20.00000000",
1552
- // "eur": 0,
1553
- // },
1554
- // {
1555
- // "fee": "0.00000000",
1556
- // "btc_usd": "0.00",
1557
- // "id": 1134567891,
1558
- // "usd": 0,
1559
- // "btc": 0,
1560
- // "datetime": "2018-09-07 18:47:52",
1561
- // "type": "0",
1562
- // "xrp": "20.00000000",
1563
- // "eur": 0,
1564
- // },
1565
- // ]
1566
- //
1567
- let currency = undefined;
1568
- if (code !== undefined) {
1569
- currency = this.currency(code);
1570
- }
1571
- const transactions = this.filterByArray(response, 'type', ['0', '1'], false);
1572
- return this.parseTransactions(transactions, currency, since, limit);
1573
- }
1574
- async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1575
- /**
1576
- * @method
1577
- * @name bitstamp#fetchWithdrawals
1578
- * @description fetch all withdrawals made from an account
1579
- * @param {string} code unified currency code
1580
- * @param {int} [since] the earliest time in ms to fetch withdrawals for
1581
- * @param {int} [limit] the maximum number of withdrawals structures to retrieve
1582
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1583
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1584
- */
1585
- await this.loadMarkets();
1586
- const request = {};
1587
- if (since !== undefined) {
1588
- request['timedelta'] = this.milliseconds() - since;
1589
- }
1590
- else {
1591
- request['timedelta'] = 50000000; // use max bitstamp approved value
1592
- }
1593
- const response = await this.privatePostWithdrawalRequests(this.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 this.parseTransactions(response, undefined, since, limit);
1619
- }
1620
- parseTransaction(transaction, currency = undefined) {
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
- const timestamp = this.parse8601(this.safeString(transaction, 'datetime'));
1661
- const currencyId = this.getCurrencyIdFromTransaction(transaction);
1662
- const code = this.safeCurrencyCode(currencyId, currency);
1663
- const feeCost = this.safeString(transaction, 'fee');
1664
- let feeCurrency = undefined;
1665
- let amount = undefined;
1666
- if ('amount' in transaction) {
1667
- amount = this.safeString(transaction, 'amount');
1668
- }
1669
- else if (currency !== undefined) {
1670
- amount = this.safeString(transaction, currency['id'], amount);
1671
- feeCurrency = currency['code'];
1672
- }
1673
- else if ((code !== undefined) && (currencyId !== undefined)) {
1674
- amount = this.safeString(transaction, currencyId, amount);
1675
- feeCurrency = code;
1676
- }
1677
- if (amount !== undefined) {
1678
- // withdrawals have a negative amount
1679
- amount = Precise["default"].stringAbs(amount);
1680
- }
1681
- let status = 'ok';
1682
- if ('status' in transaction) {
1683
- status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
1684
- }
1685
- let type = undefined;
1686
- if ('type' in transaction) {
1687
- // from fetchDepositsWithdrawals
1688
- const rawType = this.safeString(transaction, 'type');
1689
- if (rawType === '0') {
1690
- type = 'deposit';
1691
- }
1692
- else if (rawType === '1') {
1693
- type = 'withdrawal';
1694
- }
1695
- }
1696
- else {
1697
- // from fetchWithdrawals
1698
- type = 'withdrawal';
1699
- }
1700
- let tag = undefined;
1701
- let address = this.safeString(transaction, 'address');
1702
- if (address !== undefined) {
1703
- // dt (destination tag) is embedded into the address field
1704
- const addressParts = address.split('?dt=');
1705
- const numParts = addressParts.length;
1706
- if (numParts > 1) {
1707
- address = addressParts[0];
1708
- tag = addressParts[1];
1709
- }
1710
- }
1711
- let fee = {
1712
- 'currency': undefined,
1713
- 'cost': undefined,
1714
- 'rate': undefined,
1715
- };
1716
- if (feeCost !== undefined) {
1717
- fee = {
1718
- 'currency': feeCurrency,
1719
- 'cost': feeCost,
1720
- 'rate': undefined,
1721
- };
1722
- }
1723
- return {
1724
- 'info': transaction,
1725
- 'id': this.safeString(transaction, 'id'),
1726
- 'txid': this.safeString(transaction, 'transaction_id'),
1727
- 'type': type,
1728
- 'currency': code,
1729
- 'network': undefined,
1730
- 'amount': this.parseNumber(amount),
1731
- 'status': status,
1732
- 'timestamp': timestamp,
1733
- 'datetime': this.iso8601(timestamp),
1734
- 'address': address,
1735
- 'addressFrom': undefined,
1736
- 'addressTo': address,
1737
- 'tag': tag,
1738
- 'tagFrom': undefined,
1739
- 'tagTo': tag,
1740
- 'updated': undefined,
1741
- 'comment': undefined,
1742
- 'internal': undefined,
1743
- 'fee': fee,
1744
- };
1745
- }
1746
- parseTransactionStatus(status) {
1747
- //
1748
- // withdrawals:
1749
- // 0 (open), 1 (in process), 2 (finished), 3 (canceled) or 4 (failed).
1750
- //
1751
- const statuses = {
1752
- '0': 'pending',
1753
- '1': 'pending',
1754
- '2': 'ok',
1755
- '3': 'canceled',
1756
- '4': 'failed', // Failed
1757
- };
1758
- return this.safeString(statuses, status, status);
1759
- }
1760
- parseOrder(order, market = undefined) {
1761
- //
1762
- // from fetch order:
1763
- // { status: "Finished",
1764
- // "id": 731693945,
1765
- // "client_order_id": '',
1766
- // "transactions":
1767
- // [ { fee: "0.000019",
1768
- // "price": "0.00015803",
1769
- // "datetime": "2018-01-07 10:45:34.132551",
1770
- // "btc": "0.0079015000000000",
1771
- // "tid": 42777395,
1772
- // "type": 2,
1773
- // "xrp": "50.00000000" } ] }
1774
- //
1775
- // partially filled order:
1776
- // { "id": 468646390,
1777
- // "client_order_id": "",
1778
- // "status": "Canceled",
1779
- // "transactions": [{
1780
- // "eth": "0.23000000",
1781
- // "fee": "0.09",
1782
- // "tid": 25810126,
1783
- // "usd": "69.8947000000000000",
1784
- // "type": 2,
1785
- // "price": "303.89000000",
1786
- // "datetime": "2017-11-11 07:22:20.710567"
1787
- // }]}
1788
- //
1789
- // from create order response:
1790
- // {
1791
- // "price": "0.00008012",
1792
- // "client_order_id": '',
1793
- // "currency_pair": "XRP/BTC",
1794
- // "datetime": "2019-01-31 21:23:36",
1795
- // "amount": "15.00000000",
1796
- // "type": "0",
1797
- // "id": "2814205012"
1798
- // }
1799
- //
1800
- const id = this.safeString(order, 'id');
1801
- const clientOrderId = this.safeString(order, 'client_order_id');
1802
- let side = this.safeString(order, 'type');
1803
- if (side !== undefined) {
1804
- side = (side === '1') ? 'sell' : 'buy';
1805
- }
1806
- // there is no timestamp from fetchOrder
1807
- const timestamp = this.parse8601(this.safeString(order, 'datetime'));
1808
- const marketId = this.safeStringLower(order, 'currency_pair');
1809
- const symbol = this.safeSymbol(marketId, market, '/');
1810
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
1811
- const amount = this.safeString(order, 'amount');
1812
- const transactions = this.safeValue(order, 'transactions', []);
1813
- const price = this.safeString(order, 'price');
1814
- return this.safeOrder({
1815
- 'id': id,
1816
- 'clientOrderId': clientOrderId,
1817
- 'datetime': this.iso8601(timestamp),
1818
- 'timestamp': timestamp,
1819
- 'lastTradeTimestamp': undefined,
1820
- 'status': status,
1821
- 'symbol': symbol,
1822
- 'type': undefined,
1823
- 'timeInForce': undefined,
1824
- 'postOnly': undefined,
1825
- 'side': side,
1826
- 'price': price,
1827
- 'stopPrice': undefined,
1828
- 'triggerPrice': undefined,
1829
- 'cost': undefined,
1830
- 'amount': amount,
1831
- 'filled': undefined,
1832
- 'remaining': undefined,
1833
- 'trades': transactions,
1834
- 'fee': undefined,
1835
- 'info': order,
1836
- 'average': undefined,
1837
- }, market);
1838
- }
1839
- parseLedgerEntryType(type) {
1840
- const types = {
1841
- '0': 'transaction',
1842
- '1': 'transaction',
1843
- '2': 'trade',
1844
- '14': 'transfer',
1845
- };
1846
- return this.safeString(types, type, type);
1847
- }
1848
- parseLedgerEntry(item, currency = undefined) {
1849
- //
1850
- // [
1851
- // {
1852
- // "fee": "0.00000000",
1853
- // "btc_usd": "0.00",
1854
- // "id": 1234567894,
1855
- // "usd": 0,
1856
- // "btc": 0,
1857
- // "datetime": "2018-09-08 09:00:31",
1858
- // "type": "1",
1859
- // "xrp": "-20.00000000",
1860
- // "eur": 0,
1861
- // },
1862
- // {
1863
- // "fee": "0.00000000",
1864
- // "btc_usd": "0.00",
1865
- // "id": 1134567891,
1866
- // "usd": 0,
1867
- // "btc": 0,
1868
- // "datetime": "2018-09-07 18:47:52",
1869
- // "type": "0",
1870
- // "xrp": "20.00000000",
1871
- // "eur": 0,
1872
- // },
1873
- // ]
1874
- //
1875
- const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
1876
- if (type === 'trade') {
1877
- const parsedTrade = this.parseTrade(item);
1878
- let market = undefined;
1879
- const keys = Object.keys(item);
1880
- for (let i = 0; i < keys.length; i++) {
1881
- if (keys[i].indexOf('_') >= 0) {
1882
- const marketId = keys[i].replace('_', '');
1883
- market = this.safeMarket(marketId, market);
1884
- }
1885
- }
1886
- // if the market is still not defined
1887
- // try to deduce it from used keys
1888
- if (market === undefined) {
1889
- market = this.getMarketFromTrade(item);
1890
- }
1891
- const direction = (parsedTrade['side'] === 'buy') ? 'in' : 'out';
1892
- return {
1893
- 'id': parsedTrade['id'],
1894
- 'info': item,
1895
- 'timestamp': parsedTrade['timestamp'],
1896
- 'datetime': parsedTrade['datetime'],
1897
- 'direction': direction,
1898
- 'account': undefined,
1899
- 'referenceId': parsedTrade['order'],
1900
- 'referenceAccount': undefined,
1901
- 'type': type,
1902
- 'currency': market['base'],
1903
- 'amount': parsedTrade['amount'],
1904
- 'before': undefined,
1905
- 'after': undefined,
1906
- 'status': 'ok',
1907
- 'fee': parsedTrade['fee'],
1908
- };
1909
- }
1910
- else {
1911
- const parsedTransaction = this.parseTransaction(item, currency);
1912
- let direction = undefined;
1913
- if ('amount' in item) {
1914
- const amount = this.safeString(item, 'amount');
1915
- direction = Precise["default"].stringGt(amount, '0') ? 'in' : 'out';
1916
- }
1917
- else if (('currency' in parsedTransaction) && parsedTransaction['currency'] !== undefined) {
1918
- const currencyCode = this.safeString(parsedTransaction, 'currency');
1919
- currency = this.currency(currencyCode);
1920
- const amount = this.safeString(item, currency['id']);
1921
- direction = Precise["default"].stringGt(amount, '0') ? 'in' : 'out';
1922
- }
1923
- return {
1924
- 'id': parsedTransaction['id'],
1925
- 'info': item,
1926
- 'timestamp': parsedTransaction['timestamp'],
1927
- 'datetime': parsedTransaction['datetime'],
1928
- 'direction': direction,
1929
- 'account': undefined,
1930
- 'referenceId': parsedTransaction['txid'],
1931
- 'referenceAccount': undefined,
1932
- 'type': type,
1933
- 'currency': parsedTransaction['currency'],
1934
- 'amount': parsedTransaction['amount'],
1935
- 'before': undefined,
1936
- 'after': undefined,
1937
- 'status': parsedTransaction['status'],
1938
- 'fee': parsedTransaction['fee'],
1939
- };
1940
- }
1941
- }
1942
- async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1943
- /**
1944
- * @method
1945
- * @name bitstamp#fetchLedger
1946
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1947
- * @param {string} code unified currency code, default is undefined
1948
- * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1949
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1950
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1951
- * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1952
- */
1953
- await this.loadMarkets();
1954
- const request = {};
1955
- if (limit !== undefined) {
1956
- request['limit'] = limit;
1957
- }
1958
- const response = await this.privatePostUserTransactions(this.extend(request, params));
1959
- let currency = undefined;
1960
- if (code !== undefined) {
1961
- currency = this.currency(code);
1962
- }
1963
- return this.parseLedger(response, currency, since, limit);
1964
- }
1965
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1966
- /**
1967
- * @method
1968
- * @name bitstamp#fetchOpenOrders
1969
- * @description fetch all unfilled currently open orders
1970
- * @param {string} symbol unified market symbol
1971
- * @param {int} [since] the earliest time in ms to fetch open orders for
1972
- * @param {int} [limit] the maximum number of open orders structures to retrieve
1973
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1974
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1975
- */
1976
- let market = undefined;
1977
- await this.loadMarkets();
1978
- if (symbol !== undefined) {
1979
- market = this.market(symbol);
1980
- }
1981
- const response = await this.privatePostOpenOrdersAll(params);
1982
- //
1983
- // [
1984
- // {
1985
- // "price": "0.00008012",
1986
- // "currency_pair": "XRP/BTC",
1987
- // "client_order_id": '',
1988
- // "datetime": "2019-01-31 21:23:36",
1989
- // "amount": "15.00000000",
1990
- // "type": "0",
1991
- // "id": "2814205012",
1992
- // }
1993
- // ]
1994
- //
1995
- return this.parseOrders(response, market, since, limit, {
1996
- 'status': 'open',
1997
- 'type': 'limit',
1998
- });
1999
- }
2000
- getCurrencyName(code) {
2001
- /**
2002
- * @ignore
2003
- * @method
2004
- * @param {string} code Unified currency code
2005
- * @returns {string} lowercase version of code
2006
- */
2007
- return code.toLowerCase();
2008
- }
2009
- isFiat(code) {
2010
- return code === 'USD' || code === 'EUR' || code === 'GBP';
2011
- }
2012
- async fetchDepositAddress(code, params = {}) {
2013
- /**
2014
- * @method
2015
- * @name bitstamp#fetchDepositAddress
2016
- * @description fetch the deposit address for a currency associated with this account
2017
- * @param {string} code unified currency code
2018
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2019
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
2020
- */
2021
- if (this.isFiat(code)) {
2022
- throw new errors.NotSupported(this.id + ' fiat fetchDepositAddress() for ' + code + ' is not supported!');
2023
- }
2024
- const name = this.getCurrencyName(code);
2025
- const method = 'privatePost' + this.capitalize(name) + 'Address';
2026
- const response = await this[method](params);
2027
- const address = this.safeString(response, 'address');
2028
- const tag = this.safeString2(response, 'memo_id', 'destination_tag');
2029
- this.checkAddress(address);
2030
- return {
2031
- 'currency': code,
2032
- 'address': address,
2033
- 'tag': tag,
2034
- 'network': undefined,
2035
- 'info': response,
2036
- };
2037
- }
2038
- async withdraw(code, amount, address, tag = undefined, params = {}) {
2039
- /**
2040
- * @method
2041
- * @name bitstamp#withdraw
2042
- * @description make a withdrawal
2043
- * @param {string} code unified currency code
2044
- * @param {float} amount the amount to withdraw
2045
- * @param {string} address the address to withdraw to
2046
- * @param {string} tag
2047
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2048
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2049
- */
2050
- // For fiat withdrawals please provide all required additional parameters in the 'params'
2051
- // Check https://www.bitstamp.net/api/ under 'Open bank withdrawal' for list and description.
2052
- [tag, params] = this.handleWithdrawTagAndParams(tag, params);
2053
- await this.loadMarkets();
2054
- this.checkAddress(address);
2055
- const request = {
2056
- 'amount': amount,
2057
- };
2058
- let currency = undefined;
2059
- let method = undefined;
2060
- if (!this.isFiat(code)) {
2061
- const name = this.getCurrencyName(code);
2062
- method = 'privatePost' + this.capitalize(name) + 'Withdrawal';
2063
- if (code === 'XRP') {
2064
- if (tag !== undefined) {
2065
- request['destination_tag'] = tag;
2066
- }
2067
- }
2068
- else if (code === 'XLM' || code === 'HBAR') {
2069
- if (tag !== undefined) {
2070
- request['memo_id'] = tag;
2071
- }
2072
- }
2073
- request['address'] = address;
2074
- }
2075
- else {
2076
- method = 'privatePostWithdrawalOpen';
2077
- currency = this.currency(code);
2078
- request['iban'] = address;
2079
- request['account_currency'] = currency['id'];
2080
- }
2081
- const response = await this[method](this.extend(request, params));
2082
- return this.parseTransaction(response, currency);
2083
- }
2084
- nonce() {
2085
- return this.milliseconds();
2086
- }
2087
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
2088
- let url = this.urls['api'][api] + '/';
2089
- url += this.version + '/';
2090
- url += this.implodeParams(path, params);
2091
- const query = this.omit(params, this.extractParams(path));
2092
- if (api === 'public') {
2093
- if (Object.keys(query).length) {
2094
- url += '?' + this.urlencode(query);
2095
- }
2096
- }
2097
- else {
2098
- this.checkRequiredCredentials();
2099
- const xAuth = 'BITSTAMP ' + this.apiKey;
2100
- const xAuthNonce = this.uuid();
2101
- const xAuthTimestamp = this.milliseconds().toString();
2102
- const xAuthVersion = 'v2';
2103
- let contentType = '';
2104
- headers = {
2105
- 'X-Auth': xAuth,
2106
- 'X-Auth-Nonce': xAuthNonce,
2107
- 'X-Auth-Timestamp': xAuthTimestamp,
2108
- 'X-Auth-Version': xAuthVersion,
2109
- };
2110
- if (method === 'POST') {
2111
- if (Object.keys(query).length) {
2112
- body = this.urlencode(query);
2113
- contentType = 'application/x-www-form-urlencoded';
2114
- headers['Content-Type'] = contentType;
2115
- }
2116
- else {
2117
- // sending an empty POST request will trigger
2118
- // an API0020 error returned by the exchange
2119
- // therefore for empty requests we send a dummy object
2120
- // https://github.com/ccxt/ccxt/issues/6846
2121
- body = this.urlencode({ 'foo': 'bar' });
2122
- contentType = 'application/x-www-form-urlencoded';
2123
- headers['Content-Type'] = contentType;
2124
- }
2125
- }
2126
- const authBody = body ? body : '';
2127
- const auth = xAuth + method + url.replace('https://', '') + contentType + xAuthNonce + xAuthTimestamp + xAuthVersion + authBody;
2128
- const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
2129
- headers['X-Auth-Signature'] = signature;
2130
- }
2131
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
2132
- }
2133
- handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
2134
- if (response === undefined) {
2135
- return undefined;
2136
- }
2137
- //
2138
- // {"error": "No permission found"} // fetchDepositAddress returns this on apiKeys that don't have the permission required
2139
- // {"status": "error", "reason": {"__all__": ["Minimum order size is 5.0 EUR."]}}
2140
- // reuse of a nonce gives: { status: 'error', reason: 'Invalid nonce', code: 'API0004' }
2141
- //
2142
- const status = this.safeString(response, 'status');
2143
- const error = this.safeValue(response, 'error');
2144
- if ((status === 'error') || (error !== undefined)) {
2145
- let errors$1 = [];
2146
- if (typeof error === 'string') {
2147
- errors$1.push(error);
2148
- }
2149
- else if (error !== undefined) {
2150
- const keys = Object.keys(error);
2151
- for (let i = 0; i < keys.length; i++) {
2152
- const key = keys[i];
2153
- const value = this.safeValue(error, key);
2154
- if (Array.isArray(value)) {
2155
- errors$1 = this.arrayConcat(errors$1, value);
2156
- }
2157
- else {
2158
- errors$1.push(value);
2159
- }
2160
- }
2161
- }
2162
- const reasonInner = this.safeValue(response, 'reason', {});
2163
- if (typeof reasonInner === 'string') {
2164
- errors$1.push(reasonInner);
2165
- }
2166
- else {
2167
- const all = this.safeValue(reasonInner, '__all__', []);
2168
- for (let i = 0; i < all.length; i++) {
2169
- errors$1.push(all[i]);
2170
- }
2171
- }
2172
- const code = this.safeString(response, 'code');
2173
- if (code === 'API0005') {
2174
- throw new errors.AuthenticationError(this.id + ' invalid signature, use the uid for the main account if you have subaccounts');
2175
- }
2176
- const feedback = this.id + ' ' + body;
2177
- for (let i = 0; i < errors$1.length; i++) {
2178
- const value = errors$1[i];
2179
- this.throwExactlyMatchedException(this.exceptions['exact'], value, feedback);
2180
- this.throwBroadlyMatchedException(this.exceptions['broad'], value, feedback);
2181
- }
2182
- throw new errors.ExchangeError(feedback);
2183
- }
2184
- return undefined;
2185
- }
2186
- }
2187
-
2188
- module.exports = bitstamp;