ccxt 4.2.17 → 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 (439) hide show
  1. package/README.md +9 -9
  2. package/dist/ccxt.browser.js +48992 -47725
  3. package/dist/ccxt.browser.min.js +3 -3
  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/coincheck.js +208 -0
  49. package/dist/cjs/src/pro/hitbtc.js +5 -4
  50. package/dist/cjs/src/pro/htx.js +6 -1
  51. package/dist/cjs/src/pro/kraken.js +1 -1
  52. package/dist/cjs/src/pro/krakenfutures.js +7 -1
  53. package/dist/cjs/src/pro/kucoin.js +46 -36
  54. package/dist/cjs/src/pro/kucoinfutures.js +45 -37
  55. package/dist/cjs/src/pro/lbank.js +881 -0
  56. package/dist/cjs/src/pro/okx.js +52 -2
  57. package/dist/cjs/{js/src/pro/bitpanda.js → src/pro/onetrading.js} +4 -7
  58. package/dist/cjs/src/pro/poloniex.js +2 -2
  59. package/dist/cjs/src/pro/poloniexfutures.js +43 -35
  60. package/dist/cjs/src/pro/woo.js +126 -0
  61. package/dist/cjs/src/probit.js +4 -2
  62. package/dist/cjs/src/upbit.js +12 -12
  63. package/dist/cjs/src/wavesexchange.js +1 -1
  64. package/dist/cjs/src/whitebit.js +1 -0
  65. package/dist/cjs/src/woo.js +56 -0
  66. package/js/ccxt.d.ts +14 -2
  67. package/js/ccxt.js +10 -2
  68. package/js/src/abstract/bitpanda.d.ts +4 -4
  69. package/js/src/abstract/bitstamp.d.ts +8 -0
  70. package/js/src/abstract/gate.d.ts +1 -0
  71. package/js/src/abstract/gateio.d.ts +1 -0
  72. package/js/src/abstract/htx.d.ts +3 -0
  73. package/js/src/abstract/huobi.d.ts +3 -0
  74. package/js/src/abstract/luno.d.ts +1 -0
  75. package/js/src/abstract/onetrading.d.ts +38 -0
  76. package/js/src/ascendex.js +2 -0
  77. package/js/src/base/Exchange.d.ts +2 -3
  78. package/js/src/base/Exchange.js +5 -2
  79. package/js/src/binance.js +7 -1
  80. package/js/src/bingx.d.ts +1 -0
  81. package/js/src/bingx.js +26 -0
  82. package/js/src/bitget.js +22 -3
  83. package/js/src/bitpanda.d.ts +2 -72
  84. package/js/src/bitpanda.js +5 -1991
  85. package/js/src/bitstamp.js +8 -0
  86. package/js/src/bybit.js +21 -47
  87. package/js/src/coincheck.js +1 -0
  88. package/js/src/deribit.js +16 -4
  89. package/js/src/gate.d.ts +1 -0
  90. package/js/src/gate.js +50 -110
  91. package/js/src/htx.js +3 -0
  92. package/js/src/kraken.d.ts +1 -0
  93. package/js/src/kraken.js +40 -39
  94. package/js/src/lbank.js +1 -0
  95. package/js/src/luno.d.ts +3 -1
  96. package/js/src/luno.js +84 -2
  97. package/js/src/mexc.js +1 -2
  98. package/js/src/onetrading.d.ts +74 -0
  99. package/js/src/onetrading.js +2003 -0
  100. package/js/src/poloniexfutures.js +1 -0
  101. package/js/src/pro/binance.js +7 -2
  102. package/js/src/pro/bitget.js +1 -1
  103. package/js/src/pro/bitpanda.d.ts +2 -34
  104. package/js/src/pro/bitpanda.js +5 -1330
  105. package/js/src/pro/coincheck.d.ts +12 -0
  106. package/js/src/pro/coincheck.js +209 -0
  107. package/js/src/pro/kucoin.js +43 -35
  108. package/js/src/pro/kucoinfutures.js +45 -37
  109. package/js/src/pro/lbank.d.ts +29 -0
  110. package/js/src/pro/lbank.js +882 -0
  111. package/js/src/pro/onetrading.d.ts +36 -0
  112. package/js/src/pro/onetrading.js +1339 -0
  113. package/js/src/pro/poloniexfutures.js +43 -35
  114. package/js/src/whitebit.js +1 -0
  115. package/package.json +2 -2
  116. package/rollup.config.js +2 -0
  117. package/skip-tests.json +14 -2
  118. package/test-commonjs.cjs +25 -1
  119. package/dist/cjs/js/ccxt.js +0 -476
  120. package/dist/cjs/js/src/abstract/alpaca.js +0 -9
  121. package/dist/cjs/js/src/abstract/ascendex.js +0 -9
  122. package/dist/cjs/js/src/abstract/bigone.js +0 -9
  123. package/dist/cjs/js/src/abstract/binance.js +0 -9
  124. package/dist/cjs/js/src/abstract/bingx.js +0 -9
  125. package/dist/cjs/js/src/abstract/bit2c.js +0 -9
  126. package/dist/cjs/js/src/abstract/bitbank.js +0 -9
  127. package/dist/cjs/js/src/abstract/bitbns.js +0 -9
  128. package/dist/cjs/js/src/abstract/bitfinex.js +0 -9
  129. package/dist/cjs/js/src/abstract/bitfinex2.js +0 -9
  130. package/dist/cjs/js/src/abstract/bitflyer.js +0 -9
  131. package/dist/cjs/js/src/abstract/bitforex.js +0 -9
  132. package/dist/cjs/js/src/abstract/bitget.js +0 -9
  133. package/dist/cjs/js/src/abstract/bithumb.js +0 -9
  134. package/dist/cjs/js/src/abstract/bitmart.js +0 -9
  135. package/dist/cjs/js/src/abstract/bitmex.js +0 -9
  136. package/dist/cjs/js/src/abstract/bitopro.js +0 -9
  137. package/dist/cjs/js/src/abstract/bitpanda.js +0 -9
  138. package/dist/cjs/js/src/abstract/bitrue.js +0 -9
  139. package/dist/cjs/js/src/abstract/bitso.js +0 -9
  140. package/dist/cjs/js/src/abstract/bitstamp.js +0 -9
  141. package/dist/cjs/js/src/abstract/bitteam.js +0 -9
  142. package/dist/cjs/js/src/abstract/bitvavo.js +0 -9
  143. package/dist/cjs/js/src/abstract/bl3p.js +0 -9
  144. package/dist/cjs/js/src/abstract/blockchaincom.js +0 -9
  145. package/dist/cjs/js/src/abstract/btcalpha.js +0 -9
  146. package/dist/cjs/js/src/abstract/btcbox.js +0 -9
  147. package/dist/cjs/js/src/abstract/btcmarkets.js +0 -9
  148. package/dist/cjs/js/src/abstract/btcturk.js +0 -9
  149. package/dist/cjs/js/src/abstract/bybit.js +0 -9
  150. package/dist/cjs/js/src/abstract/cex.js +0 -9
  151. package/dist/cjs/js/src/abstract/coinbase.js +0 -9
  152. package/dist/cjs/js/src/abstract/coinbasepro.js +0 -9
  153. package/dist/cjs/js/src/abstract/coincheck.js +0 -9
  154. package/dist/cjs/js/src/abstract/coinex.js +0 -9
  155. package/dist/cjs/js/src/abstract/coinlist.js +0 -9
  156. package/dist/cjs/js/src/abstract/coinmate.js +0 -9
  157. package/dist/cjs/js/src/abstract/coinone.js +0 -9
  158. package/dist/cjs/js/src/abstract/coinsph.js +0 -9
  159. package/dist/cjs/js/src/abstract/coinspot.js +0 -9
  160. package/dist/cjs/js/src/abstract/cryptocom.js +0 -9
  161. package/dist/cjs/js/src/abstract/currencycom.js +0 -9
  162. package/dist/cjs/js/src/abstract/delta.js +0 -9
  163. package/dist/cjs/js/src/abstract/deribit.js +0 -9
  164. package/dist/cjs/js/src/abstract/digifinex.js +0 -9
  165. package/dist/cjs/js/src/abstract/exmo.js +0 -9
  166. package/dist/cjs/js/src/abstract/gate.js +0 -9
  167. package/dist/cjs/js/src/abstract/gemini.js +0 -9
  168. package/dist/cjs/js/src/abstract/hitbtc.js +0 -9
  169. package/dist/cjs/js/src/abstract/hollaex.js +0 -9
  170. package/dist/cjs/js/src/abstract/htx.js +0 -9
  171. package/dist/cjs/js/src/abstract/huobijp.js +0 -9
  172. package/dist/cjs/js/src/abstract/idex.js +0 -9
  173. package/dist/cjs/js/src/abstract/independentreserve.js +0 -9
  174. package/dist/cjs/js/src/abstract/indodax.js +0 -9
  175. package/dist/cjs/js/src/abstract/kraken.js +0 -9
  176. package/dist/cjs/js/src/abstract/krakenfutures.js +0 -9
  177. package/dist/cjs/js/src/abstract/kucoin.js +0 -9
  178. package/dist/cjs/js/src/abstract/kucoinfutures.js +0 -9
  179. package/dist/cjs/js/src/abstract/kuna.js +0 -9
  180. package/dist/cjs/js/src/abstract/latoken.js +0 -9
  181. package/dist/cjs/js/src/abstract/lbank.js +0 -9
  182. package/dist/cjs/js/src/abstract/luno.js +0 -9
  183. package/dist/cjs/js/src/abstract/lykke.js +0 -9
  184. package/dist/cjs/js/src/abstract/mercado.js +0 -9
  185. package/dist/cjs/js/src/abstract/mexc.js +0 -9
  186. package/dist/cjs/js/src/abstract/ndax.js +0 -9
  187. package/dist/cjs/js/src/abstract/novadax.js +0 -9
  188. package/dist/cjs/js/src/abstract/oceanex.js +0 -9
  189. package/dist/cjs/js/src/abstract/okcoin.js +0 -9
  190. package/dist/cjs/js/src/abstract/okx.js +0 -9
  191. package/dist/cjs/js/src/abstract/p2b.js +0 -9
  192. package/dist/cjs/js/src/abstract/paymium.js +0 -9
  193. package/dist/cjs/js/src/abstract/phemex.js +0 -9
  194. package/dist/cjs/js/src/abstract/poloniex.js +0 -9
  195. package/dist/cjs/js/src/abstract/poloniexfutures.js +0 -9
  196. package/dist/cjs/js/src/abstract/probit.js +0 -9
  197. package/dist/cjs/js/src/abstract/timex.js +0 -9
  198. package/dist/cjs/js/src/abstract/tokocrypto.js +0 -9
  199. package/dist/cjs/js/src/abstract/upbit.js +0 -9
  200. package/dist/cjs/js/src/abstract/wavesexchange.js +0 -9
  201. package/dist/cjs/js/src/abstract/wazirx.js +0 -9
  202. package/dist/cjs/js/src/abstract/whitebit.js +0 -9
  203. package/dist/cjs/js/src/abstract/woo.js +0 -9
  204. package/dist/cjs/js/src/abstract/yobit.js +0 -9
  205. package/dist/cjs/js/src/abstract/zaif.js +0 -9
  206. package/dist/cjs/js/src/abstract/zonda.js +0 -9
  207. package/dist/cjs/js/src/ace.js +0 -1058
  208. package/dist/cjs/js/src/alpaca.js +0 -1125
  209. package/dist/cjs/js/src/ascendex.js +0 -3365
  210. package/dist/cjs/js/src/base/Exchange.js +0 -5257
  211. package/dist/cjs/js/src/base/Precise.js +0 -263
  212. package/dist/cjs/js/src/base/errors.js +0 -299
  213. package/dist/cjs/js/src/base/functions/crypto.js +0 -78
  214. package/dist/cjs/js/src/base/functions/encode.js +0 -44
  215. package/dist/cjs/js/src/base/functions/generic.js +0 -193
  216. package/dist/cjs/js/src/base/functions/misc.js +0 -96
  217. package/dist/cjs/js/src/base/functions/number.js +0 -297
  218. package/dist/cjs/js/src/base/functions/platform.js +0 -28
  219. package/dist/cjs/js/src/base/functions/rsa.js +0 -34
  220. package/dist/cjs/js/src/base/functions/string.js +0 -48
  221. package/dist/cjs/js/src/base/functions/throttle.js +0 -66
  222. package/dist/cjs/js/src/base/functions/time.js +0 -187
  223. package/dist/cjs/js/src/base/functions/totp.js +0 -24
  224. package/dist/cjs/js/src/base/functions/type.js +0 -162
  225. package/dist/cjs/js/src/base/functions.js +0 -157
  226. package/dist/cjs/js/src/base/ws/Cache.js +0 -254
  227. package/dist/cjs/js/src/base/ws/Client.js +0 -299
  228. package/dist/cjs/js/src/base/ws/Future.js +0 -34
  229. package/dist/cjs/js/src/base/ws/OrderBook.js +0 -107
  230. package/dist/cjs/js/src/base/ws/OrderBookSide.js +0 -281
  231. package/dist/cjs/js/src/base/ws/WsClient.js +0 -69
  232. package/dist/cjs/js/src/bequant.js +0 -33
  233. package/dist/cjs/js/src/bigone.js +0 -2213
  234. package/dist/cjs/js/src/binance.js +0 -9845
  235. package/dist/cjs/js/src/binancecoinm.js +0 -45
  236. package/dist/cjs/js/src/binanceus.js +0 -92
  237. package/dist/cjs/js/src/binanceusdm.js +0 -58
  238. package/dist/cjs/js/src/bingx.js +0 -3846
  239. package/dist/cjs/js/src/bit2c.js +0 -916
  240. package/dist/cjs/js/src/bitbank.js +0 -1000
  241. package/dist/cjs/js/src/bitbay.js +0 -17
  242. package/dist/cjs/js/src/bitbns.js +0 -1220
  243. package/dist/cjs/js/src/bitcoincom.js +0 -17
  244. package/dist/cjs/js/src/bitfinex.js +0 -1670
  245. package/dist/cjs/js/src/bitfinex2.js +0 -2990
  246. package/dist/cjs/js/src/bitflyer.js +0 -1045
  247. package/dist/cjs/js/src/bitforex.js +0 -852
  248. package/dist/cjs/js/src/bitget.js +0 -8295
  249. package/dist/cjs/js/src/bithumb.js +0 -1090
  250. package/dist/cjs/js/src/bitmart.js +0 -4454
  251. package/dist/cjs/js/src/bitmex.js +0 -2881
  252. package/dist/cjs/js/src/bitopro.js +0 -1724
  253. package/dist/cjs/js/src/bitrue.js +0 -3253
  254. package/dist/cjs/js/src/bitso.js +0 -1753
  255. package/dist/cjs/js/src/bitstamp.js +0 -2188
  256. package/dist/cjs/js/src/bitteam.js +0 -2309
  257. package/dist/cjs/js/src/bitvavo.js +0 -1968
  258. package/dist/cjs/js/src/bl3p.js +0 -447
  259. package/dist/cjs/js/src/blockchaincom.js +0 -1160
  260. package/dist/cjs/js/src/btcalpha.js +0 -929
  261. package/dist/cjs/js/src/btcbox.js +0 -565
  262. package/dist/cjs/js/src/btcmarkets.js +0 -1237
  263. package/dist/cjs/js/src/btcturk.js +0 -929
  264. package/dist/cjs/js/src/bybit.js +0 -7650
  265. package/dist/cjs/js/src/cex.js +0 -1693
  266. package/dist/cjs/js/src/coinbase.js +0 -3424
  267. package/dist/cjs/js/src/coinbasepro.js +0 -1866
  268. package/dist/cjs/js/src/coincheck.js +0 -843
  269. package/dist/cjs/js/src/coinex.js +0 -5417
  270. package/dist/cjs/js/src/coinlist.js +0 -2337
  271. package/dist/cjs/js/src/coinmate.js +0 -989
  272. package/dist/cjs/js/src/coinone.js +0 -1185
  273. package/dist/cjs/js/src/coinsph.js +0 -1933
  274. package/dist/cjs/js/src/coinspot.js +0 -548
  275. package/dist/cjs/js/src/cryptocom.js +0 -3007
  276. package/dist/cjs/js/src/currencycom.js +0 -2015
  277. package/dist/cjs/js/src/delta.js +0 -3262
  278. package/dist/cjs/js/src/deribit.js +0 -3306
  279. package/dist/cjs/js/src/digifinex.js +0 -4307
  280. package/dist/cjs/js/src/exmo.js +0 -2645
  281. package/dist/cjs/js/src/fmfwio.js +0 -34
  282. package/dist/cjs/js/src/gate.js +0 -7077
  283. package/dist/cjs/js/src/gateio.js +0 -16
  284. package/dist/cjs/js/src/gemini.js +0 -1801
  285. package/dist/cjs/js/src/hitbtc.js +0 -3660
  286. package/dist/cjs/js/src/hitbtc3.js +0 -19
  287. package/dist/cjs/js/src/hollaex.js +0 -1882
  288. package/dist/cjs/js/src/htx.js +0 -9174
  289. package/dist/cjs/js/src/huobi.js +0 -16
  290. package/dist/cjs/js/src/huobijp.js +0 -1918
  291. package/dist/cjs/js/src/idex.js +0 -1770
  292. package/dist/cjs/js/src/independentreserve.js +0 -761
  293. package/dist/cjs/js/src/indodax.js +0 -1069
  294. package/dist/cjs/js/src/kraken.js +0 -2891
  295. package/dist/cjs/js/src/krakenfutures.js +0 -2407
  296. package/dist/cjs/js/src/kucoin.js +0 -4494
  297. package/dist/cjs/js/src/kucoinfutures.js +0 -2529
  298. package/dist/cjs/js/src/kuna.js +0 -1949
  299. package/dist/cjs/js/src/latoken.js +0 -1729
  300. package/dist/cjs/js/src/lbank.js +0 -2851
  301. package/dist/cjs/js/src/luno.js +0 -1044
  302. package/dist/cjs/js/src/lykke.js +0 -1303
  303. package/dist/cjs/js/src/mercado.js +0 -897
  304. package/dist/cjs/js/src/mexc.js +0 -5407
  305. package/dist/cjs/js/src/ndax.js +0 -2450
  306. package/dist/cjs/js/src/novadax.js +0 -1556
  307. package/dist/cjs/js/src/oceanex.js +0 -964
  308. package/dist/cjs/js/src/okcoin.js +0 -3115
  309. package/dist/cjs/js/src/okx.js +0 -7331
  310. package/dist/cjs/js/src/p2b.js +0 -1243
  311. package/dist/cjs/js/src/paymium.js +0 -597
  312. package/dist/cjs/js/src/phemex.js +0 -4725
  313. package/dist/cjs/js/src/poloniex.js +0 -2356
  314. package/dist/cjs/js/src/poloniexfutures.js +0 -1794
  315. package/dist/cjs/js/src/pro/alpaca.js +0 -714
  316. package/dist/cjs/js/src/pro/ascendex.js +0 -957
  317. package/dist/cjs/js/src/pro/bequant.js +0 -33
  318. package/dist/cjs/js/src/pro/binance.js +0 -2796
  319. package/dist/cjs/js/src/pro/binancecoinm.js +0 -23
  320. package/dist/cjs/js/src/pro/binanceus.js +0 -51
  321. package/dist/cjs/js/src/pro/binanceusdm.js +0 -32
  322. package/dist/cjs/js/src/pro/bingx.js +0 -944
  323. package/dist/cjs/js/src/pro/bitcoincom.js +0 -29
  324. package/dist/cjs/js/src/pro/bitfinex.js +0 -672
  325. package/dist/cjs/js/src/pro/bitfinex2.js +0 -1159
  326. package/dist/cjs/js/src/pro/bitget.js +0 -1733
  327. package/dist/cjs/js/src/pro/bitmart.js +0 -1486
  328. package/dist/cjs/js/src/pro/bitmex.js +0 -1576
  329. package/dist/cjs/js/src/pro/bitopro.js +0 -327
  330. package/dist/cjs/js/src/pro/bitrue.js +0 -462
  331. package/dist/cjs/js/src/pro/bitstamp.js +0 -547
  332. package/dist/cjs/js/src/pro/bitvavo.js +0 -704
  333. package/dist/cjs/js/src/pro/blockchaincom.js +0 -794
  334. package/dist/cjs/js/src/pro/bybit.js +0 -1843
  335. package/dist/cjs/js/src/pro/cex.js +0 -1510
  336. package/dist/cjs/js/src/pro/coinbase.js +0 -561
  337. package/dist/cjs/js/src/pro/coinbasepro.js +0 -968
  338. package/dist/cjs/js/src/pro/coinex.js +0 -1095
  339. package/dist/cjs/js/src/pro/cryptocom.js +0 -1020
  340. package/dist/cjs/js/src/pro/currencycom.js +0 -563
  341. package/dist/cjs/js/src/pro/deribit.js +0 -825
  342. package/dist/cjs/js/src/pro/exmo.js +0 -658
  343. package/dist/cjs/js/src/pro/gate.js +0 -1316
  344. package/dist/cjs/js/src/pro/gateio.js +0 -16
  345. package/dist/cjs/js/src/pro/gemini.js +0 -649
  346. package/dist/cjs/js/src/pro/hitbtc.js +0 -1294
  347. package/dist/cjs/js/src/pro/hollaex.js +0 -597
  348. package/dist/cjs/js/src/pro/htx.js +0 -2388
  349. package/dist/cjs/js/src/pro/huobi.js +0 -16
  350. package/dist/cjs/js/src/pro/huobijp.js +0 -606
  351. package/dist/cjs/js/src/pro/idex.js +0 -714
  352. package/dist/cjs/js/src/pro/independentreserve.js +0 -280
  353. package/dist/cjs/js/src/pro/kraken.js +0 -1364
  354. package/dist/cjs/js/src/pro/krakenfutures.js +0 -1506
  355. package/dist/cjs/js/src/pro/kucoin.js +0 -1054
  356. package/dist/cjs/js/src/pro/kucoinfutures.js +0 -981
  357. package/dist/cjs/js/src/pro/luno.js +0 -322
  358. package/dist/cjs/js/src/pro/mexc.js +0 -1170
  359. package/dist/cjs/js/src/pro/ndax.js +0 -545
  360. package/dist/cjs/js/src/pro/okcoin.js +0 -760
  361. package/dist/cjs/js/src/pro/okx.js +0 -1608
  362. package/dist/cjs/js/src/pro/phemex.js +0 -1511
  363. package/dist/cjs/js/src/pro/poloniex.js +0 -1253
  364. package/dist/cjs/js/src/pro/poloniexfutures.js +0 -1014
  365. package/dist/cjs/js/src/pro/probit.js +0 -586
  366. package/dist/cjs/js/src/pro/upbit.js +0 -234
  367. package/dist/cjs/js/src/pro/wazirx.js +0 -776
  368. package/dist/cjs/js/src/pro/whitebit.js +0 -927
  369. package/dist/cjs/js/src/pro/woo.js +0 -895
  370. package/dist/cjs/js/src/probit.js +0 -1867
  371. package/dist/cjs/js/src/static_dependencies/fflake/browser.js +0 -401
  372. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +0 -195
  373. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +0 -308
  374. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +0 -554
  375. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +0 -94
  376. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +0 -70
  377. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +0 -91
  378. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +0 -16
  379. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +0 -1760
  380. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +0 -52
  381. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +0 -81
  382. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +0 -376
  383. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +0 -70
  384. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +0 -1580
  385. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +0 -74
  386. package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +0 -24
  387. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +0 -158
  388. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +0 -429
  389. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +0 -176
  390. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +0 -324
  391. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +0 -163
  392. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +0 -245
  393. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +0 -1018
  394. package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +0 -383
  395. package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +0 -258
  396. package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +0 -53
  397. package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +0 -120
  398. package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +0 -69
  399. package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +0 -7
  400. package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +0 -83
  401. package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +0 -240
  402. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +0 -91
  403. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +0 -130
  404. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +0 -214
  405. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +0 -239
  406. package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +0 -93
  407. package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +0 -354
  408. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +0 -16
  409. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +0 -20
  410. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +0 -30
  411. package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +0 -239
  412. package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +0 -372
  413. package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +0 -273
  414. package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +0 -139
  415. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +0 -14
  416. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +0 -16
  417. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +0 -81
  418. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +0 -292
  419. package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +0 -103
  420. package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +0 -140
  421. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +0 -175
  422. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +0 -95
  423. package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +0 -7
  424. package/dist/cjs/js/src/static_dependencies/scure-base/index.js +0 -383
  425. package/dist/cjs/js/src/timex.js +0 -1562
  426. package/dist/cjs/js/src/tokocrypto.js +0 -2542
  427. package/dist/cjs/js/src/upbit.js +0 -1844
  428. package/dist/cjs/js/src/wavesexchange.js +0 -2607
  429. package/dist/cjs/js/src/wazirx.js +0 -953
  430. package/dist/cjs/js/src/whitebit.js +0 -2309
  431. package/dist/cjs/js/src/woo.js +0 -2769
  432. package/dist/cjs/js/src/yobit.js +0 -1314
  433. package/dist/cjs/js/src/zaif.js +0 -736
  434. package/dist/cjs/js/src/zonda.js +0 -1883
  435. package/dist/cjs/src/abstract/bitpanda.js +0 -9
  436. package/test.ts +0 -0
  437. /package/dist/cjs/{js/src/abstract/ace.js → src/abstract/onetrading.js} +0 -0
  438. /package/dist/cjs/{js/src → src}/pro/coinone.js +0 -0
  439. /package/js/src/abstract/{bitpanda.js → onetrading.js} +0 -0
