ccxt 4.2.17 → 4.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (439) hide show
  1. package/README.md +9 -9
  2. package/dist/ccxt.browser.js +48992 -47725
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +12 -1
  5. package/dist/cjs/src/alpaca.js +18 -18
  6. package/dist/cjs/src/ascendex.js +13 -6
  7. package/dist/cjs/src/base/Exchange.js +266 -27
  8. package/dist/cjs/src/bigone.js +434 -168
  9. package/dist/cjs/src/binance.js +163 -34
  10. package/dist/cjs/src/binanceus.js +8 -0
  11. package/dist/cjs/src/bingx.js +183 -41
  12. package/dist/cjs/src/bitfinex.js +2 -3
  13. package/dist/cjs/src/bitget.js +59 -16
  14. package/dist/cjs/src/bitmart.js +5 -5
  15. package/dist/cjs/src/bitmex.js +4 -6
  16. package/dist/cjs/src/bitpanda.js +5 -1991
  17. package/dist/cjs/src/bitstamp.js +8 -0
  18. package/dist/cjs/src/bybit.js +27 -47
  19. package/dist/cjs/src/coinbase.js +176 -26
  20. package/dist/cjs/src/coincheck.js +1 -0
  21. package/dist/cjs/src/coinex.js +3 -0
  22. package/dist/cjs/src/coinlist.js +13 -6
  23. package/dist/cjs/src/coinone.js +2 -2
  24. package/dist/cjs/src/coinsph.js +4 -5
  25. package/dist/cjs/src/delta.js +7 -1
  26. package/dist/cjs/src/deribit.js +17 -4
  27. package/dist/cjs/src/gate.js +151 -169
  28. package/dist/cjs/src/gemini.js +1 -1
  29. package/dist/cjs/src/hitbtc.js +2 -3
  30. package/dist/cjs/src/htx.js +157 -7
  31. package/dist/cjs/src/huobijp.js +2 -3
  32. package/dist/cjs/src/independentreserve.js +7 -5
  33. package/dist/cjs/src/kraken.js +86 -54
  34. package/dist/cjs/src/kucoin.js +5 -0
  35. package/dist/cjs/src/kucoinfutures.js +131 -77
  36. package/dist/cjs/src/lbank.js +60 -33
  37. package/dist/cjs/src/luno.js +84 -2
  38. package/dist/cjs/src/mexc.js +3 -3
  39. package/dist/cjs/src/oceanex.js +1 -1
  40. package/dist/cjs/src/okx.js +23 -11
  41. package/dist/cjs/{js/src/bitpanda.js → src/onetrading.js} +39 -39
  42. package/dist/cjs/src/phemex.js +37 -27
  43. package/dist/cjs/src/poloniexfutures.js +1 -0
  44. package/dist/cjs/src/pro/binance.js +66 -25
  45. package/dist/cjs/src/pro/bitget.js +1 -1
  46. package/dist/cjs/src/pro/bitpanda.js +5 -1330
  47. package/dist/cjs/src/pro/coinbase.js +4 -1
  48. package/dist/cjs/src/pro/coincheck.js +208 -0
  49. package/dist/cjs/src/pro/hitbtc.js +5 -4
  50. package/dist/cjs/src/pro/htx.js +6 -1
  51. package/dist/cjs/src/pro/kraken.js +1 -1
  52. package/dist/cjs/src/pro/krakenfutures.js +7 -1
  53. package/dist/cjs/src/pro/kucoin.js +46 -36
  54. package/dist/cjs/src/pro/kucoinfutures.js +45 -37
  55. package/dist/cjs/src/pro/lbank.js +881 -0
  56. package/dist/cjs/src/pro/okx.js +52 -2
  57. package/dist/cjs/{js/src/pro/bitpanda.js → src/pro/onetrading.js} +4 -7
  58. package/dist/cjs/src/pro/poloniex.js +2 -2
  59. package/dist/cjs/src/pro/poloniexfutures.js +43 -35
  60. package/dist/cjs/src/pro/woo.js +126 -0
  61. package/dist/cjs/src/probit.js +4 -2
  62. package/dist/cjs/src/upbit.js +12 -12
  63. package/dist/cjs/src/wavesexchange.js +1 -1
  64. package/dist/cjs/src/whitebit.js +1 -0
  65. package/dist/cjs/src/woo.js +56 -0
  66. package/js/ccxt.d.ts +14 -2
  67. package/js/ccxt.js +10 -2
  68. package/js/src/abstract/bitpanda.d.ts +4 -4
  69. package/js/src/abstract/bitstamp.d.ts +8 -0
  70. package/js/src/abstract/gate.d.ts +1 -0
  71. package/js/src/abstract/gateio.d.ts +1 -0
  72. package/js/src/abstract/htx.d.ts +3 -0
  73. package/js/src/abstract/huobi.d.ts +3 -0
  74. package/js/src/abstract/luno.d.ts +1 -0
  75. package/js/src/abstract/onetrading.d.ts +38 -0
  76. package/js/src/ascendex.js +2 -0
  77. package/js/src/base/Exchange.d.ts +2 -3
  78. package/js/src/base/Exchange.js +5 -2
  79. package/js/src/binance.js +7 -1
  80. package/js/src/bingx.d.ts +1 -0
  81. package/js/src/bingx.js +26 -0
  82. package/js/src/bitget.js +22 -3
  83. package/js/src/bitpanda.d.ts +2 -72
  84. package/js/src/bitpanda.js +5 -1991
  85. package/js/src/bitstamp.js +8 -0
  86. package/js/src/bybit.js +21 -47
  87. package/js/src/coincheck.js +1 -0
  88. package/js/src/deribit.js +16 -4
  89. package/js/src/gate.d.ts +1 -0
  90. package/js/src/gate.js +50 -110
  91. package/js/src/htx.js +3 -0
  92. package/js/src/kraken.d.ts +1 -0
  93. package/js/src/kraken.js +40 -39
  94. package/js/src/lbank.js +1 -0
  95. package/js/src/luno.d.ts +3 -1
  96. package/js/src/luno.js +84 -2
  97. package/js/src/mexc.js +1 -2
  98. package/js/src/onetrading.d.ts +74 -0
  99. package/js/src/onetrading.js +2003 -0
  100. package/js/src/poloniexfutures.js +1 -0
  101. package/js/src/pro/binance.js +7 -2
  102. package/js/src/pro/bitget.js +1 -1
  103. package/js/src/pro/bitpanda.d.ts +2 -34
  104. package/js/src/pro/bitpanda.js +5 -1330
  105. package/js/src/pro/coincheck.d.ts +12 -0
  106. package/js/src/pro/coincheck.js +209 -0
  107. package/js/src/pro/kucoin.js +43 -35
  108. package/js/src/pro/kucoinfutures.js +45 -37
  109. package/js/src/pro/lbank.d.ts +29 -0
  110. package/js/src/pro/lbank.js +882 -0
  111. package/js/src/pro/onetrading.d.ts +36 -0
  112. package/js/src/pro/onetrading.js +1339 -0
  113. package/js/src/pro/poloniexfutures.js +43 -35
  114. package/js/src/whitebit.js +1 -0
  115. package/package.json +2 -2
  116. package/rollup.config.js +2 -0
  117. package/skip-tests.json +14 -2
  118. package/test-commonjs.cjs +25 -1
  119. package/dist/cjs/js/ccxt.js +0 -476
  120. package/dist/cjs/js/src/abstract/alpaca.js +0 -9
  121. package/dist/cjs/js/src/abstract/ascendex.js +0 -9
  122. package/dist/cjs/js/src/abstract/bigone.js +0 -9
  123. package/dist/cjs/js/src/abstract/binance.js +0 -9
  124. package/dist/cjs/js/src/abstract/bingx.js +0 -9
  125. package/dist/cjs/js/src/abstract/bit2c.js +0 -9
  126. package/dist/cjs/js/src/abstract/bitbank.js +0 -9
  127. package/dist/cjs/js/src/abstract/bitbns.js +0 -9
  128. package/dist/cjs/js/src/abstract/bitfinex.js +0 -9
  129. package/dist/cjs/js/src/abstract/bitfinex2.js +0 -9
  130. package/dist/cjs/js/src/abstract/bitflyer.js +0 -9
  131. package/dist/cjs/js/src/abstract/bitforex.js +0 -9
  132. package/dist/cjs/js/src/abstract/bitget.js +0 -9
  133. package/dist/cjs/js/src/abstract/bithumb.js +0 -9
  134. package/dist/cjs/js/src/abstract/bitmart.js +0 -9
  135. package/dist/cjs/js/src/abstract/bitmex.js +0 -9
  136. package/dist/cjs/js/src/abstract/bitopro.js +0 -9
  137. package/dist/cjs/js/src/abstract/bitpanda.js +0 -9
  138. package/dist/cjs/js/src/abstract/bitrue.js +0 -9
  139. package/dist/cjs/js/src/abstract/bitso.js +0 -9
  140. package/dist/cjs/js/src/abstract/bitstamp.js +0 -9
  141. package/dist/cjs/js/src/abstract/bitteam.js +0 -9
  142. package/dist/cjs/js/src/abstract/bitvavo.js +0 -9
  143. package/dist/cjs/js/src/abstract/bl3p.js +0 -9
  144. package/dist/cjs/js/src/abstract/blockchaincom.js +0 -9
  145. package/dist/cjs/js/src/abstract/btcalpha.js +0 -9
  146. package/dist/cjs/js/src/abstract/btcbox.js +0 -9
  147. package/dist/cjs/js/src/abstract/btcmarkets.js +0 -9
  148. package/dist/cjs/js/src/abstract/btcturk.js +0 -9
  149. package/dist/cjs/js/src/abstract/bybit.js +0 -9
  150. package/dist/cjs/js/src/abstract/cex.js +0 -9
  151. package/dist/cjs/js/src/abstract/coinbase.js +0 -9
  152. package/dist/cjs/js/src/abstract/coinbasepro.js +0 -9
  153. package/dist/cjs/js/src/abstract/coincheck.js +0 -9
  154. package/dist/cjs/js/src/abstract/coinex.js +0 -9
  155. package/dist/cjs/js/src/abstract/coinlist.js +0 -9
  156. package/dist/cjs/js/src/abstract/coinmate.js +0 -9
  157. package/dist/cjs/js/src/abstract/coinone.js +0 -9
  158. package/dist/cjs/js/src/abstract/coinsph.js +0 -9
  159. package/dist/cjs/js/src/abstract/coinspot.js +0 -9
  160. package/dist/cjs/js/src/abstract/cryptocom.js +0 -9
  161. package/dist/cjs/js/src/abstract/currencycom.js +0 -9
  162. package/dist/cjs/js/src/abstract/delta.js +0 -9
  163. package/dist/cjs/js/src/abstract/deribit.js +0 -9
  164. package/dist/cjs/js/src/abstract/digifinex.js +0 -9
  165. package/dist/cjs/js/src/abstract/exmo.js +0 -9
  166. package/dist/cjs/js/src/abstract/gate.js +0 -9
  167. package/dist/cjs/js/src/abstract/gemini.js +0 -9
  168. package/dist/cjs/js/src/abstract/hitbtc.js +0 -9
  169. package/dist/cjs/js/src/abstract/hollaex.js +0 -9
  170. package/dist/cjs/js/src/abstract/htx.js +0 -9
  171. package/dist/cjs/js/src/abstract/huobijp.js +0 -9
  172. package/dist/cjs/js/src/abstract/idex.js +0 -9
  173. package/dist/cjs/js/src/abstract/independentreserve.js +0 -9
  174. package/dist/cjs/js/src/abstract/indodax.js +0 -9
  175. package/dist/cjs/js/src/abstract/kraken.js +0 -9
  176. package/dist/cjs/js/src/abstract/krakenfutures.js +0 -9
  177. package/dist/cjs/js/src/abstract/kucoin.js +0 -9
  178. package/dist/cjs/js/src/abstract/kucoinfutures.js +0 -9
  179. package/dist/cjs/js/src/abstract/kuna.js +0 -9
  180. package/dist/cjs/js/src/abstract/latoken.js +0 -9
  181. package/dist/cjs/js/src/abstract/lbank.js +0 -9
  182. package/dist/cjs/js/src/abstract/luno.js +0 -9
  183. package/dist/cjs/js/src/abstract/lykke.js +0 -9
  184. package/dist/cjs/js/src/abstract/mercado.js +0 -9
  185. package/dist/cjs/js/src/abstract/mexc.js +0 -9
  186. package/dist/cjs/js/src/abstract/ndax.js +0 -9
  187. package/dist/cjs/js/src/abstract/novadax.js +0 -9
  188. package/dist/cjs/js/src/abstract/oceanex.js +0 -9
  189. package/dist/cjs/js/src/abstract/okcoin.js +0 -9
  190. package/dist/cjs/js/src/abstract/okx.js +0 -9
  191. package/dist/cjs/js/src/abstract/p2b.js +0 -9
  192. package/dist/cjs/js/src/abstract/paymium.js +0 -9
  193. package/dist/cjs/js/src/abstract/phemex.js +0 -9
  194. package/dist/cjs/js/src/abstract/poloniex.js +0 -9
  195. package/dist/cjs/js/src/abstract/poloniexfutures.js +0 -9
  196. package/dist/cjs/js/src/abstract/probit.js +0 -9
  197. package/dist/cjs/js/src/abstract/timex.js +0 -9
  198. package/dist/cjs/js/src/abstract/tokocrypto.js +0 -9
  199. package/dist/cjs/js/src/abstract/upbit.js +0 -9
  200. package/dist/cjs/js/src/abstract/wavesexchange.js +0 -9
  201. package/dist/cjs/js/src/abstract/wazirx.js +0 -9
  202. package/dist/cjs/js/src/abstract/whitebit.js +0 -9
  203. package/dist/cjs/js/src/abstract/woo.js +0 -9
  204. package/dist/cjs/js/src/abstract/yobit.js +0 -9
  205. package/dist/cjs/js/src/abstract/zaif.js +0 -9
  206. package/dist/cjs/js/src/abstract/zonda.js +0 -9
  207. package/dist/cjs/js/src/ace.js +0 -1058
  208. package/dist/cjs/js/src/alpaca.js +0 -1125
  209. package/dist/cjs/js/src/ascendex.js +0 -3365
  210. package/dist/cjs/js/src/base/Exchange.js +0 -5257
  211. package/dist/cjs/js/src/base/Precise.js +0 -263
  212. package/dist/cjs/js/src/base/errors.js +0 -299
  213. package/dist/cjs/js/src/base/functions/crypto.js +0 -78
  214. package/dist/cjs/js/src/base/functions/encode.js +0 -44
  215. package/dist/cjs/js/src/base/functions/generic.js +0 -193
  216. package/dist/cjs/js/src/base/functions/misc.js +0 -96
  217. package/dist/cjs/js/src/base/functions/number.js +0 -297
  218. package/dist/cjs/js/src/base/functions/platform.js +0 -28
  219. package/dist/cjs/js/src/base/functions/rsa.js +0 -34
  220. package/dist/cjs/js/src/base/functions/string.js +0 -48
  221. package/dist/cjs/js/src/base/functions/throttle.js +0 -66
  222. package/dist/cjs/js/src/base/functions/time.js +0 -187
  223. package/dist/cjs/js/src/base/functions/totp.js +0 -24
  224. package/dist/cjs/js/src/base/functions/type.js +0 -162
  225. package/dist/cjs/js/src/base/functions.js +0 -157
  226. package/dist/cjs/js/src/base/ws/Cache.js +0 -254
  227. package/dist/cjs/js/src/base/ws/Client.js +0 -299
  228. package/dist/cjs/js/src/base/ws/Future.js +0 -34
  229. package/dist/cjs/js/src/base/ws/OrderBook.js +0 -107
  230. package/dist/cjs/js/src/base/ws/OrderBookSide.js +0 -281
  231. package/dist/cjs/js/src/base/ws/WsClient.js +0 -69
  232. package/dist/cjs/js/src/bequant.js +0 -33
  233. package/dist/cjs/js/src/bigone.js +0 -2213
  234. package/dist/cjs/js/src/binance.js +0 -9845
  235. package/dist/cjs/js/src/binancecoinm.js +0 -45
  236. package/dist/cjs/js/src/binanceus.js +0 -92
  237. package/dist/cjs/js/src/binanceusdm.js +0 -58
  238. package/dist/cjs/js/src/bingx.js +0 -3846
  239. package/dist/cjs/js/src/bit2c.js +0 -916
  240. package/dist/cjs/js/src/bitbank.js +0 -1000
  241. package/dist/cjs/js/src/bitbay.js +0 -17
  242. package/dist/cjs/js/src/bitbns.js +0 -1220
  243. package/dist/cjs/js/src/bitcoincom.js +0 -17
  244. package/dist/cjs/js/src/bitfinex.js +0 -1670
  245. package/dist/cjs/js/src/bitfinex2.js +0 -2990
  246. package/dist/cjs/js/src/bitflyer.js +0 -1045
  247. package/dist/cjs/js/src/bitforex.js +0 -852
  248. package/dist/cjs/js/src/bitget.js +0 -8295
  249. package/dist/cjs/js/src/bithumb.js +0 -1090
  250. package/dist/cjs/js/src/bitmart.js +0 -4454
  251. package/dist/cjs/js/src/bitmex.js +0 -2881
  252. package/dist/cjs/js/src/bitopro.js +0 -1724
  253. package/dist/cjs/js/src/bitrue.js +0 -3253
  254. package/dist/cjs/js/src/bitso.js +0 -1753
  255. package/dist/cjs/js/src/bitstamp.js +0 -2188
  256. package/dist/cjs/js/src/bitteam.js +0 -2309
  257. package/dist/cjs/js/src/bitvavo.js +0 -1968
  258. package/dist/cjs/js/src/bl3p.js +0 -447
  259. package/dist/cjs/js/src/blockchaincom.js +0 -1160
  260. package/dist/cjs/js/src/btcalpha.js +0 -929
  261. package/dist/cjs/js/src/btcbox.js +0 -565
  262. package/dist/cjs/js/src/btcmarkets.js +0 -1237
  263. package/dist/cjs/js/src/btcturk.js +0 -929
  264. package/dist/cjs/js/src/bybit.js +0 -7650
  265. package/dist/cjs/js/src/cex.js +0 -1693
  266. package/dist/cjs/js/src/coinbase.js +0 -3424
  267. package/dist/cjs/js/src/coinbasepro.js +0 -1866
  268. package/dist/cjs/js/src/coincheck.js +0 -843
  269. package/dist/cjs/js/src/coinex.js +0 -5417
  270. package/dist/cjs/js/src/coinlist.js +0 -2337
  271. package/dist/cjs/js/src/coinmate.js +0 -989
  272. package/dist/cjs/js/src/coinone.js +0 -1185
  273. package/dist/cjs/js/src/coinsph.js +0 -1933
  274. package/dist/cjs/js/src/coinspot.js +0 -548
  275. package/dist/cjs/js/src/cryptocom.js +0 -3007
  276. package/dist/cjs/js/src/currencycom.js +0 -2015
  277. package/dist/cjs/js/src/delta.js +0 -3262
  278. package/dist/cjs/js/src/deribit.js +0 -3306
  279. package/dist/cjs/js/src/digifinex.js +0 -4307
  280. package/dist/cjs/js/src/exmo.js +0 -2645
  281. package/dist/cjs/js/src/fmfwio.js +0 -34
  282. package/dist/cjs/js/src/gate.js +0 -7077
  283. package/dist/cjs/js/src/gateio.js +0 -16
  284. package/dist/cjs/js/src/gemini.js +0 -1801
  285. package/dist/cjs/js/src/hitbtc.js +0 -3660
  286. package/dist/cjs/js/src/hitbtc3.js +0 -19
  287. package/dist/cjs/js/src/hollaex.js +0 -1882
  288. package/dist/cjs/js/src/htx.js +0 -9174
  289. package/dist/cjs/js/src/huobi.js +0 -16
  290. package/dist/cjs/js/src/huobijp.js +0 -1918
  291. package/dist/cjs/js/src/idex.js +0 -1770
  292. package/dist/cjs/js/src/independentreserve.js +0 -761
  293. package/dist/cjs/js/src/indodax.js +0 -1069
  294. package/dist/cjs/js/src/kraken.js +0 -2891
  295. package/dist/cjs/js/src/krakenfutures.js +0 -2407
  296. package/dist/cjs/js/src/kucoin.js +0 -4494
  297. package/dist/cjs/js/src/kucoinfutures.js +0 -2529
  298. package/dist/cjs/js/src/kuna.js +0 -1949
  299. package/dist/cjs/js/src/latoken.js +0 -1729
  300. package/dist/cjs/js/src/lbank.js +0 -2851
  301. package/dist/cjs/js/src/luno.js +0 -1044
  302. package/dist/cjs/js/src/lykke.js +0 -1303
  303. package/dist/cjs/js/src/mercado.js +0 -897
  304. package/dist/cjs/js/src/mexc.js +0 -5407
  305. package/dist/cjs/js/src/ndax.js +0 -2450
  306. package/dist/cjs/js/src/novadax.js +0 -1556
  307. package/dist/cjs/js/src/oceanex.js +0 -964
  308. package/dist/cjs/js/src/okcoin.js +0 -3115
  309. package/dist/cjs/js/src/okx.js +0 -7331
  310. package/dist/cjs/js/src/p2b.js +0 -1243
  311. package/dist/cjs/js/src/paymium.js +0 -597
  312. package/dist/cjs/js/src/phemex.js +0 -4725
  313. package/dist/cjs/js/src/poloniex.js +0 -2356
  314. package/dist/cjs/js/src/poloniexfutures.js +0 -1794
  315. package/dist/cjs/js/src/pro/alpaca.js +0 -714
  316. package/dist/cjs/js/src/pro/ascendex.js +0 -957
  317. package/dist/cjs/js/src/pro/bequant.js +0 -33
  318. package/dist/cjs/js/src/pro/binance.js +0 -2796
  319. package/dist/cjs/js/src/pro/binancecoinm.js +0 -23
  320. package/dist/cjs/js/src/pro/binanceus.js +0 -51
  321. package/dist/cjs/js/src/pro/binanceusdm.js +0 -32
  322. package/dist/cjs/js/src/pro/bingx.js +0 -944
  323. package/dist/cjs/js/src/pro/bitcoincom.js +0 -29
  324. package/dist/cjs/js/src/pro/bitfinex.js +0 -672
  325. package/dist/cjs/js/src/pro/bitfinex2.js +0 -1159
  326. package/dist/cjs/js/src/pro/bitget.js +0 -1733
  327. package/dist/cjs/js/src/pro/bitmart.js +0 -1486
  328. package/dist/cjs/js/src/pro/bitmex.js +0 -1576
  329. package/dist/cjs/js/src/pro/bitopro.js +0 -327
  330. package/dist/cjs/js/src/pro/bitrue.js +0 -462
  331. package/dist/cjs/js/src/pro/bitstamp.js +0 -547
  332. package/dist/cjs/js/src/pro/bitvavo.js +0 -704
  333. package/dist/cjs/js/src/pro/blockchaincom.js +0 -794
  334. package/dist/cjs/js/src/pro/bybit.js +0 -1843
  335. package/dist/cjs/js/src/pro/cex.js +0 -1510
  336. package/dist/cjs/js/src/pro/coinbase.js +0 -561
  337. package/dist/cjs/js/src/pro/coinbasepro.js +0 -968
  338. package/dist/cjs/js/src/pro/coinex.js +0 -1095
  339. package/dist/cjs/js/src/pro/cryptocom.js +0 -1020
  340. package/dist/cjs/js/src/pro/currencycom.js +0 -563
  341. package/dist/cjs/js/src/pro/deribit.js +0 -825
  342. package/dist/cjs/js/src/pro/exmo.js +0 -658
  343. package/dist/cjs/js/src/pro/gate.js +0 -1316
  344. package/dist/cjs/js/src/pro/gateio.js +0 -16
  345. package/dist/cjs/js/src/pro/gemini.js +0 -649
  346. package/dist/cjs/js/src/pro/hitbtc.js +0 -1294
  347. package/dist/cjs/js/src/pro/hollaex.js +0 -597
  348. package/dist/cjs/js/src/pro/htx.js +0 -2388
  349. package/dist/cjs/js/src/pro/huobi.js +0 -16
  350. package/dist/cjs/js/src/pro/huobijp.js +0 -606
  351. package/dist/cjs/js/src/pro/idex.js +0 -714
  352. package/dist/cjs/js/src/pro/independentreserve.js +0 -280
  353. package/dist/cjs/js/src/pro/kraken.js +0 -1364
  354. package/dist/cjs/js/src/pro/krakenfutures.js +0 -1506
  355. package/dist/cjs/js/src/pro/kucoin.js +0 -1054
  356. package/dist/cjs/js/src/pro/kucoinfutures.js +0 -981
  357. package/dist/cjs/js/src/pro/luno.js +0 -322
  358. package/dist/cjs/js/src/pro/mexc.js +0 -1170
  359. package/dist/cjs/js/src/pro/ndax.js +0 -545
  360. package/dist/cjs/js/src/pro/okcoin.js +0 -760
  361. package/dist/cjs/js/src/pro/okx.js +0 -1608
  362. package/dist/cjs/js/src/pro/phemex.js +0 -1511
  363. package/dist/cjs/js/src/pro/poloniex.js +0 -1253
  364. package/dist/cjs/js/src/pro/poloniexfutures.js +0 -1014
  365. package/dist/cjs/js/src/pro/probit.js +0 -586
  366. package/dist/cjs/js/src/pro/upbit.js +0 -234
  367. package/dist/cjs/js/src/pro/wazirx.js +0 -776
  368. package/dist/cjs/js/src/pro/whitebit.js +0 -927
  369. package/dist/cjs/js/src/pro/woo.js +0 -895
  370. package/dist/cjs/js/src/probit.js +0 -1867
  371. package/dist/cjs/js/src/static_dependencies/fflake/browser.js +0 -401
  372. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +0 -195
  373. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +0 -308
  374. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +0 -554
  375. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +0 -94
  376. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +0 -70
  377. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +0 -91
  378. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +0 -16
  379. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +0 -1760
  380. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +0 -52
  381. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +0 -81
  382. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +0 -376
  383. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +0 -70
  384. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +0 -1580
  385. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +0 -74
  386. package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +0 -24
  387. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +0 -158
  388. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +0 -429
  389. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +0 -176
  390. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +0 -324
  391. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +0 -163
  392. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +0 -245
  393. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +0 -1018
  394. package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +0 -383
  395. package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +0 -258
  396. package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +0 -53
  397. package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +0 -120
  398. package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +0 -69
  399. package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +0 -7
  400. package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +0 -83
  401. package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +0 -240
  402. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +0 -91
  403. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +0 -130
  404. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +0 -214
  405. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +0 -239
  406. package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +0 -93
  407. package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +0 -354
  408. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +0 -16
  409. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +0 -20
  410. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +0 -30
  411. package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +0 -239
  412. package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +0 -372
  413. package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +0 -273
  414. package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +0 -139
  415. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +0 -14
  416. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +0 -16
  417. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +0 -81
  418. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +0 -292
  419. package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +0 -103
  420. package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +0 -140
  421. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +0 -175
  422. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +0 -95
  423. package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +0 -7
  424. package/dist/cjs/js/src/static_dependencies/scure-base/index.js +0 -383
  425. package/dist/cjs/js/src/timex.js +0 -1562
  426. package/dist/cjs/js/src/tokocrypto.js +0 -2542
  427. package/dist/cjs/js/src/upbit.js +0 -1844
  428. package/dist/cjs/js/src/wavesexchange.js +0 -2607
  429. package/dist/cjs/js/src/wazirx.js +0 -953
  430. package/dist/cjs/js/src/whitebit.js +0 -2309
  431. package/dist/cjs/js/src/woo.js +0 -2769
  432. package/dist/cjs/js/src/yobit.js +0 -1314
  433. package/dist/cjs/js/src/zaif.js +0 -736
  434. package/dist/cjs/js/src/zonda.js +0 -1883
  435. package/dist/cjs/src/abstract/bitpanda.js +0 -9
  436. package/test.ts +0 -0
  437. /package/dist/cjs/{js/src/abstract/ace.js → src/abstract/onetrading.js} +0 -0
  438. /package/dist/cjs/{js/src → src}/pro/coinone.js +0 -0
  439. /package/js/src/abstract/{bitpanda.js → onetrading.js} +0 -0
