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,2891 +0,0 @@
1
- 'use strict';
2
-
3
- var kraken$1 = require('./abstract/kraken.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
- var sha512 = require('./static_dependencies/noble-hashes/sha512.js');
9
-
10
- // ---------------------------------------------------------------------------
11
- // ---------------------------------------------------------------------------
12
- /**
13
- * @class kraken
14
- * @augments Exchange
15
- */
16
- class kraken extends kraken$1 {
17
- describe() {
18
- return this.deepExtend(super.describe(), {
19
- 'id': 'kraken',
20
- 'name': 'Kraken',
21
- 'countries': ['US'],
22
- 'version': '0',
23
- 'rateLimit': 1000,
24
- 'certified': false,
25
- 'pro': true,
26
- 'has': {
27
- 'CORS': undefined,
28
- 'spot': true,
29
- 'margin': true,
30
- 'swap': false,
31
- 'future': false,
32
- 'option': false,
33
- 'addMargin': false,
34
- 'cancelAllOrders': true,
35
- 'cancelOrder': true,
36
- 'cancelOrders': true,
37
- 'createDepositAddress': true,
38
- 'createOrder': true,
39
- 'createStopLimitOrder': true,
40
- 'createStopMarketOrder': true,
41
- 'createStopOrder': true,
42
- 'createTrailingAmountOrder': true,
43
- 'editOrder': true,
44
- 'fetchBalance': true,
45
- 'fetchBorrowInterest': false,
46
- 'fetchBorrowRateHistories': false,
47
- 'fetchBorrowRateHistory': false,
48
- 'fetchClosedOrders': true,
49
- 'fetchCrossBorrowRate': false,
50
- 'fetchCrossBorrowRates': false,
51
- 'fetchCurrencies': true,
52
- 'fetchDepositAddress': true,
53
- 'fetchDeposits': true,
54
- 'fetchFundingHistory': false,
55
- 'fetchFundingRate': false,
56
- 'fetchFundingRateHistory': false,
57
- 'fetchFundingRates': false,
58
- 'fetchIndexOHLCV': false,
59
- 'fetchIsolatedBorrowRate': false,
60
- 'fetchIsolatedBorrowRates': false,
61
- 'fetchLedger': true,
62
- 'fetchLedgerEntry': true,
63
- 'fetchLeverageTiers': false,
64
- 'fetchMarkets': true,
65
- 'fetchMarkOHLCV': false,
66
- 'fetchMyTrades': true,
67
- 'fetchOHLCV': true,
68
- 'fetchOpenInterestHistory': false,
69
- 'fetchOpenOrders': true,
70
- 'fetchOrder': true,
71
- 'fetchOrderBook': true,
72
- 'fetchOrderTrades': 'emulated',
73
- 'fetchPositions': true,
74
- 'fetchPremiumIndexOHLCV': false,
75
- 'fetchTicker': true,
76
- 'fetchTickers': true,
77
- 'fetchTime': true,
78
- 'fetchTrades': true,
79
- 'fetchTradingFee': true,
80
- 'fetchTradingFees': false,
81
- 'fetchWithdrawals': true,
82
- 'setLeverage': false,
83
- 'setMarginMode': false,
84
- 'transfer': true,
85
- 'withdraw': true,
86
- },
87
- 'timeframes': {
88
- '1m': 1,
89
- '5m': 5,
90
- '15m': 15,
91
- '30m': 30,
92
- '1h': 60,
93
- '4h': 240,
94
- '1d': 1440,
95
- '1w': 10080,
96
- '2w': 21600,
97
- },
98
- 'urls': {
99
- 'logo': 'https://user-images.githubusercontent.com/51840849/76173629-fc67fb00-61b1-11ea-84fe-f2de582f58a3.jpg',
100
- 'api': {
101
- 'public': 'https://api.kraken.com',
102
- 'private': 'https://api.kraken.com',
103
- 'zendesk': 'https://kraken.zendesk.com/api/v2/help_center/en-us/articles', // use the public zendesk api to receive article bodies and bypass new anti-spam protections
104
- },
105
- 'www': 'https://www.kraken.com',
106
- 'doc': 'https://docs.kraken.com/rest/',
107
- 'fees': 'https://www.kraken.com/en-us/features/fee-schedule',
108
- },
109
- 'fees': {
110
- 'trading': {
111
- 'tierBased': true,
112
- 'percentage': true,
113
- 'taker': this.parseNumber('0.0026'),
114
- 'maker': this.parseNumber('0.0016'),
115
- 'tiers': {
116
- 'taker': [
117
- [this.parseNumber('0'), this.parseNumber('0.0026')],
118
- [this.parseNumber('50000'), this.parseNumber('0.0024')],
119
- [this.parseNumber('100000'), this.parseNumber('0.0022')],
120
- [this.parseNumber('250000'), this.parseNumber('0.0020')],
121
- [this.parseNumber('500000'), this.parseNumber('0.0018')],
122
- [this.parseNumber('1000000'), this.parseNumber('0.0016')],
123
- [this.parseNumber('2500000'), this.parseNumber('0.0014')],
124
- [this.parseNumber('5000000'), this.parseNumber('0.0012')],
125
- [this.parseNumber('10000000'), this.parseNumber('0.0001')],
126
- ],
127
- 'maker': [
128
- [this.parseNumber('0'), this.parseNumber('0.0016')],
129
- [this.parseNumber('50000'), this.parseNumber('0.0014')],
130
- [this.parseNumber('100000'), this.parseNumber('0.0012')],
131
- [this.parseNumber('250000'), this.parseNumber('0.0010')],
132
- [this.parseNumber('500000'), this.parseNumber('0.0008')],
133
- [this.parseNumber('1000000'), this.parseNumber('0.0006')],
134
- [this.parseNumber('2500000'), this.parseNumber('0.0004')],
135
- [this.parseNumber('5000000'), this.parseNumber('0.0002')],
136
- [this.parseNumber('10000000'), this.parseNumber('0.0')],
137
- ],
138
- },
139
- },
140
- },
141
- 'handleContentTypeApplicationZip': true,
142
- 'api': {
143
- 'zendesk': {
144
- 'get': [
145
- // we should really refrain from putting fixed fee numbers and stop hardcoding
146
- // we will be using their web APIs to scrape all numbers from these articles
147
- '360000292886',
148
- '201893608', // -What-are-the-withdrawal-fees-
149
- ],
150
- },
151
- 'public': {
152
- 'get': {
153
- // public endpoint rate-limits are described in article: https://support.kraken.com/hc/en-us/articles/206548367-What-are-the-API-rate-limits-#1
154
- 'Assets': 1,
155
- 'AssetPairs': 1,
156
- 'Depth': 1,
157
- 'OHLC': 1,
158
- 'Spread': 1,
159
- 'SystemStatus': 1,
160
- 'Ticker': 1,
161
- 'Time': 1,
162
- 'Trades': 1,
163
- },
164
- },
165
- 'private': {
166
- 'post': {
167
- 'AddOrder': 0,
168
- 'AddOrderBatch': 0,
169
- 'AddExport': 3,
170
- 'Balance': 3,
171
- 'CancelAll': 3,
172
- 'CancelAllOrdersAfter': 3,
173
- 'CancelOrder': 0,
174
- 'CancelOrderBatch': 0,
175
- 'ClosedOrders': 6,
176
- 'DepositAddresses': 3,
177
- 'DepositMethods': 3,
178
- 'DepositStatus': 3,
179
- 'EditOrder': 0,
180
- 'ExportStatus': 3,
181
- 'GetWebSocketsToken': 3,
182
- 'Ledgers': 6,
183
- 'OpenOrders': 3,
184
- 'OpenPositions': 3,
185
- 'QueryLedgers': 3,
186
- 'QueryOrders': 3,
187
- 'QueryTrades': 3,
188
- 'RetrieveExport': 3,
189
- 'RemoveExport': 3,
190
- 'BalanceEx': 3,
191
- 'TradeBalance': 3,
192
- 'TradesHistory': 6,
193
- 'TradeVolume': 3,
194
- 'Withdraw': 3,
195
- 'WithdrawCancel': 3,
196
- 'WithdrawInfo': 3,
197
- 'WithdrawMethods': 3,
198
- 'WithdrawAddresses': 3,
199
- 'WithdrawStatus': 3,
200
- 'WalletTransfer': 3,
201
- // sub accounts
202
- 'CreateSubaccount': 3,
203
- 'AccountTransfer': 3,
204
- // earn
205
- 'Earn/Allocate': 3,
206
- 'Earn/Deallocate': 3,
207
- 'Earn/AllocateStatus': 3,
208
- 'Earn/DeallocateStatus': 3,
209
- 'Earn/Strategies': 3,
210
- 'Earn/Allocations': 3,
211
- },
212
- },
213
- },
214
- 'commonCurrencies': {
215
- 'LUNA': 'LUNC',
216
- 'LUNA2': 'LUNA',
217
- 'REPV2': 'REP',
218
- 'REP': 'REPV1',
219
- 'UST': 'USTC',
220
- 'XBT': 'BTC',
221
- 'XBT.M': 'BTC.M',
222
- 'XDG': 'DOGE',
223
- },
224
- 'options': {
225
- 'marketsByAltname': {},
226
- 'delistedMarketsById': {},
227
- // cannot withdraw/deposit these
228
- 'inactiveCurrencies': ['CAD', 'USD', 'JPY', 'GBP'],
229
- 'networks': {
230
- 'ETH': 'ERC20',
231
- 'TRX': 'TRC20',
232
- },
233
- 'depositMethods': {
234
- '1INCH': '1inch (1INCH)',
235
- 'AAVE': 'Aave',
236
- 'ADA': 'ADA',
237
- 'ALGO': 'Algorand',
238
- 'ANKR': 'ANKR (ANKR)',
239
- 'ANT': 'Aragon (ANT)',
240
- 'ATOM': 'Cosmos',
241
- 'AXS': 'Axie Infinity Shards (AXS)',
242
- 'BADGER': 'Bager DAO (BADGER)',
243
- 'BAL': 'Balancer (BAL)',
244
- 'BAND': 'Band Protocol (BAND)',
245
- 'BAT': 'BAT',
246
- 'BCH': 'Bitcoin Cash',
247
- 'BNC': 'Bifrost (BNC)',
248
- 'BNT': 'Bancor (BNT)',
249
- 'BTC': 'Bitcoin',
250
- 'CHZ': 'Chiliz (CHZ)',
251
- 'COMP': 'Compound (COMP)',
252
- 'CQT': '\tCovalent Query Token (CQT)',
253
- 'CRV': 'Curve DAO Token (CRV)',
254
- 'CTSI': 'Cartesi (CTSI)',
255
- 'DAI': 'Dai',
256
- 'DASH': 'Dash',
257
- 'DOGE': 'Dogecoin',
258
- 'DOT': 'Polkadot',
259
- 'DYDX': 'dYdX (DYDX)',
260
- 'ENJ': 'Enjin Coin (ENJ)',
261
- 'EOS': 'EOS',
262
- 'ETC': 'Ether Classic (Hex)',
263
- 'ETH': 'Ether (Hex)',
264
- 'EWT': 'Energy Web Token',
265
- 'FEE': 'Kraken Fee Credit',
266
- 'FIL': 'Filecoin',
267
- 'FLOW': 'Flow',
268
- 'GHST': 'Aavegotchi (GHST)',
269
- 'GNO': 'GNO',
270
- 'GRT': 'GRT',
271
- 'ICX': 'Icon',
272
- 'INJ': 'Injective Protocol (INJ)',
273
- 'KAR': 'Karura (KAR)',
274
- 'KAVA': 'Kava',
275
- 'KEEP': 'Keep Token (KEEP)',
276
- 'KNC': 'Kyber Network (KNC)',
277
- 'KSM': 'Kusama',
278
- 'LINK': 'Link',
279
- 'LPT': 'Livepeer Token (LPT)',
280
- 'LRC': 'Loopring (LRC)',
281
- 'LSK': 'Lisk',
282
- 'LTC': 'Litecoin',
283
- 'MANA': 'MANA',
284
- 'MATIC': 'Polygon (MATIC)',
285
- 'MINA': 'Mina',
286
- 'MIR': 'Mirror Protocol (MIR)',
287
- 'MKR': 'Maker (MKR)',
288
- 'MLN': 'MLN',
289
- 'MOVR': 'Moonriver (MOVR)',
290
- 'NANO': 'NANO',
291
- 'OCEAN': 'OCEAN',
292
- 'OGN': 'Origin Protocol (OGN)',
293
- 'OMG': 'OMG',
294
- 'OXT': 'Orchid (OXT)',
295
- 'OXY': 'Oxygen (OXY)',
296
- 'PAXG': 'PAX (Gold)',
297
- 'PERP': 'Perpetual Protocol (PERP)',
298
- 'PHA': 'Phala (PHA)',
299
- 'QTUM': 'QTUM',
300
- 'RARI': 'Rarible (RARI)',
301
- 'RAY': 'Raydium (RAY)',
302
- 'REN': 'Ren Protocol (REN)',
303
- 'REP': 'REPv2',
304
- 'REPV1': 'REP',
305
- 'SAND': 'The Sandbox (SAND)',
306
- 'SC': 'Siacoin',
307
- 'SDN': 'Shiden (SDN)',
308
- 'SOL': 'Solana',
309
- 'SNX': 'Synthetix Network (SNX)',
310
- 'SRM': 'Serum',
311
- 'STORJ': 'Storj (STORJ)',
312
- 'SUSHI': 'Sushiswap (SUSHI)',
313
- 'TBTC': 'tBTC',
314
- 'TRX': 'Tron',
315
- 'UNI': 'UNI',
316
- 'USDC': 'USDC',
317
- 'USDT': 'Tether USD (ERC20)',
318
- 'USDT-TRC20': 'Tether USD (TRC20)',
319
- 'WAVES': 'Waves',
320
- 'WBTC': 'Wrapped Bitcoin (WBTC)',
321
- 'XLM': 'Stellar XLM',
322
- 'XMR': 'Monero',
323
- 'XRP': 'Ripple XRP',
324
- 'XTZ': 'XTZ',
325
- 'YFI': 'YFI',
326
- 'ZEC': 'Zcash (Transparent)',
327
- 'ZRX': '0x (ZRX)',
328
- },
329
- 'withdrawMethods': {
330
- 'Lightning': 'Lightning',
331
- 'Bitcoin': 'BTC',
332
- 'Ripple': 'XRP',
333
- 'Litecoin': 'LTC',
334
- 'Dogecoin': 'DOGE',
335
- 'Stellar': 'XLM',
336
- 'Ethereum': 'ERC20',
337
- 'Arbitrum One': 'Arbitrum',
338
- 'Polygon': 'MATIC',
339
- 'Arbitrum Nova': 'Arbitrum',
340
- 'Optimism': 'Optimism',
341
- 'zkSync Era': 'zkSync',
342
- 'Ethereum Classic': 'ETC',
343
- 'Zcash': 'ZEC',
344
- 'Monero': 'XMR',
345
- 'Tron': 'TRC20',
346
- 'Solana': 'SOL',
347
- 'EOS': 'EOS',
348
- 'Bitcoin Cash': 'BCH',
349
- 'Cardano': 'ADA',
350
- 'Qtum': 'QTUM',
351
- 'Tezos': 'XTZ',
352
- 'Cosmos': 'ATOM',
353
- 'Nano': 'NANO',
354
- 'Siacoin': 'SC',
355
- 'Lisk': 'LSK',
356
- 'Waves': 'WAVES',
357
- 'ICON': 'ICX',
358
- 'Algorand': 'ALGO',
359
- 'Polygon - USDC.e': 'MATIC',
360
- 'Arbitrum One - USDC.e': 'Arbitrum',
361
- 'Polkadot': 'DOT',
362
- 'Kava': 'KAVA',
363
- 'Filecoin': 'FIL',
364
- 'Kusama': 'KSM',
365
- 'Flow': 'FLOW',
366
- 'Energy Web': 'EW',
367
- 'Mina': 'MINA',
368
- 'Centrifuge': 'CFG',
369
- 'Karura': 'KAR',
370
- 'Moonriver': 'MOVR',
371
- 'Shiden': 'SDN',
372
- 'Khala': 'PHA',
373
- 'Bifrost Kusama': 'BNC',
374
- 'Songbird': 'SGB',
375
- 'Terra classic': 'LUNC',
376
- 'KILT': 'KILT',
377
- 'Basilisk': 'BSX',
378
- 'Flare': 'FLR',
379
- 'Avalanche C-Chain': 'AVAX',
380
- 'Kintsugi': 'KINT',
381
- 'Altair': 'AIR',
382
- 'Moonbeam': 'GLMR',
383
- 'Acala': 'ACA',
384
- 'Astar': 'ASTR',
385
- 'Akash': 'AKT',
386
- 'Robonomics': 'XRT',
387
- 'Fantom': 'FTM',
388
- 'Elrond': 'EGLD',
389
- 'THORchain': 'RUNE',
390
- 'Secret': 'SCRT',
391
- 'Near': 'NEAR',
392
- 'Internet Computer Protocol': 'ICP',
393
- 'Picasso': 'PICA',
394
- 'Crust Shadow': 'CSM',
395
- 'Integritee': 'TEER',
396
- 'Parallel Finance': 'PARA',
397
- 'HydraDX': 'HDX',
398
- 'Interlay': 'INTR',
399
- 'Fetch.ai': 'FET',
400
- 'NYM': 'NYM',
401
- 'Terra 2.0': 'LUNA2',
402
- 'Juno': 'JUNO',
403
- 'Nodle': 'NODL',
404
- 'Stacks': 'STX',
405
- 'Ethereum PoW': 'ETHW',
406
- 'Aptos': 'APT',
407
- 'Sui': 'SUI',
408
- 'Genshiro': 'GENS',
409
- 'Aventus': 'AVT',
410
- 'Sei': 'SEI',
411
- 'OriginTrail': 'OTP',
412
- 'Celestia': 'TIA',
413
- },
414
- },
415
- 'precisionMode': number.TICK_SIZE,
416
- 'exceptions': {
417
- 'EQuery:Invalid asset pair': errors.BadSymbol,
418
- 'EAPI:Invalid key': errors.AuthenticationError,
419
- 'EFunding:Unknown withdraw key': errors.InvalidAddress,
420
- 'EFunding:Invalid amount': errors.InsufficientFunds,
421
- 'EService:Unavailable': errors.ExchangeNotAvailable,
422
- 'EDatabase:Internal error': errors.ExchangeNotAvailable,
423
- 'EService:Busy': errors.ExchangeNotAvailable,
424
- 'EQuery:Unknown asset': errors.BadSymbol,
425
- 'EAPI:Rate limit exceeded': errors.DDoSProtection,
426
- 'EOrder:Rate limit exceeded': errors.DDoSProtection,
427
- 'EGeneral:Internal error': errors.ExchangeNotAvailable,
428
- 'EGeneral:Temporary lockout': errors.DDoSProtection,
429
- 'EGeneral:Permission denied': errors.PermissionDenied,
430
- 'EOrder:Unknown order': errors.InvalidOrder,
431
- 'EOrder:Order minimum not met': errors.InvalidOrder,
432
- 'EGeneral:Invalid arguments': errors.BadRequest,
433
- 'ESession:Invalid session': errors.AuthenticationError,
434
- 'EAPI:Invalid nonce': errors.InvalidNonce,
435
- 'EFunding:No funding method': errors.BadRequest,
436
- 'EFunding:Unknown asset': errors.BadSymbol,
437
- 'EService:Market in post_only mode': errors.OnMaintenance,
438
- 'EGeneral:Too many requests': errors.DDoSProtection,
439
- 'ETrade:User Locked': errors.AccountSuspended, // {"error":["ETrade:User Locked"]}
440
- },
441
- });
442
- }
443
- feeToPrecision(symbol, fee) {
444
- return this.decimalToPrecision(fee, number.TRUNCATE, this.markets[symbol]['precision']['amount'], this.precisionMode);
445
- }
446
- async fetchMarkets(params = {}) {
447
- /**
448
- * @method
449
- * @name kraken#fetchMarkets
450
- * @description retrieves data on all markets for kraken
451
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTradableAssetPairs
452
- * @param {object} [params] extra parameters specific to the exchange API endpoint
453
- * @returns {object[]} an array of objects representing market data
454
- */
455
- const response = await this.publicGetAssetPairs(params);
456
- //
457
- // {
458
- // "error": [],
459
- // "result": {
460
- // "ADAETH": {
461
- // "altname": "ADAETH",
462
- // "wsname": "ADA\/ETH",
463
- // "aclass_base": "currency",
464
- // "base": "ADA",
465
- // "aclass_quote": "currency",
466
- // "quote": "XETH",
467
- // "lot": "unit",
468
- // "pair_decimals": 7,
469
- // "lot_decimals": 8,
470
- // "lot_multiplier": 1,
471
- // "leverage_buy": [],
472
- // "leverage_sell": [],
473
- // "fees": [
474
- // [0, 0.26],
475
- // [50000, 0.24],
476
- // [100000, 0.22],
477
- // [250000, 0.2],
478
- // [500000, 0.18],
479
- // [1000000, 0.16],
480
- // [2500000, 0.14],
481
- // [5000000, 0.12],
482
- // [10000000, 0.1]
483
- // ],
484
- // "fees_maker": [
485
- // [0, 0.16],
486
- // [50000, 0.14],
487
- // [100000, 0.12],
488
- // [250000, 0.1],
489
- // [500000, 0.08],
490
- // [1000000, 0.06],
491
- // [2500000, 0.04],
492
- // [5000000, 0.02],
493
- // [10000000, 0]
494
- // ],
495
- // "fee_volume_currency": "ZUSD",
496
- // "margin_call": 80,
497
- // "margin_stop": 40,
498
- // "ordermin": "1"
499
- // },
500
- // }
501
- // }
502
- //
503
- const markets = this.safeValue(response, 'result', {});
504
- const keys = Object.keys(markets);
505
- let result = [];
506
- for (let i = 0; i < keys.length; i++) {
507
- const id = keys[i];
508
- const market = markets[id];
509
- const baseId = this.safeString(market, 'base');
510
- const quoteId = this.safeString(market, 'quote');
511
- const base = this.safeCurrencyCode(baseId);
512
- const quote = this.safeCurrencyCode(quoteId);
513
- const darkpool = id.indexOf('.d') >= 0;
514
- const altname = this.safeString(market, 'altname');
515
- const makerFees = this.safeValue(market, 'fees_maker', []);
516
- const firstMakerFee = this.safeValue(makerFees, 0, []);
517
- const firstMakerFeeRate = this.safeString(firstMakerFee, 1);
518
- let maker = undefined;
519
- if (firstMakerFeeRate !== undefined) {
520
- maker = this.parseNumber(Precise["default"].stringDiv(firstMakerFeeRate, '100'));
521
- }
522
- const takerFees = this.safeValue(market, 'fees', []);
523
- const firstTakerFee = this.safeValue(takerFees, 0, []);
524
- const firstTakerFeeRate = this.safeString(firstTakerFee, 1);
525
- let taker = undefined;
526
- if (firstTakerFeeRate !== undefined) {
527
- taker = this.parseNumber(Precise["default"].stringDiv(firstTakerFeeRate, '100'));
528
- }
529
- const leverageBuy = this.safeValue(market, 'leverage_buy', []);
530
- const leverageBuyLength = leverageBuy.length;
531
- const precisionPrice = this.parseNumber(this.parsePrecision(this.safeString(market, 'pair_decimals')));
532
- result.push({
533
- 'id': id,
534
- 'wsId': this.safeString(market, 'wsname'),
535
- 'symbol': darkpool ? altname : (base + '/' + quote),
536
- 'base': base,
537
- 'quote': quote,
538
- 'settle': undefined,
539
- 'baseId': baseId,
540
- 'quoteId': quoteId,
541
- 'settleId': undefined,
542
- 'darkpool': darkpool,
543
- 'altname': market['altname'],
544
- 'type': 'spot',
545
- 'spot': true,
546
- 'margin': (leverageBuyLength > 0),
547
- 'swap': false,
548
- 'future': false,
549
- 'option': false,
550
- 'active': true,
551
- 'contract': false,
552
- 'linear': undefined,
553
- 'inverse': undefined,
554
- 'taker': taker,
555
- 'maker': maker,
556
- 'contractSize': undefined,
557
- 'expiry': undefined,
558
- 'expiryDatetime': undefined,
559
- 'strike': undefined,
560
- 'optionType': undefined,
561
- 'precision': {
562
- 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'lot_decimals'))),
563
- 'price': precisionPrice,
564
- },
565
- 'limits': {
566
- 'leverage': {
567
- 'min': this.parseNumber('1'),
568
- 'max': this.safeNumber(leverageBuy, leverageBuyLength - 1, 1),
569
- },
570
- 'amount': {
571
- 'min': this.safeNumber(market, 'ordermin'),
572
- 'max': undefined,
573
- },
574
- 'price': {
575
- 'min': precisionPrice,
576
- 'max': undefined,
577
- },
578
- 'cost': {
579
- 'min': this.safeNumber(market, 'costmin'),
580
- 'max': undefined,
581
- },
582
- },
583
- 'created': undefined,
584
- 'info': market,
585
- });
586
- }
587
- result = this.appendInactiveMarkets(result);
588
- this.options['marketsByAltname'] = this.indexBy(result, 'altname');
589
- return result;
590
- }
591
- safeCurrency(currencyId, currency = undefined) {
592
- if (currencyId !== undefined) {
593
- if (currencyId.length > 3) {
594
- if ((currencyId.indexOf('X') === 0) || (currencyId.indexOf('Z') === 0)) {
595
- if (currencyId.indexOf('.') > 0) {
596
- return super.safeCurrency(currencyId, currency);
597
- }
598
- else {
599
- currencyId = currencyId.slice(1);
600
- }
601
- }
602
- }
603
- }
604
- return super.safeCurrency(currencyId, currency);
605
- }
606
- appendInactiveMarkets(result) {
607
- // result should be an array to append to
608
- const precision = {
609
- 'amount': this.parseNumber('1e-8'),
610
- 'price': this.parseNumber('1e-8'),
611
- };
612
- const costLimits = { 'min': undefined, 'max': undefined };
613
- const priceLimits = { 'min': precision['price'], 'max': undefined };
614
- const amountLimits = { 'min': precision['amount'], 'max': undefined };
615
- const limits = { 'amount': amountLimits, 'price': priceLimits, 'cost': costLimits };
616
- const defaults = {
617
- 'darkpool': false,
618
- 'info': undefined,
619
- 'maker': undefined,
620
- 'taker': undefined,
621
- 'active': false,
622
- 'precision': precision,
623
- 'limits': limits,
624
- };
625
- const markets = [
626
- // { 'id': 'XXLMZEUR', 'symbol': 'XLM/EUR', 'base': 'XLM', 'quote': 'EUR', 'altname': 'XLMEUR' },
627
- ];
628
- for (let i = 0; i < markets.length; i++) {
629
- result.push(this.extend(defaults, markets[i]));
630
- }
631
- return result;
632
- }
633
- async fetchCurrencies(params = {}) {
634
- /**
635
- * @method
636
- * @name kraken#fetchCurrencies
637
- * @description fetches all available currencies on an exchange
638
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getAssetInfo
639
- * @param {object} [params] extra parameters specific to the exchange API endpoint
640
- * @returns {object} an associative dictionary of currencies
641
- */
642
- const response = await this.publicGetAssets(params);
643
- //
644
- // {
645
- // "error": [],
646
- // "result": {
647
- // "ADA": { "aclass": "currency", "altname": "ADA", "decimals": 8, "display_decimals": 6 },
648
- // "BCH": { "aclass": "currency", "altname": "BCH", "decimals": 10, "display_decimals": 5 },
649
- // ...
650
- // },
651
- // }
652
- //
653
- const currencies = this.safeValue(response, 'result', {});
654
- const ids = Object.keys(currencies);
655
- const result = {};
656
- for (let i = 0; i < ids.length; i++) {
657
- const id = ids[i];
658
- const currency = currencies[id];
659
- // todo: will need to rethink the fees
660
- // see: https://support.kraken.com/hc/en-us/articles/201893608-What-are-the-withdrawal-fees-
661
- // to add support for multiple withdrawal/deposit methods and
662
- // differentiated fees for each particular method
663
- const code = this.safeCurrencyCode(this.safeString(currency, 'altname'));
664
- const precision = this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals')));
665
- // assumes all currencies are active except those listed above
666
- const active = !this.inArray(code, this.options['inactiveCurrencies']);
667
- result[code] = {
668
- 'id': id,
669
- 'code': code,
670
- 'info': currency,
671
- 'name': code,
672
- 'active': active,
673
- 'deposit': undefined,
674
- 'withdraw': undefined,
675
- 'fee': undefined,
676
- 'precision': precision,
677
- 'limits': {
678
- 'amount': {
679
- 'min': precision,
680
- 'max': undefined,
681
- },
682
- 'withdraw': {
683
- 'min': undefined,
684
- 'max': undefined,
685
- },
686
- },
687
- 'networks': {},
688
- };
689
- }
690
- return result;
691
- }
692
- async fetchTradingFee(symbol, params = {}) {
693
- /**
694
- * @method
695
- * @name kraken#fetchTradingFee
696
- * @description fetch the trading fees for a market
697
- * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getTradeVolume
698
- * @param {string} symbol unified market symbol
699
- * @param {object} [params] extra parameters specific to the exchange API endpoint
700
- * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
701
- */
702
- await this.loadMarkets();
703
- const market = this.market(symbol);
704
- const request = {
705
- 'pair': market['id'],
706
- 'fee-info': true,
707
- };
708
- const response = await this.privatePostTradeVolume(this.extend(request, params));
709
- //
710
- // {
711
- // "error": [],
712
- // "result": {
713
- // "currency": 'ZUSD',
714
- // "volume": '0.0000',
715
- // "fees": {
716
- // "XXBTZUSD": {
717
- // "fee": '0.2600',
718
- // "minfee": '0.1000',
719
- // "maxfee": '0.2600',
720
- // "nextfee": '0.2400',
721
- // "tiervolume": '0.0000',
722
- // "nextvolume": '50000.0000'
723
- // }
724
- // },
725
- // "fees_maker": {
726
- // "XXBTZUSD": {
727
- // "fee": '0.1600',
728
- // "minfee": '0.0000',
729
- // "maxfee": '0.1600',
730
- // "nextfee": '0.1400',
731
- // "tiervolume": '0.0000',
732
- // "nextvolume": '50000.0000'
733
- // }
734
- // }
735
- // }
736
- // }
737
- //
738
- const result = this.safeValue(response, 'result', {});
739
- return this.parseTradingFee(result, market);
740
- }
741
- parseTradingFee(response, market) {
742
- const makerFees = this.safeValue(response, 'fees_maker', {});
743
- const takerFees = this.safeValue(response, 'fees', {});
744
- const symbolMakerFee = this.safeValue(makerFees, market['id'], {});
745
- const symbolTakerFee = this.safeValue(takerFees, market['id'], {});
746
- return {
747
- 'info': response,
748
- 'symbol': market['symbol'],
749
- 'maker': this.safeNumber(symbolMakerFee, 'fee'),
750
- 'taker': this.safeNumber(symbolTakerFee, 'fee'),
751
- 'percentage': true,
752
- 'tierBased': true,
753
- };
754
- }
755
- parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
756
- const price = this.safeNumber(bidask, priceKey);
757
- const amount = this.safeNumber(bidask, amountKey);
758
- const timestamp = this.safeInteger(bidask, 2);
759
- return [price, amount, timestamp];
760
- }
761
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
762
- /**
763
- * @method
764
- * @name kraken#fetchOrderBook
765
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
766
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getOrderBook
767
- * @param {string} symbol unified symbol of the market to fetch the order book for
768
- * @param {int} [limit] the maximum amount of order book entries to return
769
- * @param {object} [params] extra parameters specific to the exchange API endpoint
770
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
771
- */
772
- await this.loadMarkets();
773
- const market = this.market(symbol);
774
- if (market['darkpool']) {
775
- throw new errors.ExchangeError(this.id + ' fetchOrderBook() does not provide an order book for darkpool symbol ' + symbol);
776
- }
777
- const request = {
778
- 'pair': market['id'],
779
- };
780
- if (limit !== undefined) {
781
- request['count'] = limit; // 100
782
- }
783
- const response = await this.publicGetDepth(this.extend(request, params));
784
- //
785
- // {
786
- // "error":[],
787
- // "result":{
788
- // "XETHXXBT":{
789
- // "asks":[
790
- // ["0.023480","4.000",1586321307],
791
- // ["0.023490","50.095",1586321306],
792
- // ["0.023500","28.535",1586321302],
793
- // ],
794
- // "bids":[
795
- // ["0.023470","59.580",1586321307],
796
- // ["0.023460","20.000",1586321301],
797
- // ["0.023440","67.832",1586321306],
798
- // ]
799
- // }
800
- // }
801
- // }
802
- //
803
- const result = this.safeValue(response, 'result', {});
804
- let orderbook = this.safeValue(result, market['id']);
805
- // sometimes kraken returns wsname instead of market id
806
- // https://github.com/ccxt/ccxt/issues/8662
807
- const marketInfo = this.safeValue(market, 'info', {});
808
- const wsName = this.safeValue(marketInfo, 'wsname');
809
- if (wsName !== undefined) {
810
- orderbook = this.safeValue(result, wsName, orderbook);
811
- }
812
- return this.parseOrderBook(orderbook, symbol);
813
- }
814
- parseTicker(ticker, market = undefined) {
815
- //
816
- // {
817
- // "a":["2432.77000","1","1.000"],
818
- // "b":["2431.37000","2","2.000"],
819
- // "c":["2430.58000","0.04408910"],
820
- // "v":["4147.94474901","8896.96086304"],
821
- // "p":["2456.22239","2568.63032"],
822
- // "t":[3907,10056],
823
- // "l":["2302.18000","2302.18000"],
824
- // "h":["2621.14000","2860.01000"],
825
- // "o":"2571.56000"
826
- // }
827
- //
828
- const symbol = this.safeSymbol(undefined, market);
829
- const v = this.safeValue(ticker, 'v', []);
830
- const baseVolume = this.safeString(v, 1);
831
- const p = this.safeValue(ticker, 'p', []);
832
- const vwap = this.safeString(p, 1);
833
- const quoteVolume = Precise["default"].stringMul(baseVolume, vwap);
834
- const c = this.safeValue(ticker, 'c', []);
835
- const last = this.safeString(c, 0);
836
- const high = this.safeValue(ticker, 'h', []);
837
- const low = this.safeValue(ticker, 'l', []);
838
- const bid = this.safeValue(ticker, 'b', []);
839
- const ask = this.safeValue(ticker, 'a', []);
840
- return this.safeTicker({
841
- 'symbol': symbol,
842
- 'timestamp': undefined,
843
- 'datetime': undefined,
844
- 'high': this.safeString(high, 1),
845
- 'low': this.safeString(low, 1),
846
- 'bid': this.safeString(bid, 0),
847
- 'bidVolume': undefined,
848
- 'ask': this.safeString(ask, 0),
849
- 'askVolume': undefined,
850
- 'vwap': vwap,
851
- 'open': this.safeString(ticker, 'o'),
852
- 'close': last,
853
- 'last': last,
854
- 'previousClose': undefined,
855
- 'change': undefined,
856
- 'percentage': undefined,
857
- 'average': undefined,
858
- 'baseVolume': baseVolume,
859
- 'quoteVolume': quoteVolume,
860
- 'info': ticker,
861
- }, market);
862
- }
863
- async fetchTickers(symbols = undefined, params = {}) {
864
- /**
865
- * @method
866
- * @name kraken#fetchTickers
867
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
868
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTickerInformation
869
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
870
- * @param {object} [params] extra parameters specific to the exchange API endpoint
871
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
872
- */
873
- await this.loadMarkets();
874
- const request = {};
875
- if (symbols !== undefined) {
876
- symbols = this.marketSymbols(symbols);
877
- const marketIds = [];
878
- for (let i = 0; i < symbols.length; i++) {
879
- const symbol = symbols[i];
880
- const market = this.markets[symbol];
881
- if (market['active'] && !market['darkpool']) {
882
- marketIds.push(market['id']);
883
- }
884
- }
885
- request['pair'] = marketIds.join(',');
886
- }
887
- const response = await this.publicGetTicker(this.extend(request, params));
888
- const tickers = response['result'];
889
- const ids = Object.keys(tickers);
890
- const result = {};
891
- for (let i = 0; i < ids.length; i++) {
892
- const id = ids[i];
893
- const market = this.safeMarket(id);
894
- const symbol = market['symbol'];
895
- const ticker = tickers[id];
896
- result[symbol] = this.parseTicker(ticker, market);
897
- }
898
- return this.filterByArrayTickers(result, 'symbol', symbols);
899
- }
900
- async fetchTicker(symbol, params = {}) {
901
- /**
902
- * @method
903
- * @name kraken#fetchTicker
904
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
905
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getTickerInformation
906
- * @param {string} symbol unified symbol of the market to fetch the ticker for
907
- * @param {object} [params] extra parameters specific to the exchange API endpoint
908
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
909
- */
910
- await this.loadMarkets();
911
- const darkpool = symbol.indexOf('.d') >= 0;
912
- if (darkpool) {
913
- throw new errors.ExchangeError(this.id + ' fetchTicker() does not provide a ticker for darkpool symbol ' + symbol);
914
- }
915
- const market = this.market(symbol);
916
- const request = {
917
- 'pair': market['id'],
918
- };
919
- const response = await this.publicGetTicker(this.extend(request, params));
920
- const ticker = response['result'][market['id']];
921
- return this.parseTicker(ticker, market);
922
- }
923
- parseOHLCV(ohlcv, market = undefined) {
924
- //
925
- // [
926
- // 1591475640,
927
- // "0.02500",
928
- // "0.02500",
929
- // "0.02500",
930
- // "0.02500",
931
- // "0.02500",
932
- // "9.12201000",
933
- // 5
934
- // ]
935
- //
936
- return [
937
- this.safeTimestamp(ohlcv, 0),
938
- this.safeNumber(ohlcv, 1),
939
- this.safeNumber(ohlcv, 2),
940
- this.safeNumber(ohlcv, 3),
941
- this.safeNumber(ohlcv, 4),
942
- this.safeNumber(ohlcv, 6),
943
- ];
944
- }
945
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
946
- /**
947
- * @method
948
- * @name kraken#fetchOHLCV
949
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
950
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getOHLCData
951
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
952
- * @param {string} timeframe the length of time each candle represents
953
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
954
- * @param {int} [limit] the maximum amount of candles to fetch
955
- * @param {object} [params] extra parameters specific to the exchange API endpoint
956
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
957
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
958
- */
959
- await this.loadMarkets();
960
- let paginate = false;
961
- [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
962
- if (paginate) {
963
- return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 720);
964
- }
965
- const market = this.market(symbol);
966
- const parsedTimeframe = this.safeInteger(this.timeframes, timeframe);
967
- const request = {
968
- 'pair': market['id'],
969
- };
970
- if (parsedTimeframe !== undefined) {
971
- request['interval'] = parsedTimeframe;
972
- }
973
- else {
974
- request['interval'] = timeframe;
975
- }
976
- if (since !== undefined) {
977
- request['since'] = this.parseToInt((since - 1) / 1000);
978
- }
979
- const response = await this.publicGetOHLC(this.extend(request, params));
980
- //
981
- // {
982
- // "error":[],
983
- // "result":{
984
- // "XETHXXBT":[
985
- // [1591475580,"0.02499","0.02499","0.02499","0.02499","0.00000","0.00000000",0],
986
- // [1591475640,"0.02500","0.02500","0.02500","0.02500","0.02500","9.12201000",5],
987
- // [1591475700,"0.02499","0.02499","0.02499","0.02499","0.02499","1.28681415",2],
988
- // [1591475760,"0.02499","0.02499","0.02499","0.02499","0.02499","0.08800000",1],
989
- // ],
990
- // "last":1591517580
991
- // }
992
- // }
993
- const result = this.safeValue(response, 'result', {});
994
- const ohlcvs = this.safeValue(result, market['id'], []);
995
- return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
996
- }
997
- parseLedgerEntryType(type) {
998
- const types = {
999
- 'trade': 'trade',
1000
- 'withdrawal': 'transaction',
1001
- 'deposit': 'transaction',
1002
- 'transfer': 'transfer',
1003
- 'margin': 'margin',
1004
- };
1005
- return this.safeString(types, type, type);
1006
- }
1007
- parseLedgerEntry(item, currency = undefined) {
1008
- //
1009
- // {
1010
- // 'LTFK7F-N2CUX-PNY4SX': {
1011
- // "refid": "TSJTGT-DT7WN-GPPQMJ",
1012
- // "time": 1520102320.555,
1013
- // "type": "trade",
1014
- // "aclass": "currency",
1015
- // "asset": "XETH",
1016
- // "amount": "0.1087194600",
1017
- // "fee": "0.0000000000",
1018
- // "balance": "0.2855851000"
1019
- // },
1020
- // ...
1021
- // }
1022
- //
1023
- const id = this.safeString(item, 'id');
1024
- let direction = undefined;
1025
- const account = undefined;
1026
- const referenceId = this.safeString(item, 'refid');
1027
- const referenceAccount = undefined;
1028
- const type = this.parseLedgerEntryType(this.safeString(item, 'type'));
1029
- const code = this.safeCurrencyCode(this.safeString(item, 'asset'), currency);
1030
- let amount = this.safeString(item, 'amount');
1031
- if (Precise["default"].stringLt(amount, '0')) {
1032
- direction = 'out';
1033
- amount = Precise["default"].stringAbs(amount);
1034
- }
1035
- else {
1036
- direction = 'in';
1037
- }
1038
- const timestamp = this.safeTimestamp(item, 'time');
1039
- return {
1040
- 'info': item,
1041
- 'id': id,
1042
- 'direction': direction,
1043
- 'account': account,
1044
- 'referenceId': referenceId,
1045
- 'referenceAccount': referenceAccount,
1046
- 'type': type,
1047
- 'currency': code,
1048
- 'amount': this.parseNumber(amount),
1049
- 'before': undefined,
1050
- 'after': this.safeNumber(item, 'balance'),
1051
- 'status': 'ok',
1052
- 'timestamp': timestamp,
1053
- 'datetime': this.iso8601(timestamp),
1054
- 'fee': {
1055
- 'cost': this.safeNumber(item, 'fee'),
1056
- 'currency': code,
1057
- },
1058
- };
1059
- }
1060
- async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1061
- /**
1062
- * @method
1063
- * @name kraken#fetchLedger
1064
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1065
- * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getLedgers
1066
- * @param {string} code unified currency code, default is undefined
1067
- * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1068
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1069
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1070
- * @param {int} [params.until] timestamp in ms of the latest ledger entry
1071
- * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1072
- */
1073
- // https://www.kraken.com/features/api#get-ledgers-info
1074
- await this.loadMarkets();
1075
- let request = {};
1076
- let currency = undefined;
1077
- if (code !== undefined) {
1078
- currency = this.currency(code);
1079
- request['asset'] = currency['id'];
1080
- }
1081
- if (since !== undefined) {
1082
- request['start'] = this.parseToInt(since / 1000);
1083
- }
1084
- [request, params] = this.handleUntilOption('end', request, params);
1085
- const response = await this.privatePostLedgers(this.extend(request, params));
1086
- // { error: [],
1087
- // "result": { ledger: { 'LPUAIB-TS774-UKHP7X': { refid: "A2B4HBV-L4MDIE-JU4N3N",
1088
- // "time": 1520103488.314,
1089
- // "type": "withdrawal",
1090
- // "aclass": "currency",
1091
- // "asset": "XETH",
1092
- // "amount": "-0.2805800000",
1093
- // "fee": "0.0050000000",
1094
- // "balance": "0.0000051000" },
1095
- const result = this.safeValue(response, 'result', {});
1096
- const ledger = this.safeValue(result, 'ledger', {});
1097
- const keys = Object.keys(ledger);
1098
- const items = [];
1099
- for (let i = 0; i < keys.length; i++) {
1100
- const key = keys[i];
1101
- const value = ledger[key];
1102
- value['id'] = key;
1103
- items.push(value);
1104
- }
1105
- return this.parseLedger(items, currency, since, limit);
1106
- }
1107
- async fetchLedgerEntriesByIds(ids, code = undefined, params = {}) {
1108
- // https://www.kraken.com/features/api#query-ledgers
1109
- await this.loadMarkets();
1110
- ids = ids.join(',');
1111
- const request = this.extend({
1112
- 'id': ids,
1113
- }, params);
1114
- const response = await this.privatePostQueryLedgers(request);
1115
- // { error: [],
1116
- // "result": { 'LPUAIB-TS774-UKHP7X': { refid: "A2B4HBV-L4MDIE-JU4N3N",
1117
- // "time": 1520103488.314,
1118
- // "type": "withdrawal",
1119
- // "aclass": "currency",
1120
- // "asset": "XETH",
1121
- // "amount": "-0.2805800000",
1122
- // "fee": "0.0050000000",
1123
- // "balance": "0.0000051000" } } }
1124
- const result = response['result'];
1125
- const keys = Object.keys(result);
1126
- const items = [];
1127
- for (let i = 0; i < keys.length; i++) {
1128
- const key = keys[i];
1129
- const value = result[key];
1130
- value['id'] = key;
1131
- items.push(value);
1132
- }
1133
- return this.parseLedger(items);
1134
- }
1135
- async fetchLedgerEntry(id, code = undefined, params = {}) {
1136
- const items = await this.fetchLedgerEntriesByIds([id], code, params);
1137
- return items[0];
1138
- }
1139
- parseTrade(trade, market = undefined) {
1140
- //
1141
- // fetchTrades (public)
1142
- //
1143
- // [
1144
- // "0.032310", // price
1145
- // "4.28169434", // amount
1146
- // 1541390792.763, // timestamp
1147
- // "s", // sell or buy
1148
- // "l", // limit or market
1149
- // ""
1150
- // ]
1151
- //
1152
- // fetchOrderTrades (private)
1153
- //
1154
- // {
1155
- // "id": 'TIMIRG-WUNNE-RRJ6GT', // injected from outside
1156
- // "ordertxid": 'OQRPN2-LRHFY-HIFA7D',
1157
- // "postxid": 'TKH2SE-M7IF5-CFI7LT',
1158
- // "pair": 'USDCUSDT',
1159
- // "time": 1586340086.457,
1160
- // "type": 'sell',
1161
- // "ordertype": 'market',
1162
- // "price": '0.99860000',
1163
- // "cost": '22.16892001',
1164
- // "fee": '0.04433784',
1165
- // "vol": '22.20000000',
1166
- // "margin": '0.00000000',
1167
- // "misc": ''
1168
- // }
1169
- //
1170
- let timestamp = undefined;
1171
- let side = undefined;
1172
- let type = undefined;
1173
- let price = undefined;
1174
- let amount = undefined;
1175
- let id = undefined;
1176
- let orderId = undefined;
1177
- let fee = undefined;
1178
- let symbol = undefined;
1179
- if (Array.isArray(trade)) {
1180
- timestamp = this.safeTimestamp(trade, 2);
1181
- side = (trade[3] === 's') ? 'sell' : 'buy';
1182
- type = (trade[4] === 'l') ? 'limit' : 'market';
1183
- price = this.safeString(trade, 0);
1184
- amount = this.safeString(trade, 1);
1185
- const tradeLength = trade.length;
1186
- if (tradeLength > 6) {
1187
- id = this.safeString(trade, 6); // artificially added as per #1794
1188
- }
1189
- }
1190
- else if (typeof trade === 'string') {
1191
- id = trade;
1192
- }
1193
- else if ('ordertxid' in trade) {
1194
- const marketId = this.safeString(trade, 'pair');
1195
- const foundMarket = this.findMarketByAltnameOrId(marketId);
1196
- if (foundMarket !== undefined) {
1197
- market = foundMarket;
1198
- }
1199
- else if (marketId !== undefined) {
1200
- // delisted market ids go here
1201
- market = this.getDelistedMarketById(marketId);
1202
- }
1203
- orderId = this.safeString(trade, 'ordertxid');
1204
- id = this.safeString2(trade, 'id', 'postxid');
1205
- timestamp = this.safeTimestamp(trade, 'time');
1206
- side = this.safeString(trade, 'type');
1207
- type = this.safeString(trade, 'ordertype');
1208
- price = this.safeString(trade, 'price');
1209
- amount = this.safeString(trade, 'vol');
1210
- if ('fee' in trade) {
1211
- let currency = undefined;
1212
- if (market !== undefined) {
1213
- currency = market['quote'];
1214
- }
1215
- fee = {
1216
- 'cost': this.safeString(trade, 'fee'),
1217
- 'currency': currency,
1218
- };
1219
- }
1220
- }
1221
- if (market !== undefined) {
1222
- symbol = market['symbol'];
1223
- }
1224
- const cost = this.safeString(trade, 'cost');
1225
- return this.safeTrade({
1226
- 'id': id,
1227
- 'order': orderId,
1228
- 'info': trade,
1229
- 'timestamp': timestamp,
1230
- 'datetime': this.iso8601(timestamp),
1231
- 'symbol': symbol,
1232
- 'type': type,
1233
- 'side': side,
1234
- 'takerOrMaker': undefined,
1235
- 'price': price,
1236
- 'amount': amount,
1237
- 'cost': cost,
1238
- 'fee': fee,
1239
- }, market);
1240
- }
1241
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1242
- /**
1243
- * @method
1244
- * @name kraken#fetchTrades
1245
- * @description get the list of most recent trades for a particular symbol
1246
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getRecentTrades
1247
- * @param {string} symbol unified symbol of the market to fetch trades for
1248
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
1249
- * @param {int} [limit] the maximum amount of trades to fetch
1250
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1251
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1252
- */
1253
- await this.loadMarkets();
1254
- const market = this.market(symbol);
1255
- const id = market['id'];
1256
- const request = {
1257
- 'pair': id,
1258
- };
1259
- // https://support.kraken.com/hc/en-us/articles/218198197-How-to-pull-all-trade-data-using-the-Kraken-REST-API
1260
- // https://github.com/ccxt/ccxt/issues/5677
1261
- if (since !== undefined) {
1262
- // php does not format it properly
1263
- // therefore we use string concatenation here
1264
- request['since'] = since * 1e6;
1265
- request['since'] = since.toString() + '000000'; // expected to be in nanoseconds
1266
- }
1267
- if (limit !== undefined) {
1268
- request['count'] = limit;
1269
- }
1270
- const response = await this.publicGetTrades(this.extend(request, params));
1271
- //
1272
- // {
1273
- // "error": [],
1274
- // "result": {
1275
- // "XETHXXBT": [
1276
- // ["0.032310","4.28169434",1541390792.763,"s","l",""]
1277
- // ],
1278
- // "last": "1541439421200678657"
1279
- // }
1280
- // }
1281
- //
1282
- const result = response['result'];
1283
- const trades = result[id];
1284
- // trades is a sorted array: last (most recent trade) goes last
1285
- const length = trades.length;
1286
- if (length <= 0) {
1287
- return [];
1288
- }
1289
- const lastTrade = trades[length - 1];
1290
- const lastTradeId = this.safeString(result, 'last');
1291
- lastTrade.push(lastTradeId);
1292
- return this.parseTrades(trades, market, since, limit);
1293
- }
1294
- parseBalance(response) {
1295
- const balances = this.safeValue(response, 'result', {});
1296
- const result = {
1297
- 'info': response,
1298
- 'timestamp': undefined,
1299
- 'datetime': undefined,
1300
- };
1301
- const currencyIds = Object.keys(balances);
1302
- for (let i = 0; i < currencyIds.length; i++) {
1303
- const currencyId = currencyIds[i];
1304
- const code = this.safeCurrencyCode(currencyId);
1305
- const balance = this.safeValue(balances, currencyId, {});
1306
- const account = this.account();
1307
- account['used'] = this.safeString(balance, 'hold_trade');
1308
- account['total'] = this.safeString(balance, 'balance');
1309
- result[code] = account;
1310
- }
1311
- return this.safeBalance(result);
1312
- }
1313
- async fetchBalance(params = {}) {
1314
- /**
1315
- * @method
1316
- * @name kraken#fetchBalance
1317
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
1318
- * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getExtendedBalance
1319
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1320
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1321
- */
1322
- await this.loadMarkets();
1323
- const response = await this.privatePostBalanceEx(params);
1324
- //
1325
- // {
1326
- // "error": [],
1327
- // "result": {
1328
- // "ZUSD": {
1329
- // "balance": 25435.21,
1330
- // "hold_trade": 8249.76
1331
- // },
1332
- // "XXBT": {
1333
- // "balance": 1.2435,
1334
- // "hold_trade": 0.8423
1335
- // }
1336
- // }
1337
- // }
1338
- //
1339
- return this.parseBalance(response);
1340
- }
1341
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1342
- /**
1343
- * @method
1344
- * @name kraken#createOrder
1345
- * @see https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
1346
- * @description create a trade order
1347
- * @param {string} symbol unified symbol of the market to create an order in
1348
- * @param {string} type 'market' or 'limit'
1349
- * @param {string} side 'buy' or 'sell'
1350
- * @param {float} amount how much of currency you want to trade in units of base currency
1351
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1352
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1353
- * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
1354
- * @param {bool} [params.reduceOnly] *margin only* indicates if this order is to reduce the size of a position
1355
- * @param {float} [params.stopLossPrice] *margin only* the price that a stop loss order is triggered at
1356
- * @param {float} [params.takeProfitPrice] *margin only* the price that a take profit order is triggered at
1357
- * @param {string} [params.trailingAmount] *margin only* the quote amount to trail away from the current market price
1358
- * @param {string} [params.trailingLimitAmount] *margin only* the quote amount away from the trailingAmount
1359
- * @param {string} [params.offset] *margin only* '+' or '-' whether you want the trailingLimitAmount value to be positive or negative, default is negative '-'
1360
- * @param {string} [params.trigger] *margin only* the activation price type, 'last' or 'index', default is 'last'
1361
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1362
- */
1363
- await this.loadMarkets();
1364
- const market = this.market(symbol);
1365
- const request = {
1366
- 'pair': market['id'],
1367
- 'type': side,
1368
- 'ordertype': type,
1369
- 'volume': this.amountToPrecision(symbol, amount),
1370
- };
1371
- const orderRequest = this.orderRequest('createOrder()', symbol, type, request, price, params);
1372
- const response = await this.privatePostAddOrder(this.extend(orderRequest[0], orderRequest[1]));
1373
- //
1374
- // {
1375
- // "error": [],
1376
- // "result": {
1377
- // "descr": { order: 'buy 0.02100000 ETHUSDT @ limit 330.00' },
1378
- // "txid": [ 'OEKVV2-IH52O-TPL6GZ' ]
1379
- // }
1380
- // }
1381
- //
1382
- const result = this.safeValue(response, 'result');
1383
- return this.parseOrder(result);
1384
- }
1385
- findMarketByAltnameOrId(id) {
1386
- const marketsByAltname = this.safeValue(this.options, 'marketsByAltname', {});
1387
- if (id in marketsByAltname) {
1388
- return marketsByAltname[id];
1389
- }
1390
- else {
1391
- return this.safeMarket(id);
1392
- }
1393
- }
1394
- getDelistedMarketById(id) {
1395
- if (id === undefined) {
1396
- return id;
1397
- }
1398
- let market = this.safeValue(this.options['delistedMarketsById'], id);
1399
- if (market !== undefined) {
1400
- return market;
1401
- }
1402
- const baseIdStart = 0;
1403
- let baseIdEnd = 3;
1404
- let quoteIdStart = 3;
1405
- let quoteIdEnd = 6;
1406
- if (id.length === 8) {
1407
- baseIdEnd = 4;
1408
- quoteIdStart = 4;
1409
- quoteIdEnd = 8;
1410
- }
1411
- else if (id.length === 7) {
1412
- baseIdEnd = 4;
1413
- quoteIdStart = 4;
1414
- quoteIdEnd = 7;
1415
- }
1416
- const baseId = id.slice(baseIdStart, baseIdEnd);
1417
- const quoteId = id.slice(quoteIdStart, quoteIdEnd);
1418
- const base = this.safeCurrencyCode(baseId);
1419
- const quote = this.safeCurrencyCode(quoteId);
1420
- const symbol = base + '/' + quote;
1421
- market = {
1422
- 'symbol': symbol,
1423
- 'base': base,
1424
- 'quote': quote,
1425
- 'baseId': baseId,
1426
- 'quoteId': quoteId,
1427
- };
1428
- this.options['delistedMarketsById'][id] = market;
1429
- return market;
1430
- }
1431
- parseOrderStatus(status) {
1432
- const statuses = {
1433
- 'pending': 'open',
1434
- 'open': 'open',
1435
- 'closed': 'closed',
1436
- 'canceled': 'canceled',
1437
- 'expired': 'expired',
1438
- };
1439
- return this.safeString(statuses, status, status);
1440
- }
1441
- parseOrderType(status) {
1442
- const statuses = {
1443
- 'take-profit': 'market',
1444
- 'stop-loss-limit': 'limit',
1445
- 'stop-loss': 'market',
1446
- 'take-profit-limit': 'limit',
1447
- 'trailing-stop-limit': 'limit',
1448
- };
1449
- return this.safeString(statuses, status, status);
1450
- }
1451
- parseOrder(order, market = undefined) {
1452
- //
1453
- // createOrder for regular orders
1454
- //
1455
- // {
1456
- // "descr": { order: 'buy 0.02100000 ETHUSDT @ limit 330.00' },
1457
- // "txid": [ 'OEKVV2-IH52O-TPL6GZ' ]
1458
- // }
1459
- // {
1460
- // "txid": [ "TX_ID_HERE" ],
1461
- // "descr": { "order":"buy 0.12345678 ETHEUR @ market" },
1462
- // }
1463
- //
1464
- //
1465
- // createOrder for stop orders
1466
- //
1467
- // {
1468
- // "txid":["OSILNC-VQI5Q-775ZDQ"],
1469
- // "descr":{"order":"sell 167.28002676 ADAXBT @ stop loss 0.00003280 -> limit 0.00003212"}
1470
- // }
1471
- //
1472
- //
1473
- // {
1474
- // "txid":["OVHMJV-BZW2V-6NZFWF"],
1475
- // "descr":{"order":"sell 0.00100000 ETHUSD @ stop loss 2677.00 -> limit 2577.00 with 5:1 leverage"}
1476
- // }
1477
- //
1478
- // editOrder
1479
- //
1480
- // {
1481
- // "status": "ok",
1482
- // "txid": "OAW2BO-7RWEK-PZY5UO",
1483
- // "originaltxid": "OXL6SS-UPNMC-26WBE7",
1484
- // "volume": "0.00075000",
1485
- // "price": "13500.0",
1486
- // "orders_cancelled": 1,
1487
- // "descr": {
1488
- // "order": "buy 0.00075000 XBTUSDT @ limit 13500.0"
1489
- // }
1490
- // }
1491
- // ws - createOrder
1492
- // {
1493
- // "descr": 'sell 0.00010000 XBTUSDT @ market',
1494
- // "event": 'addOrderStatus',
1495
- // "reqid": 1,
1496
- // "status": 'ok',
1497
- // "txid": 'OAVXZH-XIE54-JCYYDG'
1498
- // }
1499
- // ws - editOrder
1500
- // {
1501
- // "descr": "order edited price = 9000.00000000",
1502
- // "event": "editOrderStatus",
1503
- // "originaltxid": "O65KZW-J4AW3-VFS74A",
1504
- // "reqid": 3,
1505
- // "status": "ok",
1506
- // "txid": "OTI672-HJFAO-XOIPPK"
1507
- // }
1508
- //
1509
- const description = this.safeValue(order, 'descr', {});
1510
- const orderDescription = this.safeString(description, 'order', description);
1511
- let side = undefined;
1512
- let type = undefined;
1513
- let marketId = undefined;
1514
- let price = undefined;
1515
- let amount = undefined;
1516
- let stopPrice = undefined;
1517
- if (orderDescription !== undefined) {
1518
- const parts = orderDescription.split(' ');
1519
- side = this.safeString(parts, 0);
1520
- amount = this.safeString(parts, 1);
1521
- marketId = this.safeString(parts, 2);
1522
- type = this.safeString(parts, 4);
1523
- if (type === 'stop') {
1524
- stopPrice = this.safeString(parts, 6);
1525
- price = this.safeString(parts, 9);
1526
- }
1527
- else if (type === 'limit') {
1528
- price = this.safeString(parts, 5);
1529
- }
1530
- }
1531
- side = this.safeString(description, 'type', side);
1532
- type = this.safeString(description, 'ordertype', type);
1533
- marketId = this.safeString(description, 'pair', marketId);
1534
- const foundMarket = this.findMarketByAltnameOrId(marketId);
1535
- let symbol = undefined;
1536
- if (foundMarket !== undefined) {
1537
- market = foundMarket;
1538
- }
1539
- else if (marketId !== undefined) {
1540
- // delisted market ids go here
1541
- market = this.getDelistedMarketById(marketId);
1542
- }
1543
- const timestamp = this.safeTimestamp(order, 'opentm');
1544
- amount = this.safeString(order, 'vol', amount);
1545
- const filled = this.safeString(order, 'vol_exec');
1546
- let fee = undefined;
1547
- // kraken truncates the cost in the api response so we will ignore it and calculate it from average & filled
1548
- // const cost = this.safeString (order, 'cost');
1549
- price = this.safeString(description, 'price', price);
1550
- if ((price === undefined) || Precise["default"].stringEquals(price, '0')) {
1551
- price = this.safeString(description, 'price2');
1552
- }
1553
- if ((price === undefined) || Precise["default"].stringEquals(price, '0')) {
1554
- price = this.safeString(order, 'price', price);
1555
- }
1556
- const flags = this.safeString(order, 'oflags', '');
1557
- const isPostOnly = flags.indexOf('post') > -1;
1558
- const average = this.safeNumber(order, 'price');
1559
- if (market !== undefined) {
1560
- symbol = market['symbol'];
1561
- if ('fee' in order) {
1562
- const feeCost = this.safeString(order, 'fee');
1563
- fee = {
1564
- 'cost': feeCost,
1565
- 'rate': undefined,
1566
- };
1567
- if (flags.indexOf('fciq') >= 0) {
1568
- fee['currency'] = market['quote'];
1569
- }
1570
- else if (flags.indexOf('fcib') >= 0) {
1571
- fee['currency'] = market['base'];
1572
- }
1573
- }
1574
- }
1575
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
1576
- let id = this.safeString2(order, 'id', 'txid');
1577
- if ((id === undefined) || (id.slice(0, 1) === '[')) {
1578
- const txid = this.safeValue(order, 'txid');
1579
- id = this.safeString(txid, 0);
1580
- }
1581
- const clientOrderId = this.safeString(order, 'userref');
1582
- const rawTrades = this.safeValue(order, 'trades', []);
1583
- const trades = [];
1584
- for (let i = 0; i < rawTrades.length; i++) {
1585
- const rawTrade = rawTrades[i];
1586
- if (typeof rawTrade === 'string') {
1587
- trades.push(this.safeTrade({ 'id': rawTrade, 'orderId': id, 'symbol': symbol, 'info': {} }));
1588
- }
1589
- else {
1590
- trades.push(rawTrade);
1591
- }
1592
- }
1593
- stopPrice = this.omitZero(this.safeString(order, 'stopprice', stopPrice));
1594
- let stopLossPrice = undefined;
1595
- let takeProfitPrice = undefined;
1596
- if (type.startsWith('take-profit')) {
1597
- takeProfitPrice = this.safeString(description, 'price');
1598
- price = this.omitZero(this.safeString(description, 'price2'));
1599
- }
1600
- else if (type.startsWith('stop-loss')) {
1601
- stopLossPrice = this.safeString(description, 'price');
1602
- price = this.omitZero(this.safeString(description, 'price2'));
1603
- }
1604
- return this.safeOrder({
1605
- 'id': id,
1606
- 'clientOrderId': clientOrderId,
1607
- 'info': order,
1608
- 'timestamp': timestamp,
1609
- 'datetime': this.iso8601(timestamp),
1610
- 'lastTradeTimestamp': undefined,
1611
- 'status': status,
1612
- 'symbol': symbol,
1613
- 'type': this.parseOrderType(type),
1614
- 'timeInForce': undefined,
1615
- 'postOnly': isPostOnly,
1616
- 'side': side,
1617
- 'price': price,
1618
- 'stopPrice': stopPrice,
1619
- 'triggerPrice': stopPrice,
1620
- 'takeProfitPrice': takeProfitPrice,
1621
- 'stopLossPrice': stopLossPrice,
1622
- 'cost': undefined,
1623
- 'amount': amount,
1624
- 'filled': filled,
1625
- 'average': average,
1626
- 'remaining': undefined,
1627
- 'fee': fee,
1628
- 'trades': trades,
1629
- }, market);
1630
- }
1631
- orderRequest(method, symbol, type, request, price = undefined, params = {}) {
1632
- const clientOrderId = this.safeString2(params, 'userref', 'clientOrderId');
1633
- params = this.omit(params, ['userref', 'clientOrderId']);
1634
- if (clientOrderId !== undefined) {
1635
- request['userref'] = clientOrderId;
1636
- }
1637
- const stopLossTriggerPrice = this.safeString(params, 'stopLossPrice');
1638
- const takeProfitTriggerPrice = this.safeString(params, 'takeProfitPrice');
1639
- const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
1640
- const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
1641
- const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
1642
- const trailingAmount = this.safeString(params, 'trailingAmount');
1643
- const trailingLimitAmount = this.safeString(params, 'trailingLimitAmount');
1644
- const isTrailingAmountOrder = trailingAmount !== undefined;
1645
- const isLimitOrder = type.endsWith('limit'); // supporting limit, stop-loss-limit, take-profit-limit, etc
1646
- if (isLimitOrder && !isTrailingAmountOrder) {
1647
- request['price'] = this.priceToPrecision(symbol, price);
1648
- }
1649
- const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
1650
- if (isStopLossOrTakeProfitTrigger) {
1651
- if (isStopLossTriggerOrder) {
1652
- request['price'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
1653
- if (isLimitOrder) {
1654
- request['ordertype'] = 'stop-loss-limit';
1655
- }
1656
- else {
1657
- request['ordertype'] = 'stop-loss';
1658
- }
1659
- }
1660
- else if (isTakeProfitTriggerOrder) {
1661
- request['price'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
1662
- if (isLimitOrder) {
1663
- request['ordertype'] = 'take-profit-limit';
1664
- }
1665
- else {
1666
- request['ordertype'] = 'take-profit';
1667
- }
1668
- }
1669
- if (isLimitOrder) {
1670
- request['price2'] = this.priceToPrecision(symbol, price);
1671
- }
1672
- }
1673
- else if (isTrailingAmountOrder) {
1674
- const trailingActivationPriceType = this.safeString(params, 'trigger', 'last');
1675
- const trailingAmountString = '+' + trailingAmount;
1676
- request['trigger'] = trailingActivationPriceType;
1677
- if (isLimitOrder || (trailingLimitAmount !== undefined)) {
1678
- const offset = this.safeString(params, 'offset', '-');
1679
- const trailingLimitAmountString = offset + this.numberToString(trailingLimitAmount);
1680
- request['price'] = trailingAmountString;
1681
- request['price2'] = trailingLimitAmountString;
1682
- request['ordertype'] = 'trailing-stop-limit';
1683
- }
1684
- else {
1685
- request['price'] = trailingAmountString;
1686
- request['ordertype'] = 'trailing-stop';
1687
- }
1688
- }
1689
- if (reduceOnly) {
1690
- request['reduce_only'] = 'true'; // not using boolean in this case, because the urlencodedNested transforms it into 'True' string
1691
- }
1692
- let close = this.safeValue(params, 'close');
1693
- if (close !== undefined) {
1694
- close = this.extend({}, close);
1695
- const closePrice = this.safeValue(close, 'price');
1696
- if (closePrice !== undefined) {
1697
- close['price'] = this.priceToPrecision(symbol, closePrice);
1698
- }
1699
- const closePrice2 = this.safeValue(close, 'price2'); // stopPrice
1700
- if (closePrice2 !== undefined) {
1701
- close['price2'] = this.priceToPrecision(symbol, closePrice2);
1702
- }
1703
- request['close'] = close;
1704
- }
1705
- const timeInForce = this.safeString2(params, 'timeInForce', 'timeinforce');
1706
- if (timeInForce !== undefined) {
1707
- request['timeinforce'] = timeInForce;
1708
- }
1709
- const isMarket = (type === 'market');
1710
- let postOnly = undefined;
1711
- [postOnly, params] = this.handlePostOnly(isMarket, false, params);
1712
- if (postOnly) {
1713
- request['oflags'] = 'post';
1714
- }
1715
- params = this.omit(params, ['timeInForce', 'reduceOnly', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingLimitAmount', 'offset']);
1716
- return [request, params];
1717
- }
1718
- async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1719
- /**
1720
- * @method
1721
- * @name kraken#editOrder
1722
- * @description edit a trade order
1723
- * @see https://docs.kraken.com/rest/#tag/Trading/operation/editOrder
1724
- * @param {string} id order id
1725
- * @param {string} symbol unified symbol of the market to create an order in
1726
- * @param {string} type 'market' or 'limit'
1727
- * @param {string} side 'buy' or 'sell'
1728
- * @param {float} amount how much of the currency you want to trade in units of the base currency
1729
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1730
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1731
- * @param {float} [params.stopLossPrice] *margin only* the price that a stop loss order is triggered at
1732
- * @param {float} [params.takeProfitPrice] *margin only* the price that a take profit order is triggered at
1733
- * @param {string} [params.trailingAmount] *margin only* the quote price away from the current market price
1734
- * @param {string} [params.trailingLimitAmount] *margin only* the quote amount away from the trailingAmount
1735
- * @param {string} [params.offset] *margin only* '+' or '-' whether you want the trailingLimitAmount value to be positive or negative, default is negative '-'
1736
- * @param {string} [params.trigger] *margin only* the activation price type, 'last' or 'index', default is 'last'
1737
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1738
- */
1739
- await this.loadMarkets();
1740
- const market = this.market(symbol);
1741
- if (!market['spot']) {
1742
- throw new errors.NotSupported(this.id + ' editOrder() does not support ' + market['type'] + ' orders, only spot orders are accepted');
1743
- }
1744
- const request = {
1745
- 'txid': id,
1746
- 'pair': market['id'],
1747
- };
1748
- if (amount !== undefined) {
1749
- request['volume'] = this.amountToPrecision(symbol, amount);
1750
- }
1751
- const orderRequest = this.orderRequest('editOrder()', symbol, type, request, price, params);
1752
- const response = await this.privatePostEditOrder(this.extend(orderRequest[0], orderRequest[1]));
1753
- //
1754
- // {
1755
- // "error": [],
1756
- // "result": {
1757
- // "status": "ok",
1758
- // "txid": "OAW2BO-7RWEK-PZY5UO",
1759
- // "originaltxid": "OXL6SS-UPNMC-26WBE7",
1760
- // "volume": "0.00075000",
1761
- // "price": "13500.0",
1762
- // "orders_cancelled": 1,
1763
- // "descr": {
1764
- // "order": "buy 0.00075000 XBTUSDT @ limit 13500.0"
1765
- // }
1766
- // }
1767
- // }
1768
- //
1769
- const data = this.safeValue(response, 'result', {});
1770
- return this.parseOrder(data, market);
1771
- }
1772
- async fetchOrder(id, symbol = undefined, params = {}) {
1773
- /**
1774
- * @method
1775
- * @name kraken#fetchOrder
1776
- * @description fetches information on an order made by the user
1777
- * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getOrdersInfo
1778
- * @param {string} symbol not used by kraken fetchOrder
1779
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1780
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1781
- */
1782
- await this.loadMarkets();
1783
- const clientOrderId = this.safeValue2(params, 'userref', 'clientOrderId');
1784
- const request = {
1785
- 'trades': true, // whether or not to include trades in output (optional, default false)
1786
- // 'txid': id, // do not comma separate a list of ids - use fetchOrdersByIds instead
1787
- // 'userref': 'optional', // restrict results to given user reference id (optional)
1788
- };
1789
- let query = params;
1790
- if (clientOrderId !== undefined) {
1791
- request['userref'] = clientOrderId;
1792
- query = this.omit(params, ['userref', 'clientOrderId']);
1793
- }
1794
- else {
1795
- request['txid'] = id;
1796
- }
1797
- const response = await this.privatePostQueryOrders(this.extend(request, query));
1798
- //
1799
- // {
1800
- // "error":[],
1801
- // "result":{
1802
- // "OTLAS3-RRHUF-NDWH5A":{
1803
- // "refid":null,
1804
- // "userref":null,
1805
- // "status":"closed",
1806
- // "reason":null,
1807
- // "opentm":1586822919.3342,
1808
- // "closetm":1586822919.365,
1809
- // "starttm":0,
1810
- // "expiretm":0,
1811
- // "descr":{
1812
- // "pair":"XBTUSDT",
1813
- // "type":"sell",
1814
- // "ordertype":"market",
1815
- // "price":"0",
1816
- // "price2":"0",
1817
- // "leverage":"none",
1818
- // "order":"sell 0.21804000 XBTUSDT @ market",
1819
- // "close":""
1820
- // },
1821
- // "vol":"0.21804000",
1822
- // "vol_exec":"0.21804000",
1823
- // "cost":"1493.9",
1824
- // "fee":"3.8",
1825
- // "price":"6851.5",
1826
- // "stopprice":"0.00000",
1827
- // "limitprice":"0.00000",
1828
- // "misc":"",
1829
- // "oflags":"fciq",
1830
- // "trades":["TT5UC3-GOIRW-6AZZ6R"]
1831
- // }
1832
- // }
1833
- // }
1834
- //
1835
- const result = this.safeValue(response, 'result', []);
1836
- if (!(id in result)) {
1837
- throw new errors.OrderNotFound(this.id + ' fetchOrder() could not find order id ' + id);
1838
- }
1839
- return this.parseOrder(this.extend({ 'id': id }, result[id]));
1840
- }
1841
- async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
1842
- /**
1843
- * @method
1844
- * @name kraken#fetchOrderTrades
1845
- * @description fetch all the trades made from a single order
1846
- * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getTradesInfo
1847
- * @param {string} id order id
1848
- * @param {string} symbol unified market symbol
1849
- * @param {int} [since] the earliest time in ms to fetch trades for
1850
- * @param {int} [limit] the maximum number of trades to retrieve
1851
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1852
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1853
- */
1854
- const orderTrades = this.safeValue(params, 'trades');
1855
- const tradeIds = [];
1856
- if (orderTrades === undefined) {
1857
- throw new errors.ArgumentsRequired(this.id + " fetchOrderTrades() requires a unified order structure in the params argument or a 'trades' param (an array of trade id strings)");
1858
- }
1859
- else {
1860
- for (let i = 0; i < orderTrades.length; i++) {
1861
- const orderTrade = orderTrades[i];
1862
- if (typeof orderTrade === 'string') {
1863
- tradeIds.push(orderTrade);
1864
- }
1865
- else {
1866
- tradeIds.push(orderTrade['id']);
1867
- }
1868
- }
1869
- }
1870
- await this.loadMarkets();
1871
- if (symbol !== undefined) {
1872
- symbol = this.symbol(symbol);
1873
- }
1874
- const options = this.safeValue(this.options, 'fetchOrderTrades', {});
1875
- const batchSize = this.safeInteger(options, 'batchSize', 20);
1876
- const numTradeIds = tradeIds.length;
1877
- let numBatches = this.parseToInt(numTradeIds / batchSize);
1878
- numBatches = this.sum(numBatches, 1);
1879
- let result = [];
1880
- for (let j = 0; j < numBatches; j++) {
1881
- const requestIds = [];
1882
- for (let k = 0; k < batchSize; k++) {
1883
- const index = this.sum(j * batchSize, k);
1884
- if (index < numTradeIds) {
1885
- requestIds.push(tradeIds[index]);
1886
- }
1887
- }
1888
- const request = {
1889
- 'txid': requestIds.join(','),
1890
- };
1891
- const response = await this.privatePostQueryTrades(request);
1892
- //
1893
- // {
1894
- // "error": [],
1895
- // "result": {
1896
- // 'TIMIRG-WUNNE-RRJ6GT': {
1897
- // "ordertxid": 'OQRPN2-LRHFY-HIFA7D',
1898
- // "postxid": 'TKH2SE-M7IF5-CFI7LT',
1899
- // "pair": 'USDCUSDT',
1900
- // "time": 1586340086.457,
1901
- // "type": 'sell',
1902
- // "ordertype": 'market',
1903
- // "price": '0.99860000',
1904
- // "cost": '22.16892001',
1905
- // "fee": '0.04433784',
1906
- // "vol": '22.20000000',
1907
- // "margin": '0.00000000',
1908
- // "misc": ''
1909
- // }
1910
- // }
1911
- // }
1912
- //
1913
- const rawTrades = this.safeValue(response, 'result');
1914
- const ids = Object.keys(rawTrades);
1915
- for (let i = 0; i < ids.length; i++) {
1916
- rawTrades[ids[i]]['id'] = ids[i];
1917
- }
1918
- const trades = this.parseTrades(rawTrades, undefined, since, limit);
1919
- const tradesFilteredBySymbol = this.filterBySymbol(trades, symbol);
1920
- result = this.arrayConcat(result, tradesFilteredBySymbol);
1921
- }
1922
- return result;
1923
- }
1924
- async fetchOrdersByIds(ids, symbol = undefined, params = {}) {
1925
- /**
1926
- * @method
1927
- * @name kraken#fetchOrdersByIds
1928
- * @description fetch orders by the list of order id
1929
- * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getClosedOrders
1930
- * @param {string[]|undefined} ids list of order id
1931
- * @param {object} [params] extra parameters specific to the kraken api endpoint
1932
- * @returns {object[]} a list of [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1933
- */
1934
- await this.loadMarkets();
1935
- const response = await this.privatePostQueryOrders(this.extend({
1936
- 'trades': true,
1937
- 'txid': ids.join(','), // comma delimited list of transaction ids to query info about (20 maximum)
1938
- }, params));
1939
- const result = this.safeValue(response, 'result', {});
1940
- const orders = [];
1941
- const orderIds = Object.keys(result);
1942
- for (let i = 0; i < orderIds.length; i++) {
1943
- const id = orderIds[i];
1944
- const item = result[id];
1945
- const order = this.parseOrder(this.extend({ 'id': id }, item));
1946
- orders.push(order);
1947
- }
1948
- return orders;
1949
- }
1950
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1951
- /**
1952
- * @method
1953
- * @name kraken#fetchMyTrades
1954
- * @description fetch all trades made by the user
1955
- * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getTradeHistory
1956
- * @param {string} symbol unified market symbol
1957
- * @param {int} [since] the earliest time in ms to fetch trades for
1958
- * @param {int} [limit] the maximum number of trades structures to retrieve
1959
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1960
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1961
- */
1962
- await this.loadMarkets();
1963
- const request = {
1964
- // 'type': 'all', // any position, closed position, closing position, no position
1965
- // 'trades': false, // whether or not to include trades related to position in output
1966
- // 'start': 1234567890, // starting unix timestamp or trade tx id of results (exclusive)
1967
- // 'end': 1234567890, // ending unix timestamp or trade tx id of results (inclusive)
1968
- // 'ofs' = result offset
1969
- };
1970
- if (since !== undefined) {
1971
- request['start'] = this.parseToInt(since / 1000);
1972
- }
1973
- const response = await this.privatePostTradesHistory(this.extend(request, params));
1974
- //
1975
- // {
1976
- // "error": [],
1977
- // "result": {
1978
- // "trades": {
1979
- // "GJ3NYQ-XJRTF-THZABF": {
1980
- // "ordertxid": "TKH2SE-ZIF5E-CFI7LT",
1981
- // "postxid": "OEN3VX-M7IF5-JNBJAM",
1982
- // "pair": "XICNXETH",
1983
- // "time": 1527213229.4491,
1984
- // "type": "sell",
1985
- // "ordertype": "limit",
1986
- // "price": "0.001612",
1987
- // "cost": "0.025792",
1988
- // "fee": "0.000026",
1989
- // "vol": "16.00000000",
1990
- // "margin": "0.000000",
1991
- // "misc": ""
1992
- // },
1993
- // ...
1994
- // },
1995
- // "count": 9760,
1996
- // },
1997
- // }
1998
- //
1999
- const trades = response['result']['trades'];
2000
- const ids = Object.keys(trades);
2001
- for (let i = 0; i < ids.length; i++) {
2002
- trades[ids[i]]['id'] = ids[i];
2003
- }
2004
- let market = undefined;
2005
- if (symbol !== undefined) {
2006
- market = this.market(symbol);
2007
- }
2008
- return this.parseTrades(trades, market, since, limit);
2009
- }
2010
- async cancelOrder(id, symbol = undefined, params = {}) {
2011
- /**
2012
- * @method
2013
- * @name kraken#cancelOrder
2014
- * @description cancels an open order
2015
- * @see https://docs.kraken.com/rest/#tag/Trading/operation/cancelOrder
2016
- * @param {string} id order id
2017
- * @param {string} symbol unified symbol of the market the order was made in
2018
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2019
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2020
- */
2021
- await this.loadMarkets();
2022
- let response = undefined;
2023
- const clientOrderId = this.safeValue2(params, 'userref', 'clientOrderId', id);
2024
- const request = {
2025
- 'txid': clientOrderId, // order id or userref
2026
- };
2027
- params = this.omit(params, ['userref', 'clientOrderId']);
2028
- try {
2029
- response = await this.privatePostCancelOrder(this.extend(request, params));
2030
- }
2031
- catch (e) {
2032
- if (this.last_http_response) {
2033
- if (this.last_http_response.indexOf('EOrder:Unknown order') >= 0) {
2034
- throw new errors.OrderNotFound(this.id + ' cancelOrder() error ' + this.last_http_response);
2035
- }
2036
- }
2037
- throw e;
2038
- }
2039
- return response;
2040
- }
2041
- async cancelOrders(ids, symbol = undefined, params = {}) {
2042
- /**
2043
- * @method
2044
- * @name kraken#cancelOrders
2045
- * @description cancel multiple orders
2046
- * @see https://docs.kraken.com/rest/#tag/Trading/operation/cancelOrderBatch
2047
- * @param {string[]} ids open orders transaction ID (txid) or user reference (userref)
2048
- * @param {string} symbol unified market symbol
2049
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2050
- * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2051
- */
2052
- const request = {
2053
- 'orders': ids,
2054
- };
2055
- const response = await this.privatePostCancelOrderBatch(this.extend(request, params));
2056
- //
2057
- // {
2058
- // "error": [],
2059
- // "result": {
2060
- // "count": 2
2061
- // }
2062
- // }
2063
- //
2064
- return response;
2065
- }
2066
- async cancelAllOrders(symbol = undefined, params = {}) {
2067
- /**
2068
- * @method
2069
- * @name kraken#cancelAllOrders
2070
- * @description cancel all open orders
2071
- * @see https://docs.kraken.com/rest/#tag/Trading/operation/cancelAllOrders
2072
- * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2073
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2074
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2075
- */
2076
- await this.loadMarkets();
2077
- return await this.privatePostCancelAll(params);
2078
- }
2079
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2080
- /**
2081
- * @method
2082
- * @name kraken#fetchOpenOrders
2083
- * @description fetch all unfilled currently open orders
2084
- * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenOrders
2085
- * @param {string} symbol unified market symbol
2086
- * @param {int} [since] the earliest time in ms to fetch open orders for
2087
- * @param {int} [limit] the maximum number of open orders structures to retrieve
2088
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2089
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2090
- */
2091
- await this.loadMarkets();
2092
- const request = {};
2093
- if (since !== undefined) {
2094
- request['start'] = this.parseToInt(since / 1000);
2095
- }
2096
- let query = params;
2097
- const clientOrderId = this.safeValue2(params, 'userref', 'clientOrderId');
2098
- if (clientOrderId !== undefined) {
2099
- request['userref'] = clientOrderId;
2100
- query = this.omit(params, ['userref', 'clientOrderId']);
2101
- }
2102
- const response = await this.privatePostOpenOrders(this.extend(request, query));
2103
- let market = undefined;
2104
- if (symbol !== undefined) {
2105
- market = this.market(symbol);
2106
- }
2107
- const result = this.safeValue(response, 'result', {});
2108
- const orders = this.safeValue(result, 'open', []);
2109
- return this.parseOrders(orders, market, since, limit);
2110
- }
2111
- async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
2112
- /**
2113
- * @method
2114
- * @name kraken#fetchClosedOrders
2115
- * @description fetches information on multiple closed orders made by the user
2116
- * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getClosedOrders
2117
- * @param {string} symbol unified market symbol of the market orders were made in
2118
- * @param {int} [since] the earliest time in ms to fetch orders for
2119
- * @param {int} [limit] the maximum number of order structures to retrieve
2120
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2121
- * @param {int} [params.until] timestamp in ms of the latest entry
2122
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2123
- */
2124
- await this.loadMarkets();
2125
- let request = {};
2126
- if (since !== undefined) {
2127
- request['start'] = this.parseToInt(since / 1000);
2128
- }
2129
- let query = params;
2130
- const clientOrderId = this.safeValue2(params, 'userref', 'clientOrderId');
2131
- if (clientOrderId !== undefined) {
2132
- request['userref'] = clientOrderId;
2133
- query = this.omit(params, ['userref', 'clientOrderId']);
2134
- }
2135
- [request, params] = this.handleUntilOption('end', request, params);
2136
- const response = await this.privatePostClosedOrders(this.extend(request, query));
2137
- //
2138
- // {
2139
- // "error":[],
2140
- // "result":{
2141
- // "closed":{
2142
- // "OETZYO-UL524-QJMXCT":{
2143
- // "refid":null,
2144
- // "userref":null,
2145
- // "status":"canceled",
2146
- // "reason":"User requested",
2147
- // "opentm":1601489313.3898,
2148
- // "closetm":1601489346.5507,
2149
- // "starttm":0,
2150
- // "expiretm":0,
2151
- // "descr":{
2152
- // "pair":"ETHUSDT",
2153
- // "type":"buy",
2154
- // "ordertype":"limit",
2155
- // "price":"330.00",
2156
- // "price2":"0",
2157
- // "leverage":"none",
2158
- // "order":"buy 0.02100000 ETHUSDT @ limit 330.00",
2159
- // "close":""
2160
- // },
2161
- // "vol":"0.02100000",
2162
- // "vol_exec":"0.00000000",
2163
- // "cost":"0.00000",
2164
- // "fee":"0.00000",
2165
- // "price":"0.00000",
2166
- // "stopprice":"0.00000",
2167
- // "limitprice":"0.00000",
2168
- // "misc":"",
2169
- // "oflags":"fciq"
2170
- // },
2171
- // },
2172
- // "count":16
2173
- // }
2174
- // }
2175
- //
2176
- let market = undefined;
2177
- if (symbol !== undefined) {
2178
- market = this.market(symbol);
2179
- }
2180
- const result = this.safeValue(response, 'result', {});
2181
- const orders = this.safeValue(result, 'closed', []);
2182
- return this.parseOrders(orders, market, since, limit);
2183
- }
2184
- parseTransactionStatus(status) {
2185
- // IFEX transaction states
2186
- const statuses = {
2187
- 'Initial': 'pending',
2188
- 'Pending': 'pending',
2189
- 'Success': 'ok',
2190
- 'Settled': 'pending',
2191
- 'Failure': 'failed',
2192
- 'Partial': 'ok',
2193
- };
2194
- return this.safeString(statuses, status, status);
2195
- }
2196
- parseNetwork(network) {
2197
- const withdrawMethods = this.safeValue(this.options, 'withdrawMethods', {});
2198
- return this.safeString(withdrawMethods, network, network);
2199
- }
2200
- parseTransaction(transaction, currency = undefined) {
2201
- //
2202
- // fetchDeposits
2203
- //
2204
- // {
2205
- // "method": "Ether (Hex)",
2206
- // "aclass": "currency",
2207
- // "asset": "XETH",
2208
- // "refid": "Q2CANKL-LBFVEE-U4Y2WQ",
2209
- // "txid": "0x57fd704dab1a73c20e24c8696099b695d596924b401b261513cfdab23…",
2210
- // "info": "0x615f9ba7a9575b0ab4d571b2b36b1b324bd83290",
2211
- // "amount": "7.9999257900",
2212
- // "fee": "0.0000000000",
2213
- // "time": 1529223212,
2214
- // "status": "Success"
2215
- // }
2216
- //
2217
- // there can be an additional 'status-prop' field present
2218
- // deposit pending review by exchange => 'on-hold'
2219
- // the deposit is initiated by the exchange => 'return'
2220
- //
2221
- // {
2222
- // "type": 'deposit',
2223
- // "method": 'Fidor Bank AG (Wire Transfer)',
2224
- // "aclass": 'currency',
2225
- // "asset": 'ZEUR',
2226
- // "refid": 'xxx-xxx-xxx',
2227
- // "txid": '12341234',
2228
- // "info": 'BANKCODEXXX',
2229
- // "amount": '38769.08',
2230
- // "fee": '0.0000',
2231
- // "time": 1644306552,
2232
- // "status": 'Success',
2233
- // status-prop: 'on-hold'
2234
- // }
2235
- //
2236
- //
2237
- // fetchWithdrawals
2238
- //
2239
- // {
2240
- // "method": "Ether",
2241
- // "aclass": "currency",
2242
- // "asset": "XETH",
2243
- // "refid": "A2BF34S-O7LBNQ-UE4Y4O",
2244
- // "txid": "0x288b83c6b0904d8400ef44e1c9e2187b5c8f7ea3d838222d53f701a15b5c274d",
2245
- // "info": "0x7cb275a5e07ba943fee972e165d80daa67cb2dd0",
2246
- // "amount": "9.9950000000",
2247
- // "fee": "0.0050000000",
2248
- // "time": 1530481750,
2249
- // "status": "Success"
2250
- // "key":"Huobi wallet",
2251
- // "network":"Tron"
2252
- // status-prop: 'on-hold' // this field might not be present in some cases
2253
- // }
2254
- //
2255
- // withdraw
2256
- //
2257
- // {
2258
- // "refid": "AGBSO6T-UFMTTQ-I7KGS6"
2259
- // }
2260
- //
2261
- const id = this.safeString(transaction, 'refid');
2262
- const txid = this.safeString(transaction, 'txid');
2263
- const timestamp = this.safeTimestamp(transaction, 'time');
2264
- const currencyId = this.safeString(transaction, 'asset');
2265
- const code = this.safeCurrencyCode(currencyId, currency);
2266
- const address = this.safeString(transaction, 'info');
2267
- const amount = this.safeNumber(transaction, 'amount');
2268
- let status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
2269
- const statusProp = this.safeString(transaction, 'status-prop');
2270
- const isOnHoldDeposit = statusProp === 'on-hold';
2271
- const isCancellationRequest = statusProp === 'cancel-pending';
2272
- const isOnHoldWithdrawal = statusProp === 'onhold';
2273
- if (isOnHoldDeposit || isCancellationRequest || isOnHoldWithdrawal) {
2274
- status = 'pending';
2275
- }
2276
- const type = this.safeString(transaction, 'type'); // injected from the outside
2277
- let feeCost = this.safeNumber(transaction, 'fee');
2278
- if (feeCost === undefined) {
2279
- if (type === 'deposit') {
2280
- feeCost = 0;
2281
- }
2282
- }
2283
- return {
2284
- 'info': transaction,
2285
- 'id': id,
2286
- 'currency': code,
2287
- 'amount': amount,
2288
- 'network': this.parseNetwork(this.safeString(transaction, 'network')),
2289
- 'address': address,
2290
- 'addressTo': undefined,
2291
- 'addressFrom': undefined,
2292
- 'tag': undefined,
2293
- 'tagTo': undefined,
2294
- 'tagFrom': undefined,
2295
- 'status': status,
2296
- 'type': type,
2297
- 'updated': undefined,
2298
- 'txid': txid,
2299
- 'timestamp': timestamp,
2300
- 'datetime': this.iso8601(timestamp),
2301
- 'comment': undefined,
2302
- 'internal': undefined,
2303
- 'fee': {
2304
- 'currency': code,
2305
- 'cost': feeCost,
2306
- },
2307
- };
2308
- }
2309
- parseTransactionsByType(type, transactions, code = undefined, since = undefined, limit = undefined) {
2310
- const result = [];
2311
- for (let i = 0; i < transactions.length; i++) {
2312
- const transaction = this.parseTransaction(this.extend({
2313
- 'type': type,
2314
- }, transactions[i]));
2315
- result.push(transaction);
2316
- }
2317
- return this.filterByCurrencySinceLimit(result, code, since, limit);
2318
- }
2319
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
2320
- /**
2321
- * @method
2322
- * @name kraken#fetchDeposits
2323
- * @description fetch all deposits made to an account
2324
- * @see https://docs.kraken.com/rest/#tag/Funding/operation/getStatusRecentDeposits
2325
- * @param {string} code unified currency code
2326
- * @param {int} [since] the earliest time in ms to fetch deposits for
2327
- * @param {int} [limit] the maximum number of deposits structures to retrieve
2328
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2329
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2330
- */
2331
- // https://www.kraken.com/en-us/help/api#deposit-status
2332
- if (code === undefined) {
2333
- throw new errors.ArgumentsRequired(this.id + ' fetchDeposits() requires a currency code argument');
2334
- }
2335
- await this.loadMarkets();
2336
- const currency = this.currency(code);
2337
- const request = {
2338
- 'asset': currency['id'],
2339
- };
2340
- if (since !== undefined) {
2341
- request['start'] = since;
2342
- }
2343
- const response = await this.privatePostDepositStatus(this.extend(request, params));
2344
- //
2345
- // { error: [],
2346
- // "result": [ { "method": "Ether (Hex)",
2347
- // "aclass": "currency",
2348
- // "asset": "XETH",
2349
- // "refid": "Q2CANKL-LBFVEE-U4Y2WQ",
2350
- // "txid": "0x57fd704dab1a73c20e24c8696099b695d596924b401b261513cfdab23…",
2351
- // "info": "0x615f9ba7a9575b0ab4d571b2b36b1b324bd83290",
2352
- // "amount": "7.9999257900",
2353
- // "fee": "0.0000000000",
2354
- // "time": 1529223212,
2355
- // "status": "Success" } ] }
2356
- //
2357
- return this.parseTransactionsByType('deposit', response['result'], code, since, limit);
2358
- }
2359
- async fetchTime(params = {}) {
2360
- /**
2361
- * @method
2362
- * @name kraken#fetchTime
2363
- * @description fetches the current integer timestamp in milliseconds from the exchange server
2364
- * @see https://docs.kraken.com/rest/#tag/Market-Data/operation/getServerTime
2365
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2366
- * @returns {int} the current integer timestamp in milliseconds from the exchange server
2367
- */
2368
- // https://www.kraken.com/en-us/features/api#get-server-time
2369
- const response = await this.publicGetTime(params);
2370
- //
2371
- // {
2372
- // "error": [],
2373
- // "result": {
2374
- // "unixtime": 1591502873,
2375
- // "rfc1123": "Sun, 7 Jun 20 04:07:53 +0000"
2376
- // }
2377
- // }
2378
- //
2379
- const result = this.safeValue(response, 'result', {});
2380
- return this.safeTimestamp(result, 'unixtime');
2381
- }
2382
- async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
2383
- /**
2384
- * @method
2385
- * @name kraken#fetchWithdrawals
2386
- * @description fetch all withdrawals made from an account
2387
- * @see https://docs.kraken.com/rest/#tag/Funding/operation/getStatusRecentWithdrawals
2388
- * @param {string} code unified currency code
2389
- * @param {int} [since] the earliest time in ms to fetch withdrawals for
2390
- * @param {int} [limit] the maximum number of withdrawals structures to retrieve
2391
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2392
- * @param {object} [params.end] End timestamp, withdrawals created strictly after will be not be included in the response
2393
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times
2394
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2395
- */
2396
- await this.loadMarkets();
2397
- let paginate = false;
2398
- [paginate, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'paginate');
2399
- if (paginate) {
2400
- params['cursor'] = true;
2401
- return await this.fetchPaginatedCallCursor('fetchWithdrawals', code, since, limit, params, 'next_cursor', 'cursor');
2402
- }
2403
- const request = {};
2404
- if (code !== undefined) {
2405
- const currency = this.currency(code);
2406
- request['asset'] = currency['id'];
2407
- }
2408
- if (since !== undefined) {
2409
- request['since'] = since.toString();
2410
- }
2411
- const response = await this.privatePostWithdrawStatus(this.extend(request, params));
2412
- //
2413
- // with no pagination
2414
- // { error: [],
2415
- // "result": [ { "method": "Ether",
2416
- // "aclass": "currency",
2417
- // "asset": "XETH",
2418
- // "refid": "A2BF34S-O7LBNQ-UE4Y4O",
2419
- // "txid": "0x298c83c7b0904d8400ef43e1c9e2287b518f7ea3d838822d53f704a1565c274d",
2420
- // "info": "0x7cb275a5e07ba943fee972e165d80daa67cb2dd0",
2421
- // "amount": "9.9950000000",
2422
- // "fee": "0.0050000000",
2423
- // "time": 1530481750,
2424
- // "status": "Success" } ] }
2425
- // with pagination
2426
- // {
2427
- // "error":[],
2428
- // "result":{
2429
- // "withdrawals":[
2430
- // {
2431
- // "method":"Tether USD (TRC20)",
2432
- // "aclass":"currency",
2433
- // "asset":"USDT",
2434
- // "refid":"BSNFZU2-MEFN4G-J3NEZV",
2435
- // "txid":"1c7a642fb7387bbc2c6a2c509fd1ae146937f4cf793b4079a4f0715e3a02615a",
2436
- // "info":"TQmdxSuC16EhFg8FZWtYgrfFRosoRF7bCp",
2437
- // "amount":"1996.50000000",
2438
- // "fee":"2.50000000",
2439
- // "time":1669126657,
2440
- // "status":"Success",
2441
- // "key":"poloniex",
2442
- // "network":"Tron"
2443
- // },
2444
- // ...
2445
- // ],
2446
- // "next_cursor":"HgAAAAAAAABGVFRSd3k1LVF4Y0JQY05Gd0xRY0NxenFndHpybkwBAQH2AwEBAAAAAQAAAAAAAAABAAAAAAAZAAAAAAAAAA=="
2447
- // }
2448
- // }
2449
- //
2450
- let rawWithdrawals = undefined;
2451
- const result = this.safeValue(response, 'result');
2452
- if (!Array.isArray(result)) {
2453
- rawWithdrawals = this.addPaginationCursorToResult(result);
2454
- }
2455
- else {
2456
- rawWithdrawals = result;
2457
- }
2458
- return this.parseTransactionsByType('withdrawal', rawWithdrawals, code, since, limit);
2459
- }
2460
- addPaginationCursorToResult(result) {
2461
- const cursor = this.safeString(result, 'next_cursor');
2462
- const data = this.safeValue(result, 'withdrawals');
2463
- const dataLength = data.length;
2464
- if (cursor !== undefined && dataLength > 0) {
2465
- const last = data[dataLength - 1];
2466
- last['next_cursor'] = cursor;
2467
- data[dataLength - 1] = last;
2468
- }
2469
- return data;
2470
- }
2471
- async createDepositAddress(code, params = {}) {
2472
- /**
2473
- * @method
2474
- * @name kraken#createDepositAddress
2475
- * @description create a currency deposit address
2476
- * @see https://docs.kraken.com/rest/#tag/Funding/operation/getDepositAddresses
2477
- * @param {string} code unified currency code of the currency for the deposit address
2478
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2479
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
2480
- */
2481
- const request = {
2482
- 'new': 'true',
2483
- };
2484
- return await this.fetchDepositAddress(code, this.extend(request, params));
2485
- }
2486
- async fetchDepositMethods(code, params = {}) {
2487
- /**
2488
- * @method
2489
- * @name kraken#fetchDepositMethods
2490
- * @description fetch deposit methods for a currency associated with this account
2491
- * @see https://docs.kraken.com/rest/#tag/Funding/operation/getDepositMethods
2492
- * @param {string} code unified currency code
2493
- * @param {object} [params] extra parameters specific to the kraken api endpoint
2494
- * @returns {object} of deposit methods
2495
- */
2496
- await this.loadMarkets();
2497
- const currency = this.currency(code);
2498
- const request = {
2499
- 'asset': currency['id'],
2500
- };
2501
- const response = await this.privatePostDepositMethods(this.extend(request, params));
2502
- //
2503
- // {
2504
- // "error":[],
2505
- // "result":[
2506
- // {"method":"Ether (Hex)","limit":false,"gen-address":true}
2507
- // ]
2508
- // }
2509
- //
2510
- // {
2511
- // "error":[],
2512
- // "result":[
2513
- // {"method":"Tether USD (ERC20)","limit":false,"address-setup-fee":"0.00000000","gen-address":true},
2514
- // {"method":"Tether USD (TRC20)","limit":false,"address-setup-fee":"0.00000000","gen-address":true}
2515
- // ]
2516
- // }
2517
- //
2518
- // {
2519
- // "error":[],
2520
- // "result":[
2521
- // {"method":"Bitcoin","limit":false,"fee":"0.0000000000","gen-address":true}
2522
- // ]
2523
- // }
2524
- //
2525
- return this.safeValue(response, 'result');
2526
- }
2527
- async fetchDepositAddress(code, params = {}) {
2528
- /**
2529
- * @method
2530
- * @name kraken#fetchDepositAddress
2531
- * @description fetch the deposit address for a currency associated with this account
2532
- * @see https://docs.kraken.com/rest/#tag/Funding/operation/getDepositAddresses
2533
- * @param {string} code unified currency code
2534
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2535
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
2536
- */
2537
- await this.loadMarkets();
2538
- const currency = this.currency(code);
2539
- let network = this.safeStringUpper(params, 'network');
2540
- const networks = this.safeValue(this.options, 'networks', {});
2541
- network = this.safeString(networks, network, network); // support ETH > ERC20 aliases
2542
- params = this.omit(params, 'network');
2543
- if ((code === 'USDT') && (network === 'TRC20')) {
2544
- code = code + '-' + network;
2545
- }
2546
- const defaultDepositMethods = this.safeValue(this.options, 'depositMethods', {});
2547
- const defaultDepositMethod = this.safeString(defaultDepositMethods, code);
2548
- let depositMethod = this.safeString(params, 'method', defaultDepositMethod);
2549
- // if the user has specified an exchange-specific method in params
2550
- // we pass it as is, otherwise we take the 'network' unified param
2551
- if (depositMethod === undefined) {
2552
- const depositMethods = await this.fetchDepositMethods(code);
2553
- if (network !== undefined) {
2554
- // find best matching deposit method, or fallback to the first one
2555
- for (let i = 0; i < depositMethods.length; i++) {
2556
- const entry = this.safeString(depositMethods[i], 'method');
2557
- if (entry.indexOf(network) >= 0) {
2558
- depositMethod = entry;
2559
- break;
2560
- }
2561
- }
2562
- }
2563
- // if depositMethod was not specified, fallback to the first available deposit method
2564
- if (depositMethod === undefined) {
2565
- const firstDepositMethod = this.safeValue(depositMethods, 0, {});
2566
- depositMethod = this.safeString(firstDepositMethod, 'method');
2567
- }
2568
- }
2569
- const request = {
2570
- 'asset': currency['id'],
2571
- 'method': depositMethod,
2572
- };
2573
- const response = await this.privatePostDepositAddresses(this.extend(request, params));
2574
- //
2575
- // {
2576
- // "error":[],
2577
- // "result":[
2578
- // {"address":"0x77b5051f97efa9cc52c9ad5b023a53fc15c200d3","expiretm":"0"}
2579
- // ]
2580
- // }
2581
- //
2582
- const result = this.safeValue(response, 'result', []);
2583
- const firstResult = this.safeValue(result, 0, {});
2584
- if (firstResult === undefined) {
2585
- throw new errors.InvalidAddress(this.id + ' privatePostDepositAddresses() returned no addresses for ' + code);
2586
- }
2587
- return this.parseDepositAddress(firstResult, currency);
2588
- }
2589
- parseDepositAddress(depositAddress, currency = undefined) {
2590
- //
2591
- // {
2592
- // "address":"0x77b5051f97efa9cc52c9ad5b023a53fc15c200d3",
2593
- // "expiretm":"0"
2594
- // }
2595
- //
2596
- const address = this.safeString(depositAddress, 'address');
2597
- const tag = this.safeString(depositAddress, 'tag');
2598
- currency = this.safeCurrency(undefined, currency);
2599
- const code = currency['code'];
2600
- this.checkAddress(address);
2601
- return {
2602
- 'currency': code,
2603
- 'address': address,
2604
- 'tag': tag,
2605
- 'network': undefined,
2606
- 'info': depositAddress,
2607
- };
2608
- }
2609
- async withdraw(code, amount, address, tag = undefined, params = {}) {
2610
- /**
2611
- * @method
2612
- * @name kraken#withdraw
2613
- * @description make a withdrawal
2614
- * @see https://docs.kraken.com/rest/#tag/Funding/operation/withdrawFunds
2615
- * @param {string} code unified currency code
2616
- * @param {float} amount the amount to withdraw
2617
- * @param {string} address the address to withdraw to
2618
- * @param {string} tag
2619
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2620
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2621
- */
2622
- [tag, params] = this.handleWithdrawTagAndParams(tag, params);
2623
- this.checkAddress(address);
2624
- if ('key' in params) {
2625
- await this.loadMarkets();
2626
- const currency = this.currency(code);
2627
- const request = {
2628
- 'asset': currency['id'],
2629
- 'amount': amount,
2630
- 'address': address,
2631
- };
2632
- const response = await this.privatePostWithdraw(this.extend(request, params));
2633
- //
2634
- // {
2635
- // "error": [],
2636
- // "result": {
2637
- // "refid": "AGBSO6T-UFMTTQ-I7KGS6"
2638
- // }
2639
- // }
2640
- //
2641
- const result = this.safeValue(response, 'result', {});
2642
- return this.parseTransaction(result, currency);
2643
- }
2644
- throw new errors.ExchangeError(this.id + " withdraw() requires a 'key' parameter (withdrawal key name, as set up on your account)");
2645
- }
2646
- async fetchPositions(symbols = undefined, params = {}) {
2647
- /**
2648
- * @method
2649
- * @name kraken#fetchPositions
2650
- * @description fetch all open positions
2651
- * @see https://docs.kraken.com/rest/#tag/Account-Data/operation/getOpenPositions
2652
- * @param {string[]|undefined} symbols not used by kraken fetchPositions ()
2653
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2654
- * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2655
- */
2656
- await this.loadMarkets();
2657
- const request = {
2658
- // 'txid': 'comma delimited list of transaction ids to restrict output to',
2659
- // 'docalcs': false, // whether or not to include profit/loss calculations
2660
- // 'consolidation': 'market', // what to consolidate the positions data around, market will consolidate positions based on market pair
2661
- };
2662
- const response = await this.privatePostOpenPositions(this.extend(request, params));
2663
- //
2664
- // no consolidation
2665
- //
2666
- // {
2667
- // "error": [],
2668
- // "result": {
2669
- // 'TGUFMY-FLESJ-VYIX3J': {
2670
- // "ordertxid": "O3LRNU-ZKDG5-XNCDFR",
2671
- // "posstatus": "open",
2672
- // "pair": "ETHUSDT",
2673
- // "time": 1611557231.4584,
2674
- // "type": "buy",
2675
- // "ordertype": "market",
2676
- // "cost": "28.49800",
2677
- // "fee": "0.07979",
2678
- // "vol": "0.02000000",
2679
- // "vol_closed": "0.00000000",
2680
- // "margin": "14.24900",
2681
- // "terms": "0.0200% per 4 hours",
2682
- // "rollovertm": "1611571631",
2683
- // "misc": "",
2684
- // "oflags": ""
2685
- // }
2686
- // }
2687
- // }
2688
- //
2689
- // consolidation by market
2690
- //
2691
- // {
2692
- // "error": [],
2693
- // "result": [
2694
- // {
2695
- // "pair": "ETHUSDT",
2696
- // "positions": "1",
2697
- // "type": "buy",
2698
- // "leverage": "2.00000",
2699
- // "cost": "28.49800",
2700
- // "fee": "0.07979",
2701
- // "vol": "0.02000000",
2702
- // "vol_closed": "0.00000000",
2703
- // "margin": "14.24900"
2704
- // }
2705
- // ]
2706
- // }
2707
- //
2708
- const result = this.safeValue(response, 'result');
2709
- // todo unify parsePosition/parsePositions
2710
- return result;
2711
- }
2712
- parseAccount(account) {
2713
- const accountByType = {
2714
- 'spot': 'Spot Wallet',
2715
- 'swap': 'Futures Wallet',
2716
- 'future': 'Futures Wallet',
2717
- };
2718
- return this.safeString(accountByType, account, account);
2719
- }
2720
- async transferOut(code, amount, params = {}) {
2721
- /**
2722
- * @description transfer from spot wallet to futures wallet
2723
- * @see https://docs.kraken.com/rest/#tag/User-Funding/operation/walletTransfer
2724
- * @param {str} code Unified currency code
2725
- * @param {float} amount Size of the transfer
2726
- * @param {dict} [params] Exchange specific parameters
2727
- * @returns a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
2728
- */
2729
- return await this.transfer(code, amount, 'spot', 'swap', params);
2730
- }
2731
- async transfer(code, amount, fromAccount, toAccount, params = {}) {
2732
- /**
2733
- * @method
2734
- * @name kraken#transfer
2735
- * @see https://docs.kraken.com/rest/#tag/User-Funding/operation/walletTransfer
2736
- * @description transfers currencies between sub-accounts (only spot->swap direction is supported)
2737
- * @param {string} code Unified currency code
2738
- * @param {float} amount Size of the transfer
2739
- * @param {string} fromAccount 'spot' or 'Spot Wallet'
2740
- * @param {string} toAccount 'swap' or 'Futures Wallet'
2741
- * @param {object} [params] Exchange specific parameters
2742
- * @returns a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
2743
- */
2744
- await this.loadMarkets();
2745
- const currency = this.currency(code);
2746
- fromAccount = this.parseAccount(fromAccount);
2747
- toAccount = this.parseAccount(toAccount);
2748
- const request = {
2749
- 'amount': this.currencyToPrecision(code, amount),
2750
- 'from': fromAccount,
2751
- 'to': toAccount,
2752
- 'asset': currency['id'],
2753
- };
2754
- if (fromAccount !== 'Spot Wallet') {
2755
- throw new errors.BadRequest(this.id + ' transfer cannot transfer from ' + fromAccount + ' to ' + toAccount + '. Use krakenfutures instead to transfer from the futures account.');
2756
- }
2757
- const response = await this.privatePostWalletTransfer(this.extend(request, params));
2758
- //
2759
- // {
2760
- // "error":[
2761
- // ],
2762
- // "result":{
2763
- // "refid":"BOIUSIF-M7DLMN-UXZ3P5"
2764
- // }
2765
- // }
2766
- //
2767
- const transfer = this.parseTransfer(response, currency);
2768
- return this.extend(transfer, {
2769
- 'amount': amount,
2770
- 'fromAccount': fromAccount,
2771
- 'toAccount': toAccount,
2772
- });
2773
- }
2774
- parseTransfer(transfer, currency = undefined) {
2775
- //
2776
- // transfer
2777
- //
2778
- // {
2779
- // "error":[
2780
- // ],
2781
- // "result":{
2782
- // "refid":"BOIUSIF-M7DLMN-UXZ3P5"
2783
- // }
2784
- // }
2785
- //
2786
- const result = this.safeValue(transfer, 'result', {});
2787
- const refid = this.safeString(result, 'refid');
2788
- return {
2789
- 'info': transfer,
2790
- 'id': refid,
2791
- 'timestamp': undefined,
2792
- 'datetime': undefined,
2793
- 'currency': this.safeString(currency, 'code'),
2794
- 'amount': undefined,
2795
- 'fromAccount': undefined,
2796
- 'toAccount': undefined,
2797
- 'status': 'sucess',
2798
- };
2799
- }
2800
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
2801
- let url = '/' + this.version + '/' + api + '/' + path;
2802
- if (api === 'public') {
2803
- if (Object.keys(params).length) {
2804
- // urlencodeNested is used to address https://github.com/ccxt/ccxt/issues/12872
2805
- url += '?' + this.urlencodeNested(params);
2806
- }
2807
- }
2808
- else if (api === 'private') {
2809
- const isCancelOrderBatch = (path === 'CancelOrderBatch');
2810
- this.checkRequiredCredentials();
2811
- const nonce = this.nonce().toString();
2812
- // urlencodeNested is used to address https://github.com/ccxt/ccxt/issues/12872
2813
- if (isCancelOrderBatch) {
2814
- body = this.json(this.extend({ 'nonce': nonce }, params));
2815
- }
2816
- else {
2817
- body = this.urlencodeNested(this.extend({ 'nonce': nonce }, params));
2818
- }
2819
- const auth = this.encode(nonce + body);
2820
- const hash = this.hash(auth, sha256.sha256, 'binary');
2821
- const binary = this.encode(url);
2822
- const binhash = this.binaryConcat(binary, hash);
2823
- const secret = this.base64ToBinary(this.secret);
2824
- const signature = this.hmac(binhash, secret, sha512.sha512, 'base64');
2825
- headers = {
2826
- 'API-Key': this.apiKey,
2827
- 'API-Sign': signature,
2828
- // 'Content-Type': 'application/x-www-form-urlencoded',
2829
- };
2830
- if (isCancelOrderBatch) {
2831
- headers['Content-Type'] = 'application/json';
2832
- }
2833
- else {
2834
- headers['Content-Type'] = 'application/x-www-form-urlencoded';
2835
- }
2836
- }
2837
- else {
2838
- url = '/' + path;
2839
- }
2840
- url = this.urls['api'][api] + url;
2841
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
2842
- }
2843
- nonce() {
2844
- return this.milliseconds();
2845
- }
2846
- handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
2847
- if (code === 520) {
2848
- throw new errors.ExchangeNotAvailable(this.id + ' ' + code.toString() + ' ' + reason);
2849
- }
2850
- // todo: rewrite this for "broad" exceptions matching
2851
- if (body.indexOf('Invalid order') >= 0) {
2852
- throw new errors.InvalidOrder(this.id + ' ' + body);
2853
- }
2854
- if (body.indexOf('Invalid nonce') >= 0) {
2855
- throw new errors.InvalidNonce(this.id + ' ' + body);
2856
- }
2857
- if (body.indexOf('Insufficient funds') >= 0) {
2858
- throw new errors.InsufficientFunds(this.id + ' ' + body);
2859
- }
2860
- if (body.indexOf('Cancel pending') >= 0) {
2861
- throw new errors.CancelPending(this.id + ' ' + body);
2862
- }
2863
- if (body.indexOf('Invalid arguments:volume') >= 0) {
2864
- throw new errors.InvalidOrder(this.id + ' ' + body);
2865
- }
2866
- if (body.indexOf('Rate limit exceeded') >= 0) {
2867
- throw new errors.RateLimitExceeded(this.id + ' ' + body);
2868
- }
2869
- if (response === undefined) {
2870
- return undefined;
2871
- }
2872
- if (body[0] === '{') {
2873
- if (typeof response !== 'string') {
2874
- if ('error' in response) {
2875
- const numErrors = response['error'].length;
2876
- if (numErrors) {
2877
- const message = this.id + ' ' + body;
2878
- for (let i = 0; i < response['error'].length; i++) {
2879
- const error = response['error'][i];
2880
- this.throwExactlyMatchedException(this.exceptions, error, message);
2881
- }
2882
- throw new errors.ExchangeError(message);
2883
- }
2884
- }
2885
- }
2886
- }
2887
- return undefined;
2888
- }
2889
- }
2890
-
2891
- module.exports = kraken;