@@ -1,2309 +0,0 @@
1
- 'use strict';
2
-
3
- var whitebit$1 = require('./abstract/whitebit.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 sha512 = require('./static_dependencies/noble-hashes/sha512.js');
8
-
9
- // ---------------------------------------------------------------------------
10
- // ---------------------------------------------------------------------------
11
- /**
12
- * @class whitebit
13
- * @augments Exchange
14
- */
15
- class whitebit extends whitebit$1 {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'whitebit',
19
- 'name': 'WhiteBit',
20
- 'version': 'v4',
21
- 'countries': ['EE'],
22
- 'rateLimit': 500,
23
- 'pro': true,
24
- 'has': {
25
- 'CORS': undefined,
26
- 'spot': true,
27
- 'margin': true,
28
- 'swap': false,
29
- 'future': false,
30
- 'option': false,
31
- 'cancelAllOrders': false,
32
- 'cancelOrder': true,
33
- 'cancelOrders': false,
34
- 'createOrder': true,
35
- 'createStopLimitOrder': true,
36
- 'createStopMarketOrder': true,
37
- 'createStopOrder': true,
38
- 'editOrder': false,
39
- 'fetchBalance': true,
40
- 'fetchBorrowRateHistories': false,
41
- 'fetchBorrowRateHistory': false,
42
- 'fetchClosedOrders': true,
43
- 'fetchCrossBorrowRate': false,
44
- 'fetchCrossBorrowRates': false,
45
- 'fetchCurrencies': true,
46
- 'fetchDeposit': true,
47
- 'fetchDepositAddress': true,
48
- 'fetchDeposits': true,
49
- 'fetchDepositWithdrawFee': 'emulated',
50
- 'fetchDepositWithdrawFees': true,
51
- 'fetchFundingHistory': false,
52
- 'fetchFundingRate': true,
53
- 'fetchFundingRateHistory': false,
54
- 'fetchFundingRates': true,
55
- 'fetchIndexOHLCV': false,
56
- 'fetchIsolatedBorrowRate': false,
57
- 'fetchIsolatedBorrowRates': false,
58
- 'fetchMarginMode': false,
59
- 'fetchMarkets': true,
60
- 'fetchMarkOHLCV': false,
61
- 'fetchMyTrades': true,
62
- 'fetchOHLCV': true,
63
- 'fetchOpenInterestHistory': false,
64
- 'fetchOpenOrders': true,
65
- 'fetchOrderBook': true,
66
- 'fetchOrderTrades': true,
67
- 'fetchPositionMode': false,
68
- 'fetchPremiumIndexOHLCV': false,
69
- 'fetchTicker': true,
70
- 'fetchTickers': true,
71
- 'fetchTime': true,
72
- 'fetchTrades': true,
73
- 'fetchTradingFee': false,
74
- 'fetchTradingFees': true,
75
- 'fetchTransactionFees': true,
76
- 'repayCrossMargin': false,
77
- 'repayIsolatedMargin': false,
78
- 'setLeverage': true,
79
- 'transfer': true,
80
- 'withdraw': true,
81
- },
82
- 'timeframes': {
83
- '1m': '1m',
84
- '3m': '3m',
85
- '5m': '5m',
86
- '15m': '15m',
87
- '30m': '30m',
88
- '1h': '1h',
89
- '2h': '2h',
90
- '4h': '4h',
91
- '6h': '6h',
92
- '8h': '8h',
93
- '12h': '12h',
94
- '1d': '1d',
95
- '3d': '3d',
96
- '1w': '1w',
97
- '1M': '1M',
98
- },
99
- 'urls': {
100
- 'logo': 'https://user-images.githubusercontent.com/1294454/66732963-8eb7dd00-ee66-11e9-849b-10d9282bb9e0.jpg',
101
- 'api': {
102
- 'v1': {
103
- 'public': 'https://whitebit.com/api/v1/public',
104
- 'private': 'https://whitebit.com/api/v1',
105
- },
106
- 'v2': {
107
- 'public': 'https://whitebit.com/api/v2/public',
108
- },
109
- 'v4': {
110
- 'public': 'https://whitebit.com/api/v4/public',
111
- 'private': 'https://whitebit.com/api/v4',
112
- },
113
- },
114
- 'www': 'https://www.whitebit.com',
115
- 'doc': 'https://github.com/whitebit-exchange/api-docs',
116
- 'fees': 'https://whitebit.com/fee-schedule',
117
- 'referral': 'https://whitebit.com/referral/d9bdf40e-28f2-4b52-b2f9-cd1415d82963',
118
- },
119
- 'api': {
120
- 'web': {
121
- 'get': [
122
- 'v1/healthcheck',
123
- ],
124
- },
125
- 'v1': {
126
- 'public': {
127
- 'get': [
128
- 'markets',
129
- 'tickers',
130
- 'ticker',
131
- 'symbols',
132
- 'depth/result',
133
- 'history',
134
- 'kline',
135
- ],
136
- },
137
- 'private': {
138
- 'post': [
139
- 'account/balance',
140
- 'order/new',
141
- 'order/cancel',
142
- 'orders',
143
- 'account/order_history',
144
- 'account/executed_history',
145
- 'account/executed_history/all',
146
- 'account/order',
147
- ],
148
- },
149
- },
150
- 'v2': {
151
- 'public': {
152
- 'get': [
153
- 'markets',
154
- 'ticker',
155
- 'assets',
156
- 'fee',
157
- 'depth/{market}',
158
- 'trades/{market}',
159
- ],
160
- },
161
- },
162
- 'v4': {
163
- 'public': {
164
- 'get': [
165
- 'assets',
166
- 'collateral/markets',
167
- 'fee',
168
- 'orderbook/{market}',
169
- 'ticker',
170
- 'trades/{market}',
171
- 'time',
172
- 'ping',
173
- 'markets',
174
- 'futures',
175
- ],
176
- },
177
- 'private': {
178
- 'post': [
179
- 'collateral-account/balance',
180
- 'collateral-account/positions/history',
181
- 'collateral-account/leverage',
182
- 'collateral-account/positions/open',
183
- 'collateral-account/summary',
184
- 'main-account/address',
185
- 'main-account/balance',
186
- 'main-account/create-new-address',
187
- 'main-account/codes',
188
- 'main-account/codes/apply',
189
- 'main-account/codes/my',
190
- 'main-account/codes/history',
191
- 'main-account/fiat-deposit-url',
192
- 'main-account/history',
193
- 'main-account/withdraw',
194
- 'main-account/withdraw-pay',
195
- 'main-account/transfer',
196
- 'trade-account/balance',
197
- 'trade-account/executed-history',
198
- 'trade-account/order',
199
- 'trade-account/order/history',
200
- 'order/collateral/limit',
201
- 'order/collateral/market',
202
- 'order/collateral/trigger_market',
203
- 'order/new',
204
- 'order/market',
205
- 'order/stock_market',
206
- 'order/stop_limit',
207
- 'order/stop_market',
208
- 'order/cancel',
209
- 'orders',
210
- 'profile/websocket_token',
211
- ],
212
- },
213
- },
214
- },
215
- 'fees': {
216
- 'trading': {
217
- 'tierBased': false,
218
- 'percentage': true,
219
- 'taker': this.parseNumber('0.001'),
220
- 'maker': this.parseNumber('0.001'),
221
- },
222
- },
223
- 'options': {
224
- 'fiatCurrencies': ['EUR', 'USD', 'RUB', 'UAH'],
225
- 'fetchBalance': {
226
- 'account': 'spot',
227
- },
228
- 'accountsByType': {
229
- 'main': 'main',
230
- 'spot': 'spot',
231
- 'margin': 'collateral',
232
- 'trade': 'spot',
233
- },
234
- 'networksById': {
235
- 'BEP20': 'BSC',
236
- },
237
- 'defaultType': 'spot',
238
- 'brokerId': 'ccxt',
239
- },
240
- 'precisionMode': number.TICK_SIZE,
241
- 'exceptions': {
242
- 'exact': {
243
- 'Unauthorized request.': errors.AuthenticationError,
244
- 'The market format is invalid.': errors.BadSymbol,
245
- 'Market is not available': errors.BadSymbol,
246
- 'Invalid payload.': errors.BadRequest,
247
- 'Amount must be greater than 0': errors.InvalidOrder,
248
- 'Not enough balance.': errors.InsufficientFunds,
249
- 'The order id field is required.': errors.InvalidOrder,
250
- 'Not enough balance': errors.InsufficientFunds,
251
- 'This action is unauthorized.': errors.PermissionDenied,
252
- 'This API Key is not authorized to perform this action.': errors.PermissionDenied,
253
- 'Unexecuted order was not found.': errors.OrderNotFound,
254
- 'The selected from is invalid.': errors.BadRequest,
255
- '503': errors.ExchangeNotAvailable,
256
- '422': errors.OrderNotFound, // {"response":null,"status":422,"errors":{"orderId":["Finished order id 1295772653 not found on your account"]},"notification":null,"warning":"Finished order id 1295772653 not found on your account","_token":null}
257
- },
258
- 'broad': {
259
- 'This action is unauthorized': errors.PermissionDenied,
260
- 'Given amount is less than min amount': errors.InvalidOrder,
261
- 'Total is less than': errors.InvalidOrder,
262
- 'fee must be no less than': errors.InvalidOrder,
263
- 'Enable your key in API settings': errors.PermissionDenied,
264
- 'You don\'t have such amount for transfer': errors.InsufficientFunds, // {"code":3,"message":"Inner validation failed","errors":{"amount":["You don't have such amount for transfer (available 0.44523433, in amount: 2)"]}}
265
- },
266
- },
267
- });
268
- }
269
- async fetchMarkets(params = {}) {
270
- /**
271
- * @method
272
- * @name whitebit#fetchMarkets
273
- * @description retrieves data on all markets for whitebit
274
- * @see https://docs.whitebit.com/public/http-v4/#market-info
275
- * @param {object} [params] extra parameters specific to the exchange API endpoint
276
- * @returns {object[]} an array of objects representing market data
277
- */
278
- const markets = await this.v4PublicGetMarkets();
279
- //
280
- // [
281
- // {
282
- // "name": "SON_USD", // Market pair name
283
- // "stock": "SON", // Ticker of stock currency
284
- // "money": "USD", // Ticker of money currency
285
- // "stockPrec": "3", // Stock currency precision
286
- // "moneyPrec": "2", // Precision of money currency
287
- // "feePrec": "4", // Fee precision
288
- // "makerFee": "0.1", // Default maker fee ratio
289
- // "takerFee": "0.1", // Default taker fee ratio
290
- // "minAmount": "0.001", // Minimal amount of stock to trade
291
- // "minTotal": "0.001", // Minimal amount of money to trade
292
- // "tradesEnabled": true, // Is trading enabled
293
- // "isCollateral": true, // Is margin trading enabled
294
- // "type": "spot", // Market type. Possible values: "spot", "futures"
295
- // "maxTotal": "1000000000" // Maximum total(amount * price) of money to trade
296
- // },
297
- // {
298
- // ...
299
- // }
300
- // ]
301
- //
302
- return this.parseMarkets(markets);
303
- }
304
- parseMarket(market) {
305
- const id = this.safeString(market, 'name');
306
- const baseId = this.safeString(market, 'stock');
307
- let quoteId = this.safeString(market, 'money');
308
- quoteId = (quoteId === 'PERP') ? 'USDT' : quoteId;
309
- const base = this.safeCurrencyCode(baseId);
310
- const quote = this.safeCurrencyCode(quoteId);
311
- const active = this.safeValue(market, 'tradesEnabled');
312
- const isCollateral = this.safeValue(market, 'isCollateral');
313
- const typeId = this.safeString(market, 'type');
314
- let type;
315
- let settle = undefined;
316
- let settleId = undefined;
317
- let symbol = base + '/' + quote;
318
- const swap = typeId === 'futures';
319
- const margin = isCollateral && !swap;
320
- let contract = false;
321
- const amountPrecision = this.parseNumber(this.parsePrecision(this.safeString(market, 'stockPrec')));
322
- const contractSize = amountPrecision;
323
- let linear = undefined;
324
- let inverse = undefined;
325
- if (swap) {
326
- settleId = quoteId;
327
- settle = this.safeCurrencyCode(settleId);
328
- symbol = symbol + ':' + settle;
329
- type = 'swap';
330
- contract = true;
331
- linear = true;
332
- inverse = false;
333
- }
334
- else {
335
- type = 'spot';
336
- }
337
- const takerFeeRate = this.safeString(market, 'takerFee');
338
- const taker = Precise["default"].stringDiv(takerFeeRate, '100');
339
- const makerFeeRate = this.safeString(market, 'makerFee');
340
- const maker = Precise["default"].stringDiv(makerFeeRate, '100');
341
- return {
342
- 'id': id,
343
- 'symbol': symbol,
344
- 'base': base,
345
- 'quote': quote,
346
- 'settle': settle,
347
- 'baseId': baseId,
348
- 'quoteId': quoteId,
349
- 'settleId': settleId,
350
- 'type': type,
351
- 'spot': !swap,
352
- 'margin': margin,
353
- 'swap': swap,
354
- 'future': false,
355
- 'option': false,
356
- 'active': active,
357
- 'contract': contract,
358
- 'linear': linear,
359
- 'inverse': inverse,
360
- 'taker': this.parseNumber(taker),
361
- 'maker': this.parseNumber(maker),
362
- 'contractSize': contractSize,
363
- 'expiry': undefined,
364
- 'expiryDatetime': undefined,
365
- 'strike': undefined,
366
- 'optionType': undefined,
367
- 'precision': {
368
- 'amount': amountPrecision,
369
- 'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'moneyPrec'))),
370
- },
371
- 'limits': {
372
- 'leverage': {
373
- 'min': undefined,
374
- 'max': undefined,
375
- },
376
- 'amount': {
377
- 'min': this.safeNumber(market, 'minAmount'),
378
- 'max': undefined,
379
- },
380
- 'price': {
381
- 'min': undefined,
382
- 'max': undefined,
383
- },
384
- 'cost': {
385
- 'min': this.safeNumber(market, 'minTotal'),
386
- 'max': this.safeNumber(market, 'maxTotal'),
387
- },
388
- },
389
- 'created': undefined,
390
- 'info': market,
391
- };
392
- }
393
- async fetchCurrencies(params = {}) {
394
- /**
395
- * @method
396
- * @name whitebit#fetchCurrencies
397
- * @description fetches all available currencies on an exchange
398
- * @see https://docs.whitebit.com/public/http-v4/#asset-status-list
399
- * @param {object} [params] extra parameters specific to the exchange API endpoint
400
- * @returns {object} an associative dictionary of currencies
401
- */
402
- const response = await this.v4PublicGetAssets(params);
403
- //
404
- // "BTC": {
405
- // "name": "Bitcoin",
406
- // "unified_cryptoasset_id": 1,
407
- // "can_withdraw": true,
408
- // "can_deposit": true,
409
- // "min_withdraw": "0.001",
410
- // "max_withdraw": "2",
411
- // "maker_fee": "0.1",
412
- // "taker_fee": "0.1",
413
- // "min_deposit": "0.0001",
414
- // "max_deposit": "0",
415
- // },
416
- //
417
- const ids = Object.keys(response);
418
- const result = {};
419
- for (let i = 0; i < ids.length; i++) {
420
- const id = ids[i];
421
- const currency = response[id];
422
- // breaks down in Python due to utf8 encoding issues on the exchange side
423
- // const name = this.safeString (currency, 'name');
424
- const canDeposit = this.safeValue(currency, 'can_deposit', true);
425
- const canWithdraw = this.safeValue(currency, 'can_withdraw', true);
426
- const active = canDeposit && canWithdraw;
427
- const code = this.safeCurrencyCode(id);
428
- result[code] = {
429
- 'id': id,
430
- 'code': code,
431
- 'info': currency,
432
- 'name': undefined,
433
- 'active': active,
434
- 'deposit': canDeposit,
435
- 'withdraw': canWithdraw,
436
- 'fee': undefined,
437
- 'precision': undefined,
438
- 'limits': {
439
- 'amount': {
440
- 'min': undefined,
441
- 'max': undefined,
442
- },
443
- 'withdraw': {
444
- 'min': this.safeNumber(currency, 'min_withdraw'),
445
- 'max': this.safeNumber(currency, 'max_withdraw'),
446
- },
447
- },
448
- };
449
- }
450
- return result;
451
- }
452
- async fetchTransactionFees(codes = undefined, params = {}) {
453
- /**
454
- * @method
455
- * @name whitebit#fetchTransactionFees
456
- * @deprecated
457
- * @description please use fetchDepositWithdrawFees instead
458
- * @see https://docs.whitebit.com/public/http-v4/#fee
459
- * @param {string[]|undefined} codes not used by fetchTransactionFees ()
460
- * @param {object} [params] extra parameters specific to the exchange API endpoint
461
- * @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
462
- */
463
- await this.loadMarkets();
464
- const response = await this.v4PublicGetFee(params);
465
- //
466
- // {
467
- // "1INCH":{
468
- // "is_depositable":true,
469
- // "is_withdrawal":true,
470
- // "ticker":"1INCH",
471
- // "name":"1inch",
472
- // "providers":[
473
- // ],
474
- // "withdraw":{
475
- // "max_amount":"0",
476
- // "min_amount":"21.5",
477
- // "fixed":"17.5",
478
- // "flex":null
479
- // },
480
- // "deposit":{
481
- // "max_amount":"0",
482
- // "min_amount":"19.5",
483
- // "fixed":null,
484
- // "flex":null
485
- // }
486
- // },
487
- // {...}
488
- // }
489
- //
490
- const currenciesIds = Object.keys(response);
491
- const withdrawFees = {};
492
- const depositFees = {};
493
- for (let i = 0; i < currenciesIds.length; i++) {
494
- const currency = currenciesIds[i];
495
- const data = response[currency];
496
- const code = this.safeCurrencyCode(currency);
497
- const withdraw = this.safeValue(data, 'withdraw', {});
498
- withdrawFees[code] = this.safeString(withdraw, 'fixed');
499
- const deposit = this.safeValue(data, 'deposit', {});
500
- depositFees[code] = this.safeString(deposit, 'fixed');
501
- }
502
- return {
503
- 'withdraw': withdrawFees,
504
- 'deposit': depositFees,
505
- 'info': response,
506
- };
507
- }
508
- async fetchDepositWithdrawFees(codes = undefined, params = {}) {
509
- /**
510
- * @method
511
- * @name whitebit#fetchDepositWithdrawFees
512
- * @description fetch deposit and withdraw fees
513
- * @see https://docs.whitebit.com/public/http-v4/#fee
514
- * @param {string[]|undefined} codes not used by fetchDepositWithdrawFees ()
515
- * @param {object} [params] extra parameters specific to the exchange API endpoint
516
- * @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
517
- */
518
- await this.loadMarkets();
519
- const response = await this.v4PublicGetFee(params);
520
- //
521
- // {
522
- // "1INCH": {
523
- // "is_depositable": true,
524
- // "is_withdrawal": true,
525
- // "ticker": "1INCH",
526
- // "name": "1inch",
527
- // "providers": [],
528
- // "withdraw": {
529
- // "max_amount": "0",
530
- // "min_amount": "21.5",
531
- // "fixed": "17.5",
532
- // "flex": null
533
- // },
534
- // "deposit": {
535
- // "max_amount": "0",
536
- // "min_amount": "19.5",
537
- // "fixed": null,
538
- // "flex": null
539
- // }
540
- // },
541
- // "WBT (ERC20)": {
542
- // "is_depositable": true,
543
- // "is_withdrawal": true,
544
- // "ticker": "WBT",
545
- // "name": "WhiteBIT Token",
546
- // "providers": [],
547
- // "withdraw": { max_amount: "0", min_amount: '0.7', fixed: "0.253", flex: null },
548
- // "deposit": { max_amount: "0", min_amount: "0.35", fixed: null, flex: null }
549
- // },
550
- // "WBT (TRC20)": {
551
- // "is_depositable": true,
552
- // "is_withdrawal": true,
553
- // "ticker": "WBT",
554
- // "name": "WhiteBIT Token",
555
- // "providers": [],
556
- // "withdraw": { max_amount: "0", min_amount: "1.5", fixed: "0.075", flex: null },
557
- // "deposit": { max_amount: "0", min_amount: "0.75", fixed: null, flex: null }
558
- // },
559
- // ...
560
- // }
561
- //
562
- return this.parseDepositWithdrawFees(response, codes);
563
- }
564
- parseDepositWithdrawFees(response, codes = undefined, currencyIdKey = undefined) {
565
- //
566
- // {
567
- // "1INCH": {
568
- // "is_depositable": true,
569
- // "is_withdrawal": true,
570
- // "ticker": "1INCH",
571
- // "name": "1inch",
572
- // "providers": [],
573
- // "withdraw": {
574
- // "max_amount": "0",
575
- // "min_amount": "21.5",
576
- // "fixed": "17.5",
577
- // "flex": null
578
- // },
579
- // "deposit": {
580
- // "max_amount": "0",
581
- // "min_amount": "19.5",
582
- // "fixed": null,
583
- // "flex": null
584
- // }
585
- // },
586
- // "WBT (ERC20)": {
587
- // "is_depositable": true,
588
- // "is_withdrawal": true,
589
- // "ticker": "WBT",
590
- // "name": "WhiteBIT Token",
591
- // "providers": [],
592
- // "withdraw": { max_amount: "0", min_amount: "0.7", fixed: "0.253", flex: null },
593
- // "deposit": { max_amount: "0", min_amount: "0.35", fixed: null, flex: null }
594
- // },
595
- // "WBT (TRC20)": {
596
- // "is_depositable": true,
597
- // "is_withdrawal": true,
598
- // "ticker": "WBT",
599
- // "name": "WhiteBIT Token",
600
- // "providers": [],
601
- // "withdraw": { max_amount: "0", min_amount: "1.5", fixed: "0.075", flex: null },
602
- // "deposit": { max_amount: "0", min_amount: "0.75", fixed: null, flex: null }
603
- // },
604
- // ...
605
- // }
606
- //
607
- const depositWithdrawFees = {};
608
- codes = this.marketCodes(codes);
609
- const currencyIds = Object.keys(response);
610
- for (let i = 0; i < currencyIds.length; i++) {
611
- const entry = currencyIds[i];
612
- const splitEntry = entry.split(' ');
613
- const currencyId = splitEntry[0];
614
- const feeInfo = response[entry];
615
- const code = this.safeCurrencyCode(currencyId);
616
- if ((codes === undefined) || (this.inArray(code, codes))) {
617
- const depositWithdrawFee = this.safeValue(depositWithdrawFees, code);
618
- if (depositWithdrawFee === undefined) {
619
- depositWithdrawFees[code] = this.depositWithdrawFee({});
620
- }
621
- depositWithdrawFees[code]['info'][entry] = feeInfo;
622
- let networkId = this.safeString(splitEntry, 1);
623
- const withdraw = this.safeValue(feeInfo, 'withdraw');
624
- const deposit = this.safeValue(feeInfo, 'deposit');
625
- const withdrawFee = this.safeNumber(withdraw, 'fixed');
626
- const depositFee = this.safeNumber(deposit, 'fixed');
627
- const withdrawResult = {
628
- 'fee': withdrawFee,
629
- 'percentage': (withdrawFee !== undefined) ? false : undefined,
630
- };
631
- const depositResult = {
632
- 'fee': depositFee,
633
- 'percentage': (depositFee !== undefined) ? false : undefined,
634
- };
635
- if (networkId !== undefined) {
636
- const networkLength = networkId.length;
637
- networkId = networkId.slice(1, networkLength - 1);
638
- const networkCode = this.networkIdToCode(networkId);
639
- depositWithdrawFees[code]['networks'][networkCode] = {
640
- 'withdraw': withdrawResult,
641
- 'deposit': depositResult,
642
- };
643
- }
644
- else {
645
- depositWithdrawFees[code]['withdraw'] = withdrawResult;
646
- depositWithdrawFees[code]['deposit'] = depositResult;
647
- }
648
- }
649
- }
650
- const depositWithdrawCodes = Object.keys(depositWithdrawFees);
651
- for (let i = 0; i < depositWithdrawCodes.length; i++) {
652
- const code = depositWithdrawCodes[i];
653
- const currency = this.currency(code);
654
- depositWithdrawFees[code] = this.assignDefaultDepositWithdrawFees(depositWithdrawFees[code], currency);
655
- }
656
- return depositWithdrawFees;
657
- }
658
- async fetchTradingFees(params = {}) {
659
- /**
660
- * @method
661
- * @name whitebit#fetchTradingFees
662
- * @description fetch the trading fees for multiple markets
663
- * @see https://docs.whitebit.com/public/http-v4/#asset-status-list
664
- * @param {object} [params] extra parameters specific to the exchange API endpoint
665
- * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
666
- */
667
- await this.loadMarkets();
668
- const response = await this.v4PublicGetAssets(params);
669
- //
670
- // {
671
- // "1INCH": {
672
- // "name": "1inch",
673
- // "unified_cryptoasset_id": "8104",
674
- // "can_withdraw": true,
675
- // "can_deposit": true,
676
- // "min_withdraw": "33",
677
- // "max_withdraw": "0",
678
- // "maker_fee": "0.1",
679
- // "taker_fee": "0.1",
680
- // "min_deposit": "30",
681
- // "max_deposit": "0"
682
- // },
683
- // ...
684
- // }
685
- //
686
- const result = {};
687
- for (let i = 0; i < this.symbols.length; i++) {
688
- const symbol = this.symbols[i];
689
- const market = this.market(symbol);
690
- const fee = this.safeValue(response, market['baseId'], {});
691
- let makerFee = this.safeString(fee, 'maker_fee');
692
- let takerFee = this.safeString(fee, 'taker_fee');
693
- makerFee = Precise["default"].stringDiv(makerFee, '100');
694
- takerFee = Precise["default"].stringDiv(takerFee, '100');
695
- result[symbol] = {
696
- 'info': fee,
697
- 'symbol': market['symbol'],
698
- 'percentage': true,
699
- 'tierBased': false,
700
- 'maker': this.parseNumber(makerFee),
701
- 'taker': this.parseNumber(takerFee),
702
- };
703
- }
704
- return result;
705
- }
706
- async fetchTicker(symbol, params = {}) {
707
- /**
708
- * @method
709
- * @name whitebit#fetchTicker
710
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
711
- * @see https://docs.whitebit.com/public/http-v4/#market-activity
712
- * @param {string} symbol unified symbol of the market to fetch the ticker for
713
- * @param {object} [params] extra parameters specific to the exchange API endpoint
714
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
715
- */
716
- await this.loadMarkets();
717
- const market = this.market(symbol);
718
- const request = {
719
- 'market': market['id'],
720
- };
721
- const response = await this.v1PublicGetTicker(this.extend(request, params));
722
- //
723
- // {
724
- // "success":true,
725
- // "message":"",
726
- // "result": {
727
- // "bid":"0.021979",
728
- // "ask":"0.021996",
729
- // "open":"0.02182",
730
- // "high":"0.022039",
731
- // "low":"0.02161",
732
- // "last":"0.021987",
733
- // "volume":"2810.267",
734
- // "deal":"61.383565474",
735
- // "change":"0.76",
736
- // },
737
- // }
738
- //
739
- const ticker = this.safeValue(response, 'result', {});
740
- return this.parseTicker(ticker, market);
741
- }
742
- parseTicker(ticker, market = undefined) {
743
- //
744
- // FetchTicker (v1)
745
- //
746
- // {
747
- // "bid": "0.021979",
748
- // "ask": "0.021996",
749
- // "open": "0.02182",
750
- // "high": "0.022039",
751
- // "low": "0.02161",
752
- // "last": "0.021987",
753
- // "volume": "2810.267",
754
- // "deal": "61.383565474",
755
- // "change": "0.76",
756
- // }
757
- //
758
- // FetchTickers (v4)
759
- //
760
- // "BCH_RUB": {
761
- // "base_id": 1831,
762
- // "quote_id": 0,
763
- // "last_price": "32830.21",
764
- // "quote_volume": "1494659.8024096",
765
- // "base_volume": "46.1083",
766
- // "isFrozen": false,
767
- // "change": "2.12" // in percent
768
- // }
769
- //
770
- market = this.safeMarket(undefined, market);
771
- const last = this.safeString(ticker, 'last_price');
772
- return this.safeTicker({
773
- 'symbol': market['symbol'],
774
- 'timestamp': undefined,
775
- 'datetime': undefined,
776
- 'high': this.safeString(ticker, 'high'),
777
- 'low': this.safeString(ticker, 'low'),
778
- 'bid': this.safeString(ticker, 'bid'),
779
- 'bidVolume': undefined,
780
- 'ask': this.safeString(ticker, 'ask'),
781
- 'askVolume': undefined,
782
- 'vwap': undefined,
783
- 'open': this.safeString(ticker, 'open'),
784
- 'close': last,
785
- 'last': last,
786
- 'previousClose': undefined,
787
- 'change': undefined,
788
- 'percentage': this.safeString(ticker, 'change'),
789
- 'average': undefined,
790
- 'baseVolume': this.safeString2(ticker, 'base_volume', 'volume'),
791
- 'quoteVolume': this.safeString2(ticker, 'quote_volume', 'deal'),
792
- 'info': ticker,
793
- }, market);
794
- }
795
- async fetchTickers(symbols = undefined, params = {}) {
796
- /**
797
- * @method
798
- * @name whitebit#fetchTickers
799
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
800
- * @see https://docs.whitebit.com/public/http-v4/#market-activity
801
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
802
- * @param {object} [params] extra parameters specific to the exchange API endpoint
803
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
804
- */
805
- await this.loadMarkets();
806
- symbols = this.marketSymbols(symbols);
807
- const response = await this.v4PublicGetTicker(params);
808
- //
809
- // "BCH_RUB": {
810
- // "base_id":1831,
811
- // "quote_id":0,
812
- // "last_price":"32830.21",
813
- // "quote_volume":"1494659.8024096",
814
- // "base_volume":"46.1083",
815
- // "isFrozen":false,
816
- // "change":"2.12"
817
- // },
818
- //
819
- const marketIds = Object.keys(response);
820
- const result = {};
821
- for (let i = 0; i < marketIds.length; i++) {
822
- const marketId = marketIds[i];
823
- const market = this.safeMarket(marketId);
824
- const ticker = this.parseTicker(response[marketId], market);
825
- const symbol = ticker['symbol'];
826
- result[symbol] = ticker;
827
- }
828
- return this.filterByArrayTickers(result, 'symbol', symbols);
829
- }
830
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
831
- /**
832
- * @method
833
- * @name whitebit#fetchOrderBook
834
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
835
- * @see https://docs.whitebit.com/public/http-v4/#orderbook
836
- * @param {string} symbol unified symbol of the market to fetch the order book for
837
- * @param {int} [limit] the maximum amount of order book entries to return
838
- * @param {object} [params] extra parameters specific to the exchange API endpoint
839
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
840
- */
841
- await this.loadMarkets();
842
- const market = this.market(symbol);
843
- const request = {
844
- 'market': market['id'],
845
- };
846
- if (limit !== undefined) {
847
- request['limit'] = limit; // default = 100, maximum = 100
848
- }
849
- const response = await this.v4PublicGetOrderbookMarket(this.extend(request, params));
850
- //
851
- // {
852
- // "timestamp": 1594391413,
853
- // "asks": [
854
- // [
855
- // "9184.41",
856
- // "0.773162"
857
- // ],
858
- // [ ... ]
859
- // ],
860
- // "bids": [
861
- // [
862
- // "9181.19",
863
- // "0.010873"
864
- // ],
865
- // [ ... ]
866
- // ]
867
- // }
868
- //
869
- const timestamp = this.safeTimestamp(response, 'timestamp');
870
- return this.parseOrderBook(response, symbol, timestamp);
871
- }
872
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
873
- /**
874
- * @method
875
- * @name whitebit#fetchTrades
876
- * @description get the list of most recent trades for a particular symbol
877
- * @see https://docs.whitebit.com/public/http-v4/#recent-trades
878
- * @param {string} symbol unified symbol of the market to fetch trades for
879
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
880
- * @param {int} [limit] the maximum amount of trades to fetch
881
- * @param {object} [params] extra parameters specific to the exchange API endpoint
882
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
883
- */
884
- await this.loadMarkets();
885
- const market = this.market(symbol);
886
- const request = {
887
- 'market': market['id'],
888
- };
889
- const response = await this.v4PublicGetTradesMarket(this.extend(request, params));
890
- //
891
- // [
892
- // {
893
- // "tradeID": 158056419,
894
- // "price": "9186.13",
895
- // "quote_volume": "0.0021",
896
- // "base_volume": "9186.13",
897
- // "trade_timestamp": 1594391747,
898
- // "type": "sell"
899
- // },
900
- // ],
901
- //
902
- return this.parseTrades(response, market, since, limit);
903
- }
904
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
905
- /**
906
- * @method
907
- * @name whitebit#fetchMyTrades
908
- * @description fetch all trades made by the user
909
- * @see https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-history
910
- * @param {string} symbol unified symbol of the market to fetch trades for
911
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
912
- * @param {int} [limit] the maximum amount of trades to fetch
913
- * @param {object} [params] extra parameters specific to the exchange API endpoint
914
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
915
- */
916
- await this.loadMarkets();
917
- let market = undefined;
918
- const request = {};
919
- if (symbol !== undefined) {
920
- market = this.market(symbol);
921
- request['market'] = market['id'];
922
- }
923
- const response = await this.v4PrivatePostTradeAccountExecutedHistory(this.extend(request, params));
924
- //
925
- // when no symbol is provided
926
- //
927
- // {
928
- // "USDC_USDT":[
929
- // {
930
- // "id":"1343815269",
931
- // "clientOrderId":"",
932
- // "time":"1641051917.532965",
933
- // "side":"sell",
934
- // "role":"2",
935
- // "amount":"9.986",
936
- // "price":"0.9995",
937
- // "deal":"9.981007",
938
- // "fee":"0.009981007",
939
- // "orderId":"58166729555"
940
- // },
941
- // ]
942
- // }
943
- //
944
- // when a symbol is provided
945
- //
946
- // [
947
- // {
948
- // "id": 1343815269,
949
- // "clientOrderId": '',
950
- // "time": 1641051917.532965,
951
- // "side": "sell",
952
- // "role": 2,
953
- // "amount": "9.986",
954
- // "price": "0.9995",
955
- // "deal": "9.981007",
956
- // "fee": "0.009981007",
957
- // "orderId": 58166729555,
958
- // },
959
- // ]
960
- //
961
- if (Array.isArray(response)) {
962
- return this.parseTrades(response, market, since, limit);
963
- }
964
- else {
965
- let results = [];
966
- const keys = Object.keys(response);
967
- for (let i = 0; i < keys.length; i++) {
968
- const marketId = keys[i];
969
- const marketNew = this.safeMarket(marketId, undefined, '_');
970
- const rawTrades = this.safeValue(response, marketId, []);
971
- const parsed = this.parseTrades(rawTrades, marketNew, since, limit);
972
- results = this.arrayConcat(results, parsed);
973
- }
974
- results = this.sortBy2(results, 'timestamp', 'id');
975
- return this.filterBySinceLimit(results, since, limit, 'timestamp');
976
- }
977
- }
978
- parseTrade(trade, market = undefined) {
979
- //
980
- // fetchTradesV4
981
- //
982
- // {
983
- // "tradeID": 158056419,
984
- // "price": "9186.13",
985
- // "quote_volume": "0.0021",
986
- // "base_volume": "9186.13",
987
- // "trade_timestamp": 1594391747,
988
- // "type": "sell"
989
- // }
990
- //
991
- // orderTrades (v4Private)
992
- //
993
- // {
994
- // "time": 1593342324.613711,
995
- // "fee": "0.00000419198",
996
- // "price": "0.00000701",
997
- // "amount": "598",
998
- // "id": 149156519, // trade id
999
- // "dealOrderId": 3134995325, // orderId
1000
- // "clientOrderId": "customId11",
1001
- // "role": 2, // 1 = maker, 2 = taker
1002
- // "deal": "0.00419198" // amount in money
1003
- // }
1004
- //
1005
- // fetchMyTrades
1006
- //
1007
- // {
1008
- // "id": 1343815269,
1009
- // "clientOrderId": '',
1010
- // "time": 1641051917.532965,
1011
- // "side": "sell",
1012
- // "role": 2,
1013
- // "amount": "9.986",
1014
- // "price": "0.9995",
1015
- // "deal": "9.981007",
1016
- // "fee": "0.009981007",
1017
- // "orderId": 58166729555,
1018
- // }
1019
- //
1020
- market = this.safeMarket(undefined, market);
1021
- const timestamp = this.safeTimestamp2(trade, 'time', 'trade_timestamp');
1022
- const orderId = this.safeString2(trade, 'dealOrderId', 'orderId');
1023
- const cost = this.safeString(trade, 'deal');
1024
- const price = this.safeString(trade, 'price');
1025
- const amount = this.safeString2(trade, 'amount', 'quote_volume');
1026
- const id = this.safeString2(trade, 'id', 'tradeID');
1027
- const side = this.safeString2(trade, 'type', 'side');
1028
- const symbol = market['symbol'];
1029
- const role = this.safeInteger(trade, 'role');
1030
- let takerOrMaker = undefined;
1031
- if (role !== undefined) {
1032
- takerOrMaker = (role === 1) ? 'maker' : 'taker';
1033
- }
1034
- let fee = undefined;
1035
- const feeCost = this.safeString(trade, 'fee');
1036
- if (feeCost !== undefined) {
1037
- fee = {
1038
- 'cost': feeCost,
1039
- 'currency': market['quote'],
1040
- };
1041
- }
1042
- return this.safeTrade({
1043
- 'info': trade,
1044
- 'timestamp': timestamp,
1045
- 'datetime': this.iso8601(timestamp),
1046
- 'symbol': symbol,
1047
- 'id': id,
1048
- 'order': orderId,
1049
- 'type': undefined,
1050
- 'takerOrMaker': takerOrMaker,
1051
- 'side': side,
1052
- 'price': price,
1053
- 'amount': amount,
1054
- 'cost': cost,
1055
- 'fee': fee,
1056
- }, market);
1057
- }
1058
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1059
- /**
1060
- * @method
1061
- * @name whitebit#fetchOHLCV
1062
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1063
- * @see https://docs.whitebit.com/public/http-v1/#kline
1064
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1065
- * @param {string} timeframe the length of time each candle represents
1066
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
1067
- * @param {int} [limit] the maximum amount of candles to fetch
1068
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1069
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1070
- */
1071
- await this.loadMarkets();
1072
- const market = this.market(symbol);
1073
- const request = {
1074
- 'market': market['id'],
1075
- 'interval': this.safeString(this.timeframes, timeframe, timeframe),
1076
- };
1077
- if (since !== undefined) {
1078
- const maxLimit = 1440;
1079
- if (limit === undefined) {
1080
- limit = maxLimit;
1081
- }
1082
- limit = Math.min(limit, maxLimit);
1083
- const start = this.parseToInt(since / 1000);
1084
- request['start'] = start;
1085
- }
1086
- if (limit !== undefined) {
1087
- request['limit'] = Math.min(limit, 1440);
1088
- }
1089
- const response = await this.v1PublicGetKline(this.extend(request, params));
1090
- //
1091
- // {
1092
- // "success":true,
1093
- // "message":"",
1094
- // "result":[
1095
- // [1591488000,"0.025025","0.025025","0.025029","0.025023","6.181","0.154686629"],
1096
- // [1591488060,"0.025028","0.025033","0.025035","0.025026","8.067","0.201921167"],
1097
- // [1591488120,"0.025034","0.02505","0.02505","0.025034","20.089","0.503114696"],
1098
- // ]
1099
- // }
1100
- //
1101
- const result = this.safeValue(response, 'result', []);
1102
- return this.parseOHLCVs(result, market, timeframe, since, limit);
1103
- }
1104
- parseOHLCV(ohlcv, market = undefined) {
1105
- //
1106
- // [
1107
- // 1591488000,
1108
- // "0.025025",
1109
- // "0.025025",
1110
- // "0.025029",
1111
- // "0.025023",
1112
- // "6.181",
1113
- // "0.154686629"
1114
- // ]
1115
- //
1116
- return [
1117
- this.safeTimestamp(ohlcv, 0),
1118
- this.safeNumber(ohlcv, 1),
1119
- this.safeNumber(ohlcv, 3),
1120
- this.safeNumber(ohlcv, 4),
1121
- this.safeNumber(ohlcv, 2),
1122
- this.safeNumber(ohlcv, 5), // volume
1123
- ];
1124
- }
1125
- async fetchStatus(params = {}) {
1126
- /**
1127
- * @method
1128
- * @name whitebit#fetchStatus
1129
- * @description the latest known information on the availability of the exchange API
1130
- * @see https://docs.whitebit.com/public/http-v4/#server-status
1131
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1132
- * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
1133
- */
1134
- const response = await this.v4PublicGetPing(params);
1135
- //
1136
- // [
1137
- // "pong"
1138
- // ]
1139
- //
1140
- const status = this.safeString(response, 0);
1141
- return {
1142
- 'status': (status === 'pong') ? 'ok' : status,
1143
- 'updated': undefined,
1144
- 'eta': undefined,
1145
- 'url': undefined,
1146
- 'info': response,
1147
- };
1148
- }
1149
- async fetchTime(params = {}) {
1150
- /**
1151
- * @method
1152
- * @name whitebit#fetchTime
1153
- * @description fetches the current integer timestamp in milliseconds from the exchange server
1154
- * @see https://docs.whitebit.com/public/http-v4/#server-time
1155
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1156
- * @returns {int} the current integer timestamp in milliseconds from the exchange server
1157
- */
1158
- const response = await this.v4PublicGetTime(params);
1159
- //
1160
- // {
1161
- // "time":1635467280514
1162
- // }
1163
- //
1164
- return this.safeInteger(response, 'time');
1165
- }
1166
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1167
- /**
1168
- * @method
1169
- * @name whitebit#createOrder
1170
- * @description create a trade order
1171
- * @see https://docs.whitebit.com/private/http-trade-v4/#create-limit-order
1172
- * @see https://docs.whitebit.com/private/http-trade-v4/#create-market-order
1173
- * @see https://docs.whitebit.com/private/http-trade-v4/#create-buy-stock-market-order
1174
- * @see https://docs.whitebit.com/private/http-trade-v4/#create-stop-limit-order
1175
- * @see https://docs.whitebit.com/private/http-trade-v4/#create-stop-market-order
1176
- * @param {string} symbol unified symbol of the market to create an order in
1177
- * @param {string} type 'market' or 'limit'
1178
- * @param {string} side 'buy' or 'sell'
1179
- * @param {float} amount how much of currency you want to trade in units of base currency
1180
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1181
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1182
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1183
- */
1184
- await this.loadMarkets();
1185
- const market = this.market(symbol);
1186
- const request = {
1187
- 'market': market['id'],
1188
- 'side': side,
1189
- 'amount': this.amountToPrecision(symbol, amount),
1190
- };
1191
- const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
1192
- if (clientOrderId === undefined) {
1193
- const brokerId = this.safeString(this.options, 'brokerId');
1194
- if (brokerId !== undefined) {
1195
- request['clientOrderId'] = brokerId + this.uuid16();
1196
- }
1197
- }
1198
- else {
1199
- request['clientOrderId'] = clientOrderId;
1200
- params = this.omit(params, ['clientOrderId']);
1201
- }
1202
- const marketType = this.safeString(market, 'type');
1203
- const isLimitOrder = type === 'limit';
1204
- const isMarketOrder = type === 'market';
1205
- const stopPrice = this.safeNumberN(params, ['triggerPrice', 'stopPrice', 'activation_price']);
1206
- const isStopOrder = (stopPrice !== undefined);
1207
- const postOnly = this.isPostOnly(isMarketOrder, false, params);
1208
- const [marginMode, query] = this.handleMarginModeAndParams('createOrder', params);
1209
- if (postOnly) {
1210
- request['postOnly'] = true;
1211
- }
1212
- if (marginMode !== undefined && marginMode !== 'cross') {
1213
- throw new errors.NotSupported(this.id + ' createOrder() is only available for cross margin');
1214
- }
1215
- params = this.omit(query, ['postOnly', 'triggerPrice', 'stopPrice']);
1216
- const useCollateralEndpoint = marginMode !== undefined || marketType === 'swap';
1217
- let response = undefined;
1218
- if (isStopOrder) {
1219
- request['activation_price'] = this.priceToPrecision(symbol, stopPrice);
1220
- if (isLimitOrder) {
1221
- // stop limit order
1222
- request['price'] = this.priceToPrecision(symbol, price);
1223
- response = await this.v4PrivatePostOrderStopLimit(this.extend(request, params));
1224
- }
1225
- else {
1226
- // stop market order
1227
- if (useCollateralEndpoint) {
1228
- response = await this.v4PrivatePostOrderCollateralTriggerMarket(this.extend(request, params));
1229
- }
1230
- else {
1231
- response = await this.v4PrivatePostOrderStopMarket(this.extend(request, params));
1232
- }
1233
- }
1234
- }
1235
- else {
1236
- if (isLimitOrder) {
1237
- // limit order
1238
- request['price'] = this.priceToPrecision(symbol, price);
1239
- if (useCollateralEndpoint) {
1240
- response = await this.v4PrivatePostOrderCollateralLimit(this.extend(request, params));
1241
- }
1242
- else {
1243
- response = await this.v4PrivatePostOrderNew(this.extend(request, params));
1244
- }
1245
- }
1246
- else {
1247
- // market order
1248
- if (useCollateralEndpoint) {
1249
- response = await this.v4PrivatePostOrderCollateralMarket(this.extend(request, params));
1250
- }
1251
- else {
1252
- response = await this.v4PrivatePostOrderStockMarket(this.extend(request, params));
1253
- }
1254
- }
1255
- }
1256
- return this.parseOrder(response);
1257
- }
1258
- async cancelOrder(id, symbol = undefined, params = {}) {
1259
- /**
1260
- * @method
1261
- * @name whitebit#cancelOrder
1262
- * @description cancels an open order
1263
- * @see https://docs.whitebit.com/private/http-trade-v4/#cancel-order
1264
- * @param {string} id order id
1265
- * @param {string} symbol unified symbol of the market the order was made in
1266
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1267
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1268
- */
1269
- if (symbol === undefined) {
1270
- throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
1271
- }
1272
- await this.loadMarkets();
1273
- const market = this.market(symbol);
1274
- const request = {
1275
- 'market': market['id'],
1276
- 'orderId': parseInt(id),
1277
- };
1278
- return await this.v4PrivatePostOrderCancel(this.extend(request, params));
1279
- }
1280
- parseBalance(response) {
1281
- const balanceKeys = Object.keys(response);
1282
- const result = {};
1283
- for (let i = 0; i < balanceKeys.length; i++) {
1284
- const id = balanceKeys[i];
1285
- const code = this.safeCurrencyCode(id);
1286
- const balance = response[id];
1287
- if (typeof balance === 'object' && balance !== undefined) {
1288
- const account = this.account();
1289
- account['free'] = this.safeString(balance, 'available');
1290
- account['used'] = this.safeString(balance, 'freeze');
1291
- account['total'] = this.safeString(balance, 'main_balance');
1292
- result[code] = account;
1293
- }
1294
- else {
1295
- const account = this.account();
1296
- account['total'] = balance;
1297
- result[code] = account;
1298
- }
1299
- }
1300
- return this.safeBalance(result);
1301
- }
1302
- async fetchBalance(params = {}) {
1303
- /**
1304
- * @method
1305
- * @name whitebit#fetchBalance
1306
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
1307
- * @see https://docs.whitebit.com/private/http-main-v4/#main-balance
1308
- * @see https://docs.whitebit.com/private/http-trade-v4/#trading-balance
1309
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1310
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1311
- */
1312
- await this.loadMarkets();
1313
- let marketType = undefined;
1314
- [marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
1315
- let response = undefined;
1316
- if (marketType === 'swap') {
1317
- response = await this.v4PrivatePostCollateralAccountBalance(params);
1318
- }
1319
- else {
1320
- const options = this.safeValue(this.options, 'fetchBalance', {});
1321
- const defaultAccount = this.safeString(options, 'account');
1322
- const account = this.safeString(params, 'account', defaultAccount);
1323
- params = this.omit(params, 'account');
1324
- if (account === 'main') {
1325
- response = await this.v4PrivatePostMainAccountBalance(params);
1326
- }
1327
- else {
1328
- response = await this.v4PrivatePostTradeAccountBalance(params);
1329
- }
1330
- }
1331
- //
1332
- // main account
1333
- //
1334
- // {
1335
- // "BTC":{"main_balance":"0.0013929494020316"},
1336
- // "ETH":{"main_balance":"0.001398289308"},
1337
- // }
1338
- //
1339
- // spot trade account
1340
- //
1341
- // {
1342
- // "BTC": { "available": "0.123", "freeze": "1" },
1343
- // "XMR": { "available": "3013", "freeze": "100" },
1344
- // }
1345
- //
1346
- // swap
1347
- //
1348
- // {
1349
- // "BTC": 1,
1350
- // "USDT": 1000
1351
- // }
1352
- //
1353
- return this.parseBalance(response);
1354
- }
1355
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1356
- /**
1357
- * @method
1358
- * @name whitebit#fetchOpenOrders
1359
- * @description fetch all unfilled currently open orders
1360
- * @see https://docs.whitebit.com/private/http-trade-v4/#query-unexecutedactive-orders
1361
- * @param {string} symbol unified market symbol
1362
- * @param {int} [since] the earliest time in ms to fetch open orders for
1363
- * @param {int} [limit] the maximum number of open order structures to retrieve
1364
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1365
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1366
- */
1367
- if (symbol === undefined) {
1368
- throw new errors.ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
1369
- }
1370
- await this.loadMarkets();
1371
- const market = this.market(symbol);
1372
- const request = {
1373
- 'market': market['id'],
1374
- };
1375
- if (limit !== undefined) {
1376
- request['limit'] = Math.min(limit, 100);
1377
- }
1378
- const response = await this.v4PrivatePostOrders(this.extend(request, params));
1379
- //
1380
- // [
1381
- // {
1382
- // "orderId": 3686033640,
1383
- // "clientOrderId": "customId11",
1384
- // "market": "BTC_USDT",
1385
- // "side": "buy",
1386
- // "type": "limit",
1387
- // "timestamp": 1594605801.49815, // current timestamp of unexecuted order
1388
- // "dealMoney": "0", // executed amount in money
1389
- // "dealStock": "0", // executed amount in stock
1390
- // "amount": "2.241379", // active order amount
1391
- // "takerFee": "0.001",
1392
- // "makerFee": "0.001",
1393
- // "left": "2.241379", // unexecuted amount in stock
1394
- // "dealFee": "0", // executed fee by deal
1395
- // "price": "40000"
1396
- // },
1397
- // ]
1398
- //
1399
- return this.parseOrders(response, market, since, limit, { 'status': 'open' });
1400
- }
1401
- async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1402
- /**
1403
- * @method
1404
- * @name whitebit#fetchClosedOrders
1405
- * @description fetches information on multiple closed orders made by the user
1406
- * @see https://docs.whitebit.com/private/http-trade-v4/#query-executed-orders
1407
- * @param {string} symbol unified market symbol of the market orders were made in
1408
- * @param {int} [since] the earliest time in ms to fetch orders for
1409
- * @param {int} [limit] the maximum number of order structures to retrieve
1410
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1411
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1412
- */
1413
- await this.loadMarkets();
1414
- const request = {};
1415
- let market = undefined;
1416
- if (symbol !== undefined) {
1417
- market = this.market(symbol);
1418
- symbol = market['symbol'];
1419
- request['market'] = market['id'];
1420
- }
1421
- if (limit !== undefined) {
1422
- request['limit'] = Math.min(limit, 100); // default 50 max 100
1423
- }
1424
- const response = await this.v4PrivatePostTradeAccountOrderHistory(this.extend(request, params));
1425
- //
1426
- // {
1427
- // "BTC_USDT": [
1428
- // {
1429
- // "id": 160305483,
1430
- // "clientOrderId": "customId11",
1431
- // "time": 1594667731.724403,
1432
- // "side": "sell",
1433
- // "role": 2, // 1 = maker, 2 = taker
1434
- // "amount": "0.000076",
1435
- // "price": "9264.21",
1436
- // "deal": "0.70407996",
1437
- // "fee": "0.00070407996"
1438
- // },
1439
- // ],
1440
- // }
1441
- //
1442
- const marketIds = Object.keys(response);
1443
- let results = [];
1444
- for (let i = 0; i < marketIds.length; i++) {
1445
- const marketId = marketIds[i];
1446
- const marketNew = this.safeMarket(marketId, undefined, '_');
1447
- const orders = response[marketId];
1448
- for (let j = 0; j < orders.length; j++) {
1449
- const order = this.parseOrder(orders[j], marketNew);
1450
- results.push(this.extend(order, { 'status': 'closed' }));
1451
- }
1452
- }
1453
- results = this.sortBy(results, 'timestamp');
1454
- results = this.filterBySymbolSinceLimit(results, symbol, since, limit);
1455
- return results;
1456
- }
1457
- parseOrderType(type) {
1458
- const types = {
1459
- 'limit': 'limit',
1460
- 'market': 'market',
1461
- 'stop market': 'market',
1462
- 'stop limit': 'limit',
1463
- 'stock market': 'market',
1464
- 'margin limit': 'limit',
1465
- 'margin market': 'market',
1466
- };
1467
- return this.safeString(types, type, type);
1468
- }
1469
- parseOrder(order, market = undefined) {
1470
- //
1471
- // createOrder, fetchOpenOrders
1472
- //
1473
- // {
1474
- // "orderId":105687928629,
1475
- // "clientOrderId":"",
1476
- // "market":"DOGE_USDT",
1477
- // "side":"sell",
1478
- // "type":"stop market",
1479
- // "timestamp":1659091079.729576,
1480
- // "dealMoney":"0", // executed amount in quote
1481
- // "dealStock":"0", // base filled amount
1482
- // "amount":"100",
1483
- // "takerFee":"0.001",
1484
- // "makerFee":"0",
1485
- // "left":"100",
1486
- // "dealFee":"0",
1487
- // "activation_price":"0.065" // stop price (if stop limit or stop market)
1488
- // }
1489
- //
1490
- // fetchClosedOrders
1491
- //
1492
- // {
1493
- // "id":105531094719,
1494
- // "clientOrderId":"",
1495
- // "ctime":1659045334.550127,
1496
- // "ftime":1659045334.550127,
1497
- // "side":"buy",
1498
- // "amount":"5.9940059", // cost in terms of quote for regular market orders, amount in terms or base for all other order types
1499
- // "price":"0",
1500
- // "type":"market",
1501
- // "takerFee":"0.001",
1502
- // "makerFee":"0",
1503
- // "dealFee":"0.0059375815",
1504
- // "dealStock":"85", // base filled amount
1505
- // "dealMoney":"5.9375815", // executed amount in quote
1506
- // }
1507
- //
1508
- const marketId = this.safeString(order, 'market');
1509
- market = this.safeMarket(marketId, market, '_');
1510
- const symbol = market['symbol'];
1511
- const side = this.safeString(order, 'side');
1512
- const filled = this.safeString(order, 'dealStock');
1513
- const remaining = this.safeString(order, 'left');
1514
- let clientOrderId = this.safeString(order, 'clientOrderId');
1515
- if (clientOrderId === '') {
1516
- clientOrderId = undefined;
1517
- }
1518
- const price = this.safeString(order, 'price');
1519
- const stopPrice = this.safeNumber(order, 'activation_price');
1520
- const orderId = this.safeString2(order, 'orderId', 'id');
1521
- const type = this.safeString(order, 'type');
1522
- let amount = this.safeString(order, 'amount');
1523
- const cost = this.safeString(order, 'dealMoney');
1524
- if ((side === 'buy') && ((type === 'market') || (type === 'stop market'))) {
1525
- amount = filled;
1526
- }
1527
- const dealFee = this.safeString(order, 'dealFee');
1528
- let fee = undefined;
1529
- if (dealFee !== undefined) {
1530
- fee = {
1531
- 'cost': this.parseNumber(dealFee),
1532
- 'currency': market['quote'],
1533
- };
1534
- }
1535
- const timestamp = this.safeTimestamp2(order, 'ctime', 'timestamp');
1536
- const lastTradeTimestamp = this.safeTimestamp(order, 'ftime');
1537
- return this.safeOrder({
1538
- 'info': order,
1539
- 'id': orderId,
1540
- 'symbol': symbol,
1541
- 'clientOrderId': clientOrderId,
1542
- 'timestamp': timestamp,
1543
- 'datetime': this.iso8601(timestamp),
1544
- 'lastTradeTimestamp': lastTradeTimestamp,
1545
- 'timeInForce': undefined,
1546
- 'postOnly': undefined,
1547
- 'status': undefined,
1548
- 'side': side,
1549
- 'price': price,
1550
- 'type': this.parseOrderType(type),
1551
- 'stopPrice': stopPrice,
1552
- 'triggerPrice': stopPrice,
1553
- 'amount': amount,
1554
- 'filled': filled,
1555
- 'remaining': remaining,
1556
- 'average': undefined,
1557
- 'cost': cost,
1558
- 'fee': fee,
1559
- 'trades': undefined,
1560
- }, market);
1561
- }
1562
- async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
1563
- /**
1564
- * @method
1565
- * @name whitebit#fetchOrderTrades
1566
- * @description fetch all the trades made from a single order
1567
- * @see https://docs.whitebit.com/private/http-trade-v4/#query-executed-order-deals
1568
- * @param {string} id order id
1569
- * @param {string} symbol unified market symbol
1570
- * @param {int} [since] the earliest time in ms to fetch trades for
1571
- * @param {int} [limit] the maximum number of trades to retrieve
1572
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1573
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1574
- */
1575
- await this.loadMarkets();
1576
- const request = {
1577
- 'orderId': parseInt(id),
1578
- };
1579
- let market = undefined;
1580
- if (symbol !== undefined) {
1581
- market = this.market(symbol);
1582
- request['market'] = market['id'];
1583
- }
1584
- if (limit !== undefined) {
1585
- request['limit'] = Math.min(limit, 100);
1586
- }
1587
- const response = await this.v4PrivatePostTradeAccountOrder(this.extend(request, params));
1588
- //
1589
- // {
1590
- // "records": [
1591
- // {
1592
- // "time": 1593342324.613711,
1593
- // "fee": "0.00000419198",
1594
- // "price": "0.00000701",
1595
- // "amount": "598",
1596
- // "id": 149156519, // trade id
1597
- // "dealOrderId": 3134995325, // orderId
1598
- // "clientOrderId": "customId11", // empty string if not specified
1599
- // "role": 2, // 1 = maker, 2 = taker
1600
- // "deal": "0.00419198"
1601
- // }
1602
- // ],
1603
- // "offset": 0,
1604
- // "limit": 100
1605
- // }
1606
- //
1607
- const data = this.safeValue(response, 'records', []);
1608
- return this.parseTrades(data, market);
1609
- }
1610
- async fetchDepositAddress(code, params = {}) {
1611
- /**
1612
- * @method
1613
- * @name whitebit#fetchDepositAddress
1614
- * @description fetch the deposit address for a currency associated with this account
1615
- * @see https://docs.whitebit.com/private/http-main-v4/#get-fiat-deposit-address
1616
- * @see https://docs.whitebit.com/private/http-main-v4/#get-cryptocurrency-deposit-address
1617
- * @param {string} code unified currency code
1618
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1619
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1620
- */
1621
- await this.loadMarkets();
1622
- const currency = this.currency(code);
1623
- const request = {
1624
- 'ticker': currency['id'],
1625
- };
1626
- let response = undefined;
1627
- if (this.isFiat(code)) {
1628
- const provider = this.safeString(params, 'provider');
1629
- if (provider === undefined) {
1630
- throw new errors.ArgumentsRequired(this.id + ' fetchDepositAddress() requires a provider when the ticker is fiat');
1631
- }
1632
- request['provider'] = provider;
1633
- const amount = this.safeNumber(params, 'amount');
1634
- if (amount === undefined) {
1635
- throw new errors.ArgumentsRequired(this.id + ' fetchDepositAddress() requires an amount when the ticker is fiat');
1636
- }
1637
- request['amount'] = amount;
1638
- const uniqueId = this.safeValue(params, 'uniqueId');
1639
- if (uniqueId === undefined) {
1640
- throw new errors.ArgumentsRequired(this.id + ' fetchDepositAddress() requires an uniqueId when the ticker is fiat');
1641
- }
1642
- response = await this.v4PrivatePostMainAccountFiatDepositUrl(this.extend(request, params));
1643
- }
1644
- else {
1645
- response = await this.v4PrivatePostMainAccountAddress(this.extend(request, params));
1646
- }
1647
- //
1648
- // fiat
1649
- //
1650
- // {
1651
- // "url": "https://someaddress.com"
1652
- // }
1653
- //
1654
- // crypto
1655
- //
1656
- // {
1657
- // "account": {
1658
- // "address": "GDTSOI56XNVAKJNJBLJGRNZIVOCIZJRBIDKTWSCYEYNFAZEMBLN75RMN",
1659
- // "memo": "48565488244493"
1660
- // },
1661
- // "required": {
1662
- // "fixedFee": "0",
1663
- // "flexFee": {
1664
- // "maxFee": "0",
1665
- // "minFee": "0",
1666
- // "percent": "0"
1667
- // },
1668
- // "maxAmount": "0",
1669
- // "minAmount": "1"
1670
- // }
1671
- // }
1672
- //
1673
- const url = this.safeString(response, 'url');
1674
- const account = this.safeValue(response, 'account', {});
1675
- const address = this.safeString(account, 'address', url);
1676
- const tag = this.safeString(account, 'memo');
1677
- this.checkAddress(address);
1678
- return {
1679
- 'currency': code,
1680
- 'address': address,
1681
- 'tag': tag,
1682
- 'network': undefined,
1683
- 'info': response,
1684
- };
1685
- }
1686
- async setLeverage(leverage, symbol = undefined, params = {}) {
1687
- /**
1688
- * @method
1689
- * @name whitebit#setLeverage
1690
- * @description set the level of leverage for a market
1691
- * @see https://docs.whitebit.com/private/http-trade-v4/#change-collateral-account-leverage
1692
- * @param {float} leverage the rate of leverage
1693
- * @param {string} symbol unified market symbol
1694
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1695
- * @returns {object} response from the exchange
1696
- */
1697
- await this.loadMarkets();
1698
- if (symbol !== undefined) {
1699
- throw new errors.NotSupported(this.id + ' setLeverage() does not allow to set per symbol');
1700
- }
1701
- if ((leverage < 1) || (leverage > 20)) {
1702
- throw new errors.BadRequest(this.id + ' setLeverage() leverage should be between 1 and 20');
1703
- }
1704
- const request = {
1705
- 'leverage': leverage,
1706
- };
1707
- return await this.v4PrivatePostCollateralAccountLeverage(this.extend(request, params));
1708
- // {
1709
- // "leverage": 5
1710
- // }
1711
- }
1712
- async transfer(code, amount, fromAccount, toAccount, params = {}) {
1713
- /**
1714
- * @method
1715
- * @name whitebit#transfer
1716
- * @description transfer currency internally between wallets on the same account
1717
- * @see https://docs.whitebit.com/private/http-main-v4/#transfer-between-main-and-trade-balances
1718
- * @param {string} code unified currency code
1719
- * @param {float} amount amount to transfer
1720
- * @param {string} fromAccount account to transfer from - main, spot, collateral
1721
- * @param {string} toAccount account to transfer to - main, spot, collateral
1722
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1723
- * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
1724
- */
1725
- await this.loadMarkets();
1726
- const currency = this.currency(code);
1727
- const accountsByType = this.safeValue(this.options, 'accountsByType');
1728
- const fromAccountId = this.safeString(accountsByType, fromAccount, fromAccount);
1729
- const toAccountId = this.safeString(accountsByType, toAccount, toAccount);
1730
- const amountString = this.currencyToPrecision(code, amount);
1731
- const request = {
1732
- 'ticker': currency['id'],
1733
- 'amount': amountString,
1734
- 'from': fromAccountId,
1735
- 'to': toAccountId,
1736
- };
1737
- const response = await this.v4PrivatePostMainAccountTransfer(this.extend(request, params));
1738
- //
1739
- // []
1740
- //
1741
- return this.parseTransfer(response, currency);
1742
- }
1743
- parseTransfer(transfer, currency = undefined) {
1744
- //
1745
- // []
1746
- //
1747
- return {
1748
- 'info': transfer,
1749
- 'id': undefined,
1750
- 'timestamp': undefined,
1751
- 'datetime': undefined,
1752
- 'currency': this.safeCurrencyCode(undefined, currency),
1753
- 'amount': undefined,
1754
- 'fromAccount': undefined,
1755
- 'toAccount': undefined,
1756
- 'status': undefined,
1757
- };
1758
- }
1759
- async withdraw(code, amount, address, tag = undefined, params = {}) {
1760
- /**
1761
- * @method
1762
- * @name whitebit#withdraw
1763
- * @description make a withdrawal
1764
- * @see https://docs.whitebit.com/private/http-main-v4/#create-withdraw-request
1765
- * @param {string} code unified currency code
1766
- * @param {float} amount the amount to withdraw
1767
- * @param {string} address the address to withdraw to
1768
- * @param {string} tag
1769
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1770
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1771
- */
1772
- await this.loadMarkets();
1773
- const currency = this.currency(code); // check if it has canDeposit
1774
- const request = {
1775
- 'ticker': currency['id'],
1776
- 'amount': this.currencyToPrecision(code, amount),
1777
- 'address': address,
1778
- };
1779
- let uniqueId = this.safeValue(params, 'uniqueId');
1780
- if (uniqueId === undefined) {
1781
- uniqueId = this.uuid22();
1782
- }
1783
- request['uniqueId'] = uniqueId;
1784
- if (tag !== undefined) {
1785
- request['memo'] = tag;
1786
- }
1787
- if (this.isFiat(code)) {
1788
- const provider = this.safeValue(params, 'provider');
1789
- if (provider === undefined) {
1790
- throw new errors.ArgumentsRequired(this.id + ' withdraw() requires a provider when the ticker is fiat');
1791
- }
1792
- request['provider'] = provider;
1793
- }
1794
- const response = await this.v4PrivatePostMainAccountWithdraw(this.extend(request, params));
1795
- //
1796
- // empty array with a success status
1797
- // go to deposit/withdraw history and check you request status by uniqueId
1798
- //
1799
- // []
1800
- //
1801
- return this.extend({ 'id': uniqueId }, this.parseTransaction(response, currency));
1802
- }
1803
- parseTransaction(transaction, currency = undefined) {
1804
- //
1805
- // {
1806
- // "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", // deposit address
1807
- // "uniqueId": null, // unique Id of deposit
1808
- // "createdAt": 1593437922, // timestamp of deposit
1809
- // "currency": "Bitcoin", // deposit currency
1810
- // "ticker": "BTC", // deposit currency ticker
1811
- // "method": 1, // called method 1 - deposit, 2 - withdraw
1812
- // "amount": "0.0006", // amount of deposit
1813
- // "description": "", // deposit description
1814
- // "memo": "", // deposit memo
1815
- // "fee": "0", // deposit fee
1816
- // "status": 15, // transactions status
1817
- // "network": null, // if currency is multinetwork
1818
- // "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", // deposit transaction hash
1819
- // "details": {
1820
- // "partial": { // details about partially successful withdrawals
1821
- // "requestAmount": "50000", // requested withdrawal amount
1822
- // "processedAmount": "39000", // processed withdrawal amount
1823
- // "processedFee": "273", // fee for processed withdrawal amount
1824
- // "normalizeTransaction": "" // deposit id
1825
- // }
1826
- // },
1827
- // "confirmations": { // if transaction status == 15 you can see this object
1828
- // "actual": 1, // current block confirmations
1829
- // "required": 2 // required block confirmation for successful deposit
1830
- // }
1831
- // }
1832
- //
1833
- currency = this.safeCurrency(undefined, currency);
1834
- const address = this.safeString(transaction, 'address');
1835
- const timestamp = this.safeTimestamp(transaction, 'createdAt');
1836
- const currencyId = this.safeString(transaction, 'ticker');
1837
- const status = this.safeString(transaction, 'status');
1838
- const method = this.safeString(transaction, 'method');
1839
- return {
1840
- 'id': this.safeString(transaction, 'uniqueId'),
1841
- 'txid': this.safeString(transaction, 'transactionHash'),
1842
- 'timestamp': timestamp,
1843
- 'datetime': this.iso8601(timestamp),
1844
- 'network': this.safeString(transaction, 'network'),
1845
- 'addressFrom': (method === '1') ? address : undefined,
1846
- 'address': address,
1847
- 'addressTo': (method === '2') ? address : undefined,
1848
- 'amount': this.safeNumber(transaction, 'amount'),
1849
- 'type': (method === '1') ? 'deposit' : 'withdrawal',
1850
- 'currency': this.safeCurrencyCode(currencyId, currency),
1851
- 'status': this.parseTransactionStatus(status),
1852
- 'updated': undefined,
1853
- 'tagFrom': undefined,
1854
- 'tag': undefined,
1855
- 'tagTo': undefined,
1856
- 'comment': this.safeString(transaction, 'description'),
1857
- 'internal': undefined,
1858
- 'fee': {
1859
- 'cost': this.safeNumber(transaction, 'fee'),
1860
- 'currency': this.safeCurrencyCode(currencyId, currency),
1861
- },
1862
- 'info': transaction,
1863
- };
1864
- }
1865
- parseTransactionStatus(status) {
1866
- const statuses = {
1867
- '1': 'pending',
1868
- '2': 'pending',
1869
- '3': 'ok',
1870
- '4': 'canceled',
1871
- '5': 'pending',
1872
- '6': 'pending',
1873
- '7': 'ok',
1874
- '9': 'canceled',
1875
- '10': 'pending',
1876
- '11': 'pending',
1877
- '12': 'pending',
1878
- '13': 'pending',
1879
- '14': 'pending',
1880
- '15': 'pending',
1881
- '16': 'pending',
1882
- '17': 'pending',
1883
- };
1884
- return this.safeString(statuses, status, status);
1885
- }
1886
- async fetchDeposit(id, code = undefined, params = {}) {
1887
- /**
1888
- * @method
1889
- * @name whitebit#fetchDeposit
1890
- * @description fetch information on a deposit
1891
- * @see https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
1892
- * @param {string} id deposit id
1893
- * @param {string} code not used by whitebit fetchDeposit ()
1894
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1895
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1896
- */
1897
- await this.loadMarkets();
1898
- let currency = undefined;
1899
- const request = {
1900
- 'transactionMethod': 1,
1901
- 'uniqueId': id,
1902
- 'limit': 1,
1903
- 'offset': 0,
1904
- };
1905
- if (code !== undefined) {
1906
- currency = this.currency(code);
1907
- request['ticker'] = currency['id'];
1908
- }
1909
- const response = await this.v4PrivatePostMainAccountHistory(this.extend(request, params));
1910
- //
1911
- // {
1912
- // "limit": 100,
1913
- // "offset": 0,
1914
- // "records": [
1915
- // {
1916
- // "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", // deposit address
1917
- // "uniqueId": null, // unique Id of deposit
1918
- // "createdAt": 1593437922, // timestamp of deposit
1919
- // "currency": "Bitcoin", // deposit currency
1920
- // "ticker": "BTC", // deposit currency ticker
1921
- // "method": 1, // called method 1 - deposit, 2 - withdraw
1922
- // "amount": "0.0006", // amount of deposit
1923
- // "description": "", // deposit description
1924
- // "memo": "", // deposit memo
1925
- // "fee": "0", // deposit fee
1926
- // "status": 15, // transactions status
1927
- // "network": null, // if currency is multinetwork
1928
- // "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", // deposit transaction hash
1929
- // "details": {
1930
- // "partial": { // details about partially successful withdrawals
1931
- // "requestAmount": "50000", // requested withdrawal amount
1932
- // "processedAmount": "39000", // processed withdrawal amount
1933
- // "processedFee": "273", // fee for processed withdrawal amount
1934
- // "normalizeTransaction": "" // deposit id
1935
- // }
1936
- // },
1937
- // "confirmations": { // if transaction status == 15 you can see this object
1938
- // "actual": 1, // current block confirmations
1939
- // "required": 2 // required block confirmation for successful deposit
1940
- // }
1941
- // },
1942
- // {...},
1943
- // ],
1944
- // "total": 300 // total number of transactions, use this for calculating ‘limit’ and ‘offset'
1945
- // }
1946
- //
1947
- const records = this.safeValue(response, 'records', []);
1948
- const first = this.safeValue(records, 0, {});
1949
- return this.parseTransaction(first, currency);
1950
- }
1951
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1952
- /**
1953
- * @method
1954
- * @name whitebit#fetchDeposits
1955
- * @description fetch all deposits made to an account
1956
- * @see https://docs.whitebit.com/private/http-main-v4/#get-depositwithdraw-history
1957
- * @param {string} code unified currency code
1958
- * @param {int} [since] the earliest time in ms to fetch deposits for
1959
- * @param {int} [limit] the maximum number of deposits structures to retrieve
1960
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1961
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1962
- */
1963
- await this.loadMarkets();
1964
- let currency = undefined;
1965
- const request = {
1966
- 'transactionMethod': 1,
1967
- 'limit': 100,
1968
- 'offset': 0,
1969
- };
1970
- if (code !== undefined) {
1971
- currency = this.currency(code);
1972
- request['ticker'] = currency['id'];
1973
- }
1974
- if (limit !== undefined) {
1975
- request['limit'] = Math.min(limit, 100);
1976
- }
1977
- const response = await this.v4PrivatePostMainAccountHistory(this.extend(request, params));
1978
- //
1979
- // {
1980
- // "limit": 100,
1981
- // "offset": 0,
1982
- // "records": [
1983
- // {
1984
- // "address": "3ApEASLcrQtZpg1TsssFgYF5V5YQJAKvuE", // deposit address
1985
- // "uniqueId": null, // unique Id of deposit
1986
- // "createdAt": 1593437922, // timestamp of deposit
1987
- // "currency": "Bitcoin", // deposit currency
1988
- // "ticker": "BTC", // deposit currency ticker
1989
- // "method": 1, // called method 1 - deposit, 2 - withdraw
1990
- // "amount": "0.0006", // amount of deposit
1991
- // "description": "", // deposit description
1992
- // "memo": "", // deposit memo
1993
- // "fee": "0", // deposit fee
1994
- // "status": 15, // transactions status
1995
- // "network": null, // if currency is multinetwork
1996
- // "transactionHash": "a275a514013e4e0f927fd0d1bed215e7f6f2c4c6ce762836fe135ec22529d886", // deposit transaction hash
1997
- // "details": {
1998
- // "partial": { // details about partially successful withdrawals
1999
- // "requestAmount": "50000", // requested withdrawal amount
2000
- // "processedAmount": "39000", // processed withdrawal amount
2001
- // "processedFee": "273", // fee for processed withdrawal amount
2002
- // "normalizeTransaction": "" // deposit id
2003
- // }
2004
- // },
2005
- // "confirmations": { // if transaction status == 15 you can see this object
2006
- // "actual": 1, // current block confirmations
2007
- // "required": 2 // required block confirmation for successful deposit
2008
- // }
2009
- // },
2010
- // {...},
2011
- // ],
2012
- // "total": 300 // total number of transactions, use this for calculating ‘limit’ and ‘offset'
2013
- // }
2014
- //
2015
- const records = this.safeValue(response, 'records', []);
2016
- return this.parseTransactions(records, currency, since, limit);
2017
- }
2018
- async fetchBorrowInterest(code = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
2019
- /**
2020
- * @method
2021
- * @name whitebit#fetchBorrowInterest
2022
- * @description fetch the interest owed by the user for borrowing currency for margin trading
2023
- * @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
2024
- * @param {string} code unified currency code
2025
- * @param {string} symbol unified market symbol
2026
- * @param {int} [since] the earliest time in ms to fetch borrrow interest for
2027
- * @param {int} [limit] the maximum number of structures to retrieve
2028
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2029
- * @returns {object[]} a list of [borrow interest structures]{@link https://docs.ccxt.com/#/?id=borrow-interest-structure}
2030
- */
2031
- await this.loadMarkets();
2032
- const request = {};
2033
- let market = undefined;
2034
- if (symbol !== undefined) {
2035
- market = this.market(symbol);
2036
- request['market'] = market['id'];
2037
- }
2038
- const response = await this.v4PrivatePostCollateralAccountPositionsOpen(this.extend(request, params));
2039
- //
2040
- // [
2041
- // {
2042
- // "positionId": 191823,
2043
- // "market": "BTC_USDT",
2044
- // "openDate": 1660340344.027163,
2045
- // "modifyDate": 1660340344.027163,
2046
- // "amount": "0.003075",
2047
- // "basePrice": "24149.24512",
2048
- // "liquidationPrice": "7059.02",
2049
- // "leverage": "5",
2050
- // "pnl": "-0.15",
2051
- // "pnlPercent": "-0.20",
2052
- // "margin": "14.86",
2053
- // "freeMargin": "44.99",
2054
- // "funding": "0",
2055
- // "unrealizedFunding": "0.0000307828284903",
2056
- // "liquidationState": null
2057
- // }
2058
- // ]
2059
- //
2060
- const interest = this.parseBorrowInterests(response, market);
2061
- return this.filterByCurrencySinceLimit(interest, code, since, limit);
2062
- }
2063
- parseBorrowInterest(info, market = undefined) {
2064
- //
2065
- // {
2066
- // "positionId": 191823,
2067
- // "market": "BTC_USDT",
2068
- // "openDate": 1660340344.027163,
2069
- // "modifyDate": 1660340344.027163,
2070
- // "amount": "0.003075",
2071
- // "basePrice": "24149.24512",
2072
- // "liquidationPrice": "7059.02",
2073
- // "leverage": "5",
2074
- // "pnl": "-0.15",
2075
- // "pnlPercent": "-0.20",
2076
- // "margin": "14.86",
2077
- // "freeMargin": "44.99",
2078
- // "funding": "0",
2079
- // "unrealizedFunding": "0.0000307828284903",
2080
- // "liquidationState": null
2081
- // }
2082
- //
2083
- const marketId = this.safeString(info, 'market');
2084
- const symbol = this.safeSymbol(marketId, market, '_');
2085
- const timestamp = this.safeTimestamp(info, 'modifyDate');
2086
- return {
2087
- 'symbol': symbol,
2088
- 'marginMode': 'cross',
2089
- 'currency': 'USDT',
2090
- 'interest': this.safeNumber(info, 'unrealizedFunding'),
2091
- 'interestRate': 0.00098,
2092
- 'amountBorrowed': this.safeNumber(info, 'amount'),
2093
- 'timestamp': timestamp,
2094
- 'datetime': this.iso8601(timestamp),
2095
- 'info': info,
2096
- };
2097
- }
2098
- async fetchFundingRate(symbol, params = {}) {
2099
- /**
2100
- * @method
2101
- * @name whitebit#fetchFundingRate
2102
- * @see https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
2103
- * @description fetch the current funding rate
2104
- * @param {string} symbol unified market symbol
2105
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2106
- * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
2107
- */
2108
- await this.loadMarkets();
2109
- symbol = this.symbol(symbol);
2110
- const response = await this.fetchFundingRates([symbol], params);
2111
- return this.safeValue(response, symbol);
2112
- }
2113
- async fetchFundingRates(symbols = undefined, params = {}) {
2114
- /**
2115
- * @method
2116
- * @name whitebit#fetchFundingRates
2117
- * @see https://docs.whitebit.com/public/http-v4/#available-futures-markets-list
2118
- * @description fetch the funding rate for multiple markets
2119
- * @param {string[]|undefined} symbols list of unified market symbols
2120
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2121
- * @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
2122
- */
2123
- await this.loadMarkets();
2124
- symbols = this.marketSymbols(symbols);
2125
- const response = await this.v4PublicGetFutures(params);
2126
- //
2127
- // [
2128
- // {
2129
- // "name": "BTC_USDT",
2130
- // "type": "direct",
2131
- // "quanto_multiplier": "0.0001",
2132
- // "ref_discount_rate": "0",
2133
- // "order_price_deviate": "0.5",
2134
- // "maintenance_rate": "0.005",
2135
- // "mark_type": "index",
2136
- // "last_price": "38026",
2137
- // "mark_price": "37985.6",
2138
- // "index_price": "37954.92",
2139
- // "funding_rate_indicative": "0.000219",
2140
- // "mark_price_round": "0.01",
2141
- // "funding_offset": 0,
2142
- // "in_delisting": false,
2143
- // "risk_limit_base": "1000000",
2144
- // "interest_rate": "0.0003",
2145
- // "order_price_round": "0.1",
2146
- // "order_size_min": 1,
2147
- // "ref_rebate_rate": "0.2",
2148
- // "funding_interval": 28800,
2149
- // "risk_limit_step": "1000000",
2150
- // "leverage_min": "1",
2151
- // "leverage_max": "100",
2152
- // "risk_limit_max": "8000000",
2153
- // "maker_fee_rate": "-0.00025",
2154
- // "taker_fee_rate": "0.00075",
2155
- // "funding_rate": "0.002053",
2156
- // "order_size_max": 1000000,
2157
- // "funding_next_apply": 1610035200,
2158
- // "short_users": 977,
2159
- // "config_change_time": 1609899548,
2160
- // "trade_size": 28530850594,
2161
- // "position_size": 5223816,
2162
- // "long_users": 455,
2163
- // "funding_impact_value": "60000",
2164
- // "orders_limit": 50,
2165
- // "trade_id": 10851092,
2166
- // "orderbook_id": 2129638396
2167
- // }
2168
- // ]
2169
- //
2170
- const data = this.safeValue(response, 'result', []);
2171
- const result = this.parseFundingRates(data);
2172
- return this.filterByArray(result, 'symbol', symbols);
2173
- }
2174
- parseFundingRate(contract, market = undefined) {
2175
- //
2176
- // {
2177
- // "ticker_id":"ADA_PERP",
2178
- // "stock_currency":"ADA",
2179
- // "money_currency":"USDT",
2180
- // "last_price":"0.296708",
2181
- // "stock_volume":"7982130",
2182
- // "money_volume":"2345758.29189",
2183
- // "bid":"0.296608",
2184
- // "ask":"0.296758",
2185
- // "high":"0.298338",
2186
- // "low":"0.290171",
2187
- // "product_type":"Perpetual",
2188
- // "open_interest":"46533000",
2189
- // "index_price":"0.29659",
2190
- // "index_name":"Cardano",
2191
- // "index_currency":"ADA",
2192
- // "funding_rate":"0.0001",
2193
- // "next_funding_rate_timestamp":"1691193600000",
2194
- // "brackets":{
2195
- // "1":"0",
2196
- // "2":"0",
2197
- // "3":"0",
2198
- // "5":"0",
2199
- // "10":"0",
2200
- // "20":"0",
2201
- // "50":"-10000",
2202
- // "100":"-5000"
2203
- // },
2204
- // "max_leverage":"100"
2205
- // }
2206
- //
2207
- const marketId = this.safeString(contract, 'ticker_id');
2208
- const symbol = this.safeSymbol(marketId, market);
2209
- const markPrice = this.safeNumber(contract, 'markPrice');
2210
- const indexPrice = this.safeNumber(contract, 'indexPrice');
2211
- const interestRate = this.safeNumber(contract, 'interestRate');
2212
- const fundingRate = this.safeNumber(contract, 'funding_rate');
2213
- const nextFundingTime = this.safeInteger(contract, 'next_funding_rate_timestamp');
2214
- return {
2215
- 'info': contract,
2216
- 'symbol': symbol,
2217
- 'markPrice': markPrice,
2218
- 'indexPrice': indexPrice,
2219
- 'interestRate': interestRate,
2220
- 'timestamp': undefined,
2221
- 'datetime': undefined,
2222
- 'fundingRate': fundingRate,
2223
- 'fundingTimestamp': undefined,
2224
- 'fundingDatetime': this.iso8601(undefined),
2225
- 'nextFundingRate': undefined,
2226
- 'nextFundingTimestamp': nextFundingTime,
2227
- 'nextFundingDatetime': this.iso8601(nextFundingTime),
2228
- 'previousFundingRate': undefined,
2229
- 'previousFundingTimestamp': undefined,
2230
- 'previousFundingDatetime': undefined,
2231
- };
2232
- }
2233
- isFiat(currency) {
2234
- const fiatCurrencies = this.safeValue(this.options, 'fiatCurrencies', []);
2235
- return this.inArray(currency, fiatCurrencies);
2236
- }
2237
- nonce() {
2238
- return this.milliseconds();
2239
- }
2240
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
2241
- const query = this.omit(params, this.extractParams(path));
2242
- const version = this.safeValue(api, 0);
2243
- const accessibility = this.safeValue(api, 1);
2244
- const pathWithParams = '/' + this.implodeParams(path, params);
2245
- let url = this.urls['api'][version][accessibility] + pathWithParams;
2246
- if (accessibility === 'public') {
2247
- if (Object.keys(query).length) {
2248
- url += '?' + this.urlencode(query);
2249
- }
2250
- }
2251
- if (accessibility === 'private') {
2252
- this.checkRequiredCredentials();
2253
- const nonce = this.nonce().toString();
2254
- const secret = this.encode(this.secret);
2255
- const request = '/' + 'api' + '/' + version + pathWithParams;
2256
- body = this.json(this.extend({ 'request': request, 'nonce': nonce }, params));
2257
- const payload = this.stringToBase64(body);
2258
- const signature = this.hmac(this.encode(payload), secret, sha512.sha512);
2259
- headers = {
2260
- 'Content-Type': 'application/json',
2261
- 'X-TXC-APIKEY': this.apiKey,
2262
- 'X-TXC-PAYLOAD': payload,
2263
- 'X-TXC-SIGNATURE': signature,
2264
- };
2265
- }
2266
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
2267
- }
2268
- handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
2269
- if ((code === 418) || (code === 429)) {
2270
- throw new errors.DDoSProtection(this.id + ' ' + code.toString() + ' ' + reason + ' ' + body);
2271
- }
2272
- if (code === 404) {
2273
- throw new errors.ExchangeError(this.id + ' ' + code.toString() + ' endpoint not found');
2274
- }
2275
- if (response !== undefined) {
2276
- // For cases where we have a meaningful status
2277
- // {"response":null,"status":422,"errors":{"orderId":["Finished order id 435453454535 not found on your account"]},"notification":null,"warning":"Finished order id 435453454535 not found on your account","_token":null}
2278
- const status = this.safeString(response, 'status');
2279
- // {"code":10,"message":"Unauthorized request."}
2280
- const message = this.safeString(response, 'message');
2281
- // For these cases where we have a generic code variable error key
2282
- // {"code":0,"message":"Validation failed","errors":{"amount":["Amount must be greater than 0"]}}
2283
- const codeNew = this.safeInteger(response, 'code');
2284
- const hasErrorStatus = status !== undefined && status !== '200';
2285
- if (hasErrorStatus || codeNew !== undefined) {
2286
- const feedback = this.id + ' ' + body;
2287
- let errorInfo = message;
2288
- if (hasErrorStatus) {
2289
- errorInfo = status;
2290
- }
2291
- else {
2292
- const errorObject = this.safeValue(response, 'errors');
2293
- if (errorObject !== undefined) {
2294
- const errorKey = Object.keys(errorObject)[0];
2295
- const errorMessageArray = this.safeValue(errorObject, errorKey, []);
2296
- const errorMessageLength = errorMessageArray.length;
2297
- errorInfo = (errorMessageLength > 0) ? errorMessageArray[0] : body;
2298
- }
2299
- }
2300
- this.throwExactlyMatchedException(this.exceptions['exact'], errorInfo, feedback);
2301
- this.throwBroadlyMatchedException(this.exceptions['broad'], body, feedback);
2302
- throw new errors.ExchangeError(feedback);
2303
- }
2304
- }
2305
- return undefined;
2306
- }
2307
- }
2308
-
2309
- module.exports = whitebit;