@@ -1,1753 +0,0 @@
1
- 'use strict';
2
-
3
- var bitso$1 = require('./abstract/bitso.js');
4
- var errors = require('./base/errors.js');
5
- var Precise = require('./base/Precise.js');
6
- var number = require('./base/functions/number.js');
7
- var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
8
-
9
- // ---------------------------------------------------------------------------
10
- // ---------------------------------------------------------------------------
11
- /**
12
- * @class bitso
13
- * @augments Exchange
14
- */
15
- class bitso extends bitso$1 {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'bitso',
19
- 'name': 'Bitso',
20
- 'countries': ['MX'],
21
- 'rateLimit': 2000,
22
- 'version': 'v3',
23
- 'has': {
24
- 'CORS': undefined,
25
- 'spot': true,
26
- 'margin': false,
27
- 'swap': false,
28
- 'future': false,
29
- 'option': false,
30
- 'addMargin': false,
31
- 'cancelAllOrders': true,
32
- 'cancelOrder': true,
33
- 'cancelOrders': true,
34
- 'closeAllPositions': false,
35
- 'closePosition': false,
36
- 'createDepositAddress': false,
37
- 'createOrder': true,
38
- 'createReduceOnlyOrder': false,
39
- 'fetchAccounts': false,
40
- 'fetchBalance': true,
41
- 'fetchBorrowRateHistories': false,
42
- 'fetchBorrowRateHistory': false,
43
- 'fetchCrossBorrowRate': false,
44
- 'fetchCrossBorrowRates': false,
45
- 'fetchDeposit': true,
46
- 'fetchDepositAddress': true,
47
- 'fetchDepositAddresses': false,
48
- 'fetchDeposits': true,
49
- 'fetchDepositsWithdrawals': false,
50
- 'fetchDepositWithdrawFee': 'emulated',
51
- 'fetchDepositWithdrawFees': true,
52
- 'fetchFundingHistory': false,
53
- 'fetchFundingRate': false,
54
- 'fetchFundingRateHistory': false,
55
- 'fetchFundingRates': false,
56
- 'fetchIndexOHLCV': false,
57
- 'fetchIsolatedBorrowRate': false,
58
- 'fetchIsolatedBorrowRates': false,
59
- 'fetchLedger': true,
60
- 'fetchLeverage': false,
61
- 'fetchMarginMode': false,
62
- 'fetchMarkets': true,
63
- 'fetchMarkOHLCV': false,
64
- 'fetchMyTrades': true,
65
- 'fetchOHLCV': true,
66
- 'fetchOpenInterestHistory': false,
67
- 'fetchOpenOrders': true,
68
- 'fetchOrder': true,
69
- 'fetchOrderBook': true,
70
- 'fetchOrderTrades': true,
71
- 'fetchPosition': false,
72
- 'fetchPositionMode': false,
73
- 'fetchPositions': false,
74
- 'fetchPositionsRisk': false,
75
- 'fetchPremiumIndexOHLCV': false,
76
- 'fetchTicker': true,
77
- 'fetchTickers': false,
78
- 'fetchTime': false,
79
- 'fetchTrades': true,
80
- 'fetchTradingFee': false,
81
- 'fetchTradingFees': true,
82
- 'fetchTransactionFee': false,
83
- 'fetchTransactionFees': true,
84
- 'fetchTransactions': false,
85
- 'fetchTransfer': false,
86
- 'fetchTransfers': false,
87
- 'reduceMargin': false,
88
- 'setLeverage': false,
89
- 'setMarginMode': false,
90
- 'setPositionMode': false,
91
- 'transfer': false,
92
- 'withdraw': true,
93
- },
94
- 'urls': {
95
- 'logo': 'https://user-images.githubusercontent.com/51840849/87295554-11f98280-c50e-11ea-80d6-15b3bafa8cbf.jpg',
96
- 'api': {
97
- 'rest': 'https://api.bitso.com',
98
- },
99
- 'www': 'https://bitso.com',
100
- 'doc': 'https://bitso.com/api_info',
101
- 'fees': 'https://bitso.com/fees',
102
- 'referral': 'https://bitso.com/?ref=itej',
103
- },
104
- 'precisionMode': number.TICK_SIZE,
105
- 'options': {
106
- 'precision': {
107
- 'XRP': 0.000001,
108
- 'MXN': 0.01,
109
- 'TUSD': 0.01,
110
- },
111
- 'defaultPrecision': 0.00000001,
112
- },
113
- 'timeframes': {
114
- '1m': '60',
115
- '5m': '300',
116
- '15m': '900',
117
- '30m': '1800',
118
- '1h': '3600',
119
- '4h': '14400',
120
- '12h': '43200',
121
- '1d': '86400',
122
- '1w': '604800',
123
- },
124
- 'api': {
125
- 'public': {
126
- 'get': [
127
- 'available_books',
128
- 'ticker',
129
- 'order_book',
130
- 'trades',
131
- 'ohlc',
132
- ],
133
- },
134
- 'private': {
135
- 'get': [
136
- 'account_status',
137
- 'balance',
138
- 'fees',
139
- 'fundings',
140
- 'fundings/{fid}',
141
- 'funding_destination',
142
- 'kyc_documents',
143
- 'ledger',
144
- 'ledger/trades',
145
- 'ledger/fees',
146
- 'ledger/fundings',
147
- 'ledger/withdrawals',
148
- 'mx_bank_codes',
149
- 'open_orders',
150
- 'order_trades/{oid}',
151
- 'orders/{oid}',
152
- 'user_trades',
153
- 'user_trades/{tid}',
154
- 'withdrawals/',
155
- 'withdrawals/{wid}',
156
- ],
157
- 'post': [
158
- 'bitcoin_withdrawal',
159
- 'debit_card_withdrawal',
160
- 'ether_withdrawal',
161
- 'orders',
162
- 'phone_number',
163
- 'phone_verification',
164
- 'phone_withdrawal',
165
- 'spei_withdrawal',
166
- 'ripple_withdrawal',
167
- 'bcash_withdrawal',
168
- 'litecoin_withdrawal',
169
- ],
170
- 'delete': [
171
- 'orders',
172
- 'orders/{oid}',
173
- 'orders/all',
174
- ],
175
- },
176
- },
177
- 'exceptions': {
178
- '0201': errors.AuthenticationError,
179
- '104': errors.InvalidNonce,
180
- '0304': errors.BadRequest, // {"success":false,"error":{"code":"0304","message":"The field time_bucket () is either invalid or missing"}}
181
- },
182
- });
183
- }
184
- async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
185
- /**
186
- * @method
187
- * @name bitso#fetchLedger
188
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
189
- * @param {string} code unified currency code, default is undefined
190
- * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
191
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
192
- * @param {object} [params] extra parameters specific to the exchange API endpoint
193
- * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
194
- */
195
- const request = {};
196
- if (limit !== undefined) {
197
- request['limit'] = limit;
198
- }
199
- const response = await this.privateGetLedger(this.extend(request, params));
200
- //
201
- // {
202
- // "success": true,
203
- // "payload": [{
204
- // "eid": "2510b3e2bc1c87f584500a18084f35ed",
205
- // "created_at": "2022-06-08T12:21:42+0000",
206
- // "balance_updates": [{
207
- // "amount": "0.00080000",
208
- // "currency": "btc"
209
- // }],
210
- // "operation": "funding",
211
- // "details": {
212
- // "network": "btc",
213
- // "method": "btc",
214
- // "method_name": "Bitcoin",
215
- // "asset": "btc",
216
- // "protocol": "btc",
217
- // "integration": "bitgo-v2",
218
- // "fid": "6112c6369100d6ecceb7f54f17cf0511"
219
- // }
220
- // }]
221
- // }
222
- //
223
- const payload = this.safeValue(response, 'payload', []);
224
- const currency = this.safeCurrency(code);
225
- return this.parseLedger(payload, currency, since, limit);
226
- }
227
- parseLedgerEntryType(type) {
228
- const types = {
229
- 'funding': 'transaction',
230
- 'withdrawal': 'transaction',
231
- 'trade': 'trade',
232
- 'fee': 'fee',
233
- };
234
- return this.safeString(types, type, type);
235
- }
236
- parseLedgerEntry(item, currency = undefined) {
237
- //
238
- // {
239
- // "eid": "2510b3e2bc1c87f584500a18084f35ed",
240
- // "created_at": "2022-06-08T12:21:42+0000",
241
- // "balance_updates": [{
242
- // "amount": "0.00080000",
243
- // "currency": "btc"
244
- // }],
245
- // "operation": "funding",
246
- // "details": {
247
- // "network": "btc",
248
- // "method": "btc",
249
- // "method_name": "Bitcoin",
250
- // "asset": "btc",
251
- // "protocol": "btc",
252
- // "integration": "bitgo-v2",
253
- // "fid": "6112c6369100d6ecceb7f54f17cf0511"
254
- // }
255
- // }
256
- //
257
- // trade
258
- // {
259
- // "eid": "8976c6053f078f704f037d82a813678a",
260
- // "created_at": "2022-06-08T17:01:48+0000",
261
- // "balance_updates": [{
262
- // "amount": "59.21320500",
263
- // "currency": "mxn"
264
- // },
265
- // {
266
- // "amount": "-0.00010000",
267
- // "currency": "btc"
268
- // }
269
- // ],
270
- // "operation": "trade",
271
- // "details": {
272
- // "tid": "72145428",
273
- // "oid": "JO5TZmMZjzjlZDyT"
274
- // }
275
- // }
276
- //
277
- // fee
278
- // {
279
- // "eid": "cbbb3c8d4e41723d25d2850dcb7c3c74",
280
- // "created_at": "2022-06-08T17:01:48+0000",
281
- // "balance_updates": [{
282
- // "amount": "-0.38488583",
283
- // "currency": "mxn"
284
- // }],
285
- // "operation": "fee",
286
- // "details": {
287
- // "tid": "72145428",
288
- // "oid": "JO5TZmMZjzjlZDyT"
289
- // }
290
- // }
291
- const operation = this.safeString(item, 'operation');
292
- const type = this.parseLedgerEntryType(operation);
293
- const balanceUpdates = this.safeValue(item, 'balance_updates', []);
294
- const firstBalance = this.safeValue(balanceUpdates, 0, {});
295
- let direction = undefined;
296
- let fee = undefined;
297
- const amount = this.safeString(firstBalance, 'amount');
298
- const currencyId = this.safeString(firstBalance, 'currency');
299
- const code = this.safeCurrencyCode(currencyId, currency);
300
- const details = this.safeValue(item, 'details', {});
301
- let referenceId = this.safeString2(details, 'fid', 'wid');
302
- if (referenceId === undefined) {
303
- referenceId = this.safeString(details, 'tid');
304
- }
305
- if (operation === 'funding') {
306
- direction = 'in';
307
- }
308
- else if (operation === 'withdrawal') {
309
- direction = 'out';
310
- }
311
- else if (operation === 'trade') {
312
- direction = undefined;
313
- }
314
- else if (operation === 'fee') {
315
- direction = 'out';
316
- const cost = Precise["default"].stringAbs(amount);
317
- fee = {
318
- 'cost': cost,
319
- 'currency': currency,
320
- };
321
- }
322
- const timestamp = this.parse8601(this.safeString(item, 'created_at'));
323
- return this.safeLedgerEntry({
324
- 'id': this.safeString(item, 'eid'),
325
- 'direction': direction,
326
- 'account': undefined,
327
- 'referenceId': referenceId,
328
- 'referenceAccount': undefined,
329
- 'type': type,
330
- 'currency': code,
331
- 'amount': amount,
332
- 'timestamp': timestamp,
333
- 'datetime': this.iso8601(timestamp),
334
- 'before': undefined,
335
- 'after': undefined,
336
- 'status': 'ok',
337
- 'fee': fee,
338
- 'info': item,
339
- }, currency);
340
- }
341
- async fetchMarkets(params = {}) {
342
- /**
343
- * @method
344
- * @name bitso#fetchMarkets
345
- * @description retrieves data on all markets for bitso
346
- * @param {object} [params] extra parameters specific to the exchange API endpoint
347
- * @returns {object[]} an array of objects representing market data
348
- */
349
- const response = await this.publicGetAvailableBooks(params);
350
- //
351
- // {
352
- // "success":true,
353
- // "payload":[
354
- // {
355
- // "book":"btc_mxn",
356
- // "minimum_price":"500",
357
- // "maximum_price":"10000000",
358
- // "minimum_amount":"0.00005",
359
- // "maximum_amount":"500",
360
- // "minimum_value":"5",
361
- // "maximum_value":"10000000",
362
- // "tick_size":"0.01",
363
- // "fees":{
364
- // "flat_rate":{"maker":"0.500","taker":"0.650"},
365
- // "structure":[
366
- // {"volume":"1500000","maker":"0.00500","taker":"0.00650"},
367
- // {"volume":"2000000","maker":"0.00490","taker":"0.00637"},
368
- // {"volume":"5000000","maker":"0.00480","taker":"0.00624"},
369
- // {"volume":"7000000","maker":"0.00440","taker":"0.00572"},
370
- // {"volume":"10000000","maker":"0.00420","taker":"0.00546"},
371
- // {"volume":"15000000","maker":"0.00400","taker":"0.00520"},
372
- // {"volume":"35000000","maker":"0.00370","taker":"0.00481"},
373
- // {"volume":"50000000","maker":"0.00300","taker":"0.00390"},
374
- // {"volume":"150000000","maker":"0.00200","taker":"0.00260"},
375
- // {"volume":"250000000","maker":"0.00100","taker":"0.00130"},
376
- // {"volume":"9999999999","maker":"0.00000","taker":"0.00130"},
377
- // ]
378
- // }
379
- // },
380
- // ]
381
- // }
382
- const markets = this.safeValue(response, 'payload', []);
383
- const result = [];
384
- for (let i = 0; i < markets.length; i++) {
385
- const market = markets[i];
386
- const id = this.safeString(market, 'book');
387
- const [baseId, quoteId] = id.split('_');
388
- let base = baseId.toUpperCase();
389
- let quote = quoteId.toUpperCase();
390
- base = this.safeCurrencyCode(base);
391
- quote = this.safeCurrencyCode(quote);
392
- const fees = this.safeValue(market, 'fees', {});
393
- const flatRate = this.safeValue(fees, 'flat_rate', {});
394
- const takerString = this.safeString(flatRate, 'taker');
395
- const makerString = this.safeString(flatRate, 'maker');
396
- const taker = this.parseNumber(Precise["default"].stringDiv(takerString, '100'));
397
- const maker = this.parseNumber(Precise["default"].stringDiv(makerString, '100'));
398
- const feeTiers = this.safeValue(fees, 'structure', []);
399
- const fee = {
400
- 'taker': taker,
401
- 'maker': maker,
402
- 'percentage': true,
403
- 'tierBased': true,
404
- };
405
- const takerFees = [];
406
- const makerFees = [];
407
- for (let j = 0; j < feeTiers.length; j++) {
408
- const tier = feeTiers[j];
409
- const volume = this.safeNumber(tier, 'volume');
410
- const takerFee = this.safeNumber(tier, 'taker');
411
- const makerFee = this.safeNumber(tier, 'maker');
412
- takerFees.push([volume, takerFee]);
413
- makerFees.push([volume, makerFee]);
414
- if (j === 0) {
415
- fee['taker'] = takerFee;
416
- fee['maker'] = makerFee;
417
- }
418
- }
419
- const tiers = {
420
- 'taker': takerFees,
421
- 'maker': makerFees,
422
- };
423
- fee['tiers'] = tiers;
424
- // TODO: precisions can be also set from https://bitso.com/api/v3/catalogues ->available_currency_conversions->currencies (or ->currencies->metadata) or https://bitso.com/api/v3/get_exchange_rates/mxn
425
- const defaultPricePrecision = this.safeNumber(this.options['precision'], quote, this.options['defaultPrecision']);
426
- result.push(this.extend({
427
- 'id': id,
428
- 'symbol': base + '/' + quote,
429
- 'base': base,
430
- 'quote': quote,
431
- 'settle': undefined,
432
- 'baseId': baseId,
433
- 'quoteId': quoteId,
434
- 'settleId': undefined,
435
- 'type': 'spot',
436
- 'spot': true,
437
- 'margin': false,
438
- 'swap': false,
439
- 'future': false,
440
- 'option': false,
441
- 'active': undefined,
442
- 'contract': false,
443
- 'linear': undefined,
444
- 'inverse': undefined,
445
- 'taker': taker,
446
- 'maker': maker,
447
- 'contractSize': undefined,
448
- 'expiry': undefined,
449
- 'expiryDatetime': undefined,
450
- 'strike': undefined,
451
- 'optionType': undefined,
452
- 'precision': {
453
- 'amount': this.safeNumber(this.options['precision'], base, this.options['defaultPrecision']),
454
- 'price': this.safeNumber(market, 'tick_size', defaultPricePrecision),
455
- },
456
- 'limits': {
457
- 'leverage': {
458
- 'min': undefined,
459
- 'max': undefined,
460
- },
461
- 'amount': {
462
- 'min': this.safeNumber(market, 'minimum_amount'),
463
- 'max': this.safeNumber(market, 'maximum_amount'),
464
- },
465
- 'price': {
466
- 'min': this.safeNumber(market, 'minimum_price'),
467
- 'max': this.safeNumber(market, 'maximum_price'),
468
- },
469
- 'cost': {
470
- 'min': this.safeNumber(market, 'minimum_value'),
471
- 'max': this.safeNumber(market, 'maximum_value'),
472
- },
473
- },
474
- 'created': undefined,
475
- 'info': market,
476
- }, fee));
477
- }
478
- return result;
479
- }
480
- parseBalance(response) {
481
- const payload = this.safeValue(response, 'payload', {});
482
- const balances = this.safeValue(payload, 'balances', []);
483
- const result = {
484
- 'info': response,
485
- 'timestamp': undefined,
486
- 'datetime': undefined,
487
- };
488
- for (let i = 0; i < balances.length; i++) {
489
- const balance = balances[i];
490
- const currencyId = this.safeString(balance, 'currency');
491
- const code = this.safeCurrencyCode(currencyId);
492
- const account = this.account();
493
- account['free'] = this.safeString(balance, 'available');
494
- account['used'] = this.safeString(balance, 'locked');
495
- account['total'] = this.safeString(balance, 'total');
496
- result[code] = account;
497
- }
498
- return this.safeBalance(result);
499
- }
500
- async fetchBalance(params = {}) {
501
- /**
502
- * @method
503
- * @name bitso#fetchBalance
504
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
505
- * @param {object} [params] extra parameters specific to the exchange API endpoint
506
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
507
- */
508
- await this.loadMarkets();
509
- const response = await this.privateGetBalance(params);
510
- //
511
- // {
512
- // "success": true,
513
- // "payload": {
514
- // "balances": [
515
- // {
516
- // "currency": "bat",
517
- // "available": "0.00000000",
518
- // "locked": "0.00000000",
519
- // "total": "0.00000000",
520
- // "pending_deposit": "0.00000000",
521
- // "pending_withdrawal": "0.00000000"
522
- // },
523
- // {
524
- // "currency": "bch",
525
- // "available": "0.00000000",
526
- // "locked": "0.00000000",
527
- // "total": "0.00000000",
528
- // "pending_deposit": "0.00000000",
529
- // "pending_withdrawal": "0.00000000"
530
- // },
531
- // ],
532
- // },
533
- // }
534
- //
535
- return this.parseBalance(response);
536
- }
537
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
538
- /**
539
- * @method
540
- * @name bitso#fetchOrderBook
541
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
542
- * @param {string} symbol unified symbol of the market to fetch the order book for
543
- * @param {int} [limit] the maximum amount of order book entries to return
544
- * @param {object} [params] extra parameters specific to the exchange API endpoint
545
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
546
- */
547
- await this.loadMarkets();
548
- const market = this.market(symbol);
549
- const request = {
550
- 'book': market['id'],
551
- };
552
- const response = await this.publicGetOrderBook(this.extend(request, params));
553
- const orderbook = this.safeValue(response, 'payload');
554
- const timestamp = this.parse8601(this.safeString(orderbook, 'updated_at'));
555
- return this.parseOrderBook(orderbook, market['symbol'], timestamp, 'bids', 'asks', 'price', 'amount');
556
- }
557
- parseTicker(ticker, market = undefined) {
558
- //
559
- // {
560
- // "high":"37446.85",
561
- // "last":"36599.54",
562
- // "created_at":"2022-01-28T12:06:11+00:00",
563
- // "book":"btc_usdt",
564
- // "volume":"7.29075419",
565
- // "vwap":"36579.1564400307",
566
- // "low":"35578.52",
567
- // "ask":"36574.76",
568
- // "bid":"36538.22",
569
- // "change_24":"-105.64"
570
- // }
571
- //
572
- const symbol = this.safeSymbol(undefined, market);
573
- const timestamp = this.parse8601(this.safeString(ticker, 'created_at'));
574
- const vwap = this.safeString(ticker, 'vwap');
575
- const baseVolume = this.safeString(ticker, 'volume');
576
- const quoteVolume = Precise["default"].stringMul(baseVolume, vwap);
577
- const last = this.safeString(ticker, 'last');
578
- return this.safeTicker({
579
- 'symbol': symbol,
580
- 'timestamp': timestamp,
581
- 'datetime': this.iso8601(timestamp),
582
- 'high': this.safeString(ticker, 'high'),
583
- 'low': this.safeString(ticker, 'low'),
584
- 'bid': this.safeString(ticker, 'bid'),
585
- 'bidVolume': undefined,
586
- 'ask': this.safeString(ticker, 'ask'),
587
- 'askVolume': undefined,
588
- 'vwap': vwap,
589
- 'open': undefined,
590
- 'close': last,
591
- 'last': last,
592
- 'previousClose': undefined,
593
- 'change': undefined,
594
- 'percentage': undefined,
595
- 'average': undefined,
596
- 'baseVolume': baseVolume,
597
- 'quoteVolume': quoteVolume,
598
- 'info': ticker,
599
- }, market);
600
- }
601
- async fetchTicker(symbol, params = {}) {
602
- /**
603
- * @method
604
- * @name bitso#fetchTicker
605
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
606
- * @param {string} symbol unified symbol of the market to fetch the ticker for
607
- * @param {object} [params] extra parameters specific to the exchange API endpoint
608
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
609
- */
610
- await this.loadMarkets();
611
- const market = this.market(symbol);
612
- const request = {
613
- 'book': market['id'],
614
- };
615
- const response = await this.publicGetTicker(this.extend(request, params));
616
- const ticker = this.safeValue(response, 'payload');
617
- //
618
- // {
619
- // "success":true,
620
- // "payload":{
621
- // "high":"37446.85",
622
- // "last":"37051.96",
623
- // "created_at":"2022-01-28T17:03:29+00:00",
624
- // "book":"btc_usdt",
625
- // "volume":"6.16176186",
626
- // "vwap":"36582.6293169472",
627
- // "low":"35578.52",
628
- // "ask":"37083.62",
629
- // "bid":"37039.66",
630
- // "change_24":"478.45"
631
- // }
632
- // }
633
- //
634
- return this.parseTicker(ticker, market);
635
- }
636
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
637
- /**
638
- * @method
639
- * @name bitso#fetchOHLCV
640
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
641
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
642
- * @param {string} timeframe the length of time each candle represents
643
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
644
- * @param {int} [limit] the maximum amount of candles to fetch
645
- * @param {object} [params] extra parameters specific to the exchange API endpoint
646
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
647
- */
648
- await this.loadMarkets();
649
- const market = this.market(symbol);
650
- const request = {
651
- 'book': market['id'],
652
- 'time_bucket': this.safeString(this.timeframes, timeframe, timeframe),
653
- };
654
- if (since !== undefined) {
655
- request['start'] = since;
656
- if (limit !== undefined) {
657
- const duration = this.parseTimeframe(timeframe);
658
- request['end'] = this.sum(since, duration * limit * 1000);
659
- }
660
- }
661
- else if (limit !== undefined) {
662
- const now = this.milliseconds();
663
- request['end'] = now;
664
- request['start'] = now - this.parseTimeframe(timeframe) * 1000 * limit;
665
- }
666
- const response = await this.publicGetOhlc(this.extend(request, params));
667
- //
668
- // {
669
- // "success":true,
670
- // "payload": [
671
- // {
672
- // "bucket_start_time":1648219140000,
673
- // "first_trade_time":1648219154990,
674
- // "last_trade_time":1648219189441,
675
- // "first_rate":"44958.60",
676
- // "last_rate":"44979.88",
677
- // "min_rate":"44957.33",
678
- // "max_rate":"44979.88",
679
- // "trade_count":8,
680
- // "volume":"0.00082814",
681
- // "vwap":"44965.02"
682
- // },
683
- // ]
684
- // }
685
- //
686
- const payload = this.safeValue(response, 'payload', []);
687
- return this.parseOHLCVs(payload, market, timeframe, since, limit);
688
- }
689
- parseOHLCV(ohlcv, market = undefined) {
690
- //
691
- // {
692
- // "bucket_start_time":1648219140000,
693
- // "first_trade_time":1648219154990,
694
- // "last_trade_time":1648219189441,
695
- // "first_rate":"44958.60",
696
- // "last_rate":"44979.88",
697
- // "min_rate":"44957.33",
698
- // "max_rate":"44979.88",
699
- // "trade_count":8,
700
- // "volume":"0.00082814",
701
- // "vwap":"44965.02"
702
- // },
703
- //
704
- return [
705
- this.safeInteger(ohlcv, 'bucket_start_time'),
706
- this.safeNumber(ohlcv, 'first_rate'),
707
- this.safeNumber(ohlcv, 'max_rate'),
708
- this.safeNumber(ohlcv, 'min_rate'),
709
- this.safeNumber(ohlcv, 'last_rate'),
710
- this.safeNumber(ohlcv, 'volume'),
711
- ];
712
- }
713
- parseTrade(trade, market = undefined) {
714
- //
715
- // fetchTrades (public)
716
- //
717
- // {
718
- // "book": "btc_usdt",
719
- // "created_at": "2021-11-24T12:14:53+0000",
720
- // "amount": "0.00026562",
721
- // "maker_side": "sell",
722
- // "price": "56471.55",
723
- // "tid": "52557338"
724
- // }
725
- //
726
- // fetchMyTrades (private)
727
- //
728
- // {
729
- // "book": "btc_usdt",
730
- // "created_at": "2021-11-24T12:31:03+0000",
731
- // "minor": "11.30356000",
732
- // "major": "-0.00020000",
733
- // "fees_amount": "0.01119052",
734
- // "fees_currency": "usdt",
735
- // "minor_currency": "usdt",
736
- // "major_currency": "btc",
737
- // "oid": "djTzMIWx2Vi3iMjl",
738
- // "tid": "52559051",
739
- // "price": "56517.80",
740
- // "side": "sell",
741
- // "maker_side": "buy"
742
- // }
743
- //
744
- // fetchOrderTrades (private)
745
- //
746
- // {
747
- // "book": "btc_usdt",
748
- // "created_at": "2021-11-24T12:30:52+0000",
749
- // "minor": "-11.33047916",
750
- // "major": "0.00020020",
751
- // "fees_amount": "0.00000020",
752
- // "fees_currency": "btc",
753
- // "minor_currency": "usdt",
754
- // "major_currency": "btc",
755
- // "oid": "O0D2zcljjjQF5xlG",
756
- // "tid": "52559030",
757
- // "price": "56595.80",
758
- // "side": "buy",
759
- // "maker_side": "sell"
760
- // }
761
- //
762
- const timestamp = this.parse8601(this.safeString(trade, 'created_at'));
763
- const marketId = this.safeString(trade, 'book');
764
- const symbol = this.safeSymbol(marketId, market, '_');
765
- let side = this.safeString(trade, 'side');
766
- const makerSide = this.safeString(trade, 'maker_side');
767
- let takerOrMaker = undefined;
768
- if (side !== undefined) {
769
- if (side === makerSide) {
770
- takerOrMaker = 'maker';
771
- }
772
- else {
773
- takerOrMaker = 'taker';
774
- }
775
- }
776
- else {
777
- if (makerSide === 'buy') {
778
- side = 'sell';
779
- }
780
- else {
781
- side = 'buy';
782
- }
783
- }
784
- let amount = this.safeString2(trade, 'amount', 'major');
785
- if (amount !== undefined) {
786
- amount = Precise["default"].stringAbs(amount);
787
- }
788
- let fee = undefined;
789
- const feeCost = this.safeString(trade, 'fees_amount');
790
- if (feeCost !== undefined) {
791
- const feeCurrencyId = this.safeString(trade, 'fees_currency');
792
- const feeCurrency = this.safeCurrencyCode(feeCurrencyId);
793
- fee = {
794
- 'cost': feeCost,
795
- 'currency': feeCurrency,
796
- };
797
- }
798
- let cost = this.safeString(trade, 'minor');
799
- if (cost !== undefined) {
800
- cost = Precise["default"].stringAbs(cost);
801
- }
802
- const price = this.safeString(trade, 'price');
803
- const orderId = this.safeString(trade, 'oid');
804
- const id = this.safeString(trade, 'tid');
805
- return this.safeTrade({
806
- 'id': id,
807
- 'info': trade,
808
- 'timestamp': timestamp,
809
- 'datetime': this.iso8601(timestamp),
810
- 'symbol': symbol,
811
- 'order': orderId,
812
- 'type': undefined,
813
- 'side': side,
814
- 'takerOrMaker': takerOrMaker,
815
- 'price': price,
816
- 'amount': amount,
817
- 'cost': cost,
818
- 'fee': fee,
819
- }, market);
820
- }
821
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
822
- /**
823
- * @method
824
- * @name bitso#fetchTrades
825
- * @description get the list of most recent trades for a particular symbol
826
- * @param {string} symbol unified symbol of the market to fetch trades for
827
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
828
- * @param {int} [limit] the maximum amount of trades to fetch
829
- * @param {object} [params] extra parameters specific to the exchange API endpoint
830
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
831
- */
832
- await this.loadMarkets();
833
- const market = this.market(symbol);
834
- const request = {
835
- 'book': market['id'],
836
- };
837
- const response = await this.publicGetTrades(this.extend(request, params));
838
- return this.parseTrades(response['payload'], market, since, limit);
839
- }
840
- async fetchTradingFees(params = {}) {
841
- /**
842
- * @method
843
- * @name bitso#fetchTradingFees
844
- * @description fetch the trading fees for multiple markets
845
- * @param {object} [params] extra parameters specific to the exchange API endpoint
846
- * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
847
- */
848
- await this.loadMarkets();
849
- const response = await this.privateGetFees(params);
850
- //
851
- // {
852
- // "success": true,
853
- // "payload": {
854
- // "fees": [
855
- // {
856
- // "book": "btc_mxn",
857
- // "fee_percent": "0.6500",
858
- // "fee_decimal": "0.00650000",
859
- // "taker_fee_percent": "0.6500",
860
- // "taker_fee_decimal": "0.00650000",
861
- // "maker_fee_percent": "0.5000",
862
- // "maker_fee_decimal": "0.00500000",
863
- // "volume_currency": "mxn",
864
- // "current_volume": "0.00",
865
- // "next_volume": "1500000.00",
866
- // "next_maker_fee_percent": "0.490",
867
- // "next_taker_fee_percent": "0.637",
868
- // "nextVolume": "1500000.00",
869
- // "nextFee": "0.490",
870
- // "nextTakerFee": "0.637"
871
- // },
872
- // ...
873
- // ],
874
- // "deposit_fees": [
875
- // {
876
- // "currency": "btc",
877
- // "method": "rewards",
878
- // "fee": "0.00",
879
- // "is_fixed": false
880
- // },
881
- // ...
882
- // ],
883
- // "withdrawal_fees": {
884
- // "ada": "0.20958100",
885
- // "bch": "0.00009437",
886
- // "ars": "0",
887
- // "btc": "0.00001209",
888
- // ...
889
- // }
890
- // }
891
- // }
892
- //
893
- const payload = this.safeValue(response, 'payload', {});
894
- const fees = this.safeValue(payload, 'fees', []);
895
- const result = {};
896
- for (let i = 0; i < fees.length; i++) {
897
- const fee = fees[i];
898
- const marketId = this.safeString(fee, 'book');
899
- const symbol = this.safeSymbol(marketId, undefined, '_');
900
- result[symbol] = {
901
- 'info': fee,
902
- 'symbol': symbol,
903
- 'maker': this.safeNumber(fee, 'maker_fee_decimal'),
904
- 'taker': this.safeNumber(fee, 'taker_fee_decimal'),
905
- 'percentage': true,
906
- 'tierBased': true,
907
- };
908
- }
909
- return result;
910
- }
911
- async fetchMyTrades(symbol = undefined, since = undefined, limit = 25, params = {}) {
912
- /**
913
- * @method
914
- * @name bitso#fetchMyTrades
915
- * @description fetch all trades made by the user
916
- * @param {string} symbol unified market symbol
917
- * @param {int} [since] the earliest time in ms to fetch trades for
918
- * @param {int} [limit] the maximum number of trades structures to retrieve
919
- * @param {object} [params] extra parameters specific to the exchange API endpoint
920
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
921
- */
922
- await this.loadMarkets();
923
- const market = this.market(symbol);
924
- // the don't support fetching trades starting from a date yet
925
- // use the `marker` extra param for that
926
- // this is not a typo, the variable name is 'marker' (don't confuse with 'market')
927
- const markerInParams = ('marker' in params);
928
- // warn the user with an exception if the user wants to filter
929
- // starting from since timestamp, but does not set the trade id with an extra 'marker' param
930
- if ((since !== undefined) && !markerInParams) {
931
- throw new errors.ExchangeError(this.id + ' fetchMyTrades() does not support fetching trades starting from a timestamp with the `since` argument, use the `marker` extra param to filter starting from an integer trade id');
932
- }
933
- // convert it to an integer unconditionally
934
- if (markerInParams) {
935
- params = this.extend(params, {
936
- 'marker': parseInt(params['marker']),
937
- });
938
- }
939
- const request = {
940
- 'book': market['id'],
941
- 'limit': limit, // default = 25, max = 100
942
- // 'sort': 'desc', // default = desc
943
- // 'marker': id, // integer id to start from
944
- };
945
- const response = await this.privateGetUserTrades(this.extend(request, params));
946
- return this.parseTrades(response['payload'], market, since, limit);
947
- }
948
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
949
- /**
950
- * @method
951
- * @name bitso#createOrder
952
- * @description create a trade order
953
- * @param {string} symbol unified symbol of the market to create an order in
954
- * @param {string} type 'market' or 'limit'
955
- * @param {string} side 'buy' or 'sell'
956
- * @param {float} amount how much of currency you want to trade in units of base currency
957
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
958
- * @param {object} [params] extra parameters specific to the exchange API endpoint
959
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
960
- */
961
- await this.loadMarkets();
962
- const market = this.market(symbol);
963
- const request = {
964
- 'book': market['id'],
965
- 'side': side,
966
- 'type': type,
967
- 'major': this.amountToPrecision(market['symbol'], amount),
968
- };
969
- if (type === 'limit') {
970
- request['price'] = this.priceToPrecision(market['symbol'], price);
971
- }
972
- const response = await this.privatePostOrders(this.extend(request, params));
973
- const id = this.safeString(response['payload'], 'oid');
974
- return this.safeOrder({
975
- 'info': response,
976
- 'id': id,
977
- }, market);
978
- }
979
- async cancelOrder(id, symbol = undefined, params = {}) {
980
- /**
981
- * @method
982
- * @name bitso#cancelOrder
983
- * @description cancels an open order
984
- * @param {string} id order id
985
- * @param {string} symbol not used by bitso cancelOrder ()
986
- * @param {object} [params] extra parameters specific to the exchange API endpoint
987
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
988
- */
989
- await this.loadMarkets();
990
- const request = {
991
- 'oid': id,
992
- };
993
- return await this.privateDeleteOrdersOid(this.extend(request, params));
994
- }
995
- async cancelOrders(ids, symbol = undefined, params = {}) {
996
- /**
997
- * @method
998
- * @name bitso#cancelOrders
999
- * @description cancel multiple orders
1000
- * @param {string[]} ids order ids
1001
- * @param {string} symbol unified market symbol
1002
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1003
- * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1004
- */
1005
- if (!Array.isArray(ids)) {
1006
- throw new errors.ArgumentsRequired(this.id + ' cancelOrders() ids argument should be an array');
1007
- }
1008
- let market = undefined;
1009
- if (symbol !== undefined) {
1010
- market = this.market(symbol);
1011
- }
1012
- const oids = ids.join(',');
1013
- const request = {
1014
- 'oids': oids,
1015
- };
1016
- const response = await this.privateDeleteOrders(this.extend(request, params));
1017
- //
1018
- // {
1019
- // "success": true,
1020
- // "payload": ["yWTQGxDMZ0VimZgZ"]
1021
- // }
1022
- //
1023
- const payload = this.safeValue(response, 'payload', []);
1024
- const orders = [];
1025
- for (let i = 0; i < payload.length; i++) {
1026
- const id = payload[i];
1027
- orders.push(this.parseOrder(id, market));
1028
- }
1029
- return orders;
1030
- }
1031
- async cancelAllOrders(symbol = undefined, params = {}) {
1032
- /**
1033
- * @method
1034
- * @name bitso#cancelAllOrders
1035
- * @description cancel all open orders
1036
- * @param {undefined} symbol bitso does not support canceling orders for only a specific market
1037
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1038
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1039
- */
1040
- if (symbol !== undefined) {
1041
- throw new errors.NotSupported(this.id + ' cancelAllOrders() deletes all orders for user, it does not support filtering by symbol.');
1042
- }
1043
- const response = await this.privateDeleteOrdersAll(params);
1044
- //
1045
- // {
1046
- // "success": true,
1047
- // "payload": ["NWUZUYNT12ljwzDT", "kZUkZmQ2TTjkkYTY"]
1048
- // }
1049
- //
1050
- const payload = this.safeValue(response, 'payload', []);
1051
- const canceledOrders = [];
1052
- for (let i = 0; i < payload.length; i++) {
1053
- const order = this.parseOrder(payload[i]);
1054
- canceledOrders.push(order);
1055
- }
1056
- return canceledOrders;
1057
- }
1058
- parseOrderStatus(status) {
1059
- const statuses = {
1060
- 'partial-fill': 'open',
1061
- 'partially filled': 'open',
1062
- 'queued': 'open',
1063
- 'completed': 'closed',
1064
- };
1065
- return this.safeString(statuses, status, status);
1066
- }
1067
- parseOrder(order, market = undefined) {
1068
- //
1069
- //
1070
- // canceledOrder
1071
- // yWTQGxDMZ0VimZgZ
1072
- //
1073
- let id = undefined;
1074
- if (typeof order === 'string') {
1075
- id = order;
1076
- }
1077
- else {
1078
- id = this.safeString(order, 'oid');
1079
- }
1080
- const side = this.safeString(order, 'side');
1081
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
1082
- const marketId = this.safeString(order, 'book');
1083
- const symbol = this.safeSymbol(marketId, market, '_');
1084
- const orderType = this.safeString(order, 'type');
1085
- const timestamp = this.parse8601(this.safeString(order, 'created_at'));
1086
- const price = this.safeString(order, 'price');
1087
- const amount = this.safeString(order, 'original_amount');
1088
- const remaining = this.safeString(order, 'unfilled_amount');
1089
- const clientOrderId = this.safeString(order, 'client_id');
1090
- return this.safeOrder({
1091
- 'info': order,
1092
- 'id': id,
1093
- 'clientOrderId': clientOrderId,
1094
- 'timestamp': timestamp,
1095
- 'datetime': this.iso8601(timestamp),
1096
- 'lastTradeTimestamp': undefined,
1097
- 'symbol': symbol,
1098
- 'type': orderType,
1099
- 'timeInForce': undefined,
1100
- 'postOnly': undefined,
1101
- 'side': side,
1102
- 'price': price,
1103
- 'stopPrice': undefined,
1104
- 'triggerPrice': undefined,
1105
- 'amount': amount,
1106
- 'cost': undefined,
1107
- 'remaining': remaining,
1108
- 'filled': undefined,
1109
- 'status': status,
1110
- 'fee': undefined,
1111
- 'average': undefined,
1112
- 'trades': undefined,
1113
- }, market);
1114
- }
1115
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = 25, params = {}) {
1116
- /**
1117
- * @method
1118
- * @name bitso#fetchOpenOrders
1119
- * @description fetch all unfilled currently open orders
1120
- * @param {string} symbol unified market symbol
1121
- * @param {int} [since] the earliest time in ms to fetch open orders for
1122
- * @param {int} [limit] the maximum number of open orders structures to retrieve
1123
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1124
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1125
- */
1126
- await this.loadMarkets();
1127
- const market = this.market(symbol);
1128
- // the don't support fetching trades starting from a date yet
1129
- // use the `marker` extra param for that
1130
- // this is not a typo, the variable name is 'marker' (don't confuse with 'market')
1131
- const markerInParams = ('marker' in params);
1132
- // warn the user with an exception if the user wants to filter
1133
- // starting from since timestamp, but does not set the trade id with an extra 'marker' param
1134
- if ((since !== undefined) && !markerInParams) {
1135
- throw new errors.ExchangeError(this.id + ' fetchOpenOrders() does not support fetching orders starting from a timestamp with the `since` argument, use the `marker` extra param to filter starting from an integer trade id');
1136
- }
1137
- // convert it to an integer unconditionally
1138
- if (markerInParams) {
1139
- params = this.extend(params, {
1140
- 'marker': parseInt(params['marker']),
1141
- });
1142
- }
1143
- const request = {
1144
- 'book': market['id'],
1145
- 'limit': limit, // default = 25, max = 100
1146
- // 'sort': 'desc', // default = desc
1147
- // 'marker': id, // integer id to start from
1148
- };
1149
- const response = await this.privateGetOpenOrders(this.extend(request, params));
1150
- const orders = this.parseOrders(response['payload'], market, since, limit);
1151
- return orders;
1152
- }
1153
- async fetchOrder(id, symbol = undefined, params = {}) {
1154
- /**
1155
- * @method
1156
- * @name bitso#fetchOrder
1157
- * @description fetches information on an order made by the user
1158
- * @param {string} symbol not used by bitso fetchOrder
1159
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1160
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1161
- */
1162
- await this.loadMarkets();
1163
- const response = await this.privateGetOrdersOid({
1164
- 'oid': id,
1165
- });
1166
- const payload = this.safeValue(response, 'payload');
1167
- if (Array.isArray(payload)) {
1168
- const numOrders = response['payload'].length;
1169
- if (numOrders === 1) {
1170
- return this.parseOrder(payload[0]);
1171
- }
1172
- }
1173
- throw new errors.OrderNotFound(this.id + ': The order ' + id + ' not found.');
1174
- }
1175
- async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
1176
- /**
1177
- * @method
1178
- * @name bitso#fetchOrderTrades
1179
- * @description fetch all the trades made from a single order
1180
- * @param {string} id order id
1181
- * @param {string} symbol unified market symbol
1182
- * @param {int} [since] the earliest time in ms to fetch trades for
1183
- * @param {int} [limit] the maximum number of trades to retrieve
1184
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1185
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1186
- */
1187
- await this.loadMarkets();
1188
- const market = this.market(symbol);
1189
- const request = {
1190
- 'oid': id,
1191
- };
1192
- const response = await this.privateGetOrderTradesOid(this.extend(request, params));
1193
- return this.parseTrades(response['payload'], market);
1194
- }
1195
- async fetchDeposit(id, code = undefined, params = {}) {
1196
- /**
1197
- * @method
1198
- * @name bitso#fetchDeposit
1199
- * @description fetch information on a deposit
1200
- * @param {string} id deposit id
1201
- * @param {string} code bitso does not support filtering by currency code and will ignore this argument
1202
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1203
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1204
- */
1205
- await this.loadMarkets();
1206
- const request = {
1207
- 'fid': id,
1208
- };
1209
- const response = await this.privateGetFundingsFid(this.extend(request, params));
1210
- //
1211
- // {
1212
- // "success": true,
1213
- // "payload": [{
1214
- // "fid": "6112c6369100d6ecceb7f54f17cf0511",
1215
- // "status": "complete",
1216
- // "created_at": "2022-06-08T12:02:49+0000",
1217
- // "currency": "btc",
1218
- // "method": "btc",
1219
- // "method_name": "Bitcoin",
1220
- // "amount": "0.00080000",
1221
- // "asset": "btc",
1222
- // "network": "btc",
1223
- // "protocol": "btc",
1224
- // "integration": "bitgo-v2",
1225
- // "details": {
1226
- // "receiving_address": "3N2vbcYKhogs6RoTb4eYCUJ3beRSqLgSif",
1227
- // "tx_hash": "327f3838531f211485ec59f9d0a119fea1595591e274d942b2c10b9b8262eb1d",
1228
- // "confirmations": "4"
1229
- // }
1230
- // }]
1231
- // }
1232
- //
1233
- const transactions = this.safeValue(response, 'payload', []);
1234
- const first = this.safeValue(transactions, 0, {});
1235
- return this.parseTransaction(first);
1236
- }
1237
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1238
- /**
1239
- * @method
1240
- * @name bitso#fetchDeposits
1241
- * @description fetch all deposits made to an account
1242
- * @param {string} code unified currency code
1243
- * @param {int} [since] the earliest time in ms to fetch deposits for
1244
- * @param {int} [limit] the maximum number of deposits structures to retrieve
1245
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1246
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1247
- */
1248
- await this.loadMarkets();
1249
- let currency = undefined;
1250
- if (code !== undefined) {
1251
- currency = this.currency(code);
1252
- }
1253
- const response = await this.privateGetFundings(params);
1254
- //
1255
- // {
1256
- // "success": true,
1257
- // "payload": [{
1258
- // "fid": "6112c6369100d6ecceb7f54f17cf0511",
1259
- // "status": "complete",
1260
- // "created_at": "2022-06-08T12:02:49+0000",
1261
- // "currency": "btc",
1262
- // "method": "btc",
1263
- // "method_name": "Bitcoin",
1264
- // "amount": "0.00080000",
1265
- // "asset": "btc",
1266
- // "network": "btc",
1267
- // "protocol": "btc",
1268
- // "integration": "bitgo-v2",
1269
- // "details": {
1270
- // "receiving_address": "3N2vbcYKhogs6RoTb4eYCUJ3beRSqLgSif",
1271
- // "tx_hash": "327f3838531f211485ec59f9d0a119fea1595591e274d942b2c10b9b8262eb1d",
1272
- // "confirmations": "4"
1273
- // }
1274
- // }]
1275
- // }
1276
- //
1277
- const transactions = this.safeValue(response, 'payload', []);
1278
- return this.parseTransactions(transactions, currency, since, limit, params);
1279
- }
1280
- async fetchDepositAddress(code, params = {}) {
1281
- /**
1282
- * @method
1283
- * @name bitso#fetchDepositAddress
1284
- * @description fetch the deposit address for a currency associated with this account
1285
- * @param {string} code unified currency code
1286
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1287
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1288
- */
1289
- await this.loadMarkets();
1290
- const currency = this.currency(code);
1291
- const request = {
1292
- 'fund_currency': currency['id'],
1293
- };
1294
- const response = await this.privateGetFundingDestination(this.extend(request, params));
1295
- let address = this.safeString(response['payload'], 'account_identifier');
1296
- let tag = undefined;
1297
- if (address.indexOf('?dt=') >= 0) {
1298
- const parts = address.split('?dt=');
1299
- address = this.safeString(parts, 0);
1300
- tag = this.safeString(parts, 1);
1301
- }
1302
- this.checkAddress(address);
1303
- return {
1304
- 'currency': code,
1305
- 'address': address,
1306
- 'tag': tag,
1307
- 'network': undefined,
1308
- 'info': response,
1309
- };
1310
- }
1311
- async fetchTransactionFees(codes = undefined, params = {}) {
1312
- /**
1313
- * @method
1314
- * @name bitso#fetchTransactionFees
1315
- * @deprecated
1316
- * @description please use fetchDepositWithdrawFees instead
1317
- * @see https://bitso.com/api_info#fees
1318
- * @param {string[]|undefined} codes list of unified currency codes
1319
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1320
- * @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
1321
- */
1322
- await this.loadMarkets();
1323
- const response = await this.privateGetFees(params);
1324
- //
1325
- // {
1326
- // "success": true,
1327
- // "payload": {
1328
- // "fees": [
1329
- // {
1330
- // "book": "btc_mxn",
1331
- // "fee_percent": "0.6500",
1332
- // "fee_decimal": "0.00650000",
1333
- // "taker_fee_percent": "0.6500",
1334
- // "taker_fee_decimal": "0.00650000",
1335
- // "maker_fee_percent": "0.5000",
1336
- // "maker_fee_decimal": "0.00500000",
1337
- // "volume_currency": "mxn",
1338
- // "current_volume": "0.00",
1339
- // "next_volume": "1500000.00",
1340
- // "next_maker_fee_percent": "0.490",
1341
- // "next_taker_fee_percent": "0.637",
1342
- // "nextVolume": "1500000.00",
1343
- // "nextFee": "0.490",
1344
- // "nextTakerFee": "0.637"
1345
- // },
1346
- // ...
1347
- // ],
1348
- // "deposit_fees": [
1349
- // {
1350
- // "currency": "btc",
1351
- // "method": "rewards",
1352
- // "fee": "0.00",
1353
- // "is_fixed": false
1354
- // },
1355
- // ...
1356
- // ],
1357
- // "withdrawal_fees": {
1358
- // "ada": "0.20958100",
1359
- // "bch": "0.00009437",
1360
- // "ars": "0",
1361
- // "btc": "0.00001209",
1362
- // ...
1363
- // }
1364
- // }
1365
- // }
1366
- //
1367
- const result = {};
1368
- const payload = this.safeValue(response, 'payload', {});
1369
- const depositFees = this.safeValue(payload, 'deposit_fees', []);
1370
- for (let i = 0; i < depositFees.length; i++) {
1371
- const depositFee = depositFees[i];
1372
- const currencyId = this.safeString(depositFee, 'currency');
1373
- const code = this.safeCurrencyCode(currencyId);
1374
- if ((codes !== undefined) && !this.inArray(code, codes)) {
1375
- continue;
1376
- }
1377
- result[code] = {
1378
- 'deposit': this.safeNumber(depositFee, 'fee'),
1379
- 'withdraw': undefined,
1380
- 'info': {
1381
- 'deposit': depositFee,
1382
- 'withdraw': undefined,
1383
- },
1384
- };
1385
- }
1386
- const withdrawalFees = this.safeValue(payload, 'withdrawal_fees', []);
1387
- const currencyIds = Object.keys(withdrawalFees);
1388
- for (let i = 0; i < currencyIds.length; i++) {
1389
- const currencyId = currencyIds[i];
1390
- const code = this.safeCurrencyCode(currencyId);
1391
- if ((codes !== undefined) && !this.inArray(code, codes)) {
1392
- continue;
1393
- }
1394
- result[code] = {
1395
- 'deposit': this.safeValue(result[code], 'deposit'),
1396
- 'withdraw': this.safeNumber(withdrawalFees, currencyId),
1397
- 'info': {
1398
- 'deposit': this.safeValue(result[code]['info'], 'deposit'),
1399
- 'withdraw': this.safeNumber(withdrawalFees, currencyId),
1400
- },
1401
- };
1402
- }
1403
- return result;
1404
- }
1405
- async fetchDepositWithdrawFees(codes = undefined, params = {}) {
1406
- /**
1407
- * @method
1408
- * @name bitso#fetchDepositWithdrawFees
1409
- * @description fetch deposit and withdraw fees
1410
- * @see https://bitso.com/api_info#fees
1411
- * @param {string[]|undefined} codes list of unified currency codes
1412
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1413
- * @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
1414
- */
1415
- await this.loadMarkets();
1416
- const response = await this.privateGetFees(params);
1417
- //
1418
- // {
1419
- // "success": true,
1420
- // "payload": {
1421
- // "fees": [
1422
- // {
1423
- // "book": "btc_mxn",
1424
- // "fee_percent": "0.6500",
1425
- // "fee_decimal": "0.00650000",
1426
- // "taker_fee_percent": "0.6500",
1427
- // "taker_fee_decimal": "0.00650000",
1428
- // "maker_fee_percent": "0.5000",
1429
- // "maker_fee_decimal": "0.00500000",
1430
- // "volume_currency": "mxn",
1431
- // "current_volume": "0.00",
1432
- // "next_volume": "1500000.00",
1433
- // "next_maker_fee_percent": "0.490",
1434
- // "next_taker_fee_percent": "0.637",
1435
- // "nextVolume": "1500000.00",
1436
- // "nextFee": "0.490",
1437
- // "nextTakerFee": "0.637"
1438
- // },
1439
- // ...
1440
- // ],
1441
- // "deposit_fees": [
1442
- // {
1443
- // "currency": "btc",
1444
- // "method": "rewards",
1445
- // "fee": "0.00",
1446
- // "is_fixed": false
1447
- // },
1448
- // ...
1449
- // ],
1450
- // "withdrawal_fees": {
1451
- // "ada": "0.20958100",
1452
- // "bch": "0.00009437",
1453
- // "ars": "0",
1454
- // "btc": "0.00001209",
1455
- // ...
1456
- // }
1457
- // }
1458
- // }
1459
- //
1460
- const payload = this.safeValue(response, 'payload', {});
1461
- return this.parseDepositWithdrawFees(payload, codes);
1462
- }
1463
- parseDepositWithdrawFees(response, codes = undefined, currencyIdKey = undefined) {
1464
- //
1465
- // {
1466
- // "fees": [
1467
- // {
1468
- // "book": "btc_mxn",
1469
- // "fee_percent": "0.6500",
1470
- // "fee_decimal": "0.00650000",
1471
- // "taker_fee_percent": "0.6500",
1472
- // "taker_fee_decimal": "0.00650000",
1473
- // "maker_fee_percent": "0.5000",
1474
- // "maker_fee_decimal": "0.00500000",
1475
- // "volume_currency": "mxn",
1476
- // "current_volume": "0.00",
1477
- // "next_volume": "1500000.00",
1478
- // "next_maker_fee_percent": "0.490",
1479
- // "next_taker_fee_percent": "0.637",
1480
- // "nextVolume": "1500000.00",
1481
- // "nextFee": "0.490",
1482
- // "nextTakerFee": "0.637"
1483
- // },
1484
- // ...
1485
- // ],
1486
- // "deposit_fees": [
1487
- // {
1488
- // "currency": "btc",
1489
- // "method": "rewards",
1490
- // "fee": "0.00",
1491
- // "is_fixed": false
1492
- // },
1493
- // ...
1494
- // ],
1495
- // "withdrawal_fees": {
1496
- // "ada": "0.20958100",
1497
- // "bch": "0.00009437",
1498
- // "ars": "0",
1499
- // "btc": "0.00001209",
1500
- // ...
1501
- // }
1502
- // }
1503
- //
1504
- const result = {};
1505
- const depositResponse = this.safeValue(response, 'deposit_fees', []);
1506
- const withdrawalResponse = this.safeValue(response, 'withdrawal_fees', []);
1507
- for (let i = 0; i < depositResponse.length; i++) {
1508
- const entry = depositResponse[i];
1509
- const currencyId = this.safeString(entry, 'currency');
1510
- const code = this.safeCurrencyCode(currencyId);
1511
- if ((codes === undefined) || (code in codes)) {
1512
- result[code] = {
1513
- 'deposit': {
1514
- 'fee': this.safeNumber(entry, 'fee'),
1515
- 'percentage': !this.safeValue(entry, 'is_fixed'),
1516
- },
1517
- 'withdraw': {
1518
- 'fee': undefined,
1519
- 'percentage': undefined,
1520
- },
1521
- 'networks': {},
1522
- 'info': entry,
1523
- };
1524
- }
1525
- }
1526
- const withdrawalKeys = Object.keys(withdrawalResponse);
1527
- for (let i = 0; i < withdrawalKeys.length; i++) {
1528
- const currencyId = withdrawalKeys[i];
1529
- const code = this.safeCurrencyCode(currencyId);
1530
- if ((codes === undefined) || (code in codes)) {
1531
- const withdrawFee = this.parseNumber(withdrawalResponse[currencyId]);
1532
- const resultValue = this.safeValue(result, code);
1533
- if (resultValue === undefined) {
1534
- result[code] = this.depositWithdrawFee({});
1535
- }
1536
- result[code]['withdraw']['fee'] = withdrawFee;
1537
- result[code]['info'][code] = withdrawFee;
1538
- }
1539
- }
1540
- return result;
1541
- }
1542
- async withdraw(code, amount, address, tag = undefined, params = {}) {
1543
- /**
1544
- * @method
1545
- * @name bitso#withdraw
1546
- * @description make a withdrawal
1547
- * @param {string} code unified currency code
1548
- * @param {float} amount the amount to withdraw
1549
- * @param {string} address the address to withdraw to
1550
- * @param {string} tag
1551
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1552
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1553
- */
1554
- [tag, params] = this.handleWithdrawTagAndParams(tag, params);
1555
- this.checkAddress(address);
1556
- await this.loadMarkets();
1557
- const methods = {
1558
- 'BTC': 'Bitcoin',
1559
- 'ETH': 'Ether',
1560
- 'XRP': 'Ripple',
1561
- 'BCH': 'Bcash',
1562
- 'LTC': 'Litecoin',
1563
- };
1564
- const currency = this.currency(code);
1565
- const method = (code in methods) ? methods[code] : undefined;
1566
- if (method === undefined) {
1567
- throw new errors.ExchangeError(this.id + ' not valid withdraw coin: ' + code);
1568
- }
1569
- const request = {
1570
- 'amount': amount,
1571
- 'address': address,
1572
- 'destination_tag': tag,
1573
- };
1574
- const classMethod = 'privatePost' + method + 'Withdrawal';
1575
- const response = await this[classMethod](this.extend(request, params));
1576
- //
1577
- // {
1578
- // "success": true,
1579
- // "payload": [
1580
- // {
1581
- // "wid": "c5b8d7f0768ee91d3b33bee648318688",
1582
- // "status": "pending",
1583
- // "created_at": "2016-04-08T17:52:31.000+00:00",
1584
- // "currency": "btc",
1585
- // "method": "Bitcoin",
1586
- // "amount": "0.48650929",
1587
- // "details": {
1588
- // "withdrawal_address": "18MsnATiNiKLqUHDTRKjurwMg7inCrdNEp",
1589
- // "tx_hash": "d4f28394693e9fb5fffcaf730c11f32d1922e5837f76ca82189d3bfe30ded433"
1590
- // }
1591
- // },
1592
- // ]
1593
- // }
1594
- //
1595
- const payload = this.safeValue(response, 'payload', []);
1596
- const first = this.safeValue(payload, 0);
1597
- return this.parseTransaction(first, currency);
1598
- }
1599
- safeNetwork(networkId) {
1600
- if (networkId === undefined) {
1601
- return undefined;
1602
- }
1603
- networkId = networkId.toUpperCase();
1604
- const networksById = {
1605
- 'trx': 'TRC20',
1606
- 'erc20': 'ERC20',
1607
- 'bsc': 'BEP20',
1608
- 'bep2': 'BEP2',
1609
- };
1610
- return this.safeString(networksById, networkId, networkId);
1611
- }
1612
- parseTransaction(transaction, currency = undefined) {
1613
- //
1614
- // deposit
1615
- // {
1616
- // "fid": "6112c6369100d6ecceb7f54f17cf0511",
1617
- // "status": "complete",
1618
- // "created_at": "2022-06-08T12:02:49+0000",
1619
- // "currency": "btc",
1620
- // "method": "btc",
1621
- // "method_name": "Bitcoin",
1622
- // "amount": "0.00080000",
1623
- // "asset": "btc",
1624
- // "network": "btc",
1625
- // "protocol": "btc",
1626
- // "integration": "bitgo-v2",
1627
- // "details": {
1628
- // "receiving_address": "3NmvbcYKhogs6RoTb4eYCUJ3beRSqLgSif",
1629
- // "tx_hash": "327f3838531f611485ec59f9d0a119fea1595591e274d942b2c10b9b8262eb1d",
1630
- // "confirmations": "4"
1631
- // }
1632
- // }
1633
- //
1634
- // withdraw
1635
- //
1636
- // {
1637
- // "wid": "c5b8d7f0768ee91d3b33bee648318688",
1638
- // "status": "pending",
1639
- // "created_at": "2016-04-08T17:52:31.000+00:00",
1640
- // "currency": "btc",
1641
- // "method": "Bitcoin",
1642
- // "amount": "0.48650929",
1643
- // "details": {
1644
- // "withdrawal_address": "18MsnATiNiKLqUHDTRKjurwMg7inCrdNEp",
1645
- // "tx_hash": "d4f28394693e9fb5fffcaf730c11f32d1922e5837f76ca82189d3bfe30ded433"
1646
- // }
1647
- // }
1648
- //
1649
- const currencyId = this.safeString2(transaction, 'currency', 'asset');
1650
- currency = this.safeCurrency(currencyId, currency);
1651
- const details = this.safeValue(transaction, 'details', {});
1652
- const datetime = this.safeString(transaction, 'created_at');
1653
- const withdrawalAddress = this.safeString(details, 'withdrawal_address');
1654
- const receivingAddress = this.safeString(details, 'receiving_address');
1655
- const networkId = this.safeString2(transaction, 'network', 'method');
1656
- const status = this.safeString(transaction, 'status');
1657
- const withdrawId = this.safeString(transaction, 'wid');
1658
- return {
1659
- 'id': this.safeString2(transaction, 'wid', 'fid'),
1660
- 'txid': this.safeString(details, 'tx_hash'),
1661
- 'timestamp': this.parse8601(datetime),
1662
- 'datetime': datetime,
1663
- 'network': this.safeNetwork(networkId),
1664
- 'addressFrom': receivingAddress,
1665
- 'address': (withdrawalAddress !== undefined) ? withdrawalAddress : receivingAddress,
1666
- 'addressTo': withdrawalAddress,
1667
- 'amount': this.safeNumber(transaction, 'amount'),
1668
- 'type': (withdrawId === undefined) ? 'deposit' : 'withdrawal',
1669
- 'currency': this.safeCurrencyCode(currencyId, currency),
1670
- 'status': this.parseTransactionStatus(status),
1671
- 'updated': undefined,
1672
- 'tagFrom': undefined,
1673
- 'tag': undefined,
1674
- 'tagTo': undefined,
1675
- 'comment': undefined,
1676
- 'internal': undefined,
1677
- 'fee': undefined,
1678
- 'info': transaction,
1679
- };
1680
- }
1681
- parseTransactionStatus(status) {
1682
- const statuses = {
1683
- 'pending': 'pending',
1684
- 'in_progress': 'pending',
1685
- 'complete': 'ok',
1686
- 'failed': 'failed',
1687
- };
1688
- return this.safeString(statuses, status, status);
1689
- }
1690
- nonce() {
1691
- return this.milliseconds();
1692
- }
1693
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1694
- let endpoint = '/' + this.version + '/' + this.implodeParams(path, params);
1695
- const query = this.omit(params, this.extractParams(path));
1696
- if (method === 'GET' || method === 'DELETE') {
1697
- if (Object.keys(query).length) {
1698
- endpoint += '?' + this.urlencode(query);
1699
- }
1700
- }
1701
- const url = this.urls['api']['rest'] + endpoint;
1702
- if (api === 'private') {
1703
- this.checkRequiredCredentials();
1704
- const nonce = this.nonce().toString();
1705
- let request = [nonce, method, endpoint].join('');
1706
- if (method !== 'GET' && method !== 'DELETE') {
1707
- if (Object.keys(query).length) {
1708
- body = this.json(query);
1709
- request += body;
1710
- }
1711
- }
1712
- const signature = this.hmac(this.encode(request), this.encode(this.secret), sha256.sha256);
1713
- const auth = this.apiKey + ':' + nonce + ':' + signature;
1714
- headers = {
1715
- 'Authorization': 'Bitso ' + auth,
1716
- 'Content-Type': 'application/json',
1717
- };
1718
- }
1719
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1720
- }
1721
- handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1722
- if (response === undefined) {
1723
- return undefined; // fallback to default error handler
1724
- }
1725
- if ('success' in response) {
1726
- //
1727
- // {"success":false,"error":{"code":104,"message":"Cannot perform request - nonce must be higher than 1520307203724237"}}
1728
- //
1729
- let success = this.safeValue(response, 'success', false);
1730
- if (typeof success === 'string') {
1731
- if ((success === 'true') || (success === '1')) {
1732
- success = true;
1733
- }
1734
- else {
1735
- success = false;
1736
- }
1737
- }
1738
- if (!success) {
1739
- const feedback = this.id + ' ' + this.json(response);
1740
- const error = this.safeValue(response, 'error');
1741
- if (error === undefined) {
1742
- throw new errors.ExchangeError(feedback);
1743
- }
1744
- const code = this.safeString(error, 'code');
1745
- this.throwExactlyMatchedException(this.exceptions, code, feedback);
1746
- throw new errors.ExchangeError(feedback);
1747
- }
1748
- }
1749
- return undefined;
1750
- }
1751
- }
1752
-
1753
- module.exports = bitso;