ccxt 4.2.18 → 4.2.19

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