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,2015 +0,0 @@
1
- 'use strict';
2
-
3
- var currencycom$1 = require('./abstract/currencycom.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 currencycom
13
- * @augments Exchange
14
- */
15
- class currencycom extends currencycom$1 {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'currencycom',
19
- 'name': 'Currency.com',
20
- 'countries': ['BY'],
21
- 'rateLimit': 100,
22
- 'certified': false,
23
- 'pro': true,
24
- 'version': 'v2',
25
- // new metainfo interface
26
- 'has': {
27
- 'CORS': undefined,
28
- 'spot': true,
29
- 'margin': true,
30
- 'swap': true,
31
- 'future': false,
32
- 'option': false,
33
- 'addMargin': undefined,
34
- 'cancelAllOrders': undefined,
35
- 'cancelOrder': true,
36
- 'cancelOrders': undefined,
37
- 'createDepositAddress': undefined,
38
- 'createLimitOrder': true,
39
- 'createMarketOrder': true,
40
- 'createOrder': true,
41
- 'createStopLimitOrder': true,
42
- 'createStopMarketOrder': true,
43
- 'createStopOrder': true,
44
- 'editOrder': 'emulated',
45
- 'fetchAccounts': true,
46
- 'fetchBalance': true,
47
- 'fetchBidsAsks': undefined,
48
- 'fetchBorrowRateHistory': undefined,
49
- 'fetchCanceledOrders': undefined,
50
- 'fetchClosedOrder': undefined,
51
- 'fetchClosedOrders': undefined,
52
- 'fetchCrossBorrowRate': false,
53
- 'fetchCrossBorrowRates': false,
54
- 'fetchCurrencies': true,
55
- 'fetchDeposit': undefined,
56
- 'fetchDepositAddress': true,
57
- 'fetchDepositAddresses': false,
58
- 'fetchDepositAddressesByNetwork': false,
59
- 'fetchDeposits': true,
60
- 'fetchDepositsWithdrawals': true,
61
- 'fetchFundingHistory': false,
62
- 'fetchFundingRate': false,
63
- 'fetchFundingRateHistory': false,
64
- 'fetchFundingRates': false,
65
- 'fetchIndexOHLCV': false,
66
- 'fetchIsolatedBorrowRate': false,
67
- 'fetchIsolatedBorrowRates': false,
68
- 'fetchL2OrderBook': true,
69
- 'fetchLedger': true,
70
- 'fetchLedgerEntry': false,
71
- 'fetchLeverage': true,
72
- 'fetchLeverageTiers': false,
73
- 'fetchMarginMode': false,
74
- 'fetchMarkets': true,
75
- 'fetchMarkOHLCV': false,
76
- 'fetchMyTrades': true,
77
- 'fetchOHLCV': true,
78
- 'fetchOpenOrder': undefined,
79
- 'fetchOpenOrders': true,
80
- 'fetchOrder': true,
81
- 'fetchOrderBook': true,
82
- 'fetchOrderBooks': undefined,
83
- 'fetchOrders': undefined,
84
- 'fetchOrderTrades': undefined,
85
- 'fetchPosition': undefined,
86
- 'fetchPositionMode': false,
87
- 'fetchPositions': true,
88
- 'fetchPositionsRisk': undefined,
89
- 'fetchPremiumIndexOHLCV': false,
90
- 'fetchTicker': true,
91
- 'fetchTickers': true,
92
- 'fetchTime': true,
93
- 'fetchTrades': true,
94
- 'fetchTradingFee': false,
95
- 'fetchTradingFees': true,
96
- 'fetchTradingLimits': undefined,
97
- 'fetchTransactionFee': undefined,
98
- 'fetchTransactionFees': undefined,
99
- 'fetchTransactions': 'emulated',
100
- 'fetchTransfers': undefined,
101
- 'fetchWithdrawal': undefined,
102
- 'fetchWithdrawals': true,
103
- 'reduceMargin': undefined,
104
- 'setLeverage': undefined,
105
- 'setMarginMode': undefined,
106
- 'setPositionMode': undefined,
107
- 'signIn': undefined,
108
- 'transfer': undefined,
109
- 'withdraw': undefined,
110
- },
111
- 'timeframes': {
112
- '1m': '1m',
113
- '5m': '5m',
114
- '10m': '10m',
115
- '15m': '15m',
116
- '30m': '30m',
117
- '1h': '1h',
118
- '4h': '4h',
119
- '1d': '1d',
120
- '1w': '1w',
121
- },
122
- 'hostname': 'backend.currency.com',
123
- 'urls': {
124
- 'logo': 'https://user-images.githubusercontent.com/1294454/83718672-36745c00-a63e-11ea-81a9-677b1f789a4d.jpg',
125
- 'api': {
126
- 'public': 'https://api-adapter.{hostname}/api',
127
- 'private': 'https://api-adapter.{hostname}/api',
128
- 'marketcap': 'https://marketcap.{hostname}/api',
129
- },
130
- 'test': {
131
- 'public': 'https://demo-api-adapter.{hostname}/api',
132
- 'private': 'https://demo-api-adapter.{hostname}/api',
133
- },
134
- 'www': 'https://www.currency.com',
135
- 'referral': 'https://currency.com/trading/signup?c=362jaimv&pid=referral',
136
- 'doc': [
137
- 'https://currency.com/api',
138
- ],
139
- 'fees': 'https://currency.com/fees-charges',
140
- },
141
- // rate-limits are described at: https://currency.com/api-get-started
142
- 'api': {
143
- 'public': {
144
- 'get': {
145
- 'v1/time': 1,
146
- 'v1/exchangeInfo': 1,
147
- 'v1/depth': 1,
148
- 'v1/aggTrades': 1,
149
- 'v1/klines': 1,
150
- 'v1/ticker/24hr': 1,
151
- 'v2/time': 1,
152
- 'v2/exchangeInfo': 1,
153
- 'v2/depth': 1,
154
- 'v2/aggTrades': 1,
155
- 'v2/klines': 1,
156
- 'v2/ticker/24hr': 1,
157
- },
158
- },
159
- 'marketcap': {
160
- 'get': {
161
- 'v1/assets': 1,
162
- 'v1/candles': 1,
163
- 'v1/orderbook': 1,
164
- 'v1/summary': 1,
165
- 'v1/ticker': 1,
166
- 'v1/token/assets': 1,
167
- 'v1/token/orderbook': 1,
168
- 'v1/token/summary': 1,
169
- 'v1/token/ticker': 1,
170
- 'v1/token/trades': 1,
171
- 'v1/token_crypto/OHLC': 1,
172
- 'v1/token_crypto/assets': 1,
173
- 'v1/token_crypto/orderbook': 1,
174
- 'v1/token_crypto/summary': 1,
175
- 'v1/token_crypto/ticker': 1,
176
- 'v1/token_crypto/trades': 1,
177
- 'v1/trades': 1,
178
- },
179
- },
180
- 'private': {
181
- 'get': {
182
- 'v1/account': 1,
183
- 'v1/currencies': 1,
184
- 'v1/deposits': 1,
185
- 'v1/depositAddress': 1,
186
- 'v1/ledger': 1,
187
- 'v1/leverageSettings': 1,
188
- 'v1/myTrades': 1,
189
- 'v1/openOrders': 1,
190
- 'v1/tradingPositions': 1,
191
- 'v1/tradingPositionsHistory': 1,
192
- 'v1/transactions': 1,
193
- 'v1/withdrawals': 1,
194
- 'v2/account': 1,
195
- 'v2/currencies': 1,
196
- 'v2/deposits': 1,
197
- 'v2/depositAddress': 1,
198
- 'v2/ledger': 1,
199
- 'v2/leverageSettings': 1,
200
- 'v2/myTrades': 1,
201
- 'v2/openOrders': 1,
202
- 'v2/tradingPositions': 1,
203
- 'v2/tradingPositionsHistory': 1,
204
- 'v2/transactions': 1,
205
- 'v2/withdrawals': 1,
206
- 'v2/fetchOrder': 1,
207
- },
208
- 'post': {
209
- 'v1/order': 1,
210
- 'v1/updateTradingPosition': 1,
211
- 'v1/updateTradingOrder': 1,
212
- 'v1/closeTradingPosition': 1,
213
- 'v2/order': 1,
214
- 'v2/updateTradingPosition': 1,
215
- 'v2/updateTradingOrder': 1,
216
- 'v2/closeTradingPosition': 1,
217
- },
218
- 'delete': {
219
- 'v1/order': 1,
220
- 'v2/order': 1,
221
- },
222
- },
223
- },
224
- 'fees': {
225
- 'trading': {
226
- 'feeSide': 'get',
227
- 'tierBased': false,
228
- 'percentage': true,
229
- 'taker': this.parseNumber('0.002'),
230
- 'maker': this.parseNumber('0.002'),
231
- },
232
- },
233
- 'precisionMode': number.TICK_SIZE,
234
- // exchange-specific options
235
- 'options': {
236
- 'defaultTimeInForce': 'GTC',
237
- 'warnOnFetchOpenOrdersWithoutSymbol': true,
238
- 'recvWindow': 5 * 1000,
239
- 'timeDifference': 0,
240
- 'adjustForTimeDifference': false,
241
- 'parseOrderToPrecision': false,
242
- 'newOrderRespType': {
243
- 'market': 'FULL',
244
- 'limit': 'RESULT',
245
- 'stop': 'RESULT',
246
- },
247
- 'leverage_markets_suffix': '_LEVERAGE',
248
- 'collateralCurrencies': ['USD', 'EUR', 'USDT'],
249
- },
250
- 'exceptions': {
251
- 'broad': {
252
- 'FIELD_VALIDATION_ERROR Cancel is available only for LIMIT order': errors.InvalidOrder,
253
- 'API key does not exist': errors.AuthenticationError,
254
- 'Order would trigger immediately.': errors.InvalidOrder,
255
- 'Account has insufficient balance for requested action.': errors.InsufficientFunds,
256
- 'Rest API trading is not enabled.': errors.ExchangeNotAvailable,
257
- 'Combination of parameters invalid': errors.BadRequest,
258
- 'Invalid limit price': errors.BadRequest,
259
- 'Only leverage symbol allowed here:': errors.BadSymbol,
260
- 'market data service is not available': errors.ExchangeNotAvailable,
261
- 'your time is ahead of server': errors.InvalidNonce,
262
- 'Can not find account': errors.BadRequest,
263
- 'You mentioned an invalid value for the price parameter': errors.BadRequest, // -1030
264
- },
265
- 'exact': {
266
- '-1000': errors.ExchangeNotAvailable,
267
- '-1013': errors.InvalidOrder,
268
- // '-1021': InvalidNonce, // {"code":"-1021","msg":"your time is ahead of server"} // see above in the broad section
269
- '-1022': errors.AuthenticationError,
270
- '-1030': errors.InvalidOrder,
271
- '-1100': errors.InvalidOrder,
272
- '-1104': errors.ExchangeError,
273
- '-1025': errors.AuthenticationError,
274
- '-1128': errors.BadRequest,
275
- '-2010': errors.ExchangeError,
276
- '-2011': errors.OrderNotFound,
277
- '-2013': errors.OrderNotFound,
278
- '-2014': errors.AuthenticationError,
279
- '-2015': errors.AuthenticationError, // "Invalid API-key, IP, or permissions for action."
280
- },
281
- },
282
- 'commonCurrencies': {
283
- 'ACN': 'Accenture',
284
- 'AMC': 'AMC Entertainment Holdings',
285
- 'BNS': 'Bank of Nova Scotia',
286
- 'CAR': 'Avis Budget Group Inc',
287
- 'CLR': 'Continental Resources',
288
- 'EDU': 'New Oriental Education & Technology Group Inc',
289
- 'ETN': 'Eaton',
290
- 'FOX': 'Fox Corporation',
291
- 'GM': 'General Motors Co',
292
- 'IQ': 'iQIYI',
293
- 'OSK': 'Oshkosh',
294
- 'PLAY': "Dave & Buster's Entertainment",
295
- },
296
- });
297
- }
298
- nonce() {
299
- return this.milliseconds() - this.options['timeDifference'];
300
- }
301
- async fetchTime(params = {}) {
302
- /**
303
- * @method
304
- * @name currencycom#fetchTime
305
- * @description fetches the current integer timestamp in milliseconds from the exchange server
306
- * @param {object} [params] extra parameters specific to the exchange API endpoint
307
- * @returns {int} the current integer timestamp in milliseconds from the exchange server
308
- */
309
- const response = await this.publicGetV2Time(params);
310
- //
311
- // {
312
- // "serverTime": 1590998366609
313
- // }
314
- //
315
- return this.safeInteger(response, 'serverTime');
316
- }
317
- async fetchCurrencies(params = {}) {
318
- /**
319
- * @method
320
- * @name currencycom#fetchCurrencies
321
- * @description fetches all available currencies on an exchange
322
- * @param {object} [params] extra parameters specific to the exchange API endpoint
323
- * @returns {object} an associative dictionary of currencies
324
- */
325
- // requires authentication
326
- if (!this.checkRequiredCredentials(false)) {
327
- return undefined;
328
- }
329
- const response = await this.privateGetV2Currencies(params);
330
- //
331
- // [
332
- // {
333
- // "name": "Euro",
334
- // "displaySymbol": "EUR.cx",
335
- // "precision": "2",
336
- // "type": "FIAT",
337
- // "minWithdrawal": "90.0",
338
- // "maxWithdrawal": "1.0E+8",
339
- // "commissionMin": "0.02", // some instruments do not have this property
340
- // "commissionPercent": "1.5", // some instruments do not have this property
341
- // "minDeposit": "90.0",
342
- // },
343
- // {
344
- // "name": "Bitcoin",
345
- // "displaySymbol": "BTC",
346
- // "precision": "8",
347
- // "type": "CRYPTO", // only a few major currencies have this value, others like USDT have a value of "TOKEN"
348
- // "minWithdrawal": "0.00020",
349
- // "commissionFixed": "0.00010",
350
- // "minDeposit": "0.00010",
351
- // },
352
- // ]
353
- //
354
- const result = {};
355
- for (let i = 0; i < response.length; i++) {
356
- const currency = response[i];
357
- const id = this.safeString(currency, 'displaySymbol');
358
- const code = this.safeCurrencyCode(id);
359
- const fee = this.safeNumber(currency, 'commissionFixed');
360
- result[code] = {
361
- 'id': id,
362
- 'code': code,
363
- 'type': this.safeStringLower(currency, 'type'),
364
- 'name': this.safeString(currency, 'name'),
365
- 'active': undefined,
366
- 'deposit': undefined,
367
- 'withdraw': undefined,
368
- 'fee': fee,
369
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'precision'))),
370
- 'limits': {
371
- 'amount': {
372
- 'min': undefined,
373
- 'max': undefined,
374
- },
375
- 'withdraw': {
376
- 'min': this.safeNumber(currency, 'minWithdrawal'),
377
- 'max': this.safeNumber(currency, 'maxWithdrawal'),
378
- },
379
- 'deposit': {
380
- 'min': this.safeNumber(currency, 'minDeposit'),
381
- 'max': undefined,
382
- },
383
- },
384
- 'info': currency,
385
- };
386
- }
387
- return result;
388
- }
389
- async fetchMarkets(params = {}) {
390
- /**
391
- * @method
392
- * @name currencycom#fetchMarkets
393
- * @description retrieves data on all markets for currencycom
394
- * @param {object} [params] extra parameters specific to the exchange API endpoint
395
- * @returns {object[]} an array of objects representing market data
396
- */
397
- const response = await this.publicGetV2ExchangeInfo(params);
398
- //
399
- // {
400
- // "timezone": "UTC",
401
- // "serverTime": "1645186287261",
402
- // "rateLimits": [
403
- // { rateLimitType: "REQUEST_WEIGHT", interval: "MINUTE", intervalNum: "1", limit: "1200" },
404
- // { rateLimitType: "ORDERS", interval: "SECOND", intervalNum: "1", limit: "10" },
405
- // { rateLimitType: "ORDERS", interval: "DAY", intervalNum: "1", limit: "864000" },
406
- // ],
407
- // "exchangeFilters": [],
408
- // "symbols": [
409
- // {
410
- // "symbol": "BTC/USDT", // BTC/USDT, BTC/USDT_LEVERAGE
411
- // "name": "Bitcoin / Tether",
412
- // "status": "TRADING", // TRADING, BREAK, HALT
413
- // "baseAsset": "BTC",
414
- // "baseAssetPrecision": "4",
415
- // "quoteAsset": "USDT",
416
- // "quoteAssetId": "USDT", // USDT, USDT_LEVERAGE
417
- // "quotePrecision": "4",
418
- // "orderTypes": [ "LIMIT", "MARKET" ], // LIMIT, MARKET, STOP
419
- // "filters": [
420
- // { filterType: "LOT_SIZE", minQty: "0.0001", maxQty: "100", stepSize: "0.0001", },
421
- // { filterType: "MIN_NOTIONAL", minNotional: "5", },
422
- // ],
423
- // "marketModes": [ "REGULAR" ], // CLOSE_ONLY, LONG_ONLY, REGULAR
424
- // "marketType": "SPOT", // SPOT, LEVERAGE
425
- // "longRate": -0.0684932, // LEVERAGE only
426
- // "shortRate": -0.0684932, // LEVERAGE only
427
- // "swapChargeInterval": 1440, // LEVERAGE only
428
- // "country": "",
429
- // "sector": "",
430
- // "industry": "",
431
- // "tradingHours": "UTC; Mon - 22:00, 22:05 -; Tue - 22:00, 22:05 -; Wed - 22:00, 22:05 -; Thu - 22:00, 22:05 -; Fri - 22:00, 23:01 -; Sat - 22:00, 22:05 -; Sun - 21:00, 22:05 -",
432
- // "tickSize": "0.01",
433
- // "tickValue": "403.4405", // not available in BTC/USDT_LEVERAGE, but available in BTC/USD_LEVERAGE
434
- // "exchangeFee": "0.2", // SPOT only
435
- // "tradingFee": 0.075, // LEVERAGE only
436
- // "makerFee": -0.025, // LEVERAGE only
437
- // "takerFee": 0.06, // LEVERAGE only
438
- // "maxSLGap": 50, // LEVERAGE only
439
- // "minSLGap": 1, // LEVERAGE only
440
- // "maxTPGap": 50, // LEVERAGE only
441
- // "minTPGap": 0.5, // LEVERAGE only
442
- // "assetType": "CRYPTOCURRENCY",
443
- // },
444
- // ]
445
- // }
446
- //
447
- if (this.options['adjustForTimeDifference']) {
448
- await this.loadTimeDifference();
449
- }
450
- const markets = this.safeValue(response, 'symbols', []);
451
- const result = [];
452
- for (let i = 0; i < markets.length; i++) {
453
- const market = markets[i];
454
- const id = this.safeString(market, 'symbol');
455
- const baseId = this.safeString(market, 'baseAsset');
456
- const quoteId = this.safeString(market, 'quoteAsset');
457
- const base = this.safeCurrencyCode(baseId);
458
- const quote = this.safeCurrencyCode(quoteId);
459
- let symbol = base + '/' + quote;
460
- const typeRaw = this.safeString(market, 'marketType');
461
- const spot = (typeRaw === 'SPOT');
462
- const futures = false;
463
- const swap = (typeRaw === 'LEVERAGE');
464
- const type = swap ? 'swap' : 'spot';
465
- const margin = undefined;
466
- if (swap) {
467
- symbol = symbol.replace(this.options['leverage_markets_suffix'], '');
468
- symbol += ':' + quote;
469
- }
470
- const active = this.safeString(market, 'status') === 'TRADING';
471
- // to set taker & maker fees, we use one from the below data - pairs either have 'exchangeFee' or 'tradingFee', if none of them (rare cases), then they should have 'takerFee & makerFee'
472
- const exchangeFee = this.safeString2(market, 'exchangeFee', 'tradingFee');
473
- let makerFee = this.safeString(market, 'makerFee', exchangeFee);
474
- let takerFee = this.safeString(market, 'takerFee', exchangeFee);
475
- makerFee = Precise["default"].stringDiv(makerFee, '100');
476
- takerFee = Precise["default"].stringDiv(takerFee, '100');
477
- const filters = this.safeValue(market, 'filters', []);
478
- const filtersByType = this.indexBy(filters, 'filterType');
479
- let limitPriceMin = undefined;
480
- let limitPriceMax = undefined;
481
- let precisionPrice = this.safeNumber(market, 'tickSize');
482
- if ('PRICE_FILTER' in filtersByType) {
483
- const filter = this.safeValue(filtersByType, 'PRICE_FILTER', {});
484
- precisionPrice = this.safeNumber(filter, 'tickSize');
485
- // PRICE_FILTER reports zero values for maxPrice
486
- // since they updated filter types in November 2018
487
- // https://github.com/ccxt/ccxt/issues/4286
488
- // therefore limits['price']['max'] doesn't have any meaningful value except undefined
489
- limitPriceMin = this.safeNumber(filter, 'minPrice');
490
- const maxPrice = this.safeString(filter, 'maxPrice');
491
- if ((maxPrice !== undefined) && (Precise["default"].stringGt(maxPrice, '0'))) {
492
- limitPriceMax = maxPrice;
493
- }
494
- }
495
- let precisionAmount = this.parseNumber(this.parsePrecision(this.safeString(market, 'baseAssetPrecision')));
496
- let limitAmount = {
497
- 'min': undefined,
498
- 'max': undefined,
499
- };
500
- if ('LOT_SIZE' in filtersByType) {
501
- const filter = this.safeValue(filtersByType, 'LOT_SIZE', {});
502
- precisionAmount = this.safeNumber(filter, 'stepSize');
503
- limitAmount = {
504
- 'min': this.safeNumber(filter, 'minQty'),
505
- 'max': this.safeNumber(filter, 'maxQty'),
506
- };
507
- }
508
- let limitMarket = {
509
- 'min': undefined,
510
- 'max': undefined,
511
- };
512
- if ('MARKET_LOT_SIZE' in filtersByType) {
513
- const filter = this.safeValue(filtersByType, 'MARKET_LOT_SIZE', {});
514
- limitMarket = {
515
- 'min': this.safeNumber(filter, 'minQty'),
516
- 'max': this.safeNumber(filter, 'maxQty'),
517
- };
518
- }
519
- let costMin = undefined;
520
- if ('MIN_NOTIONAL' in filtersByType) {
521
- const filter = this.safeValue(filtersByType, 'MIN_NOTIONAL', {});
522
- costMin = this.safeNumber(filter, 'minNotional');
523
- }
524
- const isContract = swap || futures;
525
- result.push({
526
- 'id': id,
527
- 'symbol': symbol,
528
- 'base': base,
529
- 'quote': quote,
530
- 'settle': undefined,
531
- 'baseId': baseId,
532
- 'quoteId': quoteId,
533
- 'settleId': undefined,
534
- 'type': type,
535
- 'spot': spot,
536
- 'margin': margin,
537
- 'swap': swap,
538
- 'future': futures,
539
- 'option': false,
540
- 'active': active,
541
- 'contract': isContract,
542
- 'linear': isContract ? true : undefined,
543
- 'inverse': undefined,
544
- 'taker': this.parseNumber(takerFee),
545
- 'maker': this.parseNumber(makerFee),
546
- 'contractSize': undefined,
547
- 'expiry': undefined,
548
- 'expiryDatetime': undefined,
549
- 'strike': undefined,
550
- 'optionType': undefined,
551
- 'precision': {
552
- 'amount': precisionAmount,
553
- 'price': precisionPrice,
554
- },
555
- 'limits': {
556
- 'leverage': {
557
- 'min': undefined,
558
- 'max': undefined,
559
- },
560
- 'amount': limitAmount,
561
- 'market': limitMarket,
562
- 'price': {
563
- 'min': limitPriceMin,
564
- 'max': this.parseNumber(limitPriceMax),
565
- },
566
- 'cost': {
567
- 'min': costMin,
568
- 'max': undefined,
569
- },
570
- },
571
- 'created': undefined,
572
- 'info': market,
573
- });
574
- }
575
- return result;
576
- }
577
- async fetchAccounts(params = {}) {
578
- /**
579
- * @method
580
- * @name currencycom#fetchAccounts
581
- * @description fetch all the accounts associated with a profile
582
- * @param {object} [params] extra parameters specific to the exchange API endpoint
583
- * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
584
- */
585
- const response = await this.privateGetV2Account(params);
586
- //
587
- // {
588
- // "makerCommission": "0.20",
589
- // "takerCommission": "0.20",
590
- // "buyerCommission": "0.20",
591
- // "sellerCommission": "0.20",
592
- // "canTrade": true,
593
- // "canWithdraw": true,
594
- // "canDeposit": true,
595
- // "updateTime": "1645266330",
596
- // "userId": "644722",
597
- // "balances": [
598
- // {
599
- // "accountId": "120702016179403605",
600
- // "collateralCurrency": false,
601
- // "asset": "CAKE",
602
- // "free": "3.1",
603
- // "locked": "0.0",
604
- // "default": false,
605
- // },
606
- // {
607
- // "accountId": "109698017713125316",
608
- // "collateralCurrency": true,
609
- // "asset": "USD",
610
- // "free": "17.58632",
611
- // "locked": "0.0",
612
- // "default": true,
613
- // }
614
- // ]
615
- // }
616
- //
617
- const accounts = this.safeValue(response, 'balances', []);
618
- const result = [];
619
- for (let i = 0; i < accounts.length; i++) {
620
- const account = accounts[i];
621
- const accountId = this.safeString(account, 'accountId'); // must be string, because the numeric value is far too big for integer, and causes bugs
622
- const currencyId = this.safeString(account, 'asset');
623
- const currencyCode = this.safeCurrencyCode(currencyId);
624
- result.push({
625
- 'id': accountId,
626
- 'type': undefined,
627
- 'currency': currencyCode,
628
- 'info': account,
629
- });
630
- }
631
- return result;
632
- }
633
- async fetchTradingFees(params = {}) {
634
- /**
635
- * @method
636
- * @name currencycom#fetchTradingFees
637
- * @description fetch the trading fees for multiple markets
638
- * @param {object} [params] extra parameters specific to the exchange API endpoint
639
- * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
640
- */
641
- await this.loadMarkets();
642
- const response = await this.privateGetV2Account(params);
643
- //
644
- // {
645
- // "makerCommission": "0.20",
646
- // "takerCommission": "0.20",
647
- // "buyerCommission": "0.20",
648
- // "sellerCommission": "0.20",
649
- // "canTrade": true,
650
- // "canWithdraw": true,
651
- // "canDeposit": true,
652
- // "updateTime": "1645738976",
653
- // "userId": "-1924114235",
654
- // "balances": []
655
- // }
656
- //
657
- const makerFee = this.safeNumber(response, 'makerCommission');
658
- const takerFee = this.safeNumber(response, 'takerCommission');
659
- const result = {};
660
- for (let i = 0; i < this.symbols.length; i++) {
661
- const symbol = this.symbols[i];
662
- result[symbol] = {
663
- 'info': response,
664
- 'symbol': symbol,
665
- 'maker': makerFee,
666
- 'taker': takerFee,
667
- 'percentage': true,
668
- 'tierBased': false,
669
- };
670
- }
671
- return result;
672
- }
673
- parseBalance(response, type = undefined) {
674
- //
675
- // {
676
- // "makerCommission":0.20,
677
- // "takerCommission":0.20,
678
- // "buyerCommission":0.20,
679
- // "sellerCommission":0.20,
680
- // "canTrade":true,
681
- // "canWithdraw":true,
682
- // "canDeposit":true,
683
- // "updateTime":1591056268,
684
- // "balances":[
685
- // {
686
- // "accountId":5470306579272368,
687
- // "collateralCurrency":true,
688
- // "asset":"ETH",
689
- // "free":0.0,
690
- // "locked":0.0,
691
- // "default":false,
692
- // },
693
- // ]
694
- // }
695
- //
696
- const result = { 'info': response };
697
- const balances = this.safeValue(response, 'balances', []);
698
- for (let i = 0; i < balances.length; i++) {
699
- const balance = balances[i];
700
- const currencyId = this.safeString(balance, 'asset');
701
- const code = this.safeCurrencyCode(currencyId);
702
- const account = this.account();
703
- account['free'] = this.safeString(balance, 'free');
704
- account['used'] = this.safeString(balance, 'locked');
705
- result[code] = account;
706
- }
707
- return this.safeBalance(result);
708
- }
709
- async fetchBalance(params = {}) {
710
- /**
711
- * @method
712
- * @name currencycom#fetchBalance
713
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
714
- * @param {object} [params] extra parameters specific to the exchange API endpoint
715
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
716
- */
717
- await this.loadMarkets();
718
- const response = await this.privateGetV2Account(params);
719
- //
720
- // {
721
- // "makerCommission": "0.20",
722
- // "takerCommission": "0.20",
723
- // "buyerCommission": "0.20",
724
- // "sellerCommission": "0.20",
725
- // "canTrade": true,
726
- // "canWithdraw": true,
727
- // "canDeposit": true,
728
- // "updateTime": "1645266330",
729
- // "userId": "644722",
730
- // "balances": [
731
- // {
732
- // "accountId": "120702016179403605",
733
- // "collateralCurrency": false,
734
- // "asset": "CAKE",
735
- // "free": "1.784",
736
- // "locked": "0.0",
737
- // "default": false,
738
- // },
739
- // {
740
- // "accountId": "109698017413175316",
741
- // "collateralCurrency": true,
742
- // "asset": "USD",
743
- // "free": "7.58632",
744
- // "locked": "0.0",
745
- // "default": true,
746
- // }
747
- // ]
748
- // }
749
- //
750
- return this.parseBalance(response);
751
- }
752
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
753
- /**
754
- * @method
755
- * @name currencycom#fetchOrderBook
756
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
757
- * @param {string} symbol unified symbol of the market to fetch the order book for
758
- * @param {int} [limit] the maximum amount of order book entries to return
759
- * @param {object} [params] extra parameters specific to the exchange API endpoint
760
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
761
- */
762
- await this.loadMarkets();
763
- const market = this.market(symbol);
764
- const request = {
765
- 'symbol': market['id'],
766
- };
767
- if (limit !== undefined) {
768
- request['limit'] = limit; // default 100, max 1000, valid limits 5, 10, 20, 50, 100, 500, 1000, 5000
769
- }
770
- const response = await this.publicGetV2Depth(this.extend(request, params));
771
- //
772
- // {
773
- // "lastUpdateId":1590999849037,
774
- // "asks":[
775
- // [0.02495,60.0345],
776
- // [0.02496,34.1],
777
- // ...
778
- // ],
779
- // "bids":[
780
- // [0.02487,72.4144854],
781
- // [0.02486,24.043],
782
- // ...
783
- // ]
784
- // }
785
- //
786
- const orderbook = this.parseOrderBook(response, symbol);
787
- orderbook['nonce'] = this.safeInteger(response, 'lastUpdateId');
788
- return orderbook;
789
- }
790
- parseTicker(ticker, market = undefined) {
791
- //
792
- // fetchTicker
793
- //
794
- // {
795
- // "symbol":"ETH/BTC",
796
- // "priceChange":"0.00030",
797
- // "priceChangePercent":"1.21",
798
- // "weightedAvgPrice":"0.02481",
799
- // "prevClosePrice":"0.02447",
800
- // "lastPrice":"0.02477",
801
- // "lastQty":"60.0",
802
- // "bidPrice":"0.02477",
803
- // "askPrice":"0.02484",
804
- // "openPrice":"0.02447",
805
- // "highPrice":"0.02524",
806
- // "lowPrice":"0.02438",
807
- // "volume":"11.97",
808
- // "quoteVolume":"0.298053",
809
- // "openTime":1590969600000,
810
- // "closeTime":1591000072693
811
- // }
812
- //
813
- // fetchTickers
814
- //
815
- // {
816
- // "symbol": "SHIB/USD_LEVERAGE",
817
- // "weightedAvgPrice": "0.000027595",
818
- // "lastPrice": "0.00002737",
819
- // "lastQty": "1.11111111E8",
820
- // "bidPrice": "0.00002737",
821
- // "askPrice": "0.00002782",
822
- // "highPrice": "0.00002896",
823
- // "lowPrice": "0.00002738",
824
- // "volume": "16472160000",
825
- // "quoteVolume": "454796.3376",
826
- // "openTime": "1645187472000",
827
- // "closeTime": "1645273872000",
828
- // }
829
- //
830
- // ws:marketData.subscribe
831
- //
832
- // {
833
- // "symbolName":"TXN",
834
- // "bid":139.85,
835
- // "bidQty":2500,
836
- // "ofr":139.92000000000002,
837
- // "ofrQty":2500,
838
- // "timestamp":1597850971558
839
- // }
840
- //
841
- const timestamp = this.safeInteger2(ticker, 'closeTime', 'timestamp');
842
- const marketId = this.safeString2(ticker, 'symbol', 'symbolName');
843
- market = this.safeMarket(marketId, market, '/');
844
- const last = this.safeString(ticker, 'lastPrice');
845
- return this.safeTicker({
846
- 'symbol': market['symbol'],
847
- 'timestamp': timestamp,
848
- 'datetime': this.iso8601(timestamp),
849
- 'high': this.safeString(ticker, 'highPrice'),
850
- 'low': this.safeString(ticker, 'lowPrice'),
851
- 'bid': this.safeString2(ticker, 'bidPrice', 'bid'),
852
- 'bidVolume': this.safeString(ticker, 'bidQty'),
853
- 'ask': this.safeString2(ticker, 'askPrice', 'ofr'),
854
- 'askVolume': this.safeString(ticker, 'ofrQty'),
855
- 'vwap': this.safeString(ticker, 'weightedAvgPrice'),
856
- 'open': this.safeString(ticker, 'openPrice'),
857
- 'close': last,
858
- 'last': last,
859
- 'previousClose': this.safeString(ticker, 'prevClosePrice'),
860
- 'change': this.safeString(ticker, 'priceChange'),
861
- 'percentage': this.safeString(ticker, 'priceChangePercent'),
862
- 'average': undefined,
863
- 'baseVolume': this.safeString(ticker, 'volume'),
864
- 'quoteVolume': this.safeString(ticker, 'quoteVolume'),
865
- 'info': ticker,
866
- }, market);
867
- }
868
- async fetchTicker(symbol, params = {}) {
869
- /**
870
- * @method
871
- * @name currencycom#fetchTicker
872
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
873
- * @param {string} symbol unified symbol of the market to fetch the ticker for
874
- * @param {object} [params] extra parameters specific to the exchange API endpoint
875
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
876
- */
877
- await this.loadMarkets();
878
- const market = this.market(symbol);
879
- const request = {
880
- 'symbol': market['id'],
881
- };
882
- const response = await this.publicGetV2Ticker24hr(this.extend(request, params));
883
- //
884
- // {
885
- // "symbol":"ETH/BTC",
886
- // "priceChange":"0.00030",
887
- // "priceChangePercent":"1.21",
888
- // "weightedAvgPrice":"0.02481",
889
- // "prevClosePrice":"0.02447",
890
- // "lastPrice":"0.02477",
891
- // "lastQty":"60.0",
892
- // "bidPrice":"0.02477",
893
- // "askPrice":"0.02484",
894
- // "openPrice":"0.02447",
895
- // "highPrice":"0.02524",
896
- // "lowPrice":"0.02438",
897
- // "volume":"11.97",
898
- // "quoteVolume":"0.298053",
899
- // "openTime":1590969600000,
900
- // "closeTime":1591000072693
901
- // }
902
- //
903
- return this.parseTicker(response, market);
904
- }
905
- async fetchTickers(symbols = undefined, params = {}) {
906
- /**
907
- * @method
908
- * @name currencycom#fetchTickers
909
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
910
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
911
- * @param {object} [params] extra parameters specific to the exchange API endpoint
912
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
913
- */
914
- await this.loadMarkets();
915
- const response = await this.publicGetV2Ticker24hr(params);
916
- //
917
- // [
918
- // {
919
- // "symbol": "SHIB/USD_LEVERAGE",
920
- // "weightedAvgPrice": "0.000027595",
921
- // "lastPrice": "0.00002737",
922
- // "lastQty": "1.11111111E8",
923
- // "bidPrice": "0.00002737",
924
- // "askPrice": "0.00002782",
925
- // "highPrice": "0.00002896",
926
- // "lowPrice": "0.00002738",
927
- // "volume": "16472160000",
928
- // "quoteVolume": "454796.3376",
929
- // "openTime": "1645187472000",
930
- // "closeTime": "1645273872000",
931
- // }
932
- // ]
933
- //
934
- return this.parseTickers(response, symbols);
935
- }
936
- parseOHLCV(ohlcv, market = undefined) {
937
- //
938
- // [
939
- // 1590971040000,
940
- // "0.02454",
941
- // "0.02456",
942
- // "0.02452",
943
- // "0.02456",
944
- // 249
945
- // ]
946
- //
947
- return [
948
- this.safeInteger(ohlcv, 0),
949
- this.safeNumber(ohlcv, 1),
950
- this.safeNumber(ohlcv, 2),
951
- this.safeNumber(ohlcv, 3),
952
- this.safeNumber(ohlcv, 4),
953
- this.safeNumber(ohlcv, 5),
954
- ];
955
- }
956
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
957
- /**
958
- * @method
959
- * @name currencycom#fetchOHLCV
960
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
961
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
962
- * @param {string} timeframe the length of time each candle represents
963
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
964
- * @param {int} [limit] the maximum amount of candles to fetch
965
- * @param {object} [params] extra parameters specific to the exchange API endpoint
966
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
967
- */
968
- await this.loadMarkets();
969
- const market = this.market(symbol);
970
- const request = {
971
- 'symbol': market['id'],
972
- 'interval': this.safeString(this.timeframes, timeframe, timeframe),
973
- };
974
- if (since !== undefined) {
975
- request['startTime'] = since;
976
- }
977
- if (limit !== undefined) {
978
- request['limit'] = limit; // default 500, max 1000
979
- }
980
- const response = await this.publicGetV2Klines(this.extend(request, params));
981
- //
982
- // [
983
- // [1590971040000,"0.02454","0.02456","0.02452","0.02456",249],
984
- // [1590971100000,"0.02455","0.02457","0.02452","0.02456",300],
985
- // [1590971160000,"0.02455","0.02456","0.02453","0.02454",286],
986
- // ]
987
- //
988
- return this.parseOHLCVs(response, market, timeframe, since, limit);
989
- }
990
- parseTrade(trade, market = undefined) {
991
- //
992
- // fetchTrades (public aggregate trades)
993
- //
994
- // {
995
- // "a":"1658318071", // Aggregate tradeId
996
- // "p":"0.02476", // Price
997
- // "q":"0.0", // Official doc says: "Quantity (should be ignored)"
998
- // "T":"1591001423382", // Epoch timestamp in MS
999
- // "m":false // Was the buyer the maker
1000
- // }
1001
- //
1002
- // createOrder fills (private)
1003
- //
1004
- // {
1005
- // "price": "9807.05",
1006
- // "qty": "0.01",
1007
- // "commission": "0",
1008
- // "commissionAsset": "dUSD"
1009
- // }
1010
- //
1011
- // fetchMyTrades
1012
- //
1013
- // {
1014
- // "symbol": "DOGE/USD",
1015
- // "id": "116046000",
1016
- // "orderId": "00000000-0000-0000-0000-000006dbb8ad",
1017
- // "price": "0.14094",
1018
- // "qty": "40.0",
1019
- // "commission": "0.01",
1020
- // "commissionAsset": "USD",
1021
- // "time": "1645283022351",
1022
- // "buyer": false,
1023
- // "maker": false,
1024
- // "isBuyer": false,
1025
- // "isMaker": false
1026
- // }
1027
- //
1028
- const timestamp = this.safeInteger2(trade, 'T', 'time');
1029
- const priceString = this.safeString2(trade, 'p', 'price');
1030
- const amountString = this.safeString2(trade, 'q', 'qty');
1031
- const id = this.safeString2(trade, 'a', 'id');
1032
- let side = undefined;
1033
- const orderId = this.safeString(trade, 'orderId');
1034
- let takerOrMaker = undefined;
1035
- if ('m' in trade) {
1036
- side = trade['m'] ? 'sell' : 'buy'; // this is reversed intentionally [TODO: needs reason to be mentioned]
1037
- takerOrMaker = 'taker'; // in public trades, it's always taker
1038
- }
1039
- else if ('isBuyer' in trade) {
1040
- side = (trade['isBuyer']) ? 'buy' : 'sell'; // this is a true side
1041
- takerOrMaker = trade['isMaker'] ? 'maker' : 'taker';
1042
- }
1043
- let fee = undefined;
1044
- if ('commission' in trade) {
1045
- fee = {
1046
- 'cost': this.safeString(trade, 'commission'),
1047
- 'currency': this.safeCurrencyCode(this.safeString(trade, 'commissionAsset')),
1048
- };
1049
- }
1050
- const marketId = this.safeString(trade, 'symbol');
1051
- const symbol = this.safeSymbol(marketId, market);
1052
- return this.safeTrade({
1053
- 'id': id,
1054
- 'order': orderId,
1055
- 'timestamp': timestamp,
1056
- 'datetime': this.iso8601(timestamp),
1057
- 'symbol': symbol,
1058
- 'type': undefined,
1059
- 'takerOrMaker': takerOrMaker,
1060
- 'side': side,
1061
- 'price': priceString,
1062
- 'amount': amountString,
1063
- 'cost': undefined,
1064
- 'fee': fee,
1065
- 'info': trade,
1066
- }, market);
1067
- }
1068
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1069
- /**
1070
- * @method
1071
- * @name currencycom#fetchTrades
1072
- * @description get the list of most recent trades for a particular symbol
1073
- * @param {string} symbol unified symbol of the market to fetch trades for
1074
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
1075
- * @param {int} [limit] the maximum amount of trades to fetch
1076
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1077
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1078
- */
1079
- await this.loadMarkets();
1080
- const market = this.market(symbol);
1081
- const request = {
1082
- 'symbol': market['id'],
1083
- // 'limit': 500, // default 500, max 1000
1084
- };
1085
- if (limit !== undefined) {
1086
- request['limit'] = Math.min(limit, 1000); // default 500, max 1000
1087
- }
1088
- if (since !== undefined) {
1089
- request['startTime'] = since;
1090
- }
1091
- const response = await this.publicGetV2AggTrades(this.extend(request, params));
1092
- //
1093
- // [
1094
- // {
1095
- // "a":"1658318071", // Aggregate tradeId
1096
- // "p":"0.02476", // Price
1097
- // "q":"0.0", // Official doc says: "Quantity (should be ignored)"
1098
- // "T":"1591001423382", // Epoch timestamp in MS
1099
- // "m":false // Was the buyer the maker
1100
- // },
1101
- // ]
1102
- //
1103
- return this.parseTrades(response, market, since, limit);
1104
- }
1105
- parseOrder(order, market = undefined) {
1106
- //
1107
- // createOrder
1108
- //
1109
- // limit
1110
- //
1111
- // {
1112
- // "symbol": "BTC/USD",
1113
- // "orderId": "00000000-0000-0000-0000-000006eacaa0",
1114
- // "transactTime": "1645281669295",
1115
- // "price": "30000.00000000",
1116
- // "origQty": "0.0002", // might not be present for "market" order
1117
- // "executedQty": "0.0", // positive for BUY, negative for SELL. This property might not be present in Leverage markets
1118
- // "margin": 0.1, // present in leverage markets
1119
- // "status": "NEW", // NEW, FILLED, ...
1120
- // "timeInForce": "GTC",
1121
- // "type": "LIMIT", // LIMIT, MARKET
1122
- // "side": "BUY",
1123
- // "fills": [ // this field might not be present if there were no fills
1124
- // {
1125
- // "price": "0.14094",
1126
- // "qty": "40.0",
1127
- // "commission": "0",
1128
- // "commissionAsset": "dUSD",
1129
- // },
1130
- // ],
1131
- // }
1132
- //
1133
- // fetchOrder (fetchOpenOrders is an array same structure, with some extra fields)
1134
- //
1135
- // {
1136
- // "symbol": "BTC/USD_LEVERAGE",
1137
- // "accountId": "123456789012345678",
1138
- // "orderId": "00a01234-0123-54c4-0000-123451234567",
1139
- // "price": "25779.35",
1140
- // "status": "MODIFIED",
1141
- // "type": "LIMIT",
1142
- // "timeInForceType": "GTC",
1143
- // "side": "BUY",
1144
- // "guaranteedStopLoss": false,
1145
- // "trailingStopLoss": false,
1146
- // "margin": "0.05",
1147
- // "takeProfit": "27020.00",
1148
- // "stopLoss": "24500.35",
1149
- // "fills": [], // might not be present
1150
- // "timestamp": "1685958369623", // "time" in "fetchOpenOrders"
1151
- // "expireTime": "1686167960000", // "expireTimestamp" in "fetchOpenOrders"
1152
- // "quantity": "0.00040", // "origQty" in "fetchOpenOrders"
1153
- // "executedQty": "0.0", // present in "fetchOpenOrders"
1154
- // "updateTime": "1685958369542", // present in "fetchOpenOrders"
1155
- // "leverage": true, // present in "fetchOpenOrders"
1156
- // "working": true // present in "fetchOpenOrders"
1157
- // }
1158
- //
1159
- // cancelOrder
1160
- //
1161
- // {
1162
- // "symbol": "DOGE/USD",
1163
- // "orderId": "00000000-0000-0003-0000-000006db714c",
1164
- // "price": "0.13",
1165
- // "origQty": "30.0",
1166
- // "executedQty": "0.0",
1167
- // "status": "CANCELED",
1168
- // "timeInForce": "GTC",
1169
- // "type": "LIMIT",
1170
- // "side": "BUY",
1171
- // }
1172
- //
1173
- const marketId = this.safeString(order, 'symbol');
1174
- const symbol = this.safeSymbol(marketId, market, '/');
1175
- const id = this.safeString(order, 'orderId');
1176
- const price = this.safeString(order, 'price');
1177
- const amount = this.safeString2(order, 'origQty', 'quantity');
1178
- const filledRaw = this.safeString(order, 'executedQty');
1179
- const filled = Precise["default"].stringAbs(filledRaw);
1180
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
1181
- const timeInForce = this.parseOrderTimeInForce(this.safeString2(order, 'timeInForce', 'timeInForceType'));
1182
- const type = this.parseOrderType(this.safeString(order, 'type'));
1183
- const side = this.parseOrderSide(this.safeString(order, 'side'));
1184
- const timestamp = this.safeIntegerN(order, ['time', 'transactTime', 'timestamp']);
1185
- const fills = this.safeValue(order, 'fills');
1186
- return this.safeOrder({
1187
- 'info': order,
1188
- 'id': id,
1189
- 'timestamp': timestamp,
1190
- 'datetime': this.iso8601(timestamp),
1191
- 'lastTradeTimestamp': undefined,
1192
- 'symbol': symbol,
1193
- 'type': type,
1194
- 'timeInForce': timeInForce,
1195
- 'side': side,
1196
- 'price': price,
1197
- 'stopPrice': undefined,
1198
- 'triggerPrice': undefined,
1199
- 'amount': amount,
1200
- 'cost': undefined,
1201
- 'average': undefined,
1202
- 'filled': filled,
1203
- 'remaining': undefined,
1204
- 'status': status,
1205
- 'fee': undefined,
1206
- 'trades': fills,
1207
- }, market);
1208
- }
1209
- parseOrderStatus(status) {
1210
- const statuses = {
1211
- 'NEW': 'open',
1212
- 'CREATED': 'open',
1213
- 'MODIFIED': 'open',
1214
- 'PARTIALLY_FILLED': 'open',
1215
- 'FILLED': 'closed',
1216
- 'CANCELED': 'canceled',
1217
- 'PENDING_CANCEL': 'canceling',
1218
- 'REJECTED': 'rejected',
1219
- 'EXPIRED': 'expired',
1220
- };
1221
- return this.safeString(statuses, status, status);
1222
- }
1223
- parseOrderType(status) {
1224
- const statuses = {
1225
- 'MARKET': 'market',
1226
- 'LIMIT': 'limit',
1227
- 'STOP': 'stop',
1228
- // temporarily we remove custom mappings
1229
- // 'LIMIT_MAKER': '',
1230
- // 'STOP_LOSS': 'stop-loss',
1231
- // 'STOP_LOSS_LIMIT': 'stop-limit',
1232
- // 'TAKE_PROFIT': 'take-profit',
1233
- // 'TAKE_PROFIT_LIMIT': 'take-profit',
1234
- };
1235
- return this.safeString(statuses, status, status);
1236
- }
1237
- parseOrderTimeInForce(status) {
1238
- const statuses = {
1239
- 'GTC': 'GTC',
1240
- 'FOK': 'FOK',
1241
- 'IOC': 'IOC',
1242
- };
1243
- return this.safeString(statuses, status, status);
1244
- }
1245
- parseOrderSide(status) {
1246
- const statuses = {
1247
- 'BUY': 'buy',
1248
- 'SELL': 'sell',
1249
- };
1250
- return this.safeString(statuses, status, status);
1251
- }
1252
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1253
- /**
1254
- * @method
1255
- * @name currencycom#createOrder
1256
- * @description create a trade order
1257
- * @param {string} symbol unified symbol of the market to create an order in
1258
- * @param {string} type 'market' or 'limit'
1259
- * @param {string} side 'buy' or 'sell'
1260
- * @param {float} amount how much of currency you want to trade in units of base currency
1261
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1262
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1263
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1264
- */
1265
- await this.loadMarkets();
1266
- const market = this.market(symbol);
1267
- let accountId = undefined;
1268
- if (market['margin']) {
1269
- accountId = this.safeString(this.options, 'accountId');
1270
- accountId = this.safeString(params, 'accountId', accountId);
1271
- if (accountId === undefined) {
1272
- throw new errors.ArgumentsRequired(this.id + " createOrder() requires an accountId parameter or an exchange.options['accountId'] option for " + market['type'] + ' markets');
1273
- }
1274
- }
1275
- const newOrderRespType = this.safeValue(this.options['newOrderRespType'], type, 'RESULT');
1276
- const request = {
1277
- 'symbol': market['id'],
1278
- 'quantity': this.amountToPrecision(symbol, amount),
1279
- 'type': type.toUpperCase(),
1280
- 'side': side.toUpperCase(),
1281
- 'newOrderRespType': newOrderRespType, // 'RESULT' for full order or 'FULL' for order with fills
1282
- // 'leverage': 1,
1283
- // 'accountId': 5470306579272968, // required for leverage markets
1284
- // 'takeProfit': '123.45',
1285
- // 'stopLoss': '54.321',
1286
- // 'guaranteedStopLoss': '54.321',
1287
- };
1288
- if (type === 'limit') {
1289
- request['price'] = this.priceToPrecision(symbol, price);
1290
- request['timeInForce'] = this.options['defaultTimeInForce'];
1291
- }
1292
- else {
1293
- if (type === 'stop') {
1294
- request['type'] = 'STOP';
1295
- request['price'] = this.priceToPrecision(symbol, price);
1296
- }
1297
- else if (type === 'market') {
1298
- const stopPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
1299
- params = this.omit(params, ['triggerPrice', 'stopPrice']);
1300
- if (stopPrice !== undefined) {
1301
- request['type'] = 'STOP';
1302
- request['price'] = this.priceToPrecision(symbol, stopPrice);
1303
- }
1304
- }
1305
- }
1306
- const response = await this.privatePostV2Order(this.extend(request, params));
1307
- //
1308
- // limit
1309
- //
1310
- // {
1311
- // "symbol": "BTC/USD",
1312
- // "orderId": "00000000-0000-0000-0000-000006eaaaa0",
1313
- // "transactTime": "1645281669295",
1314
- // "price": "30000.00000000",
1315
- // "origQty": "0.0002",
1316
- // "executedQty": "0.0", // positive for BUY, negative for SELL
1317
- // "status": "NEW",
1318
- // "timeInForce": "GTC",
1319
- // "type": "LIMIT",
1320
- // "side": "BUY",
1321
- // }
1322
- //
1323
- // market
1324
- //
1325
- // {
1326
- // "symbol": "DOGE/USD",
1327
- // "orderId": "00000000-0000-0000-0000-000006eab8ad",
1328
- // "transactTime": "1645283022252",
1329
- // "price": "0.14066000",
1330
- // "origQty": "40",
1331
- // "executedQty": "40.0", // positive for BUY, negative for SELL
1332
- // "status": "FILLED",
1333
- // "timeInForce": "FOK",
1334
- // "type": "MARKET",
1335
- // "side": "BUY",
1336
- // "fills": [
1337
- // {
1338
- // "price": "0.14094",
1339
- // "qty": "40.0",
1340
- // "commission": "0",
1341
- // "commissionAsset": "dUSD"
1342
- // }
1343
- // ]
1344
- // }
1345
- //
1346
- return this.parseOrder(response, market);
1347
- }
1348
- async fetchOrder(id, symbol = undefined, params = {}) {
1349
- /**
1350
- * @method
1351
- * @name currencycom#fetchOrder
1352
- * @description fetches information on an order made by the user
1353
- * @see https://apitradedoc.currency.com/swagger-ui.html#/rest-api/getOrderUsingGET
1354
- * @param {string} symbol unified symbol of the market the order was made in
1355
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1356
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1357
- */
1358
- if (symbol === undefined) {
1359
- throw new errors.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
1360
- }
1361
- await this.loadMarkets();
1362
- const market = this.market(symbol);
1363
- const request = {
1364
- 'orderId': id,
1365
- 'symbol': market['id'],
1366
- };
1367
- const response = await this.privateGetV2FetchOrder(this.extend(request, params));
1368
- //
1369
- // {
1370
- // "accountId": "109698017413125316",
1371
- // "orderId": "2810f1c5-0079-54c4-0000-000080421601",
1372
- // "quantity": "20.0",
1373
- // "price": "0.06",
1374
- // "timestamp": "1661157503788",
1375
- // "status": "CREATED",
1376
- // "type": "LIMIT",
1377
- // "timeInForceType": "GTC",
1378
- // "side": "BUY",
1379
- // "margin": "0.1",
1380
- // "fills": [ // might not be present
1381
- // {
1382
- // "price": "0.14094",
1383
- // "qty": "40.0",
1384
- // "commission": "0",
1385
- // "commissionAsset": "dUSD"
1386
- // }
1387
- // ]
1388
- // }
1389
- //
1390
- return this.parseOrder(response);
1391
- }
1392
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1393
- /**
1394
- * @method
1395
- * @name currencycom#fetchOpenOrders
1396
- * @description fetch all unfilled currently open orders
1397
- * @param {string} symbol unified market symbol
1398
- * @param {int} [since] the earliest time in ms to fetch open orders for
1399
- * @param {int} [limit] the maximum number of open orders structures to retrieve
1400
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1401
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1402
- */
1403
- await this.loadMarkets();
1404
- let market = undefined;
1405
- const request = {};
1406
- if (symbol !== undefined) {
1407
- market = this.market(symbol);
1408
- request['symbol'] = market['id'];
1409
- }
1410
- else if (this.options['warnOnFetchOpenOrdersWithoutSymbol']) {
1411
- const symbols = this.symbols;
1412
- const numSymbols = symbols.length;
1413
- const fetchOpenOrdersRateLimit = this.parseToInt(numSymbols / 2);
1414
- throw new errors.ExchangeError(this.id + ' fetchOpenOrders() WARNING: fetching open orders without specifying a symbol is rate-limited to one call per ' + fetchOpenOrdersRateLimit.toString() + ' seconds. Do not call this method frequently to avoid ban. Set ' + this.id + '.options["warnOnFetchOpenOrdersWithoutSymbol"] = false to suppress this warning message.');
1415
- }
1416
- const response = await this.privateGetV2OpenOrders(this.extend(request, params));
1417
- //
1418
- // [
1419
- // {
1420
- // "symbol": "DOGE/USD",
1421
- // "orderId": "00000000-0000-0003-0000-000004bac57a",
1422
- // "price": "0.13",
1423
- // "origQty": "39.0",
1424
- // "executedQty": "0.0", // positive for BUY, negative for SELL
1425
- // "status": "NEW",
1426
- // "timeInForce": "GTC",
1427
- // "type": "LIMIT",
1428
- // "side": "BUY",
1429
- // "time": "1645284216240",
1430
- // "updateTime": "1645284216240",
1431
- // "leverage": false,
1432
- // "working": true
1433
- // },
1434
- // ]
1435
- //
1436
- return this.parseOrders(response, market, since, limit, params);
1437
- }
1438
- async cancelOrder(id, symbol = undefined, params = {}) {
1439
- /**
1440
- * @method
1441
- * @name currencycom#cancelOrder
1442
- * @description cancels an open order
1443
- * @param {string} id order id
1444
- * @param {string} symbol unified symbol of the market the order was made in
1445
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1446
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1447
- */
1448
- if (symbol === undefined) {
1449
- throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
1450
- }
1451
- await this.loadMarkets();
1452
- const market = this.market(symbol);
1453
- const origClientOrderId = this.safeValue(params, 'origClientOrderId');
1454
- const request = {
1455
- 'symbol': market['id'],
1456
- // 'orderId': parseInt (id),
1457
- // 'origClientOrderId': id,
1458
- };
1459
- if (origClientOrderId === undefined) {
1460
- request['orderId'] = id;
1461
- }
1462
- else {
1463
- request['origClientOrderId'] = origClientOrderId;
1464
- }
1465
- const response = await this.privateDeleteV2Order(this.extend(request, params));
1466
- //
1467
- // {
1468
- // "symbol": "DOGE/USD",
1469
- // "orderId": "00000000-0000-0003-0000-000006db764c",
1470
- // "price": "0.13",
1471
- // "origQty": "30.0",
1472
- // "executedQty": "0.0", // positive for BUY, negative for SELL
1473
- // "status": "CANCELED",
1474
- // "timeInForce": "GTC",
1475
- // "type": "LIMIT",
1476
- // "side": "BUY",
1477
- // }
1478
- //
1479
- return this.parseOrder(response, market);
1480
- }
1481
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1482
- /**
1483
- * @method
1484
- * @name currencycom#fetchMyTrades
1485
- * @description fetch all trades made by the user
1486
- * @param {string} symbol unified market symbol
1487
- * @param {int} [since] the earliest time in ms to fetch trades for
1488
- * @param {int} [limit] the maximum number of trades structures to retrieve
1489
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1490
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
1491
- */
1492
- if (symbol === undefined) {
1493
- throw new errors.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
1494
- }
1495
- await this.loadMarkets();
1496
- const market = this.market(symbol);
1497
- const request = {
1498
- 'symbol': market['id'],
1499
- };
1500
- if (limit !== undefined) {
1501
- request['limit'] = limit;
1502
- }
1503
- const response = await this.privateGetV2MyTrades(this.extend(request, params));
1504
- //
1505
- // [
1506
- // {
1507
- // "symbol": "DOGE/USD",
1508
- // "id": "116046000",
1509
- // "orderId": "00000000-0000-0000-0000-000006dbb8ad",
1510
- // "price": "0.14094",
1511
- // "qty": "40.0",
1512
- // "commission": "0.01",
1513
- // "commissionAsset": "USD",
1514
- // "time": "1645283022351",
1515
- // "buyer": false,
1516
- // "maker": false,
1517
- // "isBuyer": false,
1518
- // "isMaker": false
1519
- // },
1520
- // ]
1521
- //
1522
- return this.parseTrades(response, market, since, limit);
1523
- }
1524
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1525
- /**
1526
- * @method
1527
- * @name currencycom#fetchDeposits
1528
- * @description fetch all deposits made to an account
1529
- * @param {string} code unified currency code
1530
- * @param {int} [since] the earliest time in ms to fetch deposits for
1531
- * @param {int} [limit] the maximum number of deposits structures to retrieve
1532
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1533
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1534
- */
1535
- return await this.fetchTransactionsByMethod('privateGetV2Deposits', code, since, limit, params);
1536
- }
1537
- async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1538
- /**
1539
- * @method
1540
- * @name currencycom#fetchWithdrawals
1541
- * @description fetch all withdrawals made from an account
1542
- * @param {string} code unified currency code
1543
- * @param {int} [since] the earliest time in ms to fetch withdrawals for
1544
- * @param {int} [limit] the maximum number of withdrawals structures to retrieve
1545
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1546
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1547
- */
1548
- return await this.fetchTransactionsByMethod('privateGetV2Withdrawals', code, since, limit, params);
1549
- }
1550
- async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1551
- /**
1552
- * @method
1553
- * @name currencycom#fetchDepositsWithdrawals
1554
- * @description fetch history of deposits and withdrawals
1555
- * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
1556
- * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
1557
- * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
1558
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1559
- * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
1560
- */
1561
- return await this.fetchTransactionsByMethod('privateGetV2Transactions', code, since, limit, params);
1562
- }
1563
- async fetchTransactionsByMethod(method, code = undefined, since = undefined, limit = undefined, params = {}) {
1564
- await this.loadMarkets();
1565
- const request = {};
1566
- let currency = undefined;
1567
- if (code !== undefined) {
1568
- currency = this.currency(code);
1569
- }
1570
- if (since !== undefined) {
1571
- request['startTime'] = since;
1572
- }
1573
- if (limit !== undefined) {
1574
- request['limit'] = limit;
1575
- }
1576
- let response = undefined;
1577
- if (method === 'privateGetV2Deposits') {
1578
- response = await this.privateGetV2Deposits(this.extend(request, params));
1579
- }
1580
- else if (method === 'privateGetV2Withdrawals') {
1581
- response = await this.privateGetV2Withdrawals(this.extend(request, params));
1582
- }
1583
- else if (method === 'privateGetV2Transactions') {
1584
- response = await this.privateGetV2Transactions(this.extend(request, params));
1585
- }
1586
- else {
1587
- throw new errors.NotSupported(this.id + ' fetchTransactionsByMethod() not support this method');
1588
- }
1589
- //
1590
- // [
1591
- // {
1592
- // "id": "616769213",
1593
- // "balance": "2.088",
1594
- // "amount": "1.304", // negative for 'withdrawal'
1595
- // "currency": "CAKE",
1596
- // "type": "deposit",
1597
- // "timestamp": "1645282121023",
1598
- // "paymentMethod": "BLOCKCHAIN",
1599
- // "blockchainTransactionHash": "0x57c68c1f2ae74d5eda5a2a00516361d241a5c9e1ee95bf32573523857c38c112",
1600
- // "status": "PROCESSED",
1601
- // "commission": "0.14", // this property only exists in withdrawal
1602
- // },
1603
- // ]
1604
- //
1605
- return this.parseTransactions(response, currency, since, limit, params);
1606
- }
1607
- parseTransaction(transaction, currency = undefined) {
1608
- //
1609
- // {
1610
- // "id": "616769213",
1611
- // "balance": "2.088",
1612
- // "amount": "1.304", // negative for 'withdrawal'
1613
- // "currency": "CAKE",
1614
- // "type": "deposit",
1615
- // "timestamp": "1645282121023",
1616
- // "paymentMethod": "BLOCKCHAIN",
1617
- // "blockchainTransactionHash": "0x57c68c1f2ae74d5eda5a2a00516361d241a5c9e1ee95bf32573523857c38c112",
1618
- // "status": "PROCESSED",
1619
- // "commission": "0.14", // this property only exists in withdrawal
1620
- // }
1621
- //
1622
- const timestamp = this.safeInteger(transaction, 'timestamp');
1623
- const currencyId = this.safeString(transaction, 'currency');
1624
- const code = this.safeCurrencyCode(currencyId, currency);
1625
- const feeCost = this.safeString(transaction, 'commission');
1626
- const fee = {
1627
- 'currency': undefined,
1628
- 'cost': undefined,
1629
- 'rate': undefined,
1630
- };
1631
- if (feeCost !== undefined) {
1632
- fee['currency'] = code;
1633
- fee['cost'] = feeCost;
1634
- }
1635
- return {
1636
- 'info': transaction,
1637
- 'id': this.safeString(transaction, 'id'),
1638
- 'txid': this.safeString(transaction, 'blockchainTransactionHash'),
1639
- 'type': this.parseTransactionType(this.safeString(transaction, 'type')),
1640
- 'currency': code,
1641
- 'network': undefined,
1642
- 'amount': this.safeNumber(transaction, 'amount'),
1643
- 'status': this.parseTransactionStatus(this.safeString(transaction, 'state')),
1644
- 'timestamp': timestamp,
1645
- 'datetime': this.iso8601(timestamp),
1646
- 'address': undefined,
1647
- 'addressFrom': undefined,
1648
- 'addressTo': undefined,
1649
- 'tag': undefined,
1650
- 'tagFrom': undefined,
1651
- 'tagTo': undefined,
1652
- 'updated': undefined,
1653
- 'internal': undefined,
1654
- 'comment': undefined,
1655
- 'fee': fee,
1656
- };
1657
- }
1658
- parseTransactionStatus(status) {
1659
- const statuses = {
1660
- 'APPROVAL': 'pending',
1661
- 'PROCESSED': 'ok',
1662
- };
1663
- return this.safeString(statuses, status, status);
1664
- }
1665
- parseTransactionType(type) {
1666
- const types = {
1667
- 'deposit': 'deposit',
1668
- 'withdrawal': 'withdrawal',
1669
- };
1670
- return this.safeString(types, type, type);
1671
- }
1672
- async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
1673
- /**
1674
- * @method
1675
- * @name currencycom#fetchLedger
1676
- * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
1677
- * @param {string} code unified currency code, default is undefined
1678
- * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
1679
- * @param {int} [limit] max number of ledger entrys to return, default is undefined
1680
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1681
- * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/#/?id=ledger-structure}
1682
- */
1683
- await this.loadMarkets();
1684
- const request = {};
1685
- let currency = undefined;
1686
- if (code !== undefined) {
1687
- currency = this.currency(code);
1688
- }
1689
- if (since !== undefined) {
1690
- request['startTime'] = since;
1691
- }
1692
- if (limit !== undefined) {
1693
- request['limit'] = limit;
1694
- }
1695
- const response = await this.privateGetV2Ledger(this.extend(request, params));
1696
- // in the below example, first item expresses withdrawal/deposit type, second example expresses trade
1697
- //
1698
- // [
1699
- // {
1700
- // "id": "619031398",
1701
- // "balance": "0.0",
1702
- // "amount": "-1.088",
1703
- // "currency": "CAKE",
1704
- // "type": "withdrawal",
1705
- // "timestamp": "1645460496425",
1706
- // "commission": "0.13",
1707
- // "paymentMethod": "BLOCKCHAIN", // present in withdrawal/deposit
1708
- // "blockchainTransactionHash": "0x400ac905557c3d34638b1c60eba110b3ee0f97f4eb0f7318015ab76e7f16b7d6", // present in withdrawal/deposit
1709
- // "status": "PROCESSED"
1710
- // },
1711
- // {
1712
- // "id": "619031034",
1713
- // "balance": "8.17223588",
1714
- // "amount": "-0.01326294",
1715
- // "currency": "USD",
1716
- // "type": "exchange_commission",
1717
- // "timestamp": "1645460461235",
1718
- // "commission": "0.01326294",
1719
- // "status": "PROCESSED"
1720
- // },
1721
- // ]
1722
- //
1723
- return this.parseLedger(response, currency, since, limit);
1724
- }
1725
- parseLedgerEntry(item, currency = undefined) {
1726
- const id = this.safeString(item, 'id');
1727
- const amountString = this.safeString(item, 'amount');
1728
- const amount = Precise["default"].stringAbs(amountString);
1729
- const timestamp = this.safeInteger(item, 'timestamp');
1730
- const currencyId = this.safeString(item, 'currency');
1731
- const code = this.safeCurrencyCode(currencyId, currency);
1732
- const feeCost = this.safeString(item, 'commission');
1733
- let fee = undefined;
1734
- if (feeCost !== undefined) {
1735
- fee = { 'currency': code, 'cost': feeCost };
1736
- }
1737
- const direction = Precise["default"].stringLt(amountString, '0') ? 'out' : 'in';
1738
- const result = {
1739
- 'id': id,
1740
- 'timestamp': timestamp,
1741
- 'datetime': this.iso8601(timestamp),
1742
- 'direction': direction,
1743
- 'account': undefined,
1744
- 'referenceId': this.safeString(item, 'blockchainTransactionHash'),
1745
- 'referenceAccount': undefined,
1746
- 'type': this.parseLedgerEntryType(this.safeString(item, 'type')),
1747
- 'currency': code,
1748
- 'amount': amount,
1749
- 'before': undefined,
1750
- 'after': this.safeString(item, 'balance'),
1751
- 'status': this.parseLedgerEntryStatus(this.safeString(item, 'status')),
1752
- 'fee': fee,
1753
- 'info': item,
1754
- };
1755
- return result;
1756
- }
1757
- parseLedgerEntryStatus(status) {
1758
- const statuses = {
1759
- 'APPROVAL': 'pending',
1760
- 'PROCESSED': 'ok',
1761
- 'CANCELLED': 'canceled',
1762
- };
1763
- return this.safeString(statuses, status, status);
1764
- }
1765
- parseLedgerEntryType(type) {
1766
- const types = {
1767
- 'deposit': 'transaction',
1768
- 'withdrawal': 'transaction',
1769
- 'exchange_commission': 'fee',
1770
- };
1771
- return this.safeString(types, type, type);
1772
- }
1773
- async fetchLeverage(symbol, params = {}) {
1774
- /**
1775
- * @method
1776
- * @name currencycom#fetchLeverage
1777
- * @description fetch the set leverage for a market
1778
- * @param {string} symbol unified market symbol
1779
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1780
- * @returns {object} a [leverage structure]{@link https://docs.ccxt.com/#/?id=leverage-structure}
1781
- */
1782
- await this.loadMarkets();
1783
- const market = this.market(symbol);
1784
- const request = {
1785
- 'symbol': market['id'],
1786
- };
1787
- const response = await this.privateGetV2LeverageSettings(this.extend(request, params));
1788
- //
1789
- // {
1790
- // "values": [ 1, 2, 5, 10, ],
1791
- // "value": "10",
1792
- // }
1793
- //
1794
- return this.safeNumber(response, 'value');
1795
- }
1796
- async fetchDepositAddress(code, params = {}) {
1797
- /**
1798
- * @method
1799
- * @name currencycom#fetchDepositAddress
1800
- * @description fetch the deposit address for a currency associated with this account
1801
- * @param {string} code unified currency code
1802
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1803
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
1804
- */
1805
- await this.loadMarkets();
1806
- const currency = this.currency(code);
1807
- const request = {
1808
- 'coin': currency['id'],
1809
- };
1810
- const response = await this.privateGetV2DepositAddress(this.extend(request, params));
1811
- //
1812
- // { "address":"0x97d64eb014ac779194991e7264f01c74c90327f0" }
1813
- //
1814
- return this.parseDepositAddress(response, currency);
1815
- }
1816
- parseDepositAddress(depositAddress, currency = undefined) {
1817
- const address = this.safeString(depositAddress, 'address');
1818
- this.checkAddress(address);
1819
- currency = this.safeCurrency(undefined, currency);
1820
- return {
1821
- 'currency': currency['code'],
1822
- 'address': address,
1823
- 'tag': undefined,
1824
- 'network': undefined,
1825
- 'info': depositAddress,
1826
- };
1827
- }
1828
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1829
- let url = this.urls['api'][api] + '/' + path;
1830
- if (path === 'historicalTrades') {
1831
- headers = {
1832
- 'X-MBX-APIKEY': this.apiKey,
1833
- };
1834
- }
1835
- if (api === 'private') {
1836
- this.checkRequiredCredentials();
1837
- let query = this.urlencode(this.extend({
1838
- 'timestamp': this.nonce(),
1839
- 'recvWindow': this.options['recvWindow'],
1840
- }, params));
1841
- const signature = this.hmac(this.encode(query), this.encode(this.secret), sha256.sha256);
1842
- query += '&' + 'signature=' + signature;
1843
- headers = {
1844
- 'X-MBX-APIKEY': this.apiKey,
1845
- };
1846
- if ((method === 'GET') || (method === 'DELETE')) {
1847
- url += '?' + query;
1848
- }
1849
- else {
1850
- body = query;
1851
- headers['Content-Type'] = 'application/x-www-form-urlencoded';
1852
- }
1853
- }
1854
- else {
1855
- if (Object.keys(params).length) {
1856
- url += '?' + this.urlencode(params);
1857
- }
1858
- }
1859
- url = this.implodeHostname(url);
1860
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1861
- }
1862
- async fetchPositions(symbols = undefined, params = {}) {
1863
- /**
1864
- * @method
1865
- * @name currencycom#fetchPositions
1866
- * @description fetch all open positions
1867
- * @param {string[]|undefined} symbols list of unified market symbols
1868
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1869
- * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
1870
- */
1871
- await this.loadMarkets();
1872
- const response = await this.privateGetV2TradingPositions(params);
1873
- //
1874
- // {
1875
- // "positions": [
1876
- // {
1877
- // "accountId": "109698017416453793",
1878
- // "id": "00a18490-0079-54c4-0000-0000803e73d3",
1879
- // "instrumentId": "45463225268524228",
1880
- // "orderId": "00a18490-0079-54c4-0000-0000803e73d2",
1881
- // "openQuantity": "13.6",
1882
- // "openPrice": "0.75724",
1883
- // "closeQuantity": "0.0",
1884
- // "closePrice": "0",
1885
- // "rpl": "-0.007723848",
1886
- // "rplConverted": "0",
1887
- // "upl": "-0.006664",
1888
- // "uplConverted": "-0.006664",
1889
- // "swap": "0",
1890
- // "swapConverted": "0",
1891
- // "fee": "-0.007723848",
1892
- // "dividend": "0",
1893
- // "margin": "0.2",
1894
- // "state": "ACTIVE",
1895
- // "currency": "USD",
1896
- // "createdTimestamp": "1645473877236",
1897
- // "openTimestamp": "1645473877193",
1898
- // "type": "NET",
1899
- // "cost": "2.0583600",
1900
- // "symbol": "XRP/USD_LEVERAGE"
1901
- // }
1902
- // ]
1903
- // }
1904
- //
1905
- const data = this.safeValue(response, 'positions', []);
1906
- return this.parsePositions(data, symbols);
1907
- }
1908
- parsePosition(position, market = undefined) {
1909
- //
1910
- // {
1911
- // "accountId": "109698017416453793",
1912
- // "id": "00a18490-0079-54c4-0000-0000803e73d3",
1913
- // "instrumentId": "45463225268524228",
1914
- // "orderId": "00a18490-0079-54c4-0000-0000803e73d2",
1915
- // "openQuantity": "13.6",
1916
- // "openPrice": "0.75724",
1917
- // "closeQuantity": "0.0",
1918
- // "closePrice": "0",
1919
- // "rpl": "-0.007723848",
1920
- // "rplConverted": "0",
1921
- // "upl": "-0.006664",
1922
- // "uplConverted": "-0.006664",
1923
- // "swap": "0",
1924
- // "swapConverted": "0",
1925
- // "fee": "-0.007723848",
1926
- // "dividend": "0",
1927
- // "margin": "0.2",
1928
- // "state": "ACTIVE",
1929
- // "currency": "USD",
1930
- // "createdTimestamp": "1645473877236",
1931
- // "openTimestamp": "1645473877193",
1932
- // "type": "NET",
1933
- // "cost": "2.0583600",
1934
- // "symbol": "XRP/USD_LEVERAGE"
1935
- // }
1936
- //
1937
- market = this.safeMarket(this.safeString(position, 'symbol'), market);
1938
- const symbol = market['symbol'];
1939
- const timestamp = this.safeNumber(position, 'createdTimestamp');
1940
- const quantityRaw = this.safeString(position, 'openQuantity');
1941
- const side = Precise["default"].stringGt(quantityRaw, '0') ? 'long' : 'short';
1942
- const quantity = Precise["default"].stringAbs(quantityRaw);
1943
- const entryPrice = this.safeNumber(position, 'openPrice');
1944
- const unrealizedProfit = this.safeNumber(position, 'upl');
1945
- const marginCoeff = this.safeString(position, 'margin');
1946
- const leverage = Precise["default"].stringDiv('1', marginCoeff);
1947
- return this.safePosition({
1948
- 'info': position,
1949
- 'symbol': symbol,
1950
- 'timestamp': timestamp,
1951
- 'datetime': this.iso8601(timestamp),
1952
- 'lastUpdateTimestamp': undefined,
1953
- 'contracts': this.parseNumber(quantity),
1954
- 'contractSize': undefined,
1955
- 'entryPrice': entryPrice,
1956
- 'collateral': undefined,
1957
- 'side': side,
1958
- // 'realizedProfit': this.safeNumber (position, 'rpl'),
1959
- 'unrealizedProfit': unrealizedProfit,
1960
- 'leverage': leverage,
1961
- 'percentage': undefined,
1962
- 'marginMode': undefined,
1963
- 'notional': undefined,
1964
- 'markPrice': undefined,
1965
- 'lastPrice': undefined,
1966
- 'liquidationPrice': undefined,
1967
- 'initialMargin': undefined,
1968
- 'initialMarginPercentage': undefined,
1969
- 'maintenanceMargin': this.parseNumber(marginCoeff),
1970
- 'maintenanceMarginPercentage': undefined,
1971
- 'marginRatio': undefined,
1972
- 'id': undefined,
1973
- 'unrealizedPnl': undefined,
1974
- 'hedged': undefined,
1975
- 'stopLossPrice': undefined,
1976
- 'takeProfitPrice': undefined,
1977
- });
1978
- }
1979
- handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1980
- if ((httpCode === 418) || (httpCode === 429)) {
1981
- throw new errors.DDoSProtection(this.id + ' ' + httpCode.toString() + ' ' + reason + ' ' + body);
1982
- }
1983
- // error response in a form: { "code": -1013, "msg": "Invalid quantity." }
1984
- // following block cointains legacy checks against message patterns in "msg" property
1985
- // will switch "code" checks eventually, when we know all of them
1986
- if (httpCode >= 400) {
1987
- if (body.indexOf('Price * QTY is zero or less') >= 0) {
1988
- throw new errors.InvalidOrder(this.id + ' order cost = amount * price is zero or less ' + body);
1989
- }
1990
- if (body.indexOf('LOT_SIZE') >= 0) {
1991
- throw new errors.InvalidOrder(this.id + ' order amount should be evenly divisible by lot size ' + body);
1992
- }
1993
- if (body.indexOf('PRICE_FILTER') >= 0) {
1994
- throw new errors.InvalidOrder(this.id + ' order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid float value in general, use this.priceToPrecision (symbol, amount) ' + body);
1995
- }
1996
- }
1997
- if (response === undefined) {
1998
- return undefined; // fallback to default error handler
1999
- }
2000
- //
2001
- // {"code":-1128,"msg":"Combination of optional parameters invalid."}
2002
- //
2003
- const errorCode = this.safeString(response, 'code');
2004
- if ((errorCode !== undefined) && (errorCode !== '0')) {
2005
- const feedback = this.id + ' ' + this.json(response);
2006
- this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
2007
- const message = this.safeString(response, 'msg');
2008
- this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
2009
- throw new errors.ExchangeError(feedback);
2010
- }
2011
- return undefined;
2012
- }
2013
- }
2014
-
2015
- module.exports = currencycom;