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,1693 +0,0 @@
1
- 'use strict';
2
-
3
- var cex$1 = require('./abstract/cex.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 cex
13
- * @augments Exchange
14
- */
15
- class cex extends cex$1 {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'cex',
19
- 'name': 'CEX.IO',
20
- 'countries': ['GB', 'EU', 'CY', 'RU'],
21
- 'rateLimit': 1500,
22
- 'pro': true,
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': false,
34
- 'createDepositAddress': false,
35
- 'createMarketBuyOrderWithCost': true,
36
- 'createMarketOrderWithCost': false,
37
- 'createMarketSellOrderWithCost': false,
38
- 'createOrder': true,
39
- 'createStopLimitOrder': false,
40
- 'createStopMarketOrder': false,
41
- 'createStopOrder': false,
42
- 'editOrder': true,
43
- 'fetchBalance': true,
44
- 'fetchClosedOrders': true,
45
- 'fetchCurrencies': true,
46
- 'fetchDeposit': false,
47
- 'fetchDepositAddress': true,
48
- 'fetchDepositAddresses': false,
49
- 'fetchDeposits': false,
50
- 'fetchDepositsWithdrawals': false,
51
- 'fetchFundingHistory': false,
52
- 'fetchFundingRate': false,
53
- 'fetchFundingRateHistory': false,
54
- 'fetchFundingRates': false,
55
- 'fetchIndexOHLCV': false,
56
- 'fetchMarginMode': false,
57
- 'fetchMarkets': true,
58
- 'fetchMarkOHLCV': false,
59
- 'fetchOHLCV': true,
60
- 'fetchOpenInterestHistory': false,
61
- 'fetchOpenOrders': true,
62
- 'fetchOrder': true,
63
- 'fetchOrderBook': true,
64
- 'fetchOrders': true,
65
- 'fetchPositionMode': false,
66
- 'fetchPremiumIndexOHLCV': false,
67
- 'fetchTicker': true,
68
- 'fetchTickers': true,
69
- 'fetchTrades': true,
70
- 'fetchTradingFee': false,
71
- 'fetchTradingFees': true,
72
- 'fetchTransactions': false,
73
- 'fetchTransfer': false,
74
- 'fetchTransfers': false,
75
- 'fetchWithdrawal': false,
76
- 'fetchWithdrawals': false,
77
- 'fetchWithdrawalWhitelist': false,
78
- 'reduceMargin': false,
79
- 'setLeverage': false,
80
- 'setMargin': false,
81
- 'setMarginMode': false,
82
- 'transfer': false,
83
- 'withdraw': false,
84
- },
85
- 'timeframes': {
86
- '1m': '1m',
87
- '1h': '1h',
88
- '1d': '1d',
89
- },
90
- 'urls': {
91
- 'logo': 'https://user-images.githubusercontent.com/1294454/27766442-8ddc33b0-5ed8-11e7-8b98-f786aef0f3c9.jpg',
92
- 'api': {
93
- 'rest': 'https://cex.io/api',
94
- },
95
- 'www': 'https://cex.io',
96
- 'doc': 'https://cex.io/cex-api',
97
- 'fees': [
98
- 'https://cex.io/fee-schedule',
99
- 'https://cex.io/limits-commissions',
100
- ],
101
- 'referral': 'https://cex.io/r/0/up105393824/0/',
102
- },
103
- 'requiredCredentials': {
104
- 'apiKey': true,
105
- 'secret': true,
106
- 'uid': true,
107
- },
108
- 'api': {
109
- 'public': {
110
- 'get': [
111
- 'currency_profile',
112
- 'currency_limits/',
113
- 'last_price/{pair}/',
114
- 'last_prices/{currencies}/',
115
- 'ohlcv/hd/{yyyymmdd}/{pair}',
116
- 'order_book/{pair}/',
117
- 'ticker/{pair}/',
118
- 'tickers/{currencies}/',
119
- 'trade_history/{pair}/',
120
- ],
121
- 'post': [
122
- 'convert/{pair}',
123
- 'price_stats/{pair}',
124
- ],
125
- },
126
- 'private': {
127
- 'post': [
128
- 'active_orders_status/',
129
- 'archived_orders/{pair}/',
130
- 'balance/',
131
- 'cancel_order/',
132
- 'cancel_orders/{pair}/',
133
- 'cancel_replace_order/{pair}/',
134
- 'close_position/{pair}/',
135
- 'get_address/',
136
- 'get_crypto_address',
137
- 'get_myfee/',
138
- 'get_order/',
139
- 'get_order_tx/',
140
- 'open_orders/{pair}/',
141
- 'open_orders/',
142
- 'open_position/{pair}/',
143
- 'open_positions/{pair}/',
144
- 'place_order/{pair}/',
145
- 'raw_tx_history',
146
- ],
147
- },
148
- },
149
- 'fees': {
150
- 'trading': {
151
- 'maker': this.parseNumber('0.0016'),
152
- 'taker': this.parseNumber('0.0025'),
153
- },
154
- 'funding': {
155
- 'withdraw': {},
156
- 'deposit': {
157
- // 'USD': amount => amount * 0.035 + 0.25,
158
- // 'EUR': amount => amount * 0.035 + 0.24,
159
- // 'RUB': amount => amount * 0.05 + 15.57,
160
- // 'GBP': amount => amount * 0.035 + 0.2,
161
- 'BTC': 0.0,
162
- 'ETH': 0.0,
163
- 'BCH': 0.0,
164
- 'DASH': 0.0,
165
- 'BTG': 0.0,
166
- 'ZEC': 0.0,
167
- 'XRP': 0.0,
168
- 'XLM': 0.0,
169
- },
170
- },
171
- },
172
- 'precisionMode': number.TICK_SIZE,
173
- 'exceptions': {
174
- 'exact': {},
175
- 'broad': {
176
- 'Insufficient funds': errors.InsufficientFunds,
177
- 'Nonce must be incremented': errors.InvalidNonce,
178
- 'Invalid Order': errors.InvalidOrder,
179
- 'Order not found': errors.OrderNotFound,
180
- 'limit exceeded': errors.RateLimitExceeded,
181
- 'Invalid API key': errors.AuthenticationError,
182
- 'There was an error while placing your order': errors.InvalidOrder,
183
- 'Sorry, too many clients already': errors.DDoSProtection,
184
- 'Invalid Symbols Pair': errors.BadSymbol,
185
- 'Wrong currency pair': errors.BadSymbol, // {"error":"There was an error while placing your order: Wrong currency pair.","safe":true}
186
- },
187
- },
188
- 'options': {
189
- 'fetchOHLCVWarning': true,
190
- 'createMarketBuyOrderRequiresPrice': true,
191
- 'order': {
192
- 'status': {
193
- 'c': 'canceled',
194
- 'd': 'closed',
195
- 'cd': 'canceled',
196
- 'a': 'open',
197
- },
198
- },
199
- 'defaultNetwork': 'ERC20',
200
- 'defaultNetworks': {
201
- 'USDT': 'TRC20',
202
- },
203
- 'networks': {
204
- 'ERC20': 'Ethereum',
205
- 'BTC': 'BTC',
206
- 'BEP20': 'Binance Smart Chain',
207
- 'TRC20': 'Tron',
208
- },
209
- },
210
- });
211
- }
212
- async fetchCurrenciesFromCache(params = {}) {
213
- // this method is now redundant
214
- // currencies are now fetched before markets
215
- const options = this.safeValue(this.options, 'fetchCurrencies', {});
216
- const timestamp = this.safeInteger(options, 'timestamp');
217
- const expires = this.safeInteger(options, 'expires', 1000);
218
- const now = this.milliseconds();
219
- if ((timestamp === undefined) || ((now - timestamp) > expires)) {
220
- const response = await this.publicGetCurrencyProfile(params);
221
- this.options['fetchCurrencies'] = this.extend(options, {
222
- 'response': response,
223
- 'timestamp': now,
224
- });
225
- }
226
- return this.safeValue(this.options['fetchCurrencies'], 'response');
227
- }
228
- async fetchCurrencies(params = {}) {
229
- /**
230
- * @method
231
- * @name cex#fetchCurrencies
232
- * @description fetches all available currencies on an exchange
233
- * @param {object} [params] extra parameters specific to the exchange API endpoint
234
- * @returns {object} an associative dictionary of currencies
235
- */
236
- const response = await this.fetchCurrenciesFromCache(params);
237
- this.options['currencies'] = {
238
- 'timestamp': this.milliseconds(),
239
- 'response': response,
240
- };
241
- //
242
- // {
243
- // "e":"currency_profile",
244
- // "ok":"ok",
245
- // "data":{
246
- // "symbols":[
247
- // {
248
- // "code":"GHS",
249
- // "contract":true,
250
- // "commodity":true,
251
- // "fiat":false,
252
- // "description":"CEX.IO doesn't provide cloud mining services anymore.",
253
- // "precision":8,
254
- // "scale":0,
255
- // "minimumCurrencyAmount":"0.00000001",
256
- // "minimalWithdrawalAmount":-1
257
- // },
258
- // {
259
- // "code":"BTC",
260
- // "contract":false,
261
- // "commodity":false,
262
- // "fiat":false,
263
- // "description":"",
264
- // "precision":8,
265
- // "scale":0,
266
- // "minimumCurrencyAmount":"0.00000001",
267
- // "minimalWithdrawalAmount":0.002
268
- // },
269
- // {
270
- // "code":"ETH",
271
- // "contract":false,
272
- // "commodity":false,
273
- // "fiat":false,
274
- // "description":"",
275
- // "precision":8,
276
- // "scale":2,
277
- // "minimumCurrencyAmount":"0.00000100",
278
- // "minimalWithdrawalAmount":0.01
279
- // }
280
- // ],
281
- // "pairs":[
282
- // {
283
- // "symbol1":"BTC",
284
- // "symbol2":"USD",
285
- // "pricePrecision":1,
286
- // "priceScale":"/1000000",
287
- // "minLotSize":0.002,
288
- // "minLotSizeS2":20
289
- // },
290
- // {
291
- // "symbol1":"ETH",
292
- // "symbol2":"USD",
293
- // "pricePrecision":2,
294
- // "priceScale":"/10000",
295
- // "minLotSize":0.1,
296
- // "minLotSizeS2":20
297
- // }
298
- // ]
299
- // }
300
- // }
301
- //
302
- const data = this.safeValue(response, 'data', []);
303
- const currencies = this.safeValue(data, 'symbols', []);
304
- const result = {};
305
- for (let i = 0; i < currencies.length; i++) {
306
- const currency = currencies[i];
307
- const id = this.safeString(currency, 'code');
308
- const code = this.safeCurrencyCode(id);
309
- const active = true;
310
- result[code] = {
311
- 'id': id,
312
- 'code': code,
313
- 'name': id,
314
- 'active': active,
315
- 'deposit': undefined,
316
- 'withdraw': undefined,
317
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'precision'))),
318
- 'fee': undefined,
319
- 'limits': {
320
- 'amount': {
321
- 'min': this.safeNumber(currency, 'minimumCurrencyAmount'),
322
- 'max': undefined,
323
- },
324
- 'withdraw': {
325
- 'min': this.safeNumber(currency, 'minimalWithdrawalAmount'),
326
- 'max': undefined,
327
- },
328
- },
329
- 'info': currency,
330
- };
331
- }
332
- return result;
333
- }
334
- async fetchMarkets(params = {}) {
335
- /**
336
- * @method
337
- * @name cex#fetchMarkets
338
- * @description retrieves data on all markets for cex
339
- * @param {object} [params] extra parameters specific to the exchange API endpoint
340
- * @returns {object[]} an array of objects representing market data
341
- */
342
- const currenciesResponse = await this.fetchCurrenciesFromCache(params);
343
- const currenciesData = this.safeValue(currenciesResponse, 'data', {});
344
- const currencies = this.safeValue(currenciesData, 'symbols', []);
345
- const currenciesById = this.indexBy(currencies, 'code');
346
- const pairs = this.safeValue(currenciesData, 'pairs', []);
347
- const response = await this.publicGetCurrencyLimits(params);
348
- //
349
- // {
350
- // "e":"currency_limits",
351
- // "ok":"ok",
352
- // "data": {
353
- // "pairs":[
354
- // {
355
- // "symbol1":"BTC",
356
- // "symbol2":"USD",
357
- // "minLotSize":0.002,
358
- // "minLotSizeS2":20,
359
- // "maxLotSize":30,
360
- // "minPrice":"1500",
361
- // "maxPrice":"35000"
362
- // },
363
- // {
364
- // "symbol1":"BCH",
365
- // "symbol2":"EUR",
366
- // "minLotSize":0.1,
367
- // "minLotSizeS2":20,
368
- // "maxLotSize":null,
369
- // "minPrice":"25",
370
- // "maxPrice":"8192"
371
- // }
372
- // ]
373
- // }
374
- // }
375
- //
376
- const result = [];
377
- const markets = this.safeValue(response['data'], 'pairs');
378
- for (let i = 0; i < markets.length; i++) {
379
- const market = markets[i];
380
- const baseId = this.safeString(market, 'symbol1');
381
- const quoteId = this.safeString(market, 'symbol2');
382
- const base = this.safeCurrencyCode(baseId);
383
- const quote = this.safeCurrencyCode(quoteId);
384
- const baseCurrency = this.safeValue(currenciesById, baseId, {});
385
- const quoteCurrency = this.safeValue(currenciesById, quoteId, {});
386
- let pricePrecisionString = this.safeString(quoteCurrency, 'precision', '8');
387
- for (let j = 0; j < pairs.length; j++) {
388
- const pair = pairs[j];
389
- if ((pair['symbol1'] === baseId) && (pair['symbol2'] === quoteId)) {
390
- // we might need to account for `priceScale` here
391
- pricePrecisionString = this.safeString(pair, 'pricePrecision', pricePrecisionString);
392
- }
393
- }
394
- const baseCurrencyPrecision = this.safeString(baseCurrency, 'precision', '8');
395
- const baseCurrencyScale = this.safeString(baseCurrency, 'scale', '0');
396
- const amountPrecisionString = Precise["default"].stringSub(baseCurrencyPrecision, baseCurrencyScale);
397
- result.push({
398
- 'id': baseId + '/' + quoteId,
399
- 'symbol': base + '/' + quote,
400
- 'base': base,
401
- 'quote': quote,
402
- 'settle': undefined,
403
- 'baseId': baseId,
404
- 'quoteId': quoteId,
405
- 'settleId': undefined,
406
- 'type': 'spot',
407
- 'spot': true,
408
- 'margin': undefined,
409
- 'swap': false,
410
- 'future': false,
411
- 'option': false,
412
- 'active': undefined,
413
- 'contract': false,
414
- 'linear': undefined,
415
- 'inverse': undefined,
416
- 'contractSize': undefined,
417
- 'expiry': undefined,
418
- 'expiryDatetime': undefined,
419
- 'strike': undefined,
420
- 'optionType': undefined,
421
- 'precision': {
422
- 'amount': this.parseNumber(this.parsePrecision(amountPrecisionString)),
423
- 'price': this.parseNumber(this.parsePrecision(pricePrecisionString)),
424
- },
425
- 'limits': {
426
- 'leverage': {
427
- 'min': undefined,
428
- 'max': undefined,
429
- },
430
- 'amount': {
431
- 'min': this.safeNumber(market, 'minLotSize'),
432
- 'max': this.safeNumber(market, 'maxLotSize'),
433
- },
434
- 'price': {
435
- 'min': this.safeNumber(market, 'minPrice'),
436
- 'max': this.safeNumber(market, 'maxPrice'),
437
- },
438
- 'cost': {
439
- 'min': this.safeNumber(market, 'minLotSizeS2'),
440
- 'max': undefined,
441
- },
442
- },
443
- 'created': undefined,
444
- 'info': market,
445
- });
446
- }
447
- return result;
448
- }
449
- parseBalance(response) {
450
- const result = { 'info': response };
451
- const ommited = ['username', 'timestamp'];
452
- const balances = this.omit(response, ommited);
453
- const currencyIds = Object.keys(balances);
454
- for (let i = 0; i < currencyIds.length; i++) {
455
- const currencyId = currencyIds[i];
456
- const balance = this.safeValue(balances, currencyId, {});
457
- const account = this.account();
458
- account['free'] = this.safeString(balance, 'available');
459
- // https://github.com/ccxt/ccxt/issues/5484
460
- account['used'] = this.safeString(balance, 'orders', '0');
461
- const code = this.safeCurrencyCode(currencyId);
462
- result[code] = account;
463
- }
464
- return this.safeBalance(result);
465
- }
466
- async fetchBalance(params = {}) {
467
- /**
468
- * @method
469
- * @name cex#fetchBalance
470
- * @see https://docs.cex.io/#account-balance
471
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
472
- * @param {object} [params] extra parameters specific to the exchange API endpoint
473
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
474
- */
475
- await this.loadMarkets();
476
- const response = await this.privatePostBalance(params);
477
- return this.parseBalance(response);
478
- }
479
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
480
- /**
481
- * @method
482
- * @name cex#fetchOrderBook
483
- * @see https://docs.cex.io/#orderbook
484
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
485
- * @param {string} symbol unified symbol of the market to fetch the order book for
486
- * @param {int} [limit] the maximum amount of order book entries to return
487
- * @param {object} [params] extra parameters specific to the exchange API endpoint
488
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
489
- */
490
- await this.loadMarkets();
491
- const market = this.market(symbol);
492
- const request = {
493
- 'pair': market['id'],
494
- };
495
- if (limit !== undefined) {
496
- request['depth'] = limit;
497
- }
498
- const response = await this.publicGetOrderBookPair(this.extend(request, params));
499
- const timestamp = this.safeTimestamp(response, 'timestamp');
500
- return this.parseOrderBook(response, market['symbol'], timestamp);
501
- }
502
- parseOHLCV(ohlcv, market = undefined) {
503
- //
504
- // [
505
- // 1591403940,
506
- // 0.024972,
507
- // 0.024972,
508
- // 0.024969,
509
- // 0.024969,
510
- // 0.49999900
511
- // ]
512
- //
513
- return [
514
- this.safeTimestamp(ohlcv, 0),
515
- this.safeNumber(ohlcv, 1),
516
- this.safeNumber(ohlcv, 2),
517
- this.safeNumber(ohlcv, 3),
518
- this.safeNumber(ohlcv, 4),
519
- this.safeNumber(ohlcv, 5),
520
- ];
521
- }
522
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
523
- /**
524
- * @method
525
- * @name cex#fetchOHLCV
526
- * @see https://docs.cex.io/#historical-ohlcv-chart
527
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
528
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
529
- * @param {string} timeframe the length of time each candle represents
530
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
531
- * @param {int} [limit] the maximum amount of candles to fetch
532
- * @param {object} [params] extra parameters specific to the exchange API endpoint
533
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
534
- */
535
- await this.loadMarkets();
536
- const market = this.market(symbol);
537
- if (since === undefined) {
538
- since = this.milliseconds() - 86400000; // yesterday
539
- }
540
- else {
541
- if (this.options['fetchOHLCVWarning']) {
542
- throw new errors.ExchangeError(this.id + " fetchOHLCV warning: CEX can return historical candles for a certain date only, this might produce an empty or null reply. Set exchange.options['fetchOHLCVWarning'] = false or add ({ 'options': { 'fetchOHLCVWarning': false }}) to constructor params to suppress this warning message.");
543
- }
544
- }
545
- const request = {
546
- 'pair': market['id'],
547
- 'yyyymmdd': this.yyyymmdd(since, ''),
548
- };
549
- try {
550
- const response = await this.publicGetOhlcvHdYyyymmddPair(this.extend(request, params));
551
- //
552
- // {
553
- // "time":20200606,
554
- // "data1m":"[[1591403940,0.024972,0.024972,0.024969,0.024969,0.49999900]]",
555
- // }
556
- //
557
- const key = 'data' + this.safeString(this.timeframes, timeframe, timeframe);
558
- const data = this.safeString(response, key);
559
- const ohlcvs = JSON.parse(data);
560
- return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
561
- }
562
- catch (e) {
563
- if (e instanceof errors.NullResponse) {
564
- return [];
565
- }
566
- }
567
- return undefined;
568
- }
569
- parseTicker(ticker, market = undefined) {
570
- const timestamp = this.safeTimestamp(ticker, 'timestamp');
571
- const volume = this.safeString(ticker, 'volume');
572
- const high = this.safeString(ticker, 'high');
573
- const low = this.safeString(ticker, 'low');
574
- const bid = this.safeString(ticker, 'bid');
575
- const ask = this.safeString(ticker, 'ask');
576
- const last = this.safeString(ticker, 'last');
577
- const symbol = this.safeSymbol(undefined, market);
578
- return this.safeTicker({
579
- 'symbol': symbol,
580
- 'timestamp': timestamp,
581
- 'datetime': this.iso8601(timestamp),
582
- 'high': high,
583
- 'low': low,
584
- 'bid': bid,
585
- 'bidVolume': undefined,
586
- 'ask': ask,
587
- 'askVolume': undefined,
588
- 'vwap': undefined,
589
- 'open': undefined,
590
- 'close': last,
591
- 'last': last,
592
- 'previousClose': undefined,
593
- 'change': undefined,
594
- 'percentage': undefined,
595
- 'average': undefined,
596
- 'baseVolume': volume,
597
- 'quoteVolume': undefined,
598
- 'info': ticker,
599
- }, market);
600
- }
601
- async fetchTickers(symbols = undefined, params = {}) {
602
- /**
603
- * @method
604
- * @name cex#fetchTickers
605
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
606
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
607
- * @param {object} [params] extra parameters specific to the exchange API endpoint
608
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
609
- */
610
- await this.loadMarkets();
611
- symbols = this.marketSymbols(symbols);
612
- const currencies = Object.keys(this.currencies);
613
- const request = {
614
- 'currencies': currencies.join('/'),
615
- };
616
- const response = await this.publicGetTickersCurrencies(this.extend(request, params));
617
- const tickers = this.safeValue(response, 'data', []);
618
- const result = {};
619
- for (let t = 0; t < tickers.length; t++) {
620
- const ticker = tickers[t];
621
- const marketId = this.safeString(ticker, 'pair');
622
- const market = this.safeMarket(marketId, undefined, ':');
623
- const symbol = market['symbol'];
624
- result[symbol] = this.parseTicker(ticker, market);
625
- }
626
- return this.filterByArrayTickers(result, 'symbol', symbols);
627
- }
628
- async fetchTicker(symbol, params = {}) {
629
- /**
630
- * @method
631
- * @name cex#fetchTicker
632
- * @see https://docs.cex.io/#ticker
633
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
634
- * @param {string} symbol unified symbol of the market to fetch the ticker for
635
- * @param {object} [params] extra parameters specific to the exchange API endpoint
636
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
637
- */
638
- await this.loadMarkets();
639
- const market = this.market(symbol);
640
- const request = {
641
- 'pair': market['id'],
642
- };
643
- const ticker = await this.publicGetTickerPair(this.extend(request, params));
644
- return this.parseTicker(ticker, market);
645
- }
646
- parseTrade(trade, market = undefined) {
647
- //
648
- // fetchTrades (public)
649
- //
650
- // {
651
- // "type": "sell",
652
- // "date": "1638401878",
653
- // "amount": "0.401000",
654
- // "price": "249",
655
- // "tid": "11922"
656
- // }
657
- //
658
- const timestamp = this.safeTimestamp(trade, 'date');
659
- const id = this.safeString(trade, 'tid');
660
- const type = undefined;
661
- const side = this.safeString(trade, 'type');
662
- const priceString = this.safeString(trade, 'price');
663
- const amountString = this.safeString(trade, 'amount');
664
- market = this.safeMarket(undefined, market);
665
- return this.safeTrade({
666
- 'info': trade,
667
- 'id': id,
668
- 'timestamp': timestamp,
669
- 'datetime': this.iso8601(timestamp),
670
- 'symbol': market['symbol'],
671
- 'type': type,
672
- 'side': side,
673
- 'order': undefined,
674
- 'takerOrMaker': undefined,
675
- 'price': priceString,
676
- 'amount': amountString,
677
- 'cost': undefined,
678
- 'fee': undefined,
679
- }, market);
680
- }
681
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
682
- /**
683
- * @method
684
- * @name cex#fetchTrades
685
- * @see https://docs.cex.io/#trade-history
686
- * @description get the list of most recent trades for a particular symbol
687
- * @param {string} symbol unified symbol of the market to fetch trades for
688
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
689
- * @param {int} [limit] the maximum amount of trades to fetch
690
- * @param {object} [params] extra parameters specific to the exchange API endpoint
691
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
692
- */
693
- await this.loadMarkets();
694
- const market = this.market(symbol);
695
- const request = {
696
- 'pair': market['id'],
697
- };
698
- const response = await this.publicGetTradeHistoryPair(this.extend(request, params));
699
- return this.parseTrades(response, market, since, limit);
700
- }
701
- async fetchTradingFees(params = {}) {
702
- /**
703
- * @method
704
- * @name cex#fetchTradingFees
705
- * @see https://docs.cex.io/#get-my-fee
706
- * @description fetch the trading fees for multiple markets
707
- * @param {object} [params] extra parameters specific to the exchange API endpoint
708
- * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
709
- */
710
- await this.loadMarkets();
711
- const response = await this.privatePostGetMyfee(params);
712
- //
713
- // {
714
- // "e": "get_myfee",
715
- // "ok": "ok",
716
- // "data": {
717
- // 'BTC:USD': { buy: '0.25', sell: '0.25', buyMaker: '0.15', sellMaker: "0.15" },
718
- // 'ETH:USD': { buy: '0.25', sell: '0.25', buyMaker: '0.15', sellMaker: "0.15" },
719
- // ..
720
- // }
721
- // }
722
- //
723
- const data = this.safeValue(response, 'data', {});
724
- const result = {};
725
- for (let i = 0; i < this.symbols.length; i++) {
726
- const symbol = this.symbols[i];
727
- const market = this.market(symbol);
728
- const fee = this.safeValue(data, market['id'], {});
729
- const makerString = this.safeString(fee, 'buyMaker');
730
- const takerString = this.safeString(fee, 'buy');
731
- const maker = this.parseNumber(Precise["default"].stringDiv(makerString, '100'));
732
- const taker = this.parseNumber(Precise["default"].stringDiv(takerString, '100'));
733
- result[symbol] = {
734
- 'info': fee,
735
- 'symbol': symbol,
736
- 'maker': maker,
737
- 'taker': taker,
738
- 'percentage': true,
739
- };
740
- }
741
- return result;
742
- }
743
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
744
- /**
745
- * @method
746
- * @name cex#createOrder
747
- * @see https://docs.cex.io/#place-order
748
- * @description create a trade order
749
- * @see https://cex.io/rest-api#place-order
750
- * @param {string} symbol unified symbol of the market to create an order in
751
- * @param {string} type 'market' or 'limit'
752
- * @param {string} side 'buy' or 'sell'
753
- * @param {float} amount how much of currency you want to trade in units of base currency
754
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
755
- * @param {object} [params] extra parameters specific to the exchange API endpoint
756
- * @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount for market buy orders
757
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
758
- */
759
- await this.loadMarkets();
760
- const market = this.market(symbol);
761
- const request = {
762
- 'pair': market['id'],
763
- 'type': side,
764
- };
765
- // for market buy it requires the amount of quote currency to spend
766
- if ((type === 'market') && (side === 'buy')) {
767
- let quoteAmount = undefined;
768
- let createMarketBuyOrderRequiresPrice = true;
769
- [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
770
- const cost = this.safeString(params, 'cost');
771
- params = this.omit(params, 'cost');
772
- if (cost !== undefined) {
773
- quoteAmount = this.costToPrecision(symbol, cost);
774
- }
775
- else if (createMarketBuyOrderRequiresPrice) {
776
- if (price === undefined) {
777
- throw new errors.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
778
- }
779
- else {
780
- const amountString = this.numberToString(amount);
781
- const priceString = this.numberToString(price);
782
- const costRequest = Precise["default"].stringMul(amountString, priceString);
783
- quoteAmount = this.costToPrecision(symbol, costRequest);
784
- }
785
- }
786
- else {
787
- quoteAmount = this.costToPrecision(symbol, amount);
788
- }
789
- request['amount'] = quoteAmount;
790
- }
791
- else {
792
- request['amount'] = this.amountToPrecision(symbol, amount);
793
- }
794
- if (type === 'limit') {
795
- request['price'] = this.numberToString(price);
796
- }
797
- else {
798
- request['order_type'] = type;
799
- }
800
- const response = await this.privatePostPlaceOrderPair(this.extend(request, params));
801
- //
802
- // {
803
- // "id": "12978363524",
804
- // "time": 1586610022259,
805
- // "type": "buy",
806
- // "price": "0.033934",
807
- // "amount": "0.10722802",
808
- // "pending": "0.10722802",
809
- // "complete": false
810
- // }
811
- //
812
- const placedAmount = this.safeString(response, 'amount');
813
- const remaining = this.safeString(response, 'pending');
814
- const timestamp = this.safeValue(response, 'time');
815
- const complete = this.safeValue(response, 'complete');
816
- const status = complete ? 'closed' : 'open';
817
- let filled = undefined;
818
- if ((placedAmount !== undefined) && (remaining !== undefined)) {
819
- filled = Precise["default"].stringMax(Precise["default"].stringSub(placedAmount, remaining), '0');
820
- }
821
- return this.safeOrder({
822
- 'id': this.safeString(response, 'id'),
823
- 'info': response,
824
- 'clientOrderId': undefined,
825
- 'timestamp': timestamp,
826
- 'datetime': this.iso8601(timestamp),
827
- 'lastTradeTimestamp': undefined,
828
- 'type': type,
829
- 'side': this.safeString(response, 'type'),
830
- 'symbol': market['symbol'],
831
- 'status': status,
832
- 'price': this.safeString(response, 'price'),
833
- 'amount': placedAmount,
834
- 'cost': undefined,
835
- 'average': undefined,
836
- 'remaining': remaining,
837
- 'filled': filled,
838
- 'fee': undefined,
839
- 'trades': undefined,
840
- });
841
- }
842
- async cancelOrder(id, symbol = undefined, params = {}) {
843
- /**
844
- * @method
845
- * @name cex#cancelOrder
846
- * @see https://docs.cex.io/#cancel-order
847
- * @description cancels an open order
848
- * @param {string} id order id
849
- * @param {string} symbol not used by cex cancelOrder ()
850
- * @param {object} [params] extra parameters specific to the exchange API endpoint
851
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
852
- */
853
- await this.loadMarkets();
854
- const request = {
855
- 'id': id,
856
- };
857
- const response = await this.privatePostCancelOrder(this.extend(request, params));
858
- // 'true'
859
- return this.extend(this.parseOrder({}), { 'info': response, 'type': undefined, 'id': id, 'status': 'canceled' });
860
- }
861
- async cancelAllOrders(symbol = undefined, params = {}) {
862
- /**
863
- * @method
864
- * @name cex#cancelAllOrders
865
- * @see https://docs.cex.io/#cancel-all-orders-for-given-pair
866
- * @description cancel all open orders in a market
867
- * @param {string} symbol unified market symbol of the market to cancel orders in
868
- * @param {object} [params] extra parameters specific to the cex api endpoint
869
- * @param {string} [params.marginMode] 'cross' or 'isolated', for spot margin trading
870
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
871
- */
872
- if (symbol === undefined) {
873
- throw new errors.ArgumentsRequired(this.id + ' cancelAllOrders requires a symbol.');
874
- }
875
- await this.loadMarkets();
876
- const market = this.market(symbol);
877
- const request = {
878
- 'pair': market['id'],
879
- };
880
- const orders = await this.privatePostCancelOrdersPair(this.extend(request, params));
881
- //
882
- // {
883
- // "e":"cancel_orders",
884
- // "ok":"ok",
885
- // "data":[
886
- // ]
887
- // }
888
- //
889
- return orders;
890
- }
891
- parseOrder(order, market = undefined) {
892
- // Depending on the call, 'time' can be a unix int, unix string or ISO string
893
- // Yes, really
894
- let timestamp = this.safeValue(order, 'time');
895
- if (typeof timestamp === 'string' && timestamp.indexOf('T') >= 0) {
896
- // ISO8601 string
897
- timestamp = this.parse8601(timestamp);
898
- }
899
- else if (timestamp !== undefined) {
900
- // either integer or string integer
901
- timestamp = parseInt(timestamp);
902
- }
903
- let symbol = undefined;
904
- const baseId = this.safeString(order, 'symbol1');
905
- const quoteId = this.safeString(order, 'symbol2');
906
- if (market === undefined && baseId !== undefined && quoteId !== undefined) {
907
- const base = this.safeCurrencyCode(baseId);
908
- const quote = this.safeCurrencyCode(quoteId);
909
- if ((base !== undefined) && (quote !== undefined)) {
910
- symbol = base + '/' + quote;
911
- }
912
- if (symbol in this.markets) {
913
- market = this.market(symbol);
914
- }
915
- }
916
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
917
- const price = this.safeString(order, 'price');
918
- let amount = this.omitZero(this.safeString(order, 'amount'));
919
- // sell orders can have a negative amount
920
- // https://github.com/ccxt/ccxt/issues/5338
921
- if (amount !== undefined) {
922
- amount = Precise["default"].stringAbs(amount);
923
- }
924
- else if (market !== undefined) {
925
- const amountKey = 'a:' + market['base'] + 'cds:';
926
- amount = Precise["default"].stringAbs(this.safeString(order, amountKey));
927
- }
928
- const remaining = this.safeString2(order, 'pending', 'remains');
929
- const filled = Precise["default"].stringSub(amount, remaining);
930
- let fee = undefined;
931
- let cost = undefined;
932
- if (market !== undefined) {
933
- symbol = market['symbol'];
934
- const taCost = this.safeString(order, 'ta:' + market['quote']);
935
- const ttaCost = this.safeString(order, 'tta:' + market['quote']);
936
- cost = Precise["default"].stringAdd(taCost, ttaCost);
937
- const baseFee = 'fa:' + market['base'];
938
- const baseTakerFee = 'tfa:' + market['base'];
939
- const quoteFee = 'fa:' + market['quote'];
940
- const quoteTakerFee = 'tfa:' + market['quote'];
941
- let feeRate = this.safeString(order, 'tradingFeeMaker');
942
- if (!feeRate) {
943
- feeRate = this.safeString(order, 'tradingFeeTaker', feeRate);
944
- }
945
- if (feeRate) {
946
- feeRate = Precise["default"].stringDiv(feeRate, '100'); // convert to mathematically-correct percentage coefficients: 1.0 = 100%
947
- }
948
- if ((baseFee in order) || (baseTakerFee in order)) {
949
- const baseFeeCost = this.safeNumber2(order, baseFee, baseTakerFee);
950
- fee = {
951
- 'currency': market['base'],
952
- 'rate': this.parseNumber(feeRate),
953
- 'cost': baseFeeCost,
954
- };
955
- }
956
- else if ((quoteFee in order) || (quoteTakerFee in order)) {
957
- const quoteFeeCost = this.safeNumber2(order, quoteFee, quoteTakerFee);
958
- fee = {
959
- 'currency': market['quote'],
960
- 'rate': this.parseNumber(feeRate),
961
- 'cost': quoteFeeCost,
962
- };
963
- }
964
- }
965
- if (!cost) {
966
- cost = Precise["default"].stringMul(price, filled);
967
- }
968
- const side = this.safeString(order, 'type');
969
- let trades = undefined;
970
- const orderId = this.safeString(order, 'id');
971
- if ('vtx' in order) {
972
- trades = [];
973
- for (let i = 0; i < order['vtx'].length; i++) {
974
- const item = order['vtx'][i];
975
- const tradeSide = this.safeString(item, 'type');
976
- if (tradeSide === 'cancel') {
977
- // looks like this might represent the cancelled part of an order
978
- // { "id": "4426729543",
979
- // "type": "cancel",
980
- // "time": "2017-09-22T00:24:30.476Z",
981
- // "user": "up106404164",
982
- // "c": "user:up106404164:a:BCH",
983
- // "d": "order:4426728375:a:BCH",
984
- // "a": "0.09935956",
985
- // "amount": "0.09935956",
986
- // "balance": "0.42580261",
987
- // "symbol": "BCH",
988
- // "order": "4426728375",
989
- // "buy": null,
990
- // "sell": null,
991
- // "pair": null,
992
- // "pos": null,
993
- // "cs": "0.42580261",
994
- // "ds": 0 }
995
- continue;
996
- }
997
- const tradePrice = this.safeString(item, 'price');
998
- if (tradePrice === undefined) {
999
- // this represents the order
1000
- // {
1001
- // "a": "0.47000000",
1002
- // "c": "user:up106404164:a:EUR",
1003
- // "d": "order:6065499239:a:EUR",
1004
- // "cs": "1432.93",
1005
- // "ds": "476.72",
1006
- // "id": "6065499249",
1007
- // "buy": null,
1008
- // "pos": null,
1009
- // "pair": null,
1010
- // "sell": null,
1011
- // "time": "2018-04-22T13:07:22.152Z",
1012
- // "type": "buy",
1013
- // "user": "up106404164",
1014
- // "order": "6065499239",
1015
- // "amount": "-715.97000000",
1016
- // "symbol": "EUR",
1017
- // "balance": "1432.93000000" }
1018
- continue;
1019
- }
1020
- // todo: deal with these
1021
- if (tradeSide === 'costsNothing') {
1022
- continue;
1023
- }
1024
- // --
1025
- // if (side !== tradeSide)
1026
- // throw new Error (JSON.stringify (order, null, 2));
1027
- // if (orderId !== item['order'])
1028
- // throw new Error (JSON.stringify (order, null, 2));
1029
- // --
1030
- // partial buy trade
1031
- // {
1032
- // "a": "0.01589885",
1033
- // "c": "user:up106404164:a:BTC",
1034
- // "d": "order:6065499239:a:BTC",
1035
- // "cs": "0.36300000",
1036
- // "ds": 0,
1037
- // "id": "6067991213",
1038
- // "buy": "6065499239",
1039
- // "pos": null,
1040
- // "pair": null,
1041
- // "sell": "6067991206",
1042
- // "time": "2018-04-22T23:09:11.773Z",
1043
- // "type": "buy",
1044
- // "user": "up106404164",
1045
- // "order": "6065499239",
1046
- // "price": 7146.5,
1047
- // "amount": "0.01589885",
1048
- // "symbol": "BTC",
1049
- // "balance": "0.36300000",
1050
- // "symbol2": "EUR",
1051
- // "fee_amount": "0.19" }
1052
- // --
1053
- // trade with zero amount, but non-zero fee
1054
- // {
1055
- // "a": "0.00000000",
1056
- // "c": "user:up106404164:a:EUR",
1057
- // "d": "order:5840654423:a:EUR",
1058
- // "cs": 559744,
1059
- // "ds": 0,
1060
- // "id": "5840654429",
1061
- // "buy": "5807238573",
1062
- // "pos": null,
1063
- // "pair": null,
1064
- // "sell": "5840654423",
1065
- // "time": "2018-03-15T03:20:14.010Z",
1066
- // "type": "sell",
1067
- // "user": "up106404164",
1068
- // "order": "5840654423",
1069
- // "price": 730,
1070
- // "amount": "0.00000000",
1071
- // "symbol": "EUR",
1072
- // "balance": "5597.44000000",
1073
- // "symbol2": "BCH",
1074
- // "fee_amount": "0.01" }
1075
- // --
1076
- // trade which should have an amount of exactly 0.002BTC
1077
- // {
1078
- // "a": "16.70000000",
1079
- // "c": "user:up106404164:a:GBP",
1080
- // "d": "order:9927386681:a:GBP",
1081
- // "cs": "86.90",
1082
- // "ds": 0,
1083
- // "id": "9927401610",
1084
- // "buy": "9927401601",
1085
- // "pos": null,
1086
- // "pair": null,
1087
- // "sell": "9927386681",
1088
- // "time": "2019-08-21T15:25:37.777Z",
1089
- // "type": "sell",
1090
- // "user": "up106404164",
1091
- // "order": "9927386681",
1092
- // "price": 8365,
1093
- // "amount": "16.70000000",
1094
- // "office": "UK",
1095
- // "symbol": "GBP",
1096
- // "balance": "86.90000000",
1097
- // "symbol2": "BTC",
1098
- // "fee_amount": "0.03"
1099
- // }
1100
- const tradeTimestamp = this.parse8601(this.safeString(item, 'time'));
1101
- const tradeAmount = this.safeString(item, 'amount');
1102
- const feeCost = this.safeString(item, 'fee_amount');
1103
- let absTradeAmount = Precise["default"].stringAbs(tradeAmount);
1104
- let tradeCost = undefined;
1105
- if (tradeSide === 'sell') {
1106
- tradeCost = absTradeAmount;
1107
- absTradeAmount = Precise["default"].stringDiv(Precise["default"].stringAdd(feeCost, tradeCost), tradePrice);
1108
- }
1109
- else {
1110
- tradeCost = Precise["default"].stringMul(absTradeAmount, tradePrice);
1111
- }
1112
- trades.push({
1113
- 'id': this.safeString(item, 'id'),
1114
- 'timestamp': tradeTimestamp,
1115
- 'datetime': this.iso8601(tradeTimestamp),
1116
- 'order': orderId,
1117
- 'symbol': symbol,
1118
- 'price': this.parseNumber(tradePrice),
1119
- 'amount': this.parseNumber(absTradeAmount),
1120
- 'cost': this.parseNumber(tradeCost),
1121
- 'side': tradeSide,
1122
- 'fee': {
1123
- 'cost': this.parseNumber(feeCost),
1124
- 'currency': market['quote'],
1125
- },
1126
- 'info': item,
1127
- 'type': undefined,
1128
- 'takerOrMaker': undefined,
1129
- });
1130
- }
1131
- }
1132
- return this.safeOrder({
1133
- 'info': order,
1134
- 'id': orderId,
1135
- 'clientOrderId': undefined,
1136
- 'datetime': this.iso8601(timestamp),
1137
- 'timestamp': timestamp,
1138
- 'lastTradeTimestamp': undefined,
1139
- 'status': status,
1140
- 'symbol': symbol,
1141
- 'type': (price === undefined) ? 'market' : 'limit',
1142
- 'timeInForce': undefined,
1143
- 'postOnly': undefined,
1144
- 'side': side,
1145
- 'price': price,
1146
- 'stopPrice': undefined,
1147
- 'triggerPrice': undefined,
1148
- 'cost': cost,
1149
- 'amount': amount,
1150
- 'filled': filled,
1151
- 'remaining': remaining,
1152
- 'trades': trades,
1153
- 'fee': fee,
1154
- 'average': undefined,
1155
- });
1156
- }
1157
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1158
- /**
1159
- * @method
1160
- * @name cex#fetchOpenOrders
1161
- * @see https://docs.cex.io/#open-orders
1162
- * @description fetch all unfilled currently open orders
1163
- * @param {string} symbol unified market symbol
1164
- * @param {int} [since] the earliest time in ms to fetch open orders for
1165
- * @param {int} [limit] the maximum number of open orders structures to retrieve
1166
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1167
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1168
- */
1169
- await this.loadMarkets();
1170
- const request = {};
1171
- let market = undefined;
1172
- let orders = undefined;
1173
- if (symbol !== undefined) {
1174
- market = this.market(symbol);
1175
- request['pair'] = market['id'];
1176
- orders = await this.privatePostOpenOrdersPair(this.extend(request, params));
1177
- }
1178
- else {
1179
- orders = await this.privatePostOpenOrders(this.extend(request, params));
1180
- }
1181
- for (let i = 0; i < orders.length; i++) {
1182
- orders[i] = this.extend(orders[i], { 'status': 'open' });
1183
- }
1184
- return this.parseOrders(orders, market, since, limit);
1185
- }
1186
- async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1187
- /**
1188
- * @method
1189
- * @name cex#fetchClosedOrders
1190
- * @see https://docs.cex.io/#archived-orders
1191
- * @description fetches information on multiple closed orders made by the user
1192
- * @param {string} symbol unified market symbol of the market orders were made in
1193
- * @param {int} [since] the earliest time in ms to fetch orders for
1194
- * @param {int} [limit] the maximum number of order structures to retrieve
1195
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1196
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1197
- */
1198
- if (symbol === undefined) {
1199
- throw new errors.ArgumentsRequired(this.id + ' fetchClosedOrders() requires a symbol argument');
1200
- }
1201
- await this.loadMarkets();
1202
- const market = this.market(symbol);
1203
- const request = { 'pair': market['id'] };
1204
- const response = await this.privatePostArchivedOrdersPair(this.extend(request, params));
1205
- return this.parseOrders(response, market, since, limit);
1206
- }
1207
- async fetchOrder(id, symbol = undefined, params = {}) {
1208
- /**
1209
- * @method
1210
- * @name cex#fetchOrder
1211
- * @see https://docs.cex.io/?python#get-order-details
1212
- * @description fetches information on an order made by the user
1213
- * @param {string} symbol not used by cex fetchOrder
1214
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1215
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1216
- */
1217
- await this.loadMarkets();
1218
- const request = {
1219
- 'id': id.toString(),
1220
- };
1221
- const response = await this.privatePostGetOrderTx(this.extend(request, params));
1222
- const data = this.safeValue(response, 'data', {});
1223
- //
1224
- // {
1225
- // "id": "5442731603",
1226
- // "type": "sell",
1227
- // "time": 1516132358071,
1228
- // "lastTxTime": 1516132378452,
1229
- // "lastTx": "5442734452",
1230
- // "pos": null,
1231
- // "user": "up106404164",
1232
- // "status": "d",
1233
- // "symbol1": "ETH",
1234
- // "symbol2": "EUR",
1235
- // "amount": "0.50000000",
1236
- // "kind": "api",
1237
- // "price": "923.3386",
1238
- // "tfacf": "1",
1239
- // "fa:EUR": "0.55",
1240
- // "ta:EUR": "369.77",
1241
- // "remains": "0.00000000",
1242
- // "tfa:EUR": "0.22",
1243
- // "tta:EUR": "91.95",
1244
- // "a:ETH:cds": "0.50000000",
1245
- // "a:EUR:cds": "461.72",
1246
- // "f:EUR:cds": "0.77",
1247
- // "tradingFeeMaker": "0.15",
1248
- // "tradingFeeTaker": "0.23",
1249
- // "tradingFeeStrategy": "userVolumeAmount",
1250
- // "tradingFeeUserVolumeAmount": "2896912572",
1251
- // "orderId": "5442731603",
1252
- // "next": false,
1253
- // "vtx": [
1254
- // {
1255
- // "id": "5442734452",
1256
- // "type": "sell",
1257
- // "time": "2018-01-16T19:52:58.452Z",
1258
- // "user": "up106404164",
1259
- // "c": "user:up106404164:a:EUR",
1260
- // "d": "order:5442731603:a:EUR",
1261
- // "a": "104.53000000",
1262
- // "amount": "104.53000000",
1263
- // "balance": "932.71000000",
1264
- // "symbol": "EUR",
1265
- // "order": "5442731603",
1266
- // "buy": "5442734443",
1267
- // "sell": "5442731603",
1268
- // "pair": null,
1269
- // "pos": null,
1270
- // "office": null,
1271
- // "cs": "932.71",
1272
- // "ds": 0,
1273
- // "price": 923.3386,
1274
- // "symbol2": "ETH",
1275
- // "fee_amount": "0.16"
1276
- // },
1277
- // {
1278
- // "id": "5442731609",
1279
- // "type": "sell",
1280
- // "time": "2018-01-16T19:52:38.071Z",
1281
- // "user": "up106404164",
1282
- // "c": "user:up106404164:a:EUR",
1283
- // "d": "order:5442731603:a:EUR",
1284
- // "a": "91.73000000",
1285
- // "amount": "91.73000000",
1286
- // "balance": "563.49000000",
1287
- // "symbol": "EUR",
1288
- // "order": "5442731603",
1289
- // "buy": "5442618127",
1290
- // "sell": "5442731603",
1291
- // "pair": null,
1292
- // "pos": null,
1293
- // "office": null,
1294
- // "cs": "563.49",
1295
- // "ds": 0,
1296
- // "price": 924.0092,
1297
- // "symbol2": "ETH",
1298
- // "fee_amount": "0.22"
1299
- // },
1300
- // {
1301
- // "id": "5442731604",
1302
- // "type": "sell",
1303
- // "time": "2018-01-16T19:52:38.071Z",
1304
- // "user": "up106404164",
1305
- // "c": "order:5442731603:a:ETH",
1306
- // "d": "user:up106404164:a:ETH",
1307
- // "a": "0.50000000",
1308
- // "amount": "-0.50000000",
1309
- // "balance": "15.80995000",
1310
- // "symbol": "ETH",
1311
- // "order": "5442731603",
1312
- // "buy": null,
1313
- // "sell": null,
1314
- // "pair": null,
1315
- // "pos": null,
1316
- // "office": null,
1317
- // "cs": "0.50000000",
1318
- // "ds": "15.80995000"
1319
- // }
1320
- // ]
1321
- // }
1322
- //
1323
- return this.parseOrder(data);
1324
- }
1325
- async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1326
- /**
1327
- * @method
1328
- * @name cex#fetchOrders
1329
- * @see https://docs.cex.io/#archived-orders
1330
- * @description fetches information on multiple orders made by the user
1331
- * @param {string} symbol unified market symbol of the market orders were made in
1332
- * @param {int} [since] the earliest time in ms to fetch orders for
1333
- * @param {int} [limit] the maximum number of order structures to retrieve
1334
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1335
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1336
- */
1337
- await this.loadMarkets();
1338
- const market = this.market(symbol);
1339
- const request = {
1340
- 'limit': limit,
1341
- 'pair': market['id'],
1342
- 'dateFrom': since,
1343
- };
1344
- const response = await this.privatePostArchivedOrdersPair(this.extend(request, params));
1345
- const results = [];
1346
- for (let i = 0; i < response.length; i++) {
1347
- // cancelled (unfilled):
1348
- // { "id": "4005785516",
1349
- // "type": "sell",
1350
- // "time": "2017-07-18T19:08:34.223Z",
1351
- // "lastTxTime": "2017-07-18T19:08:34.396Z",
1352
- // "lastTx": "4005785522",
1353
- // "pos": null,
1354
- // "status": "c",
1355
- // "symbol1": "ETH",
1356
- // "symbol2": "GBP",
1357
- // "amount": "0.20000000",
1358
- // "price": "200.5625",
1359
- // "remains": "0.20000000",
1360
- // 'a:ETH:cds': "0.20000000",
1361
- // "tradingFeeMaker": "0",
1362
- // "tradingFeeTaker": "0.16",
1363
- // "tradingFeeUserVolumeAmount": "10155061217",
1364
- // "orderId": "4005785516" }
1365
- // --
1366
- // cancelled (partially filled buy):
1367
- // { "id": "4084911657",
1368
- // "type": "buy",
1369
- // "time": "2017-08-05T03:18:39.596Z",
1370
- // "lastTxTime": "2019-03-19T17:37:46.404Z",
1371
- // "lastTx": "8459265833",
1372
- // "pos": null,
1373
- // "status": "cd",
1374
- // "symbol1": "BTC",
1375
- // "symbol2": "GBP",
1376
- // "amount": "0.05000000",
1377
- // "price": "2241.4692",
1378
- // "tfacf": "1",
1379
- // "remains": "0.03910535",
1380
- // 'tfa:GBP': "0.04",
1381
- // 'tta:GBP': "24.39",
1382
- // 'a:BTC:cds': "0.01089465",
1383
- // 'a:GBP:cds': "112.26",
1384
- // 'f:GBP:cds': "0.04",
1385
- // "tradingFeeMaker": "0",
1386
- // "tradingFeeTaker": "0.16",
1387
- // "tradingFeeUserVolumeAmount": "13336396963",
1388
- // "orderId": "4084911657" }
1389
- // --
1390
- // cancelled (partially filled sell):
1391
- // { "id": "4426728375",
1392
- // "type": "sell",
1393
- // "time": "2017-09-22T00:24:20.126Z",
1394
- // "lastTxTime": "2017-09-22T00:24:30.476Z",
1395
- // "lastTx": "4426729543",
1396
- // "pos": null,
1397
- // "status": "cd",
1398
- // "symbol1": "BCH",
1399
- // "symbol2": "BTC",
1400
- // "amount": "0.10000000",
1401
- // "price": "0.11757182",
1402
- // "tfacf": "1",
1403
- // "remains": "0.09935956",
1404
- // 'tfa:BTC': "0.00000014",
1405
- // 'tta:BTC': "0.00007537",
1406
- // 'a:BCH:cds': "0.10000000",
1407
- // 'a:BTC:cds': "0.00007537",
1408
- // 'f:BTC:cds': "0.00000014",
1409
- // "tradingFeeMaker": "0",
1410
- // "tradingFeeTaker": "0.18",
1411
- // "tradingFeeUserVolumeAmount": "3466715450",
1412
- // "orderId": "4426728375" }
1413
- // --
1414
- // filled:
1415
- // { "id": "5342275378",
1416
- // "type": "sell",
1417
- // "time": "2018-01-04T00:28:12.992Z",
1418
- // "lastTxTime": "2018-01-04T00:28:12.992Z",
1419
- // "lastTx": "5342275393",
1420
- // "pos": null,
1421
- // "status": "d",
1422
- // "symbol1": "BCH",
1423
- // "symbol2": "BTC",
1424
- // "amount": "0.10000000",
1425
- // "kind": "api",
1426
- // "price": "0.17",
1427
- // "remains": "0.00000000",
1428
- // 'tfa:BTC': "0.00003902",
1429
- // 'tta:BTC': "0.01699999",
1430
- // 'a:BCH:cds': "0.10000000",
1431
- // 'a:BTC:cds': "0.01699999",
1432
- // 'f:BTC:cds': "0.00003902",
1433
- // "tradingFeeMaker": "0.15",
1434
- // "tradingFeeTaker": "0.23",
1435
- // "tradingFeeUserVolumeAmount": "1525951128",
1436
- // "orderId": "5342275378" }
1437
- // --
1438
- // market order (buy):
1439
- // { "id": "6281946200",
1440
- // "pos": null,
1441
- // "time": "2018-05-23T11:55:43.467Z",
1442
- // "type": "buy",
1443
- // "amount": "0.00000000",
1444
- // "lastTx": "6281946210",
1445
- // "status": "d",
1446
- // "amount2": "20.00",
1447
- // "orderId": "6281946200",
1448
- // "remains": "0.00000000",
1449
- // "symbol1": "ETH",
1450
- // "symbol2": "EUR",
1451
- // "tfa:EUR": "0.05",
1452
- // "tta:EUR": "19.94",
1453
- // "a:ETH:cds": "0.03764100",
1454
- // "a:EUR:cds": "20.00",
1455
- // "f:EUR:cds": "0.05",
1456
- // "lastTxTime": "2018-05-23T11:55:43.467Z",
1457
- // "tradingFeeTaker": "0.25",
1458
- // "tradingFeeUserVolumeAmount": "55998097" }
1459
- // --
1460
- // market order (sell):
1461
- // { "id": "6282200948",
1462
- // "pos": null,
1463
- // "time": "2018-05-23T12:42:58.315Z",
1464
- // "type": "sell",
1465
- // "amount": "-0.05000000",
1466
- // "lastTx": "6282200958",
1467
- // "status": "d",
1468
- // "orderId": "6282200948",
1469
- // "remains": "0.00000000",
1470
- // "symbol1": "ETH",
1471
- // "symbol2": "EUR",
1472
- // "tfa:EUR": "0.07",
1473
- // "tta:EUR": "26.49",
1474
- // "a:ETH:cds": "0.05000000",
1475
- // "a:EUR:cds": "26.49",
1476
- // "f:EUR:cds": "0.07",
1477
- // "lastTxTime": "2018-05-23T12:42:58.315Z",
1478
- // "tradingFeeTaker": "0.25",
1479
- // "tradingFeeUserVolumeAmount": "56294576" }
1480
- const order = response[i];
1481
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
1482
- const baseId = this.safeString(order, 'symbol1');
1483
- const quoteId = this.safeString(order, 'symbol2');
1484
- const base = this.safeCurrencyCode(baseId);
1485
- const quote = this.safeCurrencyCode(quoteId);
1486
- const symbolInner = base + '/' + quote;
1487
- const side = this.safeString(order, 'type');
1488
- const baseAmount = this.safeNumber(order, 'a:' + baseId + ':cds');
1489
- const quoteAmount = this.safeNumber(order, 'a:' + quoteId + ':cds');
1490
- const fee = this.safeNumber(order, 'f:' + quoteId + ':cds');
1491
- const amount = this.safeString(order, 'amount');
1492
- const price = this.safeString(order, 'price');
1493
- const remaining = this.safeString(order, 'remains');
1494
- const filled = Precise["default"].stringSub(amount, remaining);
1495
- let orderAmount = undefined;
1496
- let cost = undefined;
1497
- let average = undefined;
1498
- let type = undefined;
1499
- if (!price) {
1500
- type = 'market';
1501
- orderAmount = baseAmount;
1502
- cost = quoteAmount;
1503
- average = Precise["default"].stringDiv(orderAmount, cost);
1504
- }
1505
- else {
1506
- const ta = this.safeString(order, 'ta:' + quoteId, '0');
1507
- const tta = this.safeString(order, 'tta:' + quoteId, '0');
1508
- const fa = this.safeString(order, 'fa:' + quoteId, '0');
1509
- const tfa = this.safeString(order, 'tfa:' + quoteId, '0');
1510
- if (side === 'sell') {
1511
- cost = Precise["default"].stringAdd(Precise["default"].stringAdd(ta, tta), Precise["default"].stringAdd(fa, tfa));
1512
- }
1513
- else {
1514
- cost = Precise["default"].stringSub(Precise["default"].stringAdd(ta, tta), Precise["default"].stringAdd(fa, tfa));
1515
- }
1516
- type = 'limit';
1517
- orderAmount = amount;
1518
- average = Precise["default"].stringDiv(cost, filled);
1519
- }
1520
- const time = this.safeString(order, 'time');
1521
- const lastTxTime = this.safeString(order, 'lastTxTime');
1522
- const timestamp = this.parse8601(time);
1523
- const safeOrder = this.safeOrder({
1524
- 'info': order,
1525
- 'id': this.safeString(order, 'id'),
1526
- 'timestamp': timestamp,
1527
- 'datetime': this.iso8601(timestamp),
1528
- 'lastUpdated': this.parse8601(lastTxTime),
1529
- 'status': status,
1530
- 'symbol': symbolInner,
1531
- 'side': side,
1532
- 'price': price,
1533
- 'amount': orderAmount,
1534
- 'average': average,
1535
- 'type': type,
1536
- 'filled': filled,
1537
- 'cost': cost,
1538
- 'remaining': remaining,
1539
- 'fee': {
1540
- 'cost': fee,
1541
- 'currency': quote,
1542
- },
1543
- });
1544
- results.push(safeOrder);
1545
- }
1546
- return results;
1547
- }
1548
- parseOrderStatus(status) {
1549
- return this.safeString(this.options['order']['status'], status, status);
1550
- }
1551
- async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
1552
- /**
1553
- * @method
1554
- * @name cex#editOrderWs
1555
- * @description edit a trade order
1556
- * @see https://docs.cex.io/#cancel-replace-order
1557
- * @param {string} id order id
1558
- * @param {string} symbol unified symbol of the market to create an order in
1559
- * @param {string} type 'market' or 'limit'
1560
- * @param {string} side 'buy' or 'sell'
1561
- * @param {float} amount how much of the currency you want to trade in units of the base currency
1562
- * @param {float|undefined} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1563
- * @param {object} [params] extra parameters specific to the cex api endpoint
1564
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/en/latest/manual.html#order-structure}
1565
- */
1566
- if (amount === undefined) {
1567
- throw new errors.ArgumentsRequired(this.id + ' editOrder() requires a amount argument');
1568
- }
1569
- if (price === undefined) {
1570
- throw new errors.ArgumentsRequired(this.id + ' editOrder() requires a price argument');
1571
- }
1572
- await this.loadMarkets();
1573
- const market = this.market(symbol);
1574
- // see: https://cex.io/rest-api#/definitions/CancelReplaceOrderRequest
1575
- const request = {
1576
- 'pair': market['id'],
1577
- 'type': side,
1578
- 'amount': amount,
1579
- 'price': price,
1580
- 'order_id': id,
1581
- };
1582
- const response = await this.privatePostCancelReplaceOrderPair(this.extend(request, params));
1583
- return this.parseOrder(response, market);
1584
- }
1585
- async fetchDepositAddress(code, params = {}) {
1586
- /**
1587
- * @method
1588
- * @name cex#fetchDepositAddress
1589
- * @see https://docs.cex.io/#get-crypto-address
1590
- * @description fetch the deposit address for a currency associated with this account
1591
- * @param {string} code unified currency code
1592
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1593
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1594
- */
1595
- await this.loadMarkets();
1596
- const currency = this.currency(code);
1597
- const request = {
1598
- 'currency': currency['id'],
1599
- };
1600
- const [networkCode, query] = this.handleNetworkCodeAndParams(params);
1601
- // atm, cex doesn't support network in the request
1602
- const response = await this.privatePostGetCryptoAddress(this.extend(request, query));
1603
- //
1604
- // {
1605
- // "e": "get_crypto_address",
1606
- // "ok": "ok",
1607
- // "data": {
1608
- // "name": "BTC",
1609
- // "addresses": [
1610
- // {
1611
- // "blockchain": "Bitcoin",
1612
- // "address": "2BvKwe1UwrdTjq2nzhscFYXwqCjCaaHCeq"
1613
- //
1614
- // // for others coins (i.e. XRP, XLM) other keys are present:
1615
- // // "destination": "rF1sdh25BJX3qFwneeTBwaq3zPEWYcwjp2",
1616
- // // "destinationTag": "7519113655",
1617
- // // "memo": "XLM-memo12345",
1618
- // }
1619
- // ]
1620
- // }
1621
- // }
1622
- //
1623
- const data = this.safeValue(response, 'data', {});
1624
- const addresses = this.safeValue(data, 'addresses', []);
1625
- const chainsIndexedById = this.indexBy(addresses, 'blockchain');
1626
- const selectedNetworkId = this.selectNetworkIdFromRawNetworks(code, networkCode, chainsIndexedById);
1627
- const addressObject = this.safeValue(chainsIndexedById, selectedNetworkId, {});
1628
- const address = this.safeString2(addressObject, 'address', 'destination');
1629
- this.checkAddress(address);
1630
- return {
1631
- 'currency': code,
1632
- 'address': address,
1633
- 'tag': this.safeString2(addressObject, 'destinationTag', 'memo'),
1634
- 'network': this.networkIdToCode(selectedNetworkId),
1635
- 'info': data,
1636
- };
1637
- }
1638
- nonce() {
1639
- return this.milliseconds();
1640
- }
1641
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1642
- let url = this.urls['api']['rest'] + '/' + this.implodeParams(path, params);
1643
- const query = this.omit(params, this.extractParams(path));
1644
- if (api === 'public') {
1645
- if (Object.keys(query).length) {
1646
- url += '?' + this.urlencode(query);
1647
- }
1648
- }
1649
- else {
1650
- this.checkRequiredCredentials();
1651
- const nonce = this.nonce().toString();
1652
- const auth = nonce + this.uid + this.apiKey;
1653
- const signature = this.hmac(this.encode(auth), this.encode(this.secret), sha256.sha256);
1654
- body = this.json(this.extend({
1655
- 'key': this.apiKey,
1656
- 'signature': signature.toUpperCase(),
1657
- 'nonce': nonce,
1658
- }, query));
1659
- headers = {
1660
- 'Content-Type': 'application/json',
1661
- };
1662
- }
1663
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1664
- }
1665
- handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1666
- if (Array.isArray(response)) {
1667
- return response; // public endpoints may return []-arrays
1668
- }
1669
- if (body === 'true') {
1670
- return undefined;
1671
- }
1672
- if (response === undefined) {
1673
- throw new errors.NullResponse(this.id + ' returned ' + this.json(response));
1674
- }
1675
- if ('e' in response) {
1676
- if ('ok' in response) {
1677
- if (response['ok'] === 'ok') {
1678
- return undefined;
1679
- }
1680
- }
1681
- }
1682
- if ('error' in response) {
1683
- const message = this.safeString(response, 'error');
1684
- const feedback = this.id + ' ' + body;
1685
- this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
1686
- this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
1687
- throw new errors.ExchangeError(feedback);
1688
- }
1689
- return undefined;
1690
- }
1691
- }
1692
-
1693
- module.exports = cex;