ccxt 4.2.18 → 4.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (426) hide show
  1. package/README.md +8 -8
  2. package/dist/ccxt.browser.js +34202 -33193
  3. package/dist/ccxt.browser.min.js +2 -2
  4. package/dist/cjs/ccxt.js +12 -1
  5. package/dist/cjs/src/alpaca.js +18 -18
  6. package/dist/cjs/src/ascendex.js +13 -6
  7. package/dist/cjs/src/base/Exchange.js +266 -27
  8. package/dist/cjs/src/bigone.js +434 -168
  9. package/dist/cjs/src/binance.js +163 -34
  10. package/dist/cjs/src/binanceus.js +8 -0
  11. package/dist/cjs/src/bingx.js +183 -41
  12. package/dist/cjs/src/bitfinex.js +2 -3
  13. package/dist/cjs/src/bitget.js +59 -16
  14. package/dist/cjs/src/bitmart.js +5 -5
  15. package/dist/cjs/src/bitmex.js +4 -6
  16. package/dist/cjs/src/bitpanda.js +5 -1991
  17. package/dist/cjs/src/bitstamp.js +8 -0
  18. package/dist/cjs/src/bybit.js +27 -47
  19. package/dist/cjs/src/coinbase.js +176 -26
  20. package/dist/cjs/src/coincheck.js +1 -0
  21. package/dist/cjs/src/coinex.js +3 -0
  22. package/dist/cjs/src/coinlist.js +13 -6
  23. package/dist/cjs/src/coinone.js +2 -2
  24. package/dist/cjs/src/coinsph.js +4 -5
  25. package/dist/cjs/src/delta.js +7 -1
  26. package/dist/cjs/src/deribit.js +17 -4
  27. package/dist/cjs/src/gate.js +151 -169
  28. package/dist/cjs/src/gemini.js +1 -1
  29. package/dist/cjs/src/hitbtc.js +2 -3
  30. package/dist/cjs/src/htx.js +157 -7
  31. package/dist/cjs/src/huobijp.js +2 -3
  32. package/dist/cjs/src/independentreserve.js +7 -5
  33. package/dist/cjs/src/kraken.js +86 -54
  34. package/dist/cjs/src/kucoin.js +5 -0
  35. package/dist/cjs/src/kucoinfutures.js +131 -77
  36. package/dist/cjs/src/lbank.js +60 -33
  37. package/dist/cjs/src/luno.js +84 -2
  38. package/dist/cjs/src/mexc.js +3 -3
  39. package/dist/cjs/src/oceanex.js +1 -1
  40. package/dist/cjs/src/okx.js +23 -11
  41. package/dist/cjs/{js/src/bitpanda.js → src/onetrading.js} +39 -39
  42. package/dist/cjs/src/phemex.js +37 -27
  43. package/dist/cjs/src/poloniexfutures.js +1 -0
  44. package/dist/cjs/src/pro/binance.js +66 -25
  45. package/dist/cjs/src/pro/bitget.js +1 -1
  46. package/dist/cjs/src/pro/bitpanda.js +5 -1330
  47. package/dist/cjs/src/pro/coinbase.js +4 -1
  48. package/dist/cjs/src/pro/hitbtc.js +5 -4
  49. package/dist/cjs/src/pro/htx.js +6 -1
  50. package/dist/cjs/src/pro/kraken.js +1 -1
  51. package/dist/cjs/src/pro/krakenfutures.js +7 -1
  52. package/dist/cjs/src/pro/kucoin.js +46 -36
  53. package/dist/cjs/src/pro/kucoinfutures.js +45 -37
  54. package/dist/cjs/src/pro/lbank.js +881 -0
  55. package/dist/cjs/src/pro/okx.js +52 -2
  56. package/dist/cjs/{js/src/pro/bitpanda.js → src/pro/onetrading.js} +4 -7
  57. package/dist/cjs/src/pro/poloniex.js +2 -2
  58. package/dist/cjs/src/pro/poloniexfutures.js +43 -35
  59. package/dist/cjs/src/pro/woo.js +126 -0
  60. package/dist/cjs/src/probit.js +4 -2
  61. package/dist/cjs/src/upbit.js +12 -12
  62. package/dist/cjs/src/wavesexchange.js +1 -1
  63. package/dist/cjs/src/whitebit.js +1 -0
  64. package/dist/cjs/src/woo.js +56 -0
  65. package/js/ccxt.d.ts +11 -2
  66. package/js/ccxt.js +8 -2
  67. package/js/src/abstract/bitpanda.d.ts +4 -4
  68. package/js/src/abstract/bitstamp.d.ts +8 -0
  69. package/js/src/abstract/gate.d.ts +1 -0
  70. package/js/src/abstract/gateio.d.ts +1 -0
  71. package/js/src/abstract/htx.d.ts +3 -0
  72. package/js/src/abstract/huobi.d.ts +3 -0
  73. package/js/src/abstract/luno.d.ts +1 -0
  74. package/js/src/abstract/onetrading.d.ts +38 -0
  75. package/js/src/ascendex.js +2 -0
  76. package/js/src/bingx.js +1 -1
  77. package/js/src/bitget.js +22 -3
  78. package/js/src/bitpanda.d.ts +2 -72
  79. package/js/src/bitpanda.js +5 -1991
  80. package/js/src/bitstamp.js +8 -0
  81. package/js/src/deribit.js +11 -3
  82. package/js/src/gate.d.ts +1 -0
  83. package/js/src/gate.js +50 -110
  84. package/js/src/htx.js +3 -0
  85. package/js/src/kraken.d.ts +1 -0
  86. package/js/src/kraken.js +39 -38
  87. package/js/src/lbank.js +1 -0
  88. package/js/src/luno.d.ts +3 -1
  89. package/js/src/luno.js +84 -2
  90. package/js/src/mexc.js +1 -2
  91. package/js/src/onetrading.d.ts +74 -0
  92. package/js/src/onetrading.js +2003 -0
  93. package/js/src/poloniexfutures.js +1 -0
  94. package/js/src/pro/binance.js +6 -1
  95. package/js/src/pro/bitpanda.d.ts +2 -34
  96. package/js/src/pro/bitpanda.js +5 -1330
  97. package/js/src/pro/lbank.d.ts +29 -0
  98. package/js/src/pro/lbank.js +882 -0
  99. package/js/src/pro/onetrading.d.ts +36 -0
  100. package/js/src/pro/onetrading.js +1339 -0
  101. package/package.json +2 -2
  102. package/rollup.config.js +2 -0
  103. package/skip-tests.json +2 -1
  104. package/test-commonjs.cjs +25 -1
  105. package/dist/cjs/js/ccxt.js +0 -478
  106. package/dist/cjs/js/src/abstract/alpaca.js +0 -9
  107. package/dist/cjs/js/src/abstract/ascendex.js +0 -9
  108. package/dist/cjs/js/src/abstract/bigone.js +0 -9
  109. package/dist/cjs/js/src/abstract/binance.js +0 -9
  110. package/dist/cjs/js/src/abstract/bingx.js +0 -9
  111. package/dist/cjs/js/src/abstract/bit2c.js +0 -9
  112. package/dist/cjs/js/src/abstract/bitbank.js +0 -9
  113. package/dist/cjs/js/src/abstract/bitbns.js +0 -9
  114. package/dist/cjs/js/src/abstract/bitfinex.js +0 -9
  115. package/dist/cjs/js/src/abstract/bitfinex2.js +0 -9
  116. package/dist/cjs/js/src/abstract/bitflyer.js +0 -9
  117. package/dist/cjs/js/src/abstract/bitforex.js +0 -9
  118. package/dist/cjs/js/src/abstract/bitget.js +0 -9
  119. package/dist/cjs/js/src/abstract/bithumb.js +0 -9
  120. package/dist/cjs/js/src/abstract/bitmart.js +0 -9
  121. package/dist/cjs/js/src/abstract/bitmex.js +0 -9
  122. package/dist/cjs/js/src/abstract/bitopro.js +0 -9
  123. package/dist/cjs/js/src/abstract/bitpanda.js +0 -9
  124. package/dist/cjs/js/src/abstract/bitrue.js +0 -9
  125. package/dist/cjs/js/src/abstract/bitso.js +0 -9
  126. package/dist/cjs/js/src/abstract/bitstamp.js +0 -9
  127. package/dist/cjs/js/src/abstract/bitteam.js +0 -9
  128. package/dist/cjs/js/src/abstract/bitvavo.js +0 -9
  129. package/dist/cjs/js/src/abstract/bl3p.js +0 -9
  130. package/dist/cjs/js/src/abstract/blockchaincom.js +0 -9
  131. package/dist/cjs/js/src/abstract/btcalpha.js +0 -9
  132. package/dist/cjs/js/src/abstract/btcbox.js +0 -9
  133. package/dist/cjs/js/src/abstract/btcmarkets.js +0 -9
  134. package/dist/cjs/js/src/abstract/btcturk.js +0 -9
  135. package/dist/cjs/js/src/abstract/bybit.js +0 -9
  136. package/dist/cjs/js/src/abstract/cex.js +0 -9
  137. package/dist/cjs/js/src/abstract/coinbase.js +0 -9
  138. package/dist/cjs/js/src/abstract/coinbasepro.js +0 -9
  139. package/dist/cjs/js/src/abstract/coincheck.js +0 -9
  140. package/dist/cjs/js/src/abstract/coinex.js +0 -9
  141. package/dist/cjs/js/src/abstract/coinlist.js +0 -9
  142. package/dist/cjs/js/src/abstract/coinmate.js +0 -9
  143. package/dist/cjs/js/src/abstract/coinone.js +0 -9
  144. package/dist/cjs/js/src/abstract/coinsph.js +0 -9
  145. package/dist/cjs/js/src/abstract/coinspot.js +0 -9
  146. package/dist/cjs/js/src/abstract/cryptocom.js +0 -9
  147. package/dist/cjs/js/src/abstract/currencycom.js +0 -9
  148. package/dist/cjs/js/src/abstract/delta.js +0 -9
  149. package/dist/cjs/js/src/abstract/deribit.js +0 -9
  150. package/dist/cjs/js/src/abstract/digifinex.js +0 -9
  151. package/dist/cjs/js/src/abstract/exmo.js +0 -9
  152. package/dist/cjs/js/src/abstract/gate.js +0 -9
  153. package/dist/cjs/js/src/abstract/gemini.js +0 -9
  154. package/dist/cjs/js/src/abstract/hitbtc.js +0 -9
  155. package/dist/cjs/js/src/abstract/hollaex.js +0 -9
  156. package/dist/cjs/js/src/abstract/htx.js +0 -9
  157. package/dist/cjs/js/src/abstract/huobijp.js +0 -9
  158. package/dist/cjs/js/src/abstract/idex.js +0 -9
  159. package/dist/cjs/js/src/abstract/independentreserve.js +0 -9
  160. package/dist/cjs/js/src/abstract/indodax.js +0 -9
  161. package/dist/cjs/js/src/abstract/kraken.js +0 -9
  162. package/dist/cjs/js/src/abstract/krakenfutures.js +0 -9
  163. package/dist/cjs/js/src/abstract/kucoin.js +0 -9
  164. package/dist/cjs/js/src/abstract/kucoinfutures.js +0 -9
  165. package/dist/cjs/js/src/abstract/kuna.js +0 -9
  166. package/dist/cjs/js/src/abstract/latoken.js +0 -9
  167. package/dist/cjs/js/src/abstract/lbank.js +0 -9
  168. package/dist/cjs/js/src/abstract/luno.js +0 -9
  169. package/dist/cjs/js/src/abstract/lykke.js +0 -9
  170. package/dist/cjs/js/src/abstract/mercado.js +0 -9
  171. package/dist/cjs/js/src/abstract/mexc.js +0 -9
  172. package/dist/cjs/js/src/abstract/ndax.js +0 -9
  173. package/dist/cjs/js/src/abstract/novadax.js +0 -9
  174. package/dist/cjs/js/src/abstract/oceanex.js +0 -9
  175. package/dist/cjs/js/src/abstract/okcoin.js +0 -9
  176. package/dist/cjs/js/src/abstract/okx.js +0 -9
  177. package/dist/cjs/js/src/abstract/p2b.js +0 -9
  178. package/dist/cjs/js/src/abstract/paymium.js +0 -9
  179. package/dist/cjs/js/src/abstract/phemex.js +0 -9
  180. package/dist/cjs/js/src/abstract/poloniex.js +0 -9
  181. package/dist/cjs/js/src/abstract/poloniexfutures.js +0 -9
  182. package/dist/cjs/js/src/abstract/probit.js +0 -9
  183. package/dist/cjs/js/src/abstract/timex.js +0 -9
  184. package/dist/cjs/js/src/abstract/tokocrypto.js +0 -9
  185. package/dist/cjs/js/src/abstract/upbit.js +0 -9
  186. package/dist/cjs/js/src/abstract/wavesexchange.js +0 -9
  187. package/dist/cjs/js/src/abstract/wazirx.js +0 -9
  188. package/dist/cjs/js/src/abstract/whitebit.js +0 -9
  189. package/dist/cjs/js/src/abstract/woo.js +0 -9
  190. package/dist/cjs/js/src/abstract/yobit.js +0 -9
  191. package/dist/cjs/js/src/abstract/zaif.js +0 -9
  192. package/dist/cjs/js/src/abstract/zonda.js +0 -9
  193. package/dist/cjs/js/src/ace.js +0 -1058
  194. package/dist/cjs/js/src/alpaca.js +0 -1125
  195. package/dist/cjs/js/src/ascendex.js +0 -3365
  196. package/dist/cjs/js/src/base/Exchange.js +0 -5260
  197. package/dist/cjs/js/src/base/Precise.js +0 -263
  198. package/dist/cjs/js/src/base/errors.js +0 -299
  199. package/dist/cjs/js/src/base/functions/crypto.js +0 -78
  200. package/dist/cjs/js/src/base/functions/encode.js +0 -44
  201. package/dist/cjs/js/src/base/functions/generic.js +0 -193
  202. package/dist/cjs/js/src/base/functions/misc.js +0 -96
  203. package/dist/cjs/js/src/base/functions/number.js +0 -297
  204. package/dist/cjs/js/src/base/functions/platform.js +0 -28
  205. package/dist/cjs/js/src/base/functions/rsa.js +0 -34
  206. package/dist/cjs/js/src/base/functions/string.js +0 -48
  207. package/dist/cjs/js/src/base/functions/throttle.js +0 -66
  208. package/dist/cjs/js/src/base/functions/time.js +0 -187
  209. package/dist/cjs/js/src/base/functions/totp.js +0 -24
  210. package/dist/cjs/js/src/base/functions/type.js +0 -162
  211. package/dist/cjs/js/src/base/functions.js +0 -157
  212. package/dist/cjs/js/src/base/ws/Cache.js +0 -254
  213. package/dist/cjs/js/src/base/ws/Client.js +0 -299
  214. package/dist/cjs/js/src/base/ws/Future.js +0 -34
  215. package/dist/cjs/js/src/base/ws/OrderBook.js +0 -107
  216. package/dist/cjs/js/src/base/ws/OrderBookSide.js +0 -281
  217. package/dist/cjs/js/src/base/ws/WsClient.js +0 -69
  218. package/dist/cjs/js/src/bequant.js +0 -33
  219. package/dist/cjs/js/src/bigone.js +0 -2213
  220. package/dist/cjs/js/src/binance.js +0 -9851
  221. package/dist/cjs/js/src/binancecoinm.js +0 -45
  222. package/dist/cjs/js/src/binanceus.js +0 -92
  223. package/dist/cjs/js/src/binanceusdm.js +0 -58
  224. package/dist/cjs/js/src/bingx.js +0 -3872
  225. package/dist/cjs/js/src/bit2c.js +0 -916
  226. package/dist/cjs/js/src/bitbank.js +0 -1000
  227. package/dist/cjs/js/src/bitbay.js +0 -17
  228. package/dist/cjs/js/src/bitbns.js +0 -1220
  229. package/dist/cjs/js/src/bitcoincom.js +0 -17
  230. package/dist/cjs/js/src/bitfinex.js +0 -1670
  231. package/dist/cjs/js/src/bitfinex2.js +0 -2990
  232. package/dist/cjs/js/src/bitflyer.js +0 -1045
  233. package/dist/cjs/js/src/bitforex.js +0 -852
  234. package/dist/cjs/js/src/bitget.js +0 -8295
  235. package/dist/cjs/js/src/bithumb.js +0 -1090
  236. package/dist/cjs/js/src/bitmart.js +0 -4454
  237. package/dist/cjs/js/src/bitmex.js +0 -2881
  238. package/dist/cjs/js/src/bitopro.js +0 -1724
  239. package/dist/cjs/js/src/bitrue.js +0 -3253
  240. package/dist/cjs/js/src/bitso.js +0 -1753
  241. package/dist/cjs/js/src/bitstamp.js +0 -2188
  242. package/dist/cjs/js/src/bitteam.js +0 -2309
  243. package/dist/cjs/js/src/bitvavo.js +0 -1968
  244. package/dist/cjs/js/src/bl3p.js +0 -447
  245. package/dist/cjs/js/src/blockchaincom.js +0 -1160
  246. package/dist/cjs/js/src/btcalpha.js +0 -929
  247. package/dist/cjs/js/src/btcbox.js +0 -565
  248. package/dist/cjs/js/src/btcmarkets.js +0 -1237
  249. package/dist/cjs/js/src/btcturk.js +0 -929
  250. package/dist/cjs/js/src/bybit.js +0 -7624
  251. package/dist/cjs/js/src/cex.js +0 -1693
  252. package/dist/cjs/js/src/coinbase.js +0 -3424
  253. package/dist/cjs/js/src/coinbasepro.js +0 -1866
  254. package/dist/cjs/js/src/coincheck.js +0 -844
  255. package/dist/cjs/js/src/coinex.js +0 -5417
  256. package/dist/cjs/js/src/coinlist.js +0 -2337
  257. package/dist/cjs/js/src/coinmate.js +0 -989
  258. package/dist/cjs/js/src/coinone.js +0 -1185
  259. package/dist/cjs/js/src/coinsph.js +0 -1933
  260. package/dist/cjs/js/src/coinspot.js +0 -548
  261. package/dist/cjs/js/src/cryptocom.js +0 -3007
  262. package/dist/cjs/js/src/currencycom.js +0 -2015
  263. package/dist/cjs/js/src/delta.js +0 -3262
  264. package/dist/cjs/js/src/deribit.js +0 -3310
  265. package/dist/cjs/js/src/digifinex.js +0 -4307
  266. package/dist/cjs/js/src/exmo.js +0 -2645
  267. package/dist/cjs/js/src/fmfwio.js +0 -34
  268. package/dist/cjs/js/src/gate.js +0 -7077
  269. package/dist/cjs/js/src/gateio.js +0 -16
  270. package/dist/cjs/js/src/gemini.js +0 -1801
  271. package/dist/cjs/js/src/hitbtc.js +0 -3660
  272. package/dist/cjs/js/src/hitbtc3.js +0 -19
  273. package/dist/cjs/js/src/hollaex.js +0 -1882
  274. package/dist/cjs/js/src/htx.js +0 -9174
  275. package/dist/cjs/js/src/huobi.js +0 -16
  276. package/dist/cjs/js/src/huobijp.js +0 -1918
  277. package/dist/cjs/js/src/idex.js +0 -1770
  278. package/dist/cjs/js/src/independentreserve.js +0 -761
  279. package/dist/cjs/js/src/indodax.js +0 -1069
  280. package/dist/cjs/js/src/kraken.js +0 -2891
  281. package/dist/cjs/js/src/krakenfutures.js +0 -2407
  282. package/dist/cjs/js/src/kucoin.js +0 -4494
  283. package/dist/cjs/js/src/kucoinfutures.js +0 -2529
  284. package/dist/cjs/js/src/kuna.js +0 -1949
  285. package/dist/cjs/js/src/latoken.js +0 -1729
  286. package/dist/cjs/js/src/lbank.js +0 -2851
  287. package/dist/cjs/js/src/luno.js +0 -1044
  288. package/dist/cjs/js/src/lykke.js +0 -1303
  289. package/dist/cjs/js/src/mercado.js +0 -897
  290. package/dist/cjs/js/src/mexc.js +0 -5407
  291. package/dist/cjs/js/src/ndax.js +0 -2450
  292. package/dist/cjs/js/src/novadax.js +0 -1556
  293. package/dist/cjs/js/src/oceanex.js +0 -964
  294. package/dist/cjs/js/src/okcoin.js +0 -3115
  295. package/dist/cjs/js/src/okx.js +0 -7331
  296. package/dist/cjs/js/src/p2b.js +0 -1243
  297. package/dist/cjs/js/src/paymium.js +0 -597
  298. package/dist/cjs/js/src/phemex.js +0 -4725
  299. package/dist/cjs/js/src/poloniex.js +0 -2356
  300. package/dist/cjs/js/src/poloniexfutures.js +0 -1794
  301. package/dist/cjs/js/src/pro/alpaca.js +0 -714
  302. package/dist/cjs/js/src/pro/ascendex.js +0 -957
  303. package/dist/cjs/js/src/pro/bequant.js +0 -33
  304. package/dist/cjs/js/src/pro/binance.js +0 -2796
  305. package/dist/cjs/js/src/pro/binancecoinm.js +0 -23
  306. package/dist/cjs/js/src/pro/binanceus.js +0 -51
  307. package/dist/cjs/js/src/pro/binanceusdm.js +0 -32
  308. package/dist/cjs/js/src/pro/bingx.js +0 -944
  309. package/dist/cjs/js/src/pro/bitcoincom.js +0 -29
  310. package/dist/cjs/js/src/pro/bitfinex.js +0 -672
  311. package/dist/cjs/js/src/pro/bitfinex2.js +0 -1159
  312. package/dist/cjs/js/src/pro/bitget.js +0 -1733
  313. package/dist/cjs/js/src/pro/bitmart.js +0 -1486
  314. package/dist/cjs/js/src/pro/bitmex.js +0 -1576
  315. package/dist/cjs/js/src/pro/bitopro.js +0 -327
  316. package/dist/cjs/js/src/pro/bitrue.js +0 -462
  317. package/dist/cjs/js/src/pro/bitstamp.js +0 -547
  318. package/dist/cjs/js/src/pro/bitvavo.js +0 -704
  319. package/dist/cjs/js/src/pro/blockchaincom.js +0 -794
  320. package/dist/cjs/js/src/pro/bybit.js +0 -1843
  321. package/dist/cjs/js/src/pro/cex.js +0 -1510
  322. package/dist/cjs/js/src/pro/coinbase.js +0 -561
  323. package/dist/cjs/js/src/pro/coinbasepro.js +0 -968
  324. package/dist/cjs/js/src/pro/coinex.js +0 -1095
  325. package/dist/cjs/js/src/pro/cryptocom.js +0 -1020
  326. package/dist/cjs/js/src/pro/currencycom.js +0 -563
  327. package/dist/cjs/js/src/pro/deribit.js +0 -825
  328. package/dist/cjs/js/src/pro/exmo.js +0 -658
  329. package/dist/cjs/js/src/pro/gate.js +0 -1316
  330. package/dist/cjs/js/src/pro/gateio.js +0 -16
  331. package/dist/cjs/js/src/pro/gemini.js +0 -649
  332. package/dist/cjs/js/src/pro/hitbtc.js +0 -1294
  333. package/dist/cjs/js/src/pro/hollaex.js +0 -597
  334. package/dist/cjs/js/src/pro/htx.js +0 -2388
  335. package/dist/cjs/js/src/pro/huobi.js +0 -16
  336. package/dist/cjs/js/src/pro/huobijp.js +0 -606
  337. package/dist/cjs/js/src/pro/idex.js +0 -714
  338. package/dist/cjs/js/src/pro/independentreserve.js +0 -280
  339. package/dist/cjs/js/src/pro/kraken.js +0 -1364
  340. package/dist/cjs/js/src/pro/krakenfutures.js +0 -1506
  341. package/dist/cjs/js/src/pro/kucoin.js +0 -1062
  342. package/dist/cjs/js/src/pro/kucoinfutures.js +0 -989
  343. package/dist/cjs/js/src/pro/luno.js +0 -322
  344. package/dist/cjs/js/src/pro/mexc.js +0 -1170
  345. package/dist/cjs/js/src/pro/ndax.js +0 -545
  346. package/dist/cjs/js/src/pro/okcoin.js +0 -760
  347. package/dist/cjs/js/src/pro/okx.js +0 -1608
  348. package/dist/cjs/js/src/pro/phemex.js +0 -1511
  349. package/dist/cjs/js/src/pro/poloniex.js +0 -1253
  350. package/dist/cjs/js/src/pro/poloniexfutures.js +0 -1022
  351. package/dist/cjs/js/src/pro/probit.js +0 -586
  352. package/dist/cjs/js/src/pro/upbit.js +0 -234
  353. package/dist/cjs/js/src/pro/wazirx.js +0 -776
  354. package/dist/cjs/js/src/pro/whitebit.js +0 -927
  355. package/dist/cjs/js/src/pro/woo.js +0 -895
  356. package/dist/cjs/js/src/probit.js +0 -1867
  357. package/dist/cjs/js/src/static_dependencies/fflake/browser.js +0 -401
  358. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +0 -195
  359. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +0 -308
  360. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +0 -554
  361. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +0 -94
  362. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +0 -70
  363. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +0 -91
  364. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +0 -16
  365. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +0 -1760
  366. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +0 -52
  367. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +0 -81
  368. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +0 -376
  369. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +0 -70
  370. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +0 -1580
  371. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +0 -74
  372. package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +0 -24
  373. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +0 -158
  374. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +0 -429
  375. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +0 -176
  376. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +0 -324
  377. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +0 -163
  378. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +0 -245
  379. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +0 -1018
  380. package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +0 -383
  381. package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +0 -258
  382. package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +0 -53
  383. package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +0 -120
  384. package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +0 -69
  385. package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +0 -7
  386. package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +0 -83
  387. package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +0 -240
  388. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +0 -91
  389. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +0 -130
  390. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +0 -214
  391. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +0 -239
  392. package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +0 -93
  393. package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +0 -354
  394. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +0 -16
  395. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +0 -20
  396. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +0 -30
  397. package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +0 -239
  398. package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +0 -372
  399. package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +0 -273
  400. package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +0 -139
  401. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +0 -14
  402. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +0 -16
  403. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +0 -81
  404. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +0 -292
  405. package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +0 -103
  406. package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +0 -140
  407. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +0 -175
  408. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +0 -95
  409. package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +0 -7
  410. package/dist/cjs/js/src/static_dependencies/scure-base/index.js +0 -383
  411. package/dist/cjs/js/src/timex.js +0 -1562
  412. package/dist/cjs/js/src/tokocrypto.js +0 -2542
  413. package/dist/cjs/js/src/upbit.js +0 -1844
  414. package/dist/cjs/js/src/wavesexchange.js +0 -2607
  415. package/dist/cjs/js/src/wazirx.js +0 -953
  416. package/dist/cjs/js/src/whitebit.js +0 -2310
  417. package/dist/cjs/js/src/woo.js +0 -2769
  418. package/dist/cjs/js/src/yobit.js +0 -1314
  419. package/dist/cjs/js/src/zaif.js +0 -736
  420. package/dist/cjs/js/src/zonda.js +0 -1883
  421. package/dist/cjs/src/abstract/bitpanda.js +0 -9
  422. package/test.ts +0 -0
  423. /package/dist/cjs/{js/src/abstract/ace.js → src/abstract/onetrading.js} +0 -0
  424. /package/dist/cjs/{js/src → src}/pro/coincheck.js +0 -0
  425. /package/dist/cjs/{js/src → src}/pro/coinone.js +0 -0
  426. /package/js/src/abstract/{bitpanda.js → onetrading.js} +0 -0
@@ -1,3365 +0,0 @@
1
- 'use strict';
2
-
3
- var ascendex$1 = require('./abstract/ascendex.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 ascendex
13
- * @augments Exchange
14
- */
15
- class ascendex extends ascendex$1 {
16
- describe() {
17
- return this.deepExtend(super.describe(), {
18
- 'id': 'ascendex',
19
- 'name': 'AscendEX',
20
- 'countries': ['SG'],
21
- // 8 requests per minute = 0.13333 per second => rateLimit = 750
22
- // testing 400 works
23
- 'rateLimit': 400,
24
- 'certified': false,
25
- 'pro': true,
26
- // new metainfo interface
27
- 'has': {
28
- 'CORS': undefined,
29
- 'spot': true,
30
- 'margin': true,
31
- 'swap': true,
32
- 'future': false,
33
- 'option': false,
34
- 'addMargin': true,
35
- 'cancelAllOrders': true,
36
- 'cancelOrder': true,
37
- 'createOrder': true,
38
- 'createOrders': true,
39
- 'createPostOnlyOrder': true,
40
- 'createReduceOnlyOrder': true,
41
- 'createStopLimitOrder': true,
42
- 'createStopMarketOrder': true,
43
- 'createStopOrder': true,
44
- 'fetchAccounts': true,
45
- 'fetchBalance': true,
46
- 'fetchClosedOrders': true,
47
- 'fetchCurrencies': true,
48
- 'fetchDepositAddress': true,
49
- 'fetchDepositAddresses': false,
50
- 'fetchDepositAddressesByNetwork': false,
51
- 'fetchDeposits': true,
52
- 'fetchDepositsWithdrawals': true,
53
- 'fetchDepositWithdrawFee': 'emulated',
54
- 'fetchDepositWithdrawFees': true,
55
- 'fetchFundingHistory': true,
56
- 'fetchFundingRate': 'emulated',
57
- 'fetchFundingRateHistory': false,
58
- 'fetchFundingRates': true,
59
- 'fetchIndexOHLCV': false,
60
- 'fetchLeverage': false,
61
- 'fetchLeverageTiers': true,
62
- 'fetchMarginMode': false,
63
- 'fetchMarketLeverageTiers': 'emulated',
64
- 'fetchMarkets': true,
65
- 'fetchMarkOHLCV': false,
66
- 'fetchOHLCV': true,
67
- 'fetchOpenOrders': true,
68
- 'fetchOrder': true,
69
- 'fetchOrderBook': true,
70
- 'fetchOrders': false,
71
- 'fetchPosition': false,
72
- 'fetchPositionMode': false,
73
- 'fetchPositions': true,
74
- 'fetchPositionsRisk': false,
75
- 'fetchPremiumIndexOHLCV': false,
76
- 'fetchTicker': true,
77
- 'fetchTickers': true,
78
- 'fetchTime': true,
79
- 'fetchTrades': true,
80
- 'fetchTradingFee': false,
81
- 'fetchTradingFees': true,
82
- 'fetchTransactionFee': false,
83
- 'fetchTransactionFees': false,
84
- 'fetchTransactions': 'emulated',
85
- 'fetchTransfer': false,
86
- 'fetchTransfers': false,
87
- 'fetchWithdrawal': false,
88
- 'fetchWithdrawals': true,
89
- 'reduceMargin': true,
90
- 'setLeverage': true,
91
- 'setMarginMode': true,
92
- 'setPositionMode': false,
93
- 'transfer': true,
94
- },
95
- 'timeframes': {
96
- '1m': '1',
97
- '5m': '5',
98
- '15m': '15',
99
- '30m': '30',
100
- '1h': '60',
101
- '2h': '120',
102
- '4h': '240',
103
- '6h': '360',
104
- '12h': '720',
105
- '1d': '1d',
106
- '1w': '1w',
107
- '1M': '1m',
108
- },
109
- 'version': 'v2',
110
- 'urls': {
111
- 'logo': 'https://user-images.githubusercontent.com/1294454/112027508-47984600-8b48-11eb-9e17-d26459cc36c6.jpg',
112
- 'api': {
113
- 'rest': 'https://ascendex.com',
114
- },
115
- 'test': {
116
- 'rest': 'https://api-test.ascendex-sandbox.com',
117
- },
118
- 'www': 'https://ascendex.com',
119
- 'doc': [
120
- 'https://ascendex.github.io/ascendex-pro-api/#ascendex-pro-api-documentation',
121
- ],
122
- 'fees': 'https://ascendex.com/en/feerate/transactionfee-traderate',
123
- 'referral': {
124
- 'url': 'https://ascendex.com/en-us/register?inviteCode=EL6BXBQM',
125
- 'discount': 0.25,
126
- },
127
- },
128
- 'api': {
129
- 'v1': {
130
- 'public': {
131
- 'get': {
132
- 'assets': 1,
133
- 'products': 1,
134
- 'ticker': 1,
135
- 'barhist/info': 1,
136
- 'barhist': 1,
137
- 'depth': 1,
138
- 'trades': 1,
139
- 'cash/assets': 1,
140
- 'cash/products': 1,
141
- 'margin/assets': 1,
142
- 'margin/products': 1,
143
- 'futures/collateral': 1,
144
- 'futures/contracts': 1,
145
- 'futures/ref-px': 1,
146
- 'futures/market-data': 1,
147
- 'futures/funding-rates': 1,
148
- 'risk-limit-info': 1,
149
- 'exchange-info': 1,
150
- },
151
- },
152
- 'private': {
153
- 'get': {
154
- 'info': 1,
155
- 'wallet/transactions': 1,
156
- 'wallet/deposit/address': 1,
157
- 'data/balance/snapshot': 1,
158
- 'data/balance/history': 1,
159
- },
160
- 'accountCategory': {
161
- 'get': {
162
- 'balance': 1,
163
- 'order/open': 1,
164
- 'order/status': 1,
165
- 'order/hist/current': 1,
166
- 'risk': 1,
167
- },
168
- 'post': {
169
- 'order': 1,
170
- 'order/batch': 1,
171
- },
172
- 'delete': {
173
- 'order': 1,
174
- 'order/all': 1,
175
- 'order/batch': 1,
176
- },
177
- },
178
- 'accountGroup': {
179
- 'get': {
180
- 'cash/balance': 1,
181
- 'margin/balance': 1,
182
- 'margin/risk': 1,
183
- 'futures/collateral-balance': 1,
184
- 'futures/position': 1,
185
- 'futures/risk': 1,
186
- 'futures/funding-payments': 1,
187
- 'order/hist': 1,
188
- 'spot/fee': 1,
189
- },
190
- 'post': {
191
- 'transfer': 1,
192
- 'futures/transfer/deposit': 1,
193
- 'futures/transfer/withdraw': 1,
194
- },
195
- },
196
- },
197
- },
198
- 'v2': {
199
- 'public': {
200
- 'get': {
201
- 'assets': 1,
202
- 'futures/contract': 1,
203
- 'futures/collateral': 1,
204
- 'futures/pricing-data': 1,
205
- 'futures/ticker': 1,
206
- 'risk-limit-info': 1,
207
- },
208
- },
209
- 'private': {
210
- 'data': {
211
- 'get': {
212
- 'order/hist': 1,
213
- },
214
- },
215
- 'get': {
216
- 'account/info': 1,
217
- },
218
- 'accountGroup': {
219
- 'get': {
220
- 'order/hist': 1,
221
- 'futures/position': 1,
222
- 'futures/free-margin': 1,
223
- 'futures/order/hist/current': 1,
224
- 'futures/funding-payments': 1,
225
- 'futures/order/open': 1,
226
- 'futures/order/status': 1,
227
- },
228
- 'post': {
229
- 'futures/isolated-position-margin': 1,
230
- 'futures/margin-type': 1,
231
- 'futures/leverage': 1,
232
- 'futures/transfer/deposit': 1,
233
- 'futures/transfer/withdraw': 1,
234
- 'futures/order': 1,
235
- 'futures/order/batch': 1,
236
- 'futures/order/open': 1,
237
- 'subuser/subuser-transfer': 1,
238
- 'subuser/subuser-transfer-hist': 1,
239
- },
240
- 'delete': {
241
- 'futures/order': 1,
242
- 'futures/order/batch': 1,
243
- 'futures/order/all': 1,
244
- },
245
- },
246
- },
247
- },
248
- },
249
- 'fees': {
250
- 'trading': {
251
- 'feeSide': 'get',
252
- 'tierBased': true,
253
- 'percentage': true,
254
- 'taker': this.parseNumber('0.002'),
255
- 'maker': this.parseNumber('0.002'),
256
- },
257
- },
258
- 'precisionMode': number.TICK_SIZE,
259
- 'options': {
260
- 'account-category': 'cash',
261
- 'account-group': undefined,
262
- 'fetchClosedOrders': {
263
- 'method': 'v2PrivateDataGetOrderHist', // 'v1PrivateAccountCategoryGetOrderHistCurrent'
264
- },
265
- 'defaultType': 'spot',
266
- 'accountsByType': {
267
- 'spot': 'cash',
268
- 'swap': 'futures',
269
- 'margin': 'margin',
270
- },
271
- 'transfer': {
272
- 'fillResponseFromRequest': true,
273
- },
274
- 'networks': {
275
- 'BSC': 'BEP20 (BSC)',
276
- 'ARB': 'arbitrum',
277
- 'SOL': 'Solana',
278
- 'AVAX': 'avalanche C chain',
279
- 'OMNI': 'Omni',
280
- },
281
- 'networksById': {
282
- 'BEP20 (BSC)': 'BSC',
283
- 'arbitrum': 'ARB',
284
- 'Solana': 'SOL',
285
- 'avalanche C chain': 'AVAX',
286
- 'Omni': 'OMNI',
287
- },
288
- },
289
- 'exceptions': {
290
- 'exact': {
291
- // not documented
292
- '1900': errors.BadRequest,
293
- '2100': errors.AuthenticationError,
294
- '5002': errors.BadSymbol,
295
- '6001': errors.BadSymbol,
296
- '6010': errors.InsufficientFunds,
297
- '60060': errors.InvalidOrder,
298
- '600503': errors.InvalidOrder,
299
- // documented
300
- '100001': errors.BadRequest,
301
- '100002': errors.BadRequest,
302
- '100003': errors.BadRequest,
303
- '100004': errors.BadRequest,
304
- '100005': errors.BadRequest,
305
- '100006': errors.BadRequest,
306
- '100007': errors.BadRequest,
307
- '100008': errors.BadSymbol,
308
- '100009': errors.AuthenticationError,
309
- '100010': errors.BadRequest,
310
- '100011': errors.BadRequest,
311
- '100012': errors.BadRequest,
312
- '100013': errors.BadRequest,
313
- '100101': errors.ExchangeError,
314
- '150001': errors.BadRequest,
315
- '200001': errors.AuthenticationError,
316
- '200002': errors.ExchangeError,
317
- '200003': errors.ExchangeError,
318
- '200004': errors.ExchangeError,
319
- '200005': errors.ExchangeError,
320
- '200006': errors.ExchangeError,
321
- '200007': errors.ExchangeError,
322
- '200008': errors.ExchangeError,
323
- '200009': errors.ExchangeError,
324
- '200010': errors.AuthenticationError,
325
- '200011': errors.ExchangeError,
326
- '200012': errors.ExchangeError,
327
- '200013': errors.ExchangeError,
328
- '200014': errors.PermissionDenied,
329
- '200015': errors.PermissionDenied,
330
- '300001': errors.InvalidOrder,
331
- '300002': errors.InvalidOrder,
332
- '300003': errors.InvalidOrder,
333
- '300004': errors.InvalidOrder,
334
- '300005': errors.InvalidOrder,
335
- '300006': errors.InvalidOrder,
336
- '300007': errors.InvalidOrder,
337
- '300008': errors.InvalidOrder,
338
- '300009': errors.InvalidOrder,
339
- '300011': errors.InsufficientFunds,
340
- '300012': errors.BadSymbol,
341
- '300013': errors.InvalidOrder,
342
- '300014': errors.InvalidOrder,
343
- '300020': errors.InvalidOrder,
344
- '300021': errors.InvalidOrder,
345
- '300031': errors.InvalidOrder,
346
- '310001': errors.InsufficientFunds,
347
- '310002': errors.InvalidOrder,
348
- '310003': errors.InvalidOrder,
349
- '310004': errors.BadSymbol,
350
- '310005': errors.InvalidOrder,
351
- '510001': errors.ExchangeError,
352
- '900001': errors.ExchangeError, // HUMAN_CHALLENGE Human change do not pass
353
- },
354
- 'broad': {},
355
- },
356
- 'commonCurrencies': {
357
- 'BOND': 'BONDED',
358
- 'BTCBEAR': 'BEAR',
359
- 'BTCBULL': 'BULL',
360
- 'BYN': 'BeyondFi',
361
- 'PLN': 'Pollen',
362
- },
363
- });
364
- }
365
- getAccount(params = {}) {
366
- // get current or provided bitmax sub-account
367
- const account = this.safeValue(params, 'account', this.options['account']);
368
- const lowercaseAccount = account.toLowerCase();
369
- return this.capitalize(lowercaseAccount);
370
- }
371
- async fetchCurrencies(params = {}) {
372
- /**
373
- * @method
374
- * @name ascendex#fetchCurrencies
375
- * @description fetches all available currencies on an exchange
376
- * @param {object} [params] extra parameters specific to the exchange API endpoint
377
- * @returns {object} an associative dictionary of currencies
378
- */
379
- const assets = await this.v1PublicGetAssets(params);
380
- //
381
- // {
382
- // "code":0,
383
- // "data":[
384
- // {
385
- // "assetCode" : "LTCBULL",
386
- // "assetName" : "3X Long LTC Token",
387
- // "precisionScale" : 9,
388
- // "nativeScale" : 4,
389
- // "withdrawalFee" : "0.2",
390
- // "minWithdrawalAmt" : "1.0",
391
- // "status" : "Normal"
392
- // },
393
- // ]
394
- // }
395
- //
396
- const margin = await this.v1PublicGetMarginAssets(params);
397
- //
398
- // {
399
- // "code":0,
400
- // "data":[
401
- // {
402
- // "assetCode":"BTT",
403
- // "borrowAssetCode":"BTT-B",
404
- // "interestAssetCode":"BTT-I",
405
- // "nativeScale":0,
406
- // "numConfirmations":1,
407
- // "withdrawFee":"100.0",
408
- // "minWithdrawalAmt":"1000.0",
409
- // "statusCode":"Normal",
410
- // "statusMessage":"",
411
- // "interestRate":"0.001"
412
- // }
413
- // ]
414
- // }
415
- //
416
- const cash = await this.v1PublicGetCashAssets(params);
417
- //
418
- // {
419
- // "code":0,
420
- // "data":[
421
- // {
422
- // "assetCode":"LTCBULL",
423
- // "nativeScale":4,
424
- // "numConfirmations":20,
425
- // "withdrawFee":"0.2",
426
- // "minWithdrawalAmt":"1.0",
427
- // "statusCode":"Normal",
428
- // "statusMessage":""
429
- // }
430
- // ]
431
- // }
432
- //
433
- const assetsData = this.safeValue(assets, 'data', []);
434
- const marginData = this.safeValue(margin, 'data', []);
435
- const cashData = this.safeValue(cash, 'data', []);
436
- const assetsById = this.indexBy(assetsData, 'assetCode');
437
- const marginById = this.indexBy(marginData, 'assetCode');
438
- const cashById = this.indexBy(cashData, 'assetCode');
439
- const dataById = this.deepExtend(assetsById, marginById, cashById);
440
- const ids = Object.keys(dataById);
441
- const result = {};
442
- for (let i = 0; i < ids.length; i++) {
443
- const id = ids[i];
444
- const currency = dataById[id];
445
- const code = this.safeCurrencyCode(id);
446
- const scale = this.safeString2(currency, 'precisionScale', 'nativeScale');
447
- const precision = this.parseNumber(this.parsePrecision(scale));
448
- const fee = this.safeNumber2(currency, 'withdrawFee', 'withdrawalFee');
449
- const status = this.safeString2(currency, 'status', 'statusCode');
450
- const active = (status === 'Normal');
451
- const marginInside = ('borrowAssetCode' in currency);
452
- result[code] = {
453
- 'id': id,
454
- 'code': code,
455
- 'info': currency,
456
- 'type': undefined,
457
- 'margin': marginInside,
458
- 'name': this.safeString(currency, 'assetName'),
459
- 'active': active,
460
- 'deposit': undefined,
461
- 'withdraw': undefined,
462
- 'fee': fee,
463
- 'precision': precision,
464
- 'limits': {
465
- 'amount': {
466
- 'min': precision,
467
- 'max': undefined,
468
- },
469
- 'withdraw': {
470
- 'min': this.safeNumber(currency, 'minWithdrawalAmt'),
471
- 'max': undefined,
472
- },
473
- },
474
- 'networks': {},
475
- };
476
- }
477
- return result;
478
- }
479
- async fetchMarkets(params = {}) {
480
- /**
481
- * @method
482
- * @name ascendex#fetchMarkets
483
- * @description retrieves data on all markets for ascendex
484
- * @param {object} [params] extra parameters specific to the exchange API endpoint
485
- * @returns {object[]} an array of objects representing market data
486
- */
487
- const products = await this.v1PublicGetProducts(params);
488
- //
489
- // {
490
- // "code": 0,
491
- // "data": [
492
- // {
493
- // "symbol": "LBA/BTC",
494
- // "baseAsset": "LBA",
495
- // "quoteAsset": "BTC",
496
- // "status": "Normal",
497
- // "minNotional": "0.000625",
498
- // "maxNotional": "6.25",
499
- // "marginTradable": false,
500
- // "commissionType": "Quote",
501
- // "commissionReserveRate": "0.001",
502
- // "tickSize": "0.000000001",
503
- // "lotSize": "1"
504
- // },
505
- // ]
506
- // }
507
- //
508
- const cash = await this.v1PublicGetCashProducts(params);
509
- //
510
- // {
511
- // "code": 0,
512
- // "data": [
513
- // {
514
- // "symbol": "QTUM/BTC",
515
- // "displayName": "QTUM/BTC",
516
- // "domain": "BTC",
517
- // "tradingStartTime": 1569506400000,
518
- // "collapseDecimals": "0.0001,0.000001,0.00000001",
519
- // "minQty": "0.000000001",
520
- // "maxQty": "1000000000",
521
- // "minNotional": "0.000625",
522
- // "maxNotional": "12.5",
523
- // "statusCode": "Normal",
524
- // "statusMessage": "",
525
- // "tickSize": "0.00000001",
526
- // "useTick": false,
527
- // "lotSize": "0.1",
528
- // "useLot": false,
529
- // "commissionType": "Quote",
530
- // "commissionReserveRate": "0.001",
531
- // "qtyScale": 1,
532
- // "priceScale": 8,
533
- // "notionalScale": 4
534
- // }
535
- // ]
536
- // }
537
- //
538
- const perpetuals = await this.v2PublicGetFuturesContract(params);
539
- //
540
- // {
541
- // "code": 0,
542
- // "data": [
543
- // {
544
- // "symbol": "BTC-PERP",
545
- // "status": "Normal",
546
- // "displayName": "BTCUSDT",
547
- // "settlementAsset": "USDT",
548
- // "underlying": "BTC/USDT",
549
- // "tradingStartTime": 1579701600000,
550
- // "priceFilter": {
551
- // "minPrice": "1",
552
- // "maxPrice": "1000000",
553
- // "tickSize": "1"
554
- // },
555
- // "lotSizeFilter": {
556
- // "minQty": "0.0001",
557
- // "maxQty": "1000000000",
558
- // "lotSize": "0.0001"
559
- // },
560
- // "commissionType": "Quote",
561
- // "commissionReserveRate": "0.001",
562
- // "marketOrderPriceMarkup": "0.03",
563
- // "marginRequirements": [
564
- // {
565
- // "positionNotionalLowerBound": "0",
566
- // "positionNotionalUpperBound": "50000",
567
- // "initialMarginRate": "0.01",
568
- // "maintenanceMarginRate": "0.006"
569
- // },
570
- // ...
571
- // ]
572
- // }
573
- // ]
574
- // }
575
- //
576
- const productsData = this.safeValue(products, 'data', []);
577
- const productsById = this.indexBy(productsData, 'symbol');
578
- const cashData = this.safeValue(cash, 'data', []);
579
- const perpetualsData = this.safeValue(perpetuals, 'data', []);
580
- const cashAndPerpetualsData = this.arrayConcat(cashData, perpetualsData);
581
- const cashAndPerpetualsById = this.indexBy(cashAndPerpetualsData, 'symbol');
582
- const dataById = this.deepExtend(productsById, cashAndPerpetualsById);
583
- const ids = Object.keys(dataById);
584
- const result = [];
585
- for (let i = 0; i < ids.length; i++) {
586
- const id = ids[i];
587
- const market = dataById[id];
588
- const settleId = this.safeValue(market, 'settlementAsset');
589
- const settle = this.safeCurrencyCode(settleId);
590
- const status = this.safeString(market, 'status');
591
- const domain = this.safeString(market, 'domain');
592
- let active = false;
593
- if (((status === 'Normal') || (status === 'InternalTrading')) && (domain !== 'LeveragedETF')) {
594
- active = true;
595
- }
596
- const spot = settle === undefined;
597
- const swap = !spot;
598
- const linear = swap ? true : undefined;
599
- let minQty = this.safeNumber(market, 'minQty');
600
- let maxQty = this.safeNumber(market, 'maxQty');
601
- let minPrice = this.safeNumber(market, 'tickSize');
602
- let maxPrice = undefined;
603
- const underlying = this.safeString2(market, 'underlying', 'symbol');
604
- const parts = underlying.split('/');
605
- const baseId = this.safeString(parts, 0);
606
- const quoteId = this.safeString(parts, 1);
607
- const base = this.safeCurrencyCode(baseId);
608
- const quote = this.safeCurrencyCode(quoteId);
609
- let symbol = base + '/' + quote;
610
- if (swap) {
611
- const lotSizeFilter = this.safeValue(market, 'lotSizeFilter');
612
- minQty = this.safeNumber(lotSizeFilter, 'minQty');
613
- maxQty = this.safeNumber(lotSizeFilter, 'maxQty');
614
- const priceFilter = this.safeValue(market, 'priceFilter');
615
- minPrice = this.safeNumber(priceFilter, 'minPrice');
616
- maxPrice = this.safeNumber(priceFilter, 'maxPrice');
617
- symbol = base + '/' + quote + ':' + settle;
618
- }
619
- const fee = this.safeNumber(market, 'commissionReserveRate');
620
- const marginTradable = this.safeValue(market, 'marginTradable', false);
621
- result.push({
622
- 'id': id,
623
- 'symbol': symbol,
624
- 'base': base,
625
- 'quote': quote,
626
- 'settle': settle,
627
- 'baseId': baseId,
628
- 'quoteId': quoteId,
629
- 'settleId': settleId,
630
- 'type': swap ? 'swap' : 'spot',
631
- 'spot': spot,
632
- 'margin': spot ? marginTradable : undefined,
633
- 'swap': swap,
634
- 'future': false,
635
- 'option': false,
636
- 'active': active,
637
- 'contract': swap,
638
- 'linear': linear,
639
- 'inverse': swap ? !linear : undefined,
640
- 'taker': fee,
641
- 'maker': fee,
642
- 'contractSize': swap ? this.parseNumber('1') : undefined,
643
- 'expiry': undefined,
644
- 'expiryDatetime': undefined,
645
- 'strike': undefined,
646
- 'optionType': undefined,
647
- 'precision': {
648
- 'amount': this.safeNumber(market, 'lotSize'),
649
- 'price': this.safeNumber(market, 'tickSize'),
650
- },
651
- 'limits': {
652
- 'leverage': {
653
- 'min': undefined,
654
- 'max': undefined,
655
- },
656
- 'amount': {
657
- 'min': minQty,
658
- 'max': maxQty,
659
- },
660
- 'price': {
661
- 'min': minPrice,
662
- 'max': maxPrice,
663
- },
664
- 'cost': {
665
- 'min': this.safeNumber(market, 'minNotional'),
666
- 'max': this.safeNumber(market, 'maxNotional'),
667
- },
668
- },
669
- 'created': this.safeInteger(market, 'tradingStartTime'),
670
- 'info': market,
671
- });
672
- }
673
- return result;
674
- }
675
- async fetchTime(params = {}) {
676
- /**
677
- * @method
678
- * @name ascendex#fetchTime
679
- * @description fetches the current integer timestamp in milliseconds from the ascendex server
680
- * @param {object} [params] extra parameters specific to the exchange API endpoint
681
- * @returns {int} the current integer timestamp in milliseconds from the ascendex server
682
- */
683
- const request = {
684
- 'requestTime': this.milliseconds(),
685
- };
686
- const response = await this.v1PublicGetExchangeInfo(this.extend(request, params));
687
- //
688
- // {
689
- // "code": 0,
690
- // "data": {
691
- // "requestTimeEcho": 1656560463601,
692
- // "requestReceiveAt": 1656560464331,
693
- // "latency": 730
694
- // }
695
- // }
696
- //
697
- const data = this.safeValue(response, 'data');
698
- return this.safeInteger(data, 'requestReceiveAt');
699
- }
700
- async fetchAccounts(params = {}) {
701
- /**
702
- * @method
703
- * @name ascendex#fetchAccounts
704
- * @description fetch all the accounts associated with a profile
705
- * @param {object} [params] extra parameters specific to the exchange API endpoint
706
- * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/#/?id=account-structure} indexed by the account type
707
- */
708
- let accountGroup = this.safeString(this.options, 'account-group');
709
- let response = undefined;
710
- if (accountGroup === undefined) {
711
- response = await this.v1PrivateGetInfo(params);
712
- //
713
- // {
714
- // "code":0,
715
- // "data":{
716
- // "email":"igor.kroitor@gmail.com",
717
- // "accountGroup":8,
718
- // "viewPermission":true,
719
- // "tradePermission":true,
720
- // "transferPermission":true,
721
- // "cashAccount":["cshrHKLZCjlZ2ejqkmvIHHtPmLYqdnda"],
722
- // "marginAccount":["martXoh1v1N3EMQC5FDtSj5VHso8aI2Z"],
723
- // "futuresAccount":["futc9r7UmFJAyBY2rE3beA2JFxav2XFF"],
724
- // "userUID":"U6491137460"
725
- // }
726
- // }
727
- //
728
- const data = this.safeValue(response, 'data', {});
729
- accountGroup = this.safeString(data, 'accountGroup');
730
- this.options['account-group'] = accountGroup;
731
- }
732
- return [
733
- {
734
- 'id': accountGroup,
735
- 'type': undefined,
736
- 'currency': undefined,
737
- 'info': response,
738
- },
739
- ];
740
- }
741
- parseBalance(response) {
742
- const timestamp = this.milliseconds();
743
- const result = {
744
- 'info': response,
745
- 'timestamp': timestamp,
746
- 'datetime': this.iso8601(timestamp),
747
- };
748
- const balances = this.safeValue(response, 'data', []);
749
- for (let i = 0; i < balances.length; i++) {
750
- const balance = balances[i];
751
- const code = this.safeCurrencyCode(this.safeString(balance, 'asset'));
752
- const account = this.account();
753
- account['free'] = this.safeString(balance, 'availableBalance');
754
- account['total'] = this.safeString(balance, 'totalBalance');
755
- result[code] = account;
756
- }
757
- return this.safeBalance(result);
758
- }
759
- parseMarginBalance(response) {
760
- const timestamp = this.milliseconds();
761
- const result = {
762
- 'info': response,
763
- 'timestamp': timestamp,
764
- 'datetime': this.iso8601(timestamp),
765
- };
766
- const balances = this.safeValue(response, 'data', []);
767
- for (let i = 0; i < balances.length; i++) {
768
- const balance = balances[i];
769
- const code = this.safeCurrencyCode(this.safeString(balance, 'asset'));
770
- const account = this.account();
771
- account['free'] = this.safeString(balance, 'availableBalance');
772
- account['total'] = this.safeString(balance, 'totalBalance');
773
- const debt = this.safeString(balance, 'borrowed');
774
- const interest = this.safeString(balance, 'interest');
775
- account['debt'] = Precise["default"].stringAdd(debt, interest);
776
- result[code] = account;
777
- }
778
- return this.safeBalance(result);
779
- }
780
- parseSwapBalance(response) {
781
- const timestamp = this.milliseconds();
782
- const result = {
783
- 'info': response,
784
- 'timestamp': timestamp,
785
- 'datetime': this.iso8601(timestamp),
786
- };
787
- const data = this.safeValue(response, 'data', {});
788
- const collaterals = this.safeValue(data, 'collaterals', []);
789
- for (let i = 0; i < collaterals.length; i++) {
790
- const balance = collaterals[i];
791
- const code = this.safeCurrencyCode(this.safeString(balance, 'asset'));
792
- const account = this.account();
793
- account['total'] = this.safeString(balance, 'balance');
794
- result[code] = account;
795
- }
796
- return this.safeBalance(result);
797
- }
798
- async fetchBalance(params = {}) {
799
- /**
800
- * @method
801
- * @name ascendex#fetchBalance
802
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
803
- * @see https://ascendex.github.io/ascendex-pro-api/#cash-account-balance
804
- * @see https://ascendex.github.io/ascendex-pro-api/#margin-account-balance
805
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
806
- * @param {object} [params] extra parameters specific to the exchange API endpoint
807
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
808
- */
809
- await this.loadMarkets();
810
- await this.loadAccounts();
811
- let marketType = undefined;
812
- let marginMode = undefined;
813
- [marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
814
- [marginMode, params] = this.handleMarginModeAndParams('fetchBalance', params);
815
- const isMargin = this.safeValue(params, 'margin', false);
816
- const isCross = marginMode === 'cross';
817
- marketType = (isMargin || isCross) ? 'margin' : marketType;
818
- params = this.omit(params, 'margin');
819
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
820
- const accountCategory = this.safeString(accountsByType, marketType, 'cash');
821
- const account = this.safeValue(this.accounts, 0, {});
822
- const accountGroup = this.safeString(account, 'id');
823
- const request = {
824
- 'account-group': accountGroup,
825
- };
826
- if ((marginMode === 'isolated') && (marketType !== 'swap')) {
827
- throw new errors.BadRequest(this.id + ' does not supported isolated margin trading');
828
- }
829
- if ((accountCategory === 'cash') || (accountCategory === 'margin')) {
830
- request['account-category'] = accountCategory;
831
- }
832
- let response = undefined;
833
- if ((marketType === 'spot') || (marketType === 'margin')) {
834
- response = await this.v1PrivateAccountCategoryGetBalance(this.extend(request, params));
835
- }
836
- else if (marketType === 'swap') {
837
- response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, params));
838
- }
839
- else {
840
- throw new errors.NotSupported(this.id + ' fetchBalance() is not currently supported for ' + marketType + ' markets');
841
- }
842
- //
843
- // cash
844
- //
845
- // {
846
- // "code": 0,
847
- // "data": [
848
- // {
849
- // "asset": "BCHSV",
850
- // "totalBalance": "64.298000048",
851
- // "availableBalance": "64.298000048",
852
- // },
853
- // ]
854
- // }
855
- //
856
- // margin
857
- //
858
- // {
859
- // "code": 0,
860
- // "data": [
861
- // {
862
- // "asset": "BCHSV",
863
- // "totalBalance": "64.298000048",
864
- // "availableBalance": "64.298000048",
865
- // "borrowed": "0",
866
- // "interest": "0",
867
- // },
868
- // ]
869
- // }
870
- //
871
- // swap
872
- //
873
- // {
874
- // "code": 0,
875
- // "data": {
876
- // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
877
- // "ac": "FUTURES",
878
- // "collaterals": [
879
- // {"asset":"ADA","balance":"0.355803","referencePrice":"1.05095","discountFactor":"0.9"},
880
- // {"asset":"USDT","balance":"0.000014519","referencePrice":"1","discountFactor":"1"}
881
- // ],
882
- // }j
883
- // }
884
- //
885
- if (marketType === 'swap') {
886
- return this.parseSwapBalance(response);
887
- }
888
- else if (marketType === 'margin') {
889
- return this.parseMarginBalance(response);
890
- }
891
- else {
892
- return this.parseBalance(response);
893
- }
894
- }
895
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
896
- /**
897
- * @method
898
- * @name ascendex#fetchOrderBook
899
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
900
- * @param {string} symbol unified symbol of the market to fetch the order book for
901
- * @param {int} [limit] the maximum amount of order book entries to return
902
- * @param {object} [params] extra parameters specific to the exchange API endpoint
903
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
904
- */
905
- await this.loadMarkets();
906
- const market = this.market(symbol);
907
- const request = {
908
- 'symbol': market['id'],
909
- };
910
- const response = await this.v1PublicGetDepth(this.extend(request, params));
911
- //
912
- // {
913
- // "code":0,
914
- // "data":{
915
- // "m":"depth-snapshot",
916
- // "symbol":"BTC-PERP",
917
- // "data":{
918
- // "ts":1590223998202,
919
- // "seqnum":115444921,
920
- // "asks":[
921
- // ["9207.5","18.2383"],
922
- // ["9207.75","18.8235"],
923
- // ["9208","10.7873"],
924
- // ],
925
- // "bids":[
926
- // ["9207.25","0.4009"],
927
- // ["9207","0.003"],
928
- // ["9206.5","0.003"],
929
- // ]
930
- // }
931
- // }
932
- // }
933
- //
934
- const data = this.safeValue(response, 'data', {});
935
- const orderbook = this.safeValue(data, 'data', {});
936
- const timestamp = this.safeInteger(orderbook, 'ts');
937
- const result = this.parseOrderBook(orderbook, symbol, timestamp);
938
- result['nonce'] = this.safeInteger(orderbook, 'seqnum');
939
- return result;
940
- }
941
- parseTicker(ticker, market = undefined) {
942
- //
943
- // {
944
- // "symbol":"QTUM/BTC",
945
- // "open":"0.00016537",
946
- // "close":"0.00019077",
947
- // "high":"0.000192",
948
- // "low":"0.00016537",
949
- // "volume":"846.6",
950
- // "ask":["0.00018698","26.2"],
951
- // "bid":["0.00018408","503.7"],
952
- // "type":"spot"
953
- // }
954
- //
955
- const timestamp = undefined;
956
- const marketId = this.safeString(ticker, 'symbol');
957
- const type = this.safeString(ticker, 'type');
958
- const delimiter = (type === 'spot') ? '/' : undefined;
959
- const symbol = this.safeSymbol(marketId, market, delimiter);
960
- const close = this.safeString(ticker, 'close');
961
- const bid = this.safeValue(ticker, 'bid', []);
962
- const ask = this.safeValue(ticker, 'ask', []);
963
- const open = this.safeString(ticker, 'open');
964
- return this.safeTicker({
965
- 'symbol': symbol,
966
- 'timestamp': timestamp,
967
- 'datetime': undefined,
968
- 'high': this.safeString(ticker, 'high'),
969
- 'low': this.safeString(ticker, 'low'),
970
- 'bid': this.safeString(bid, 0),
971
- 'bidVolume': this.safeString(bid, 1),
972
- 'ask': this.safeString(ask, 0),
973
- 'askVolume': this.safeString(ask, 1),
974
- 'vwap': undefined,
975
- 'open': open,
976
- 'close': close,
977
- 'last': close,
978
- 'previousClose': undefined,
979
- 'change': undefined,
980
- 'percentage': undefined,
981
- 'average': undefined,
982
- 'baseVolume': this.safeString(ticker, 'volume'),
983
- 'quoteVolume': undefined,
984
- 'info': ticker,
985
- }, market);
986
- }
987
- async fetchTicker(symbol, params = {}) {
988
- /**
989
- * @method
990
- * @name ascendex#fetchTicker
991
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
992
- * @param {string} symbol unified symbol of the market to fetch the ticker for
993
- * @param {object} [params] extra parameters specific to the exchange API endpoint
994
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
995
- */
996
- await this.loadMarkets();
997
- const market = this.market(symbol);
998
- const request = {
999
- 'symbol': market['id'],
1000
- };
1001
- const response = await this.v1PublicGetTicker(this.extend(request, params));
1002
- //
1003
- // {
1004
- // "code":0,
1005
- // "data":{
1006
- // "symbol":"BTC-PERP", // or "BTC/USDT"
1007
- // "open":"9073",
1008
- // "close":"9185.75",
1009
- // "high":"9185.75",
1010
- // "low":"9185.75",
1011
- // "volume":"576.8334",
1012
- // "ask":["9185.75","15.5863"],
1013
- // "bid":["9185.5","0.003"],
1014
- // "type":"derivatives", // or "spot"
1015
- // }
1016
- // }
1017
- //
1018
- const data = this.safeValue(response, 'data', {});
1019
- return this.parseTicker(data, market);
1020
- }
1021
- async fetchTickers(symbols = undefined, params = {}) {
1022
- /**
1023
- * @method
1024
- * @name ascendex#fetchTickers
1025
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
1026
- * @see https://ascendex.github.io/ascendex-pro-api/#ticker
1027
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#ticker
1028
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1029
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1030
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1031
- */
1032
- await this.loadMarkets();
1033
- const request = {};
1034
- let market = undefined;
1035
- if (symbols !== undefined) {
1036
- const symbol = this.safeValue(symbols, 0);
1037
- market = this.market(symbol);
1038
- const marketIds = this.marketIds(symbols);
1039
- request['symbol'] = marketIds.join(',');
1040
- }
1041
- let type = undefined;
1042
- [type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
1043
- let response = undefined;
1044
- if (type === 'spot') {
1045
- response = await this.v1PublicGetTicker(this.extend(request, params));
1046
- }
1047
- else {
1048
- response = await this.v2PublicGetFuturesTicker(this.extend(request, params));
1049
- }
1050
- //
1051
- // {
1052
- // "code":0,
1053
- // "data":[
1054
- // {
1055
- // "symbol":"QTUM/BTC",
1056
- // "open":"0.00016537",
1057
- // "close":"0.00019077",
1058
- // "high":"0.000192",
1059
- // "low":"0.00016537",
1060
- // "volume":"846.6",
1061
- // "ask":["0.00018698","26.2"],
1062
- // "bid":["0.00018408","503.7"],
1063
- // "type":"spot"
1064
- // }
1065
- // ]
1066
- // }
1067
- //
1068
- const data = this.safeValue(response, 'data', []);
1069
- if (!Array.isArray(data)) {
1070
- return this.parseTickers([data], symbols);
1071
- }
1072
- return this.parseTickers(data, symbols);
1073
- }
1074
- parseOHLCV(ohlcv, market = undefined) {
1075
- //
1076
- // {
1077
- // "m":"bar",
1078
- // "s":"BTC/USDT",
1079
- // "data":{
1080
- // "i":"1",
1081
- // "ts":1590228000000,
1082
- // "o":"9139.59",
1083
- // "c":"9131.94",
1084
- // "h":"9139.99",
1085
- // "l":"9121.71",
1086
- // "v":"25.20648"
1087
- // }
1088
- // }
1089
- //
1090
- const data = this.safeValue(ohlcv, 'data', {});
1091
- return [
1092
- this.safeInteger(data, 'ts'),
1093
- this.safeNumber(data, 'o'),
1094
- this.safeNumber(data, 'h'),
1095
- this.safeNumber(data, 'l'),
1096
- this.safeNumber(data, 'c'),
1097
- this.safeNumber(data, 'v'),
1098
- ];
1099
- }
1100
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
1101
- /**
1102
- * @method
1103
- * @name ascendex#fetchOHLCV
1104
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1105
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1106
- * @param {string} timeframe the length of time each candle represents
1107
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
1108
- * @param {int} [limit] the maximum amount of candles to fetch
1109
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1110
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1111
- */
1112
- await this.loadMarkets();
1113
- const market = this.market(symbol);
1114
- const request = {
1115
- 'symbol': market['id'],
1116
- 'interval': this.safeString(this.timeframes, timeframe, timeframe),
1117
- };
1118
- // if since and limit are not specified
1119
- // the exchange will return just 1 last candle by default
1120
- const duration = this.parseTimeframe(timeframe);
1121
- const options = this.safeValue(this.options, 'fetchOHLCV', {});
1122
- const defaultLimit = this.safeInteger(options, 'limit', 500);
1123
- if (since !== undefined) {
1124
- request['from'] = since;
1125
- if (limit === undefined) {
1126
- limit = defaultLimit;
1127
- }
1128
- else {
1129
- limit = Math.min(limit, defaultLimit);
1130
- }
1131
- request['to'] = this.sum(since, limit * duration * 1000, 1);
1132
- }
1133
- else if (limit !== undefined) {
1134
- request['n'] = limit; // max 500
1135
- }
1136
- const response = await this.v1PublicGetBarhist(this.extend(request, params));
1137
- //
1138
- // {
1139
- // "code":0,
1140
- // "data":[
1141
- // {
1142
- // "m":"bar",
1143
- // "s":"BTC/USDT",
1144
- // "data":{
1145
- // "i":"1",
1146
- // "ts":1590228000000,
1147
- // "o":"9139.59",
1148
- // "c":"9131.94",
1149
- // "h":"9139.99",
1150
- // "l":"9121.71",
1151
- // "v":"25.20648"
1152
- // }
1153
- // }
1154
- // ]
1155
- // }
1156
- //
1157
- const data = this.safeValue(response, 'data', []);
1158
- return this.parseOHLCVs(data, market, timeframe, since, limit);
1159
- }
1160
- parseTrade(trade, market = undefined) {
1161
- //
1162
- // public fetchTrades
1163
- //
1164
- // {
1165
- // "p":"9128.5", // price
1166
- // "q":"0.0030", // quantity
1167
- // "ts":1590229002385, // timestamp
1168
- // "bm":false, // if true, the buyer is the market maker, we only use this field to "define the side" of a public trade
1169
- // "seqnum":180143985289898554
1170
- // }
1171
- //
1172
- const timestamp = this.safeInteger(trade, 'ts');
1173
- const priceString = this.safeString2(trade, 'price', 'p');
1174
- const amountString = this.safeString(trade, 'q');
1175
- const buyerIsMaker = this.safeValue(trade, 'bm', false);
1176
- const side = buyerIsMaker ? 'sell' : 'buy';
1177
- market = this.safeMarket(undefined, market);
1178
- return this.safeTrade({
1179
- 'info': trade,
1180
- 'timestamp': timestamp,
1181
- 'datetime': this.iso8601(timestamp),
1182
- 'symbol': market['symbol'],
1183
- 'id': undefined,
1184
- 'order': undefined,
1185
- 'type': undefined,
1186
- 'takerOrMaker': undefined,
1187
- 'side': side,
1188
- 'price': priceString,
1189
- 'amount': amountString,
1190
- 'cost': undefined,
1191
- 'fee': undefined,
1192
- }, market);
1193
- }
1194
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1195
- /**
1196
- * @method
1197
- * @name ascendex#fetchTrades
1198
- * @description get the list of most recent trades for a particular symbol
1199
- * @see https://ascendex.github.io/ascendex-pro-api/#market-trades
1200
- * @param {string} symbol unified symbol of the market to fetch trades for
1201
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
1202
- * @param {int} [limit] the maximum amount of trades to fetch
1203
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1204
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1205
- */
1206
- await this.loadMarkets();
1207
- const market = this.market(symbol);
1208
- const request = {
1209
- 'symbol': market['id'],
1210
- };
1211
- if (limit !== undefined) {
1212
- request['n'] = limit; // max 100
1213
- }
1214
- const response = await this.v1PublicGetTrades(this.extend(request, params));
1215
- //
1216
- // {
1217
- // "code":0,
1218
- // "data":{
1219
- // "m":"trades",
1220
- // "symbol":"BTC-PERP",
1221
- // "data":[
1222
- // {"p":"9128.5","q":"0.0030","ts":1590229002385,"bm":false,"seqnum":180143985289898554},
1223
- // {"p":"9129","q":"0.0030","ts":1590229002642,"bm":false,"seqnum":180143985289898587},
1224
- // {"p":"9129.5","q":"0.0030","ts":1590229021306,"bm":false,"seqnum":180143985289899043}
1225
- // ]
1226
- // }
1227
- // }
1228
- //
1229
- const records = this.safeValue(response, 'data', []);
1230
- const trades = this.safeValue(records, 'data', []);
1231
- return this.parseTrades(trades, market, since, limit);
1232
- }
1233
- parseOrderStatus(status) {
1234
- const statuses = {
1235
- 'PendingNew': 'open',
1236
- 'New': 'open',
1237
- 'PartiallyFilled': 'open',
1238
- 'Filled': 'closed',
1239
- 'Canceled': 'canceled',
1240
- 'Rejected': 'rejected',
1241
- };
1242
- return this.safeString(statuses, status, status);
1243
- }
1244
- parseOrder(order, market = undefined) {
1245
- //
1246
- // createOrder
1247
- //
1248
- // {
1249
- // "id": "16e607e2b83a8bXHbAwwoqDo55c166fa",
1250
- // "orderId": "16e85b4d9b9a8bXHbAwwoqDoc3d66830",
1251
- // "orderType": "Market",
1252
- // "symbol": "BTC/USDT",
1253
- // "timestamp": 1573576916201
1254
- // }
1255
- //
1256
- // {
1257
- // "ac": "FUTURES",
1258
- // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
1259
- // "time": 1640819389454,
1260
- // "orderId": "a17e0874ecbdU0711043490bbtcpDU5X",
1261
- // "seqNum": -1,
1262
- // "orderType": "Limit",
1263
- // "execInst": "NULL_VAL",
1264
- // "side": "Buy",
1265
- // "symbol": "BTC-PERP",
1266
- // "price": "30000",
1267
- // "orderQty": "0.002",
1268
- // "stopPrice": "0",
1269
- // "stopBy": "ref-px",
1270
- // "status": "Ack",
1271
- // "lastExecTime": 1640819389454,
1272
- // "lastQty": "0",
1273
- // "lastPx": "0",
1274
- // "avgFilledPx": "0",
1275
- // "cumFilledQty": "0",
1276
- // "fee": "0",
1277
- // "cumFee": "0",
1278
- // "feeAsset": "",
1279
- // "errorCode": "",
1280
- // "posStopLossPrice": "0",
1281
- // "posStopLossTrigger": "market",
1282
- // "posTakeProfitPrice": "0",
1283
- // "posTakeProfitTrigger": "market",
1284
- // "liquidityInd": "n"
1285
- // }
1286
- //
1287
- // fetchOrder, fetchOpenOrders, fetchClosedOrders
1288
- //
1289
- // {
1290
- // "symbol": "BTC/USDT",
1291
- // "price": "8131.22",
1292
- // "orderQty": "0.00082",
1293
- // "orderType": "Market",
1294
- // "avgPx": "7392.02",
1295
- // "cumFee": "0.005152238",
1296
- // "cumFilledQty": "0.00082",
1297
- // "errorCode": "",
1298
- // "feeAsset": "USDT",
1299
- // "lastExecTime": 1575953151764,
1300
- // "orderId": "a16eee20b6750866943712zWEDdAjt3",
1301
- // "seqNum": 2623469,
1302
- // "side": "Buy",
1303
- // "status": "Filled",
1304
- // "stopPrice": "",
1305
- // "execInst": "NULL_VAL" // "Post" (for postOnly orders), "reduceOnly" (for reduceOnly orders)
1306
- // }
1307
- //
1308
- // {
1309
- // "orderId": "a173ad938fc3U22666567717788c3b66", // orderId
1310
- // "seqNum": 18777366360, // sequence number
1311
- // "accountId": "cshwSjbpPjSwHmxPdz2CPQVU9mnbzPpt", // accountId
1312
- // "symbol": "BTC/USDT", // symbol
1313
- // "orderType": "Limit", // order type (Limit/Market/StopMarket/StopLimit)
1314
- // "side": "Sell", // order side (Buy/Sell)
1315
- // "price": "11346.77", // order price
1316
- // "stopPrice": "0", // stop price (0 by default)
1317
- // "orderQty": "0.01", // order quantity (in base asset)
1318
- // "status": "Canceled", // order status (Filled/Canceled/Rejected)
1319
- // "createTime": 1596344995793, // order creation time
1320
- // "lastExecTime": 1596344996053, // last execution time
1321
- // "avgFillPrice": "11346.77", // average filled price
1322
- // "fillQty": "0.01", // filled quantity (in base asset)
1323
- // "fee": "-0.004992579", // cummulative fee. if negative, this value is the commission charged; if possitive, this value is the rebate received.
1324
- // "feeAsset": "USDT" // fee asset
1325
- // }
1326
- //
1327
- // {
1328
- // "ac": "FUTURES",
1329
- // "accountId": "testabcdefg",
1330
- // "avgPx": "0",
1331
- // "cumFee": "0",
1332
- // "cumQty": "0",
1333
- // "errorCode": "NULL_VAL",
1334
- // "execInst": "NULL_VAL",
1335
- // "feeAsset": "USDT",
1336
- // "lastExecTime": 1584072844085,
1337
- // "orderId": "r170d21956dd5450276356bbtcpKa74",
1338
- // "orderQty": "1.1499",
1339
- // "orderType": "Limit",
1340
- // "price": "4000",
1341
- // "sendingTime": 1584072841033,
1342
- // "seqNum": 24105338,
1343
- // "side": "Buy",
1344
- // "status": "Canceled",
1345
- // "stopPrice": "",
1346
- // "symbol": "BTC-PERP"
1347
- // },
1348
- //
1349
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
1350
- const marketId = this.safeString(order, 'symbol');
1351
- const symbol = this.safeSymbol(marketId, market, '/');
1352
- let timestamp = this.safeInteger2(order, 'timestamp', 'sendingTime');
1353
- const lastTradeTimestamp = this.safeInteger(order, 'lastExecTime');
1354
- if (timestamp === undefined) {
1355
- timestamp = lastTradeTimestamp;
1356
- }
1357
- const price = this.safeString(order, 'price');
1358
- const amount = this.safeString(order, 'orderQty');
1359
- const average = this.safeString(order, 'avgPx');
1360
- const filled = this.safeStringN(order, ['cumFilledQty', 'cumQty', 'fillQty']);
1361
- const id = this.safeString(order, 'orderId');
1362
- let clientOrderId = this.safeString(order, 'id');
1363
- if (clientOrderId !== undefined) {
1364
- if (clientOrderId.length < 1) {
1365
- clientOrderId = undefined;
1366
- }
1367
- }
1368
- const rawTypeLower = this.safeStringLower(order, 'orderType');
1369
- let type = rawTypeLower;
1370
- if (rawTypeLower !== undefined) {
1371
- if (rawTypeLower === 'stoplimit') {
1372
- type = 'limit';
1373
- }
1374
- if (rawTypeLower === 'stopmarket') {
1375
- type = 'market';
1376
- }
1377
- }
1378
- const side = this.safeStringLower(order, 'side');
1379
- const feeCost = this.safeNumber2(order, 'cumFee', 'fee');
1380
- let fee = undefined;
1381
- if (feeCost !== undefined) {
1382
- const feeCurrencyId = this.safeString(order, 'feeAsset');
1383
- const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
1384
- fee = {
1385
- 'cost': feeCost,
1386
- 'currency': feeCurrencyCode,
1387
- };
1388
- }
1389
- const stopPrice = this.safeNumber(order, 'stopPrice');
1390
- let reduceOnly = undefined;
1391
- const execInst = this.safeString(order, 'execInst');
1392
- if (execInst === 'reduceOnly') {
1393
- reduceOnly = true;
1394
- }
1395
- let postOnly = undefined;
1396
- if (execInst === 'Post') {
1397
- postOnly = true;
1398
- }
1399
- return this.safeOrder({
1400
- 'info': order,
1401
- 'id': id,
1402
- 'clientOrderId': clientOrderId,
1403
- 'timestamp': timestamp,
1404
- 'datetime': this.iso8601(timestamp),
1405
- 'lastTradeTimestamp': lastTradeTimestamp,
1406
- 'symbol': symbol,
1407
- 'type': type,
1408
- 'timeInForce': undefined,
1409
- 'postOnly': postOnly,
1410
- 'reduceOnly': reduceOnly,
1411
- 'side': side,
1412
- 'price': price,
1413
- 'stopPrice': stopPrice,
1414
- 'triggerPrice': stopPrice,
1415
- 'amount': amount,
1416
- 'cost': undefined,
1417
- 'average': average,
1418
- 'filled': filled,
1419
- 'remaining': undefined,
1420
- 'status': status,
1421
- 'fee': fee,
1422
- 'trades': undefined,
1423
- }, market);
1424
- }
1425
- async fetchTradingFees(params = {}) {
1426
- /**
1427
- * @method
1428
- * @name ascendex#fetchTradingFees
1429
- * @description fetch the trading fees for multiple markets
1430
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1431
- * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
1432
- */
1433
- await this.loadMarkets();
1434
- await this.loadAccounts();
1435
- const account = this.safeValue(this.accounts, 0, {});
1436
- const accountGroup = this.safeString(account, 'id');
1437
- const request = {
1438
- 'account-group': accountGroup,
1439
- };
1440
- const response = await this.v1PrivateAccountGroupGetSpotFee(this.extend(request, params));
1441
- //
1442
- // {
1443
- // "code": "0",
1444
- // "data": {
1445
- // "domain": "spot",
1446
- // "userUID": "U1479576458",
1447
- // "vipLevel": "0",
1448
- // "fees": [
1449
- // { symbol: 'HT/USDT', fee: { taker: '0.001', maker: "0.001" } },
1450
- // { symbol: 'LAMB/BTC', fee: { taker: '0.002', maker: "0.002" } },
1451
- // { symbol: 'STOS/USDT', fee: { taker: '0.002', maker: "0.002" } },
1452
- // ...
1453
- // ]
1454
- // }
1455
- // }
1456
- //
1457
- const data = this.safeValue(response, 'data', {});
1458
- const fees = this.safeValue(data, 'fees', []);
1459
- const result = {};
1460
- for (let i = 0; i < fees.length; i++) {
1461
- const fee = fees[i];
1462
- const marketId = this.safeString(fee, 'symbol');
1463
- const symbol = this.safeSymbol(marketId, undefined, '/');
1464
- const takerMaker = this.safeValue(fee, 'fee', {});
1465
- result[symbol] = {
1466
- 'info': fee,
1467
- 'symbol': symbol,
1468
- 'maker': this.safeNumber(takerMaker, 'maker'),
1469
- 'taker': this.safeNumber(takerMaker, 'taker'),
1470
- };
1471
- }
1472
- return result;
1473
- }
1474
- createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
1475
- /**
1476
- * @method
1477
- * @ignore
1478
- * @name ascendex#createOrderRequest
1479
- * @description helper function to build request
1480
- * @param {string} symbol unified symbol of the market to create an order in
1481
- * @param {string} type 'market' or 'limit'
1482
- * @param {string} side 'buy' or 'sell'
1483
- * @param {float} amount how much you want to trade in units of the base currency
1484
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1485
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1486
- * @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
1487
- * @param {bool} [params.postOnly] true or false
1488
- * @param {float} [params.stopPrice] the price at which a trigger order is triggered at
1489
- * @returns {object} request to be sent to the exchange
1490
- */
1491
- const market = this.market(symbol);
1492
- let marginMode = undefined;
1493
- let marketType = undefined;
1494
- [marginMode, params] = this.handleMarginModeAndParams('createOrderRequest', params);
1495
- [marketType, params] = this.handleMarketTypeAndParams('createOrderRequest', market, params);
1496
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
1497
- let accountCategory = this.safeString(accountsByType, marketType, 'cash');
1498
- if (marginMode !== undefined) {
1499
- accountCategory = 'margin';
1500
- }
1501
- const account = this.safeValue(this.accounts, 0, {});
1502
- const accountGroup = this.safeValue(account, 'id');
1503
- const clientOrderId = this.safeString2(params, 'clientOrderId', 'id');
1504
- const request = {
1505
- 'account-group': accountGroup,
1506
- 'account-category': accountCategory,
1507
- 'symbol': market['id'],
1508
- 'time': this.milliseconds(),
1509
- 'orderQty': this.amountToPrecision(symbol, amount),
1510
- 'orderType': type,
1511
- 'side': side, // buy or sell,
1512
- // 'execInst': // Post for postOnly, ReduceOnly for reduceOnly
1513
- // 'respInst': 'ACK', // ACK, 'ACCEPT, DONE
1514
- };
1515
- const isMarketOrder = ((type === 'market') || (type === 'stop_market'));
1516
- const isLimitOrder = ((type === 'limit') || (type === 'stop_limit'));
1517
- const timeInForce = this.safeString(params, 'timeInForce');
1518
- const postOnly = this.isPostOnly(isMarketOrder, false, params);
1519
- const reduceOnly = this.safeValue(params, 'reduceOnly', false);
1520
- const stopPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
1521
- if (isLimitOrder) {
1522
- request['orderPrice'] = this.priceToPrecision(symbol, price);
1523
- }
1524
- if (timeInForce === 'IOC') {
1525
- request['timeInForce'] = 'IOC';
1526
- }
1527
- if (timeInForce === 'FOK') {
1528
- request['timeInForce'] = 'FOK';
1529
- }
1530
- if (postOnly) {
1531
- request['postOnly'] = true;
1532
- }
1533
- if (stopPrice !== undefined) {
1534
- request['stopPrice'] = this.priceToPrecision(symbol, stopPrice);
1535
- if (isLimitOrder) {
1536
- request['orderType'] = 'stop_limit';
1537
- }
1538
- else if (isMarketOrder) {
1539
- request['orderType'] = 'stop_market';
1540
- }
1541
- }
1542
- if (clientOrderId !== undefined) {
1543
- request['id'] = clientOrderId;
1544
- }
1545
- if (market['spot']) {
1546
- if (accountCategory !== undefined) {
1547
- request['category'] = accountCategory;
1548
- }
1549
- }
1550
- else {
1551
- request['account-category'] = accountCategory;
1552
- if (reduceOnly) {
1553
- request['execInst'] = 'ReduceOnly';
1554
- }
1555
- if (postOnly) {
1556
- request['execInst'] = 'Post';
1557
- }
1558
- }
1559
- params = this.omit(params, ['reduceOnly', 'triggerPrice']);
1560
- return this.extend(request, params);
1561
- }
1562
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
1563
- /**
1564
- * @method
1565
- * @name ascendex#createOrder
1566
- * @description create a trade order on the exchange
1567
- * @see https://ascendex.github.io/ascendex-pro-api/#place-order
1568
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#new-order
1569
- * @param {string} symbol unified CCXT market symbol
1570
- * @param {string} type "limit" or "market"
1571
- * @param {string} side "buy" or "sell"
1572
- * @param {float} amount the amount of currency to trade
1573
- * @param {float} [price] *ignored in "market" orders* the price at which the order is to be fullfilled at in units of the quote currency
1574
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1575
- * @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
1576
- * @param {bool} [params.postOnly] true or false
1577
- * @param {float} [params.stopPrice] the price at which a trigger order is triggered at
1578
- * @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice that the attached take profit order will be triggered (perpetual swap markets only)
1579
- * @param {float} [params.takeProfit.triggerPrice] *swap only* take profit trigger price
1580
- * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice that the attached stop loss order will be triggered (perpetual swap markets only)
1581
- * @param {float} [params.stopLoss.triggerPrice] *swap only* stop loss trigger price
1582
- * @returns [An order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1583
- */
1584
- await this.loadMarkets();
1585
- await this.loadAccounts();
1586
- const market = this.market(symbol);
1587
- const request = this.createOrderRequest(symbol, type, side, amount, price, params);
1588
- let response = undefined;
1589
- if (market['swap']) {
1590
- response = await this.v2PrivateAccountGroupPostFuturesOrder(request);
1591
- }
1592
- else {
1593
- response = await this.v1PrivateAccountCategoryPostOrder(request);
1594
- }
1595
- //
1596
- // spot
1597
- //
1598
- // {
1599
- // "code":0,
1600
- // "data": {
1601
- // "accountId":"cshwT8RKojkT1HoaA5UdeimR2SrmHG2I",
1602
- // "ac":"CASH",
1603
- // "action":"place-order",
1604
- // "status":"Ack",
1605
- // "info": {
1606
- // "symbol":"TRX/USDT",
1607
- // "orderType":"StopLimit",
1608
- // "timestamp":1654290662172,
1609
- // "id":"",
1610
- // "orderId":"a1812b6840ddU8191168955av0k6Eyhj"
1611
- // }
1612
- // }
1613
- // }
1614
- //
1615
- // swap
1616
- //
1617
- // {
1618
- // "code":0,
1619
- // "data": {
1620
- // "meta": {
1621
- // "id":"",
1622
- // "action":"place-order",
1623
- // "respInst":"ACK"
1624
- // },
1625
- // "order": {
1626
- // "ac":"FUTURES",
1627
- // "accountId":"futwT8RKojkT1HoaA5UdeimR2SrmHG2I",
1628
- // "time":1654290969965,
1629
- // "orderId":"a1812b6cf322U8191168955oJamfTh7b",
1630
- // "seqNum":-1,
1631
- // "orderType":"StopLimit",
1632
- // "execInst":"NULL_VAL",
1633
- // "side":"Buy",
1634
- // "symbol":"TRX-PERP",
1635
- // "price":"0.083",
1636
- // "orderQty":"1",
1637
- // "stopPrice":"0.082",
1638
- // "stopBy":"ref-px",
1639
- // "status":"Ack",
1640
- // "lastExecTime":1654290969965,
1641
- // "lastQty":"0",
1642
- // "lastPx":"0",
1643
- // "avgFilledPx":"0",
1644
- // "cumFilledQty":"0",
1645
- // "fee":"0",
1646
- // "cumFee":"0",
1647
- // "feeAsset":"",
1648
- // "errorCode":"",
1649
- // "posStopLossPrice":"0",
1650
- // "posStopLossTrigger":"market",
1651
- // "posTakeProfitPrice":"0",
1652
- // "posTakeProfitTrigger":"market",
1653
- // "liquidityInd":"n"
1654
- // }
1655
- // }
1656
- // }
1657
- //
1658
- const data = this.safeValue(response, 'data', {});
1659
- const order = this.safeValue2(data, 'order', 'info', {});
1660
- return this.parseOrder(order, market);
1661
- }
1662
- async createOrders(orders, params = {}) {
1663
- /**
1664
- * @method
1665
- * @name ascendex#createOrders
1666
- * @description create a list of trade orders
1667
- * @see https://ascendex.github.io/ascendex-pro-api/#place-batch-orders
1668
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#place-batch-orders
1669
- * @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
1670
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1671
- * @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
1672
- * @param {bool} [params.postOnly] true or false
1673
- * @param {float} [params.stopPrice] the price at which a trigger order is triggered at
1674
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1675
- */
1676
- await this.loadMarkets();
1677
- await this.loadAccounts();
1678
- const ordersRequests = [];
1679
- let symbol = undefined;
1680
- let marginMode = undefined;
1681
- for (let i = 0; i < orders.length; i++) {
1682
- const rawOrder = orders[i];
1683
- const marketId = this.safeString(rawOrder, 'symbol');
1684
- if (symbol === undefined) {
1685
- symbol = marketId;
1686
- }
1687
- else {
1688
- if (symbol !== marketId) {
1689
- throw new errors.BadRequest(this.id + ' createOrders() requires all orders to have the same symbol');
1690
- }
1691
- }
1692
- const type = this.safeString(rawOrder, 'type');
1693
- const side = this.safeString(rawOrder, 'side');
1694
- const amount = this.safeValue(rawOrder, 'amount');
1695
- const price = this.safeValue(rawOrder, 'price');
1696
- const orderParams = this.safeValue(rawOrder, 'params', {});
1697
- const marginResult = this.handleMarginModeAndParams('createOrders', orderParams);
1698
- const currentMarginMode = marginResult[0];
1699
- if (currentMarginMode !== undefined) {
1700
- if (marginMode === undefined) {
1701
- marginMode = currentMarginMode;
1702
- }
1703
- else {
1704
- if (marginMode !== currentMarginMode) {
1705
- throw new errors.BadRequest(this.id + ' createOrders() requires all orders to have the same margin mode (isolated or cross)');
1706
- }
1707
- }
1708
- }
1709
- const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
1710
- ordersRequests.push(orderRequest);
1711
- }
1712
- const market = this.market(symbol);
1713
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
1714
- let accountCategory = this.safeString(accountsByType, market['type'], 'cash');
1715
- if (marginMode !== undefined) {
1716
- accountCategory = 'margin';
1717
- }
1718
- const account = this.safeValue(this.accounts, 0, {});
1719
- const accountGroup = this.safeValue(account, 'id');
1720
- const request = {};
1721
- let response = undefined;
1722
- if (market['swap']) {
1723
- throw new errors.NotSupported(this.id + ' createOrders() is not currently supported for swap markets on ascendex');
1724
- // request['account-group'] = accountGroup;
1725
- // request['category'] = accountCategory;
1726
- // request['orders'] = ordersRequests;
1727
- // response = await this.v2PrivateAccountGroupPostFuturesOrderBatch (request);
1728
- }
1729
- else {
1730
- request['account-group'] = accountGroup;
1731
- request['account-category'] = accountCategory;
1732
- request['orders'] = ordersRequests;
1733
- response = await this.v1PrivateAccountCategoryPostOrderBatch(request);
1734
- }
1735
- //
1736
- // spot
1737
- //
1738
- // {
1739
- // "code": 0,
1740
- // "data": {
1741
- // "accountId": "cshdAKBO43TKIh2kJtq7FVVb42KIePyS",
1742
- // "ac": "CASH",
1743
- // "action": "batch-place-order",
1744
- // "status": "Ack",
1745
- // "info": [
1746
- // {
1747
- // "symbol": "BTC/USDT",
1748
- // "orderType": "Limit",
1749
- // "timestamp": 1699326589344,
1750
- // "id": "",
1751
- // "orderId": "a18ba7c1f6efU0711043490p3HvjjN5x"
1752
- // }
1753
- // ]
1754
- // }
1755
- // }
1756
- //
1757
- const data = this.safeValue(response, 'data', {});
1758
- const info = this.safeValue(data, 'info', []);
1759
- return this.parseOrders(info, market);
1760
- }
1761
- async fetchOrder(id, symbol = undefined, params = {}) {
1762
- /**
1763
- * @method
1764
- * @name ascendex#fetchOrder
1765
- * @description fetches information on an order made by the user
1766
- * @see https://ascendex.github.io/ascendex-pro-api/#query-order
1767
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#query-order-by-id
1768
- * @param {string} symbol unified symbol of the market the order was made in
1769
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1770
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1771
- */
1772
- await this.loadMarkets();
1773
- await this.loadAccounts();
1774
- let market = undefined;
1775
- if (symbol !== undefined) {
1776
- market = this.market(symbol);
1777
- }
1778
- const [type, query] = this.handleMarketTypeAndParams('fetchOrder', market, params);
1779
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
1780
- const accountCategory = this.safeString(accountsByType, type, 'cash');
1781
- const account = this.safeValue(this.accounts, 0, {});
1782
- const accountGroup = this.safeValue(account, 'id');
1783
- const request = {
1784
- 'account-group': accountGroup,
1785
- 'account-category': accountCategory,
1786
- 'orderId': id,
1787
- };
1788
- let response = undefined;
1789
- if ((type === 'spot') || (type === 'margin')) {
1790
- response = await this.v1PrivateAccountCategoryGetOrderStatus(this.extend(request, query));
1791
- }
1792
- else if (type === 'swap') {
1793
- request['account-category'] = accountCategory;
1794
- response = await this.v2PrivateAccountGroupGetFuturesOrderStatus(this.extend(request, query));
1795
- }
1796
- else {
1797
- throw new errors.NotSupported(this.id + ' fetchOrder() is not currently supported for ' + type + ' markets');
1798
- }
1799
- //
1800
- // AccountCategoryGetOrderStatus
1801
- //
1802
- // {
1803
- // "code": 0,
1804
- // "accountCategory": "CASH",
1805
- // "accountId": "cshQtyfq8XLAA9kcf19h8bXHbAwwoqDo",
1806
- // "data": [
1807
- // {
1808
- // "symbol": "BTC/USDT",
1809
- // "price": "8131.22",
1810
- // "orderQty": "0.00082",
1811
- // "orderType": "Market",
1812
- // "avgPx": "7392.02",
1813
- // "cumFee": "0.005152238",
1814
- // "cumFilledQty": "0.00082",
1815
- // "errorCode": "",
1816
- // "feeAsset": "USDT",
1817
- // "lastExecTime": 1575953151764,
1818
- // "orderId": "a16eee20b6750866943712zWEDdAjt3",
1819
- // "seqNum": 2623469,
1820
- // "side": "Buy",
1821
- // "status": "Filled",
1822
- // "stopPrice": "",
1823
- // "execInst": "NULL_VAL"
1824
- // }
1825
- // ]
1826
- // }
1827
- //
1828
- // AccountGroupGetFuturesOrderStatus
1829
- //
1830
- // {
1831
- // "code": 0,
1832
- // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
1833
- // "ac": "FUTURES",
1834
- // "data": {
1835
- // "ac": "FUTURES",
1836
- // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
1837
- // "time": 1640247020217,
1838
- // "orderId": "r17de65747aeU0711043490bbtcp0cmt",
1839
- // "seqNum": 28796162908,
1840
- // "orderType": "Limit",
1841
- // "execInst": "NULL_VAL",
1842
- // "side": "Buy",
1843
- // "symbol": "BTC-PERP",
1844
- // "price": "30000",
1845
- // "orderQty": "0.0021",
1846
- // "stopPrice": "0",
1847
- // "stopBy": "market",
1848
- // "status": "New",
1849
- // "lastExecTime": 1640247020232,
1850
- // "lastQty": "0",
1851
- // "lastPx": "0",
1852
- // "avgFilledPx": "0",
1853
- // "cumFilledQty": "0",
1854
- // "fee": "0",
1855
- // "cumFee": "0",
1856
- // "feeAsset": "USDT",
1857
- // "errorCode": "",
1858
- // "posStopLossPrice": "0",
1859
- // "posStopLossTrigger": "market",
1860
- // "posTakeProfitPrice": "0",
1861
- // "posTakeProfitTrigger": "market",
1862
- // "liquidityInd": "n"
1863
- // }
1864
- // }
1865
- //
1866
- const data = this.safeValue(response, 'data', {});
1867
- return this.parseOrder(data, market);
1868
- }
1869
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1870
- /**
1871
- * @method
1872
- * @name ascendex#fetchOpenOrders
1873
- * @description fetch all unfilled currently open orders
1874
- * @see https://ascendex.github.io/ascendex-pro-api/#list-open-orders
1875
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-open-orders
1876
- * @param {string} symbol unified market symbol
1877
- * @param {int} [since] the earliest time in ms to fetch open orders for
1878
- * @param {int} [limit] the maximum number of open orders structures to retrieve
1879
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1880
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1881
- */
1882
- await this.loadMarkets();
1883
- await this.loadAccounts();
1884
- let market = undefined;
1885
- if (symbol !== undefined) {
1886
- market = this.market(symbol);
1887
- symbol = market['symbol'];
1888
- }
1889
- const account = this.safeValue(this.accounts, 0, {});
1890
- const accountGroup = this.safeValue(account, 'id');
1891
- const [type, query] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
1892
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
1893
- const accountCategory = this.safeString(accountsByType, type, 'cash');
1894
- const request = {
1895
- 'account-group': accountGroup,
1896
- 'account-category': accountCategory,
1897
- };
1898
- let response = undefined;
1899
- if ((type === 'spot') || (type === 'margin')) {
1900
- response = await this.v1PrivateAccountCategoryGetOrderOpen(this.extend(request, query));
1901
- }
1902
- else if (type === 'swap') {
1903
- request['account-category'] = accountCategory;
1904
- response = await this.v2PrivateAccountGroupGetFuturesOrderOpen(this.extend(request, query));
1905
- }
1906
- else {
1907
- throw new errors.NotSupported(this.id + ' fetchOpenOrders() is not currently supported for ' + type + ' markets');
1908
- }
1909
- //
1910
- // AccountCategoryGetOrderOpen
1911
- //
1912
- // {
1913
- // "ac": "CASH",
1914
- // "accountId": "cshQtyfq8XLAA9kcf19h8bXHbAwwoqDo",
1915
- // "code": 0,
1916
- // "data": [
1917
- // {
1918
- // "avgPx": "0", // Average filled price of the order
1919
- // "cumFee": "0", // cumulative fee paid for this order
1920
- // "cumFilledQty": "0", // cumulative filled quantity
1921
- // "errorCode": "", // error code; could be empty
1922
- // "feeAsset": "USDT", // fee asset
1923
- // "lastExecTime": 1576019723550, // The last execution time of the order
1924
- // "orderId": "s16ef21882ea0866943712034f36d83", // server provided orderId
1925
- // "orderQty": "0.0083", // order quantity
1926
- // "orderType": "Limit", // order type
1927
- // "price": "7105", // order price
1928
- // "seqNum": 8193258, // sequence number
1929
- // "side": "Buy", // order side
1930
- // "status": "New", // order status on matching engine
1931
- // "stopPrice": "", // only available for stop market and stop limit orders; otherwise empty
1932
- // "symbol": "BTC/USDT",
1933
- // "execInst": "NULL_VAL" // execution instruction
1934
- // },
1935
- // ]
1936
- // }
1937
- //
1938
- // AccountGroupGetFuturesOrderOpen
1939
- //
1940
- // {
1941
- // "code": 0,
1942
- // "data": [
1943
- // {
1944
- // "ac": "FUTURES",
1945
- // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
1946
- // "time": 1640247020217,
1947
- // "orderId": "r17de65747aeU0711043490bbtcp0cmt",
1948
- // "seqNum": 28796162908,
1949
- // "orderType": "Limit",
1950
- // "execInst": "NULL_VAL",
1951
- // "side": "Buy",
1952
- // "symbol": "BTC-PERP",
1953
- // "price": "30000",
1954
- // "orderQty": "0.0021",
1955
- // "stopPrice": "0",
1956
- // "stopBy": "market",
1957
- // "status": "New",
1958
- // "lastExecTime": 1640247020232,
1959
- // "lastQty": "0",
1960
- // "lastPx": "0",
1961
- // "avgFilledPx": "0",
1962
- // "cumFilledQty": "0",
1963
- // "fee": "0",
1964
- // "cumFee": "0",
1965
- // "feeAsset": "USDT",
1966
- // "errorCode": "",
1967
- // "posStopLossPrice": "0",
1968
- // "posStopLossTrigger": "market",
1969
- // "posTakeProfitPrice": "0",
1970
- // "posTakeProfitTrigger": "market",
1971
- // "liquidityInd": "n"
1972
- // }
1973
- // ]
1974
- // }
1975
- //
1976
- const data = this.safeValue(response, 'data', []);
1977
- if (accountCategory === 'futures') {
1978
- return this.parseOrders(data, market, since, limit);
1979
- }
1980
- // a workaround for https://github.com/ccxt/ccxt/issues/7187
1981
- const orders = [];
1982
- for (let i = 0; i < data.length; i++) {
1983
- const order = this.parseOrder(data[i], market);
1984
- orders.push(order);
1985
- }
1986
- return this.filterBySymbolSinceLimit(orders, symbol, since, limit);
1987
- }
1988
- async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1989
- /**
1990
- * @method
1991
- * @name ascendex#fetchClosedOrders
1992
- * @description fetches information on multiple closed orders made by the user
1993
- * @see https://ascendex.github.io/ascendex-pro-api/#list-history-orders-v2
1994
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#list-current-history-orders
1995
- * @param {string} symbol unified market symbol of the market orders were made in
1996
- * @param {int} [since] the earliest time in ms to fetch orders for
1997
- * @param {int} [limit] the maximum number of order structures to retrieve
1998
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1999
- * @param {int} [params.until] the latest time in ms to fetch orders for
2000
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2001
- */
2002
- await this.loadMarkets();
2003
- await this.loadAccounts();
2004
- const account = this.safeValue(this.accounts, 0, {});
2005
- const accountGroup = this.safeValue(account, 'id');
2006
- const request = {
2007
- // 'category': accountCategory,
2008
- // 'symbol': market['id'],
2009
- // 'orderType': 'market', // optional, string
2010
- // 'side': 'buy', // or 'sell', optional, case insensitive.
2011
- // 'status': 'Filled', // "Filled", "Canceled", or "Rejected"
2012
- // 'startTime': exchange.milliseconds (),
2013
- // 'endTime': exchange.milliseconds (),
2014
- // 'page': 1,
2015
- // 'pageSize': 100,
2016
- };
2017
- let market = undefined;
2018
- if (symbol !== undefined) {
2019
- market = this.market(symbol);
2020
- request['symbol'] = market['id'];
2021
- }
2022
- const [type, query] = this.handleMarketTypeAndParams('fetchClosedOrders', market, params);
2023
- const options = this.safeValue(this.options, 'fetchClosedOrders', {});
2024
- const defaultMethod = this.safeString(options, 'method', 'v2PrivateDataGetOrderHist');
2025
- const method = this.getSupportedMapping(type, {
2026
- 'spot': defaultMethod,
2027
- 'margin': defaultMethod,
2028
- 'swap': 'v2PrivateAccountGroupGetFuturesOrderHistCurrent',
2029
- });
2030
- if (since !== undefined) {
2031
- request['startTime'] = since;
2032
- }
2033
- const until = this.safeString(params, 'until');
2034
- if (until !== undefined) {
2035
- request['endTime'] = until;
2036
- }
2037
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
2038
- const accountCategory = this.safeString(accountsByType, type, 'cash'); // margin, futures
2039
- let response = undefined;
2040
- if (method === 'v1PrivateAccountCategoryGetOrderHistCurrent') {
2041
- request['account-group'] = accountGroup;
2042
- request['account-category'] = accountCategory;
2043
- if (limit !== undefined) {
2044
- request['limit'] = limit;
2045
- }
2046
- response = await this.v1PrivateAccountCategoryGetOrderHistCurrent(this.extend(request, query));
2047
- }
2048
- else if (method === 'v2PrivateDataGetOrderHist') {
2049
- request['account'] = accountCategory;
2050
- if (limit !== undefined) {
2051
- request['limit'] = limit;
2052
- }
2053
- response = await this.v2PrivateDataGetOrderHist(this.extend(request, query));
2054
- }
2055
- else if (method === 'v2PrivateAccountGroupGetFuturesOrderHistCurrent') {
2056
- request['account-group'] = accountGroup;
2057
- request['account-category'] = accountCategory;
2058
- if (limit !== undefined) {
2059
- request['pageSize'] = limit;
2060
- }
2061
- response = await this.v2PrivateAccountGroupGetFuturesOrderHistCurrent(this.extend(request, query));
2062
- }
2063
- else {
2064
- throw new errors.NotSupported(this.id + ' fetchClosedOrders() is not currently supported for ' + type + ' markets');
2065
- }
2066
- //
2067
- // accountCategoryGetOrderHistCurrent
2068
- //
2069
- // {
2070
- // "code":0,
2071
- // "accountId":"cshrHKLZCjlZ2ejqkmvIHHtPmLYqdnda",
2072
- // "ac":"CASH",
2073
- // "data":[
2074
- // {
2075
- // "seqNum":15561826728,
2076
- // "orderId":"a17294d305c0U6491137460bethu7kw9",
2077
- // "symbol":"ETH/USDT",
2078
- // "orderType":"Limit",
2079
- // "lastExecTime":1591635618200,
2080
- // "price":"200",
2081
- // "orderQty":"0.1",
2082
- // "side":"Buy",
2083
- // "status":"Canceled",
2084
- // "avgPx":"0",
2085
- // "cumFilledQty":"0",
2086
- // "stopPrice":"",
2087
- // "errorCode":"",
2088
- // "cumFee":"0",
2089
- // "feeAsset":"USDT",
2090
- // "execInst":"NULL_VAL"
2091
- // }
2092
- // ]
2093
- // }
2094
- //
2095
- // {
2096
- // "code": 0,
2097
- // "data": [
2098
- // {
2099
- // "orderId" : "a173ad938fc3U22666567717788c3b66", // orderId
2100
- // "seqNum" : 18777366360, // sequence number
2101
- // "accountId" : "cshwSjbpPjSwHmxPdz2CPQVU9mnbzPpt", // accountId
2102
- // "symbol" : "BTC/USDT", // symbol
2103
- // "orderType" : "Limit", // order type (Limit/Market/StopMarket/StopLimit)
2104
- // "side" : "Sell", // order side (Buy/Sell)
2105
- // "price" : "11346.77", // order price
2106
- // "stopPrice" : "0", // stop price (0 by default)
2107
- // "orderQty" : "0.01", // order quantity (in base asset)
2108
- // "status" : "Canceled", // order status (Filled/Canceled/Rejected)
2109
- // "createTime" : 1596344995793, // order creation time
2110
- // "lastExecTime": 1596344996053, // last execution time
2111
- // "avgFillPrice": "11346.77", // average filled price
2112
- // "fillQty" : "0.01", // filled quantity (in base asset)
2113
- // "fee" : "-0.004992579", // cummulative fee. if negative, this value is the commission charged; if possitive, this value is the rebate received.
2114
- // "feeAsset" : "USDT" // fee asset
2115
- // }
2116
- // ]
2117
- // }
2118
- //
2119
- // accountGroupGetFuturesOrderHistCurrent
2120
- //
2121
- // {
2122
- // "code": 0,
2123
- // "data": [
2124
- // {
2125
- // "ac": "FUTURES",
2126
- // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
2127
- // "time": 1640245777002,
2128
- // "orderId": "r17de6444fa6U0711043490bbtcpJ2lI",
2129
- // "seqNum": 28796124902,
2130
- // "orderType": "Limit",
2131
- // "execInst": "NULL_VAL",
2132
- // "side": "Buy",
2133
- // "symbol": "BTC-PERP",
2134
- // "price": "30000",
2135
- // "orderQty": "0.0021",
2136
- // "stopPrice": "0",
2137
- // "stopBy": "market",
2138
- // "status": "Canceled",
2139
- // "lastExecTime": 1640246574886,
2140
- // "lastQty": "0",
2141
- // "lastPx": "0",
2142
- // "avgFilledPx": "0",
2143
- // "cumFilledQty": "0",
2144
- // "fee": "0",
2145
- // "cumFee": "0",
2146
- // "feeAsset": "USDT",
2147
- // "errorCode": "",
2148
- // "posStopLossPrice": "0",
2149
- // "posStopLossTrigger": "market",
2150
- // "posTakeProfitPrice": "0",
2151
- // "posTakeProfitTrigger": "market",
2152
- // "liquidityInd": "n"
2153
- // }
2154
- // ]
2155
- // }
2156
- //
2157
- let data = this.safeValue(response, 'data');
2158
- const isArray = Array.isArray(data);
2159
- if (!isArray) {
2160
- data = this.safeValue(data, 'data', []);
2161
- }
2162
- return this.parseOrders(data, market, since, limit);
2163
- }
2164
- async cancelOrder(id, symbol = undefined, params = {}) {
2165
- /**
2166
- * @method
2167
- * @name ascendex#cancelOrder
2168
- * @description cancels an open order
2169
- * @see https://ascendex.github.io/ascendex-pro-api/#cancel-order
2170
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-order
2171
- * @param {string} id order id
2172
- * @param {string} symbol unified symbol of the market the order was made in
2173
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2174
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2175
- */
2176
- if (symbol === undefined) {
2177
- throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
2178
- }
2179
- await this.loadMarkets();
2180
- await this.loadAccounts();
2181
- const market = this.market(symbol);
2182
- const [type, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
2183
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
2184
- const accountCategory = this.safeString(accountsByType, type, 'cash');
2185
- const account = this.safeValue(this.accounts, 0, {});
2186
- const accountGroup = this.safeValue(account, 'id');
2187
- const request = {
2188
- 'account-group': accountGroup,
2189
- 'account-category': accountCategory,
2190
- 'symbol': market['id'],
2191
- 'time': this.milliseconds(),
2192
- 'id': 'foobar',
2193
- };
2194
- const clientOrderId = this.safeString2(params, 'clientOrderId', 'id');
2195
- if (clientOrderId === undefined) {
2196
- request['orderId'] = id;
2197
- }
2198
- else {
2199
- request['id'] = clientOrderId;
2200
- params = this.omit(params, ['clientOrderId', 'id']);
2201
- }
2202
- let response = undefined;
2203
- if ((type === 'spot') || (type === 'margin')) {
2204
- response = await this.v1PrivateAccountCategoryDeleteOrder(this.extend(request, query));
2205
- }
2206
- else if (type === 'swap') {
2207
- request['account-category'] = accountCategory;
2208
- response = await this.v2PrivateAccountGroupDeleteFuturesOrder(this.extend(request, query));
2209
- }
2210
- else {
2211
- throw new errors.NotSupported(this.id + ' cancelOrder() is not currently supported for ' + type + ' markets');
2212
- }
2213
- //
2214
- // AccountCategoryDeleteOrder
2215
- //
2216
- // {
2217
- // "code": 0,
2218
- // "data": {
2219
- // "accountId": "cshQtyfq8XLAA9kcf19h8bXHbAwwoqDo",
2220
- // "ac": "CASH",
2221
- // "action": "cancel-order",
2222
- // "status": "Ack",
2223
- // "info": {
2224
- // "id": "wv8QGquoeamhssvQBeHOHGQCGlcBjj23",
2225
- // "orderId": "16e6198afb4s8bXHbAwwoqDo2ebc19dc",
2226
- // "orderType": "", // could be empty
2227
- // "symbol": "ETH/USDT",
2228
- // "timestamp": 1573594877822
2229
- // }
2230
- // }
2231
- // }
2232
- //
2233
- // AccountGroupDeleteFuturesOrder
2234
- //
2235
- // {
2236
- // "code": 0,
2237
- // "data": {
2238
- // "meta": {
2239
- // "id": "foobar",
2240
- // "action": "cancel-order",
2241
- // "respInst": "ACK"
2242
- // },
2243
- // "order": {
2244
- // "ac": "FUTURES",
2245
- // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
2246
- // "time": 1640244480476,
2247
- // "orderId": "r17de63086f4U0711043490bbtcpPUF4",
2248
- // "seqNum": 28795959269,
2249
- // "orderType": "Limit",
2250
- // "execInst": "NULL_VAL",
2251
- // "side": "Buy",
2252
- // "symbol": "BTC-PERP",
2253
- // "price": "30000",
2254
- // "orderQty": "0.0021",
2255
- // "stopPrice": "0",
2256
- // "stopBy": "market",
2257
- // "status": "New",
2258
- // "lastExecTime": 1640244480491,
2259
- // "lastQty": "0",
2260
- // "lastPx": "0",
2261
- // "avgFilledPx": "0",
2262
- // "cumFilledQty": "0",
2263
- // "fee": "0",
2264
- // "cumFee": "0",
2265
- // "feeAsset": "BTCPC",
2266
- // "errorCode": "",
2267
- // "posStopLossPrice": "0",
2268
- // "posStopLossTrigger": "market",
2269
- // "posTakeProfitPrice": "0",
2270
- // "posTakeProfitTrigger": "market",
2271
- // "liquidityInd": "n"
2272
- // }
2273
- // }
2274
- // }
2275
- //
2276
- const data = this.safeValue(response, 'data', {});
2277
- const order = this.safeValue2(data, 'order', 'info', {});
2278
- return this.parseOrder(order, market);
2279
- }
2280
- async cancelAllOrders(symbol = undefined, params = {}) {
2281
- /**
2282
- * @method
2283
- * @name ascendex#cancelAllOrders
2284
- * @description cancel all open orders
2285
- * @see https://ascendex.github.io/ascendex-pro-api/#cancel-all-orders
2286
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#cancel-all-open-orders
2287
- * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
2288
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2289
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
2290
- */
2291
- await this.loadMarkets();
2292
- await this.loadAccounts();
2293
- let market = undefined;
2294
- if (symbol !== undefined) {
2295
- market = this.market(symbol);
2296
- }
2297
- const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
2298
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
2299
- const accountCategory = this.safeString(accountsByType, type, 'cash');
2300
- const account = this.safeValue(this.accounts, 0, {});
2301
- const accountGroup = this.safeValue(account, 'id');
2302
- const request = {
2303
- 'account-group': accountGroup,
2304
- 'account-category': accountCategory,
2305
- 'time': this.milliseconds(),
2306
- };
2307
- if (symbol !== undefined) {
2308
- request['symbol'] = market['id'];
2309
- }
2310
- let response = undefined;
2311
- if ((type === 'spot') || (type === 'margin')) {
2312
- response = await this.v1PrivateAccountCategoryDeleteOrderAll(this.extend(request, query));
2313
- }
2314
- else if (type === 'swap') {
2315
- request['account-category'] = accountCategory;
2316
- response = await this.v2PrivateAccountGroupDeleteFuturesOrderAll(this.extend(request, query));
2317
- }
2318
- else {
2319
- throw new errors.NotSupported(this.id + ' cancelAllOrders() is not currently supported for ' + type + ' markets');
2320
- }
2321
- //
2322
- // AccountCategoryDeleteOrderAll
2323
- //
2324
- // {
2325
- // "code": 0,
2326
- // "data": {
2327
- // "ac": "CASH",
2328
- // "accountId": "cshQtyfq8XLAA9kcf19h8bXHbAwwoqDo",
2329
- // "action": "cancel-all",
2330
- // "info": {
2331
- // "id": "2bmYvi7lyTrneMzpcJcf2D7Pe9V1P9wy",
2332
- // "orderId": "",
2333
- // "orderType": "NULL_VAL",
2334
- // "symbol": "",
2335
- // "timestamp": 1574118495462
2336
- // },
2337
- // "status": "Ack"
2338
- // }
2339
- // }
2340
- //
2341
- // AccountGroupDeleteFuturesOrderAll
2342
- //
2343
- // {
2344
- // "code": 0,
2345
- // "data": {
2346
- // "ac": "FUTURES",
2347
- // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
2348
- // "action": "cancel-all",
2349
- // "info": {
2350
- // "symbol":"BTC-PERP"
2351
- // }
2352
- // }
2353
- // }
2354
- //
2355
- return response;
2356
- }
2357
- parseDepositAddress(depositAddress, currency = undefined) {
2358
- //
2359
- // {
2360
- // "address": "0xe7c70b4e73b6b450ee46c3b5c0f5fb127ca55722",
2361
- // "destTag": "",
2362
- // "tagType": "",
2363
- // "tagId": "",
2364
- // "chainName": "ERC20",
2365
- // "numConfirmations": 20,
2366
- // "withdrawalFee": 1,
2367
- // "nativeScale": 4,
2368
- // "tips": []
2369
- // }
2370
- //
2371
- const address = this.safeString(depositAddress, 'address');
2372
- const tagId = this.safeString(depositAddress, 'tagId');
2373
- const tag = this.safeString(depositAddress, tagId);
2374
- this.checkAddress(address);
2375
- const code = (currency === undefined) ? undefined : currency['code'];
2376
- const chainName = this.safeString(depositAddress, 'chainName');
2377
- const network = this.safeNetwork(chainName);
2378
- return {
2379
- 'currency': code,
2380
- 'address': address,
2381
- 'tag': tag,
2382
- 'network': network,
2383
- 'info': depositAddress,
2384
- };
2385
- }
2386
- safeNetwork(networkId) {
2387
- const networksById = {
2388
- 'TRC20': 'TRC20',
2389
- 'ERC20': 'ERC20',
2390
- 'GO20': 'GO20',
2391
- 'BEP2': 'BEP2',
2392
- 'BEP20 (BSC)': 'BEP20',
2393
- 'Bitcoin': 'BTC',
2394
- 'Bitcoin ABC': 'BCH',
2395
- 'Litecoin': 'LTC',
2396
- 'Matic Network': 'MATIC',
2397
- 'Solana': 'SOL',
2398
- 'xDai': 'STAKE',
2399
- 'Akash': 'AKT',
2400
- };
2401
- return this.safeString(networksById, networkId, networkId);
2402
- }
2403
- async fetchDepositAddress(code, params = {}) {
2404
- /**
2405
- * @method
2406
- * @name ascendex#fetchDepositAddress
2407
- * @description fetch the deposit address for a currency associated with this account
2408
- * @param {string} code unified currency code
2409
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2410
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
2411
- */
2412
- await this.loadMarkets();
2413
- const currency = this.currency(code);
2414
- const chainName = this.safeString(params, 'chainName');
2415
- params = this.omit(params, 'chainName');
2416
- const request = {
2417
- 'asset': currency['id'],
2418
- };
2419
- const response = await this.v1PrivateGetWalletDepositAddress(this.extend(request, params));
2420
- //
2421
- // {
2422
- // "code":0,
2423
- // "data":{
2424
- // "asset":"USDT",
2425
- // "assetName":"Tether",
2426
- // "address":[
2427
- // {
2428
- // "address":"1N22odLHXnLPCjC8kwBJPTayarr9RtPod6",
2429
- // "destTag":"",
2430
- // "tagType":"",
2431
- // "tagId":"",
2432
- // "chainName":"Omni",
2433
- // "numConfirmations":3,
2434
- // "withdrawalFee":4.7,
2435
- // "nativeScale":4,
2436
- // "tips":[]
2437
- // },
2438
- // {
2439
- // "address":"0xe7c70b4e73b6b450ee46c3b5c0f5fb127ca55722",
2440
- // "destTag":"",
2441
- // "tagType":"",
2442
- // "tagId":"",
2443
- // "chainName":"ERC20",
2444
- // "numConfirmations":20,
2445
- // "withdrawalFee":1.0,
2446
- // "nativeScale":4,
2447
- // "tips":[]
2448
- // }
2449
- // ]
2450
- // }
2451
- // }
2452
- //
2453
- const data = this.safeValue(response, 'data', {});
2454
- const addresses = this.safeValue(data, 'address', []);
2455
- const numAddresses = addresses.length;
2456
- let address = undefined;
2457
- if (numAddresses > 1) {
2458
- const addressesByChainName = this.indexBy(addresses, 'chainName');
2459
- if (chainName === undefined) {
2460
- const chainNames = Object.keys(addressesByChainName);
2461
- const chains = chainNames.join(', ');
2462
- throw new errors.ArgumentsRequired(this.id + ' fetchDepositAddress() returned more than one address, a chainName parameter is required, one of ' + chains);
2463
- }
2464
- address = this.safeValue(addressesByChainName, chainName, {});
2465
- }
2466
- else {
2467
- // first address
2468
- address = this.safeValue(addresses, 0, {});
2469
- }
2470
- const result = this.parseDepositAddress(address, currency);
2471
- return this.extend(result, {
2472
- 'info': response,
2473
- });
2474
- }
2475
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
2476
- /**
2477
- * @method
2478
- * @name ascendex#fetchDeposits
2479
- * @description fetch all deposits made to an account
2480
- * @param {string} code unified currency code
2481
- * @param {int} [since] the earliest time in ms to fetch deposits for
2482
- * @param {int} [limit] the maximum number of deposits structures to retrieve
2483
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2484
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2485
- */
2486
- const request = {
2487
- 'txType': 'deposit',
2488
- };
2489
- return await this.fetchTransactions(code, since, limit, this.extend(request, params));
2490
- }
2491
- async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
2492
- /**
2493
- * @method
2494
- * @name ascendex#fetchWithdrawals
2495
- * @description fetch all withdrawals made from an account
2496
- * @param {string} code unified currency code
2497
- * @param {int} [since] the earliest time in ms to fetch withdrawals for
2498
- * @param {int} [limit] the maximum number of withdrawals structures to retrieve
2499
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2500
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2501
- */
2502
- const request = {
2503
- 'txType': 'withdrawal',
2504
- };
2505
- return await this.fetchTransactions(code, since, limit, this.extend(request, params));
2506
- }
2507
- async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
2508
- /**
2509
- * @method
2510
- * @name ascendex#fetchDepositsWithdrawals
2511
- * @description fetch history of deposits and withdrawals
2512
- * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
2513
- * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
2514
- * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
2515
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2516
- * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
2517
- */
2518
- await this.loadMarkets();
2519
- const request = {
2520
- // 'asset': currency['id'],
2521
- // 'page': 1,
2522
- // 'pageSize': 20,
2523
- // 'startTs': this.milliseconds (),
2524
- // 'endTs': this.milliseconds (),
2525
- // 'txType': undefned, // deposit, withdrawal
2526
- };
2527
- let currency = undefined;
2528
- if (code !== undefined) {
2529
- currency = this.currency(code);
2530
- request['asset'] = currency['id'];
2531
- }
2532
- if (since !== undefined) {
2533
- request['startTs'] = since;
2534
- }
2535
- if (limit !== undefined) {
2536
- request['pageSize'] = limit;
2537
- }
2538
- const response = await this.v1PrivateGetWalletTransactions(this.extend(request, params));
2539
- //
2540
- // {
2541
- // "code": 0,
2542
- // "data": {
2543
- // "data": [
2544
- // {
2545
- // "requestId": "wuzd1Ojsqtz4bCA3UXwtUnnJDmU8PiyB",
2546
- // "time": 1591606166000,
2547
- // "asset": "USDT",
2548
- // "transactionType": "deposit",
2549
- // "amount": "25",
2550
- // "commission": "0",
2551
- // "networkTransactionId": "0xbc4eabdce92f14dbcc01d799a5f8ca1f02f4a3a804b6350ea202be4d3c738fce",
2552
- // "status": "pending",
2553
- // "numConfirmed": 8,
2554
- // "numConfirmations": 20,
2555
- // "destAddress": { address: "0xe7c70b4e73b6b450ee46c3b5c0f5fb127ca55722" }
2556
- // }
2557
- // ],
2558
- // "page": 1,
2559
- // "pageSize": 20,
2560
- // "hasNext": false
2561
- // }
2562
- // }
2563
- //
2564
- const data = this.safeValue(response, 'data', {});
2565
- const transactions = this.safeValue(data, 'data', []);
2566
- return this.parseTransactions(transactions, currency, since, limit);
2567
- }
2568
- parseTransactionStatus(status) {
2569
- const statuses = {
2570
- 'reviewing': 'pending',
2571
- 'pending': 'pending',
2572
- 'confirmed': 'ok',
2573
- 'rejected': 'rejected',
2574
- };
2575
- return this.safeString(statuses, status, status);
2576
- }
2577
- parseTransaction(transaction, currency = undefined) {
2578
- //
2579
- // {
2580
- // "requestId": "wuzd1Ojsqtz4bCA3UXwtUnnJDmU8PiyB",
2581
- // "time": 1591606166000,
2582
- // "asset": "USDT",
2583
- // "transactionType": "deposit",
2584
- // "amount": "25",
2585
- // "commission": "0",
2586
- // "networkTransactionId": "0xbc4eabdce92f14dbcc01d799a5f8ca1f02f4a3a804b6350ea202be4d3c738fce",
2587
- // "status": "pending",
2588
- // "numConfirmed": 8,
2589
- // "numConfirmations": 20,
2590
- // "destAddress": {
2591
- // "address": "0xe7c70b4e73b6b450ee46c3b5c0f5fb127ca55722",
2592
- // "destTag": "..." // for currencies that have it
2593
- // }
2594
- // }
2595
- //
2596
- const destAddress = this.safeValue(transaction, 'destAddress', {});
2597
- const address = this.safeString(destAddress, 'address');
2598
- const tag = this.safeString(destAddress, 'destTag');
2599
- const timestamp = this.safeInteger(transaction, 'time');
2600
- const currencyId = this.safeString(transaction, 'asset');
2601
- let amountString = this.safeString(transaction, 'amount');
2602
- const feeCostString = this.safeString(transaction, 'commission');
2603
- amountString = Precise["default"].stringSub(amountString, feeCostString);
2604
- const code = this.safeCurrencyCode(currencyId, currency);
2605
- return {
2606
- 'info': transaction,
2607
- 'id': this.safeString(transaction, 'requestId'),
2608
- 'txid': this.safeString(transaction, 'networkTransactionId'),
2609
- 'type': this.safeString(transaction, 'transactionType'),
2610
- 'currency': code,
2611
- 'network': undefined,
2612
- 'amount': this.parseNumber(amountString),
2613
- 'status': this.parseTransactionStatus(this.safeString(transaction, 'status')),
2614
- 'timestamp': timestamp,
2615
- 'datetime': this.iso8601(timestamp),
2616
- 'address': address,
2617
- 'addressFrom': undefined,
2618
- 'addressTo': address,
2619
- 'tag': tag,
2620
- 'tagFrom': undefined,
2621
- 'tagTo': tag,
2622
- 'updated': undefined,
2623
- 'comment': undefined,
2624
- 'fee': {
2625
- 'currency': code,
2626
- 'cost': this.parseNumber(feeCostString),
2627
- 'rate': undefined,
2628
- },
2629
- 'internal': false,
2630
- };
2631
- }
2632
- async fetchPositions(symbols = undefined, params = {}) {
2633
- /**
2634
- * @method
2635
- * @name ascendex#fetchPositions
2636
- * @description fetch all open positions
2637
- * @param {string[]|undefined} symbols list of unified market symbols
2638
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2639
- * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2640
- */
2641
- await this.loadMarkets();
2642
- await this.loadAccounts();
2643
- const account = this.safeValue(this.accounts, 0, {});
2644
- const accountGroup = this.safeString(account, 'id');
2645
- const request = {
2646
- 'account-group': accountGroup,
2647
- };
2648
- const response = await this.v2PrivateAccountGroupGetFuturesPosition(this.extend(request, params));
2649
- //
2650
- // {
2651
- // "code": 0,
2652
- // "data": {
2653
- // "accountId": "fut2ODPhGiY71Pl4vtXnOZ00ssgD7QGn",
2654
- // "ac": "FUTURES",
2655
- // "collaterals": [
2656
- // {
2657
- // "asset": "USDT",
2658
- // "balance": "44.570287262",
2659
- // "referencePrice": "1",
2660
- // "discountFactor": "1"
2661
- // }
2662
- // ],
2663
- // "contracts": [
2664
- // {
2665
- // "symbol": "BTC-PERP",
2666
- // "side": "LONG",
2667
- // "position": "0.0001",
2668
- // "referenceCost": "-3.12277254",
2669
- // "unrealizedPnl": "-0.001700233",
2670
- // "realizedPnl": "0",
2671
- // "avgOpenPrice": "31209",
2672
- // "marginType": "isolated",
2673
- // "isolatedMargin": "1.654972977",
2674
- // "leverage": "2",
2675
- // "takeProfitPrice": "0",
2676
- // "takeProfitTrigger": "market",
2677
- // "stopLossPrice": "0",
2678
- // "stopLossTrigger": "market",
2679
- // "buyOpenOrderNotional": "0",
2680
- // "sellOpenOrderNotional": "0",
2681
- // "markPrice": "31210.723063672",
2682
- // "indexPrice": "31223.148857925"
2683
- // },
2684
- // ]
2685
- // }
2686
- // }
2687
- //
2688
- const data = this.safeValue(response, 'data', {});
2689
- const position = this.safeValue(data, 'contracts', []);
2690
- const result = [];
2691
- for (let i = 0; i < position.length; i++) {
2692
- result.push(this.parsePosition(position[i]));
2693
- }
2694
- symbols = this.marketSymbols(symbols);
2695
- return this.filterByArrayPositions(result, 'symbol', symbols, false);
2696
- }
2697
- parsePosition(position, market = undefined) {
2698
- //
2699
- // {
2700
- // "symbol": "BTC-PERP",
2701
- // "side": "LONG",
2702
- // "position": "0.0001",
2703
- // "referenceCost": "-3.12277254",
2704
- // "unrealizedPnl": "-0.001700233",
2705
- // "realizedPnl": "0",
2706
- // "avgOpenPrice": "31209",
2707
- // "marginType": "isolated",
2708
- // "isolatedMargin": "1.654972977",
2709
- // "leverage": "2",
2710
- // "takeProfitPrice": "0",
2711
- // "takeProfitTrigger": "market",
2712
- // "stopLossPrice": "0",
2713
- // "stopLossTrigger": "market",
2714
- // "buyOpenOrderNotional": "0",
2715
- // "sellOpenOrderNotional": "0",
2716
- // "markPrice": "31210.723063672",
2717
- // "indexPrice": "31223.148857925"
2718
- // },
2719
- //
2720
- const marketId = this.safeString(position, 'symbol');
2721
- market = this.safeMarket(marketId, market);
2722
- let notional = this.safeString(position, 'buyOpenOrderNotional');
2723
- if (Precise["default"].stringEq(notional, '0')) {
2724
- notional = this.safeString(position, 'sellOpenOrderNotional');
2725
- }
2726
- const marginMode = this.safeString(position, 'marginType');
2727
- let collateral = undefined;
2728
- if (marginMode === 'isolated') {
2729
- collateral = this.safeString(position, 'isolatedMargin');
2730
- }
2731
- return this.safePosition({
2732
- 'info': position,
2733
- 'id': undefined,
2734
- 'symbol': market['symbol'],
2735
- 'notional': this.parseNumber(notional),
2736
- 'marginMode': marginMode,
2737
- 'liquidationPrice': undefined,
2738
- 'entryPrice': this.safeNumber(position, 'avgOpenPrice'),
2739
- 'unrealizedPnl': this.safeNumber(position, 'unrealizedPnl'),
2740
- 'percentage': undefined,
2741
- 'contracts': this.safeNumber(position, 'position'),
2742
- 'contractSize': this.safeNumber(market, 'contractSize'),
2743
- 'markPrice': this.safeNumber(position, 'markPrice'),
2744
- 'lastPrice': undefined,
2745
- 'side': this.safeStringLower(position, 'side'),
2746
- 'hedged': undefined,
2747
- 'timestamp': undefined,
2748
- 'datetime': undefined,
2749
- 'lastUpdateTimestamp': undefined,
2750
- 'maintenanceMargin': undefined,
2751
- 'maintenanceMarginPercentage': undefined,
2752
- 'collateral': collateral,
2753
- 'initialMargin': undefined,
2754
- 'initialMarginPercentage': undefined,
2755
- 'leverage': this.safeInteger(position, 'leverage'),
2756
- 'marginRatio': undefined,
2757
- 'stopLossPrice': this.safeNumber(position, 'stopLossPrice'),
2758
- 'takeProfitPrice': this.safeNumber(position, 'takeProfitPrice'),
2759
- });
2760
- }
2761
- parseFundingRate(contract, market = undefined) {
2762
- //
2763
- // {
2764
- // "time": 1640061364830,
2765
- // "symbol": "EOS-PERP",
2766
- // "markPrice": "3.353854865",
2767
- // "indexPrice": "3.3542",
2768
- // "openInterest": "14242",
2769
- // "fundingRate": "-0.000073026",
2770
- // "nextFundingTime": 1640073600000
2771
- // }
2772
- //
2773
- const marketId = this.safeString(contract, 'symbol');
2774
- const symbol = this.safeSymbol(marketId, market);
2775
- const currentTime = this.safeInteger(contract, 'time');
2776
- const nextFundingRate = this.safeNumber(contract, 'fundingRate');
2777
- const nextFundingRateTimestamp = this.safeInteger(contract, 'nextFundingTime');
2778
- return {
2779
- 'info': contract,
2780
- 'symbol': symbol,
2781
- 'markPrice': this.safeNumber(contract, 'markPrice'),
2782
- 'indexPrice': this.safeNumber(contract, 'indexPrice'),
2783
- 'interestRate': this.parseNumber('0'),
2784
- 'estimatedSettlePrice': undefined,
2785
- 'timestamp': currentTime,
2786
- 'datetime': this.iso8601(currentTime),
2787
- 'previousFundingRate': undefined,
2788
- 'nextFundingRate': undefined,
2789
- 'previousFundingTimestamp': undefined,
2790
- 'nextFundingTimestamp': undefined,
2791
- 'previousFundingDatetime': undefined,
2792
- 'nextFundingDatetime': undefined,
2793
- 'fundingRate': nextFundingRate,
2794
- 'fundingTimestamp': nextFundingRateTimestamp,
2795
- 'fundingDatetime': this.iso8601(nextFundingRateTimestamp),
2796
- };
2797
- }
2798
- async fetchFundingRates(symbols = undefined, params = {}) {
2799
- /**
2800
- * @method
2801
- * @name ascendex#fetchFundingRates
2802
- * @description fetch the funding rate for multiple markets
2803
- * @param {string[]|undefined} symbols list of unified market symbols
2804
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2805
- * @returns {object} a dictionary of [funding rates structures]{@link https://docs.ccxt.com/#/?id=funding-rates-structure}, indexe by market symbols
2806
- */
2807
- await this.loadMarkets();
2808
- symbols = this.marketSymbols(symbols);
2809
- const response = await this.v2PublicGetFuturesPricingData(params);
2810
- //
2811
- // {
2812
- // "code": 0,
2813
- // "data": {
2814
- // "contracts": [
2815
- // {
2816
- // "time": 1640061364830,
2817
- // "symbol": "EOS-PERP",
2818
- // "markPrice": "3.353854865",
2819
- // "indexPrice": "3.3542",
2820
- // "openInterest": "14242",
2821
- // "fundingRate": "-0.000073026",
2822
- // "nextFundingTime": 1640073600000
2823
- // },
2824
- // ],
2825
- // "collaterals": [
2826
- // {
2827
- // "asset": "USDTR",
2828
- // "referencePrice": "1"
2829
- // },
2830
- // ]
2831
- // }
2832
- // }
2833
- //
2834
- const data = this.safeValue(response, 'data', {});
2835
- const contracts = this.safeValue(data, 'contracts', []);
2836
- const result = this.parseFundingRates(contracts);
2837
- return this.filterByArray(result, 'symbol', symbols);
2838
- }
2839
- async modifyMarginHelper(symbol, amount, type, params = {}) {
2840
- await this.loadMarkets();
2841
- await this.loadAccounts();
2842
- const market = this.market(symbol);
2843
- const account = this.safeValue(this.accounts, 0, {});
2844
- const accountGroup = this.safeString(account, 'id');
2845
- amount = this.amountToPrecision(symbol, amount);
2846
- const request = {
2847
- 'account-group': accountGroup,
2848
- 'symbol': market['id'],
2849
- 'amount': amount, // positive value for adding margin, negative for reducing
2850
- };
2851
- const response = await this.v2PrivateAccountGroupPostFuturesIsolatedPositionMargin(this.extend(request, params));
2852
- //
2853
- // Can only change margin for perpetual futures isolated margin positions
2854
- //
2855
- // {
2856
- // "code": 0
2857
- // }
2858
- //
2859
- if (type === 'reduce') {
2860
- amount = Precise["default"].stringAbs(amount);
2861
- }
2862
- return this.extend(this.parseMarginModification(response, market), {
2863
- 'amount': this.parseNumber(amount),
2864
- 'type': type,
2865
- });
2866
- }
2867
- parseMarginModification(data, market = undefined) {
2868
- const errorCode = this.safeString(data, 'code');
2869
- const status = (errorCode === '0') ? 'ok' : 'failed';
2870
- return {
2871
- 'info': data,
2872
- 'type': undefined,
2873
- 'amount': undefined,
2874
- 'code': market['quote'],
2875
- 'symbol': market['symbol'],
2876
- 'status': status,
2877
- };
2878
- }
2879
- async reduceMargin(symbol, amount, params = {}) {
2880
- /**
2881
- * @method
2882
- * @name ascendex#reduceMargin
2883
- * @description remove margin from a position
2884
- * @param {string} symbol unified market symbol
2885
- * @param {float} amount the amount of margin to remove
2886
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2887
- * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=reduce-margin-structure}
2888
- */
2889
- return await this.modifyMarginHelper(symbol, -amount, 'reduce', params);
2890
- }
2891
- async addMargin(symbol, amount, params = {}) {
2892
- /**
2893
- * @method
2894
- * @name ascendex#addMargin
2895
- * @description add margin
2896
- * @param {string} symbol unified market symbol
2897
- * @param {float} amount amount of margin to add
2898
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2899
- * @returns {object} a [margin structure]{@link https://docs.ccxt.com/#/?id=add-margin-structure}
2900
- */
2901
- return await this.modifyMarginHelper(symbol, amount, 'add', params);
2902
- }
2903
- async setLeverage(leverage, symbol = undefined, params = {}) {
2904
- /**
2905
- * @method
2906
- * @name ascendex#setLeverage
2907
- * @description set the level of leverage for a market
2908
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-contract-leverage
2909
- * @param {float} leverage the rate of leverage
2910
- * @param {string} symbol unified market symbol
2911
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2912
- * @returns {object} response from the exchange
2913
- */
2914
- if (symbol === undefined) {
2915
- throw new errors.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
2916
- }
2917
- if ((leverage < 1) || (leverage > 100)) {
2918
- throw new errors.BadRequest(this.id + ' leverage should be between 1 and 100');
2919
- }
2920
- await this.loadMarkets();
2921
- await this.loadAccounts();
2922
- const market = this.market(symbol);
2923
- if (!market['swap']) {
2924
- throw new errors.BadSymbol(this.id + ' setLeverage() supports swap contracts only');
2925
- }
2926
- const account = this.safeValue(this.accounts, 0, {});
2927
- const accountGroup = this.safeString(account, 'id');
2928
- const request = {
2929
- 'account-group': accountGroup,
2930
- 'symbol': market['id'],
2931
- 'leverage': leverage,
2932
- };
2933
- return await this.v2PrivateAccountGroupPostFuturesLeverage(this.extend(request, params));
2934
- }
2935
- async setMarginMode(marginMode, symbol = undefined, params = {}) {
2936
- /**
2937
- * @method
2938
- * @name ascendex#setMarginMode
2939
- * @description set margin mode to 'cross' or 'isolated'
2940
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-margin-type
2941
- * @param {string} marginMode 'cross' or 'isolated'
2942
- * @param {string} symbol unified market symbol
2943
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2944
- * @returns {object} response from the exchange
2945
- */
2946
- if (symbol === undefined) {
2947
- throw new errors.ArgumentsRequired(this.id + ' setMarginMode() requires a symbol argument');
2948
- }
2949
- marginMode = marginMode.toLowerCase();
2950
- if (marginMode === 'cross') {
2951
- marginMode = 'crossed';
2952
- }
2953
- if (marginMode !== 'isolated' && marginMode !== 'crossed') {
2954
- throw new errors.BadRequest(this.id + ' setMarginMode() marginMode argument should be isolated or cross');
2955
- }
2956
- await this.loadMarkets();
2957
- await this.loadAccounts();
2958
- const market = this.market(symbol);
2959
- const account = this.safeValue(this.accounts, 0, {});
2960
- const accountGroup = this.safeString(account, 'id');
2961
- const request = {
2962
- 'account-group': accountGroup,
2963
- 'symbol': market['id'],
2964
- 'marginType': marginMode,
2965
- };
2966
- if (!market['swap']) {
2967
- throw new errors.BadSymbol(this.id + ' setMarginMode() supports swap contracts only');
2968
- }
2969
- return await this.v2PrivateAccountGroupPostFuturesMarginType(this.extend(request, params));
2970
- }
2971
- async fetchLeverageTiers(symbols = undefined, params = {}) {
2972
- /**
2973
- * @method
2974
- * @name ascendex#fetchLeverageTiers
2975
- * @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes
2976
- * @param {string[]|undefined} symbols list of unified market symbols
2977
- * @param {object} [params] extra parameters specific to the exchange API endpoint
2978
- * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
2979
- */
2980
- await this.loadMarkets();
2981
- const response = await this.v2PublicGetFuturesContract(params);
2982
- //
2983
- // {
2984
- // "code":0,
2985
- // "data":[
2986
- // {
2987
- // "symbol":"BTC-PERP",
2988
- // "status":"Normal",
2989
- // "displayName":"BTCUSDT",
2990
- // "settlementAsset":"USDT",
2991
- // "underlying":"BTC/USDT",
2992
- // "tradingStartTime":1579701600000,
2993
- // "priceFilter":{"minPrice":"1","maxPrice":"1000000","tickSize":"1"},
2994
- // "lotSizeFilter":{"minQty":"0.0001","maxQty":"1000000000","lotSize":"0.0001"},
2995
- // "commissionType":"Quote",
2996
- // "commissionReserveRate":"0.001",
2997
- // "marketOrderPriceMarkup":"0.03",
2998
- // "marginRequirements":[
2999
- // {"positionNotionalLowerBound":"0","positionNotionalUpperBound":"50000","initialMarginRate":"0.01","maintenanceMarginRate":"0.006"},
3000
- // {"positionNotionalLowerBound":"50000","positionNotionalUpperBound":"200000","initialMarginRate":"0.02","maintenanceMarginRate":"0.012"},
3001
- // {"positionNotionalLowerBound":"200000","positionNotionalUpperBound":"2000000","initialMarginRate":"0.04","maintenanceMarginRate":"0.024"},
3002
- // {"positionNotionalLowerBound":"2000000","positionNotionalUpperBound":"20000000","initialMarginRate":"0.1","maintenanceMarginRate":"0.06"},
3003
- // {"positionNotionalLowerBound":"20000000","positionNotionalUpperBound":"40000000","initialMarginRate":"0.2","maintenanceMarginRate":"0.12"},
3004
- // {"positionNotionalLowerBound":"40000000","positionNotionalUpperBound":"1000000000","initialMarginRate":"0.333333","maintenanceMarginRate":"0.2"}
3005
- // ]
3006
- // }
3007
- // ]
3008
- // }
3009
- //
3010
- const data = this.safeValue(response, 'data');
3011
- symbols = this.marketSymbols(symbols);
3012
- return this.parseLeverageTiers(data, symbols, 'symbol');
3013
- }
3014
- parseMarketLeverageTiers(info, market = undefined) {
3015
- /**
3016
- * @param {object} info Exchange market response for 1 market
3017
- * @param {object} market CCXT market
3018
- */
3019
- //
3020
- // {
3021
- // "symbol":"BTC-PERP",
3022
- // "status":"Normal",
3023
- // "displayName":"BTCUSDT",
3024
- // "settlementAsset":"USDT",
3025
- // "underlying":"BTC/USDT",
3026
- // "tradingStartTime":1579701600000,
3027
- // "priceFilter":{"minPrice":"1","maxPrice":"1000000","tickSize":"1"},
3028
- // "lotSizeFilter":{"minQty":"0.0001","maxQty":"1000000000","lotSize":"0.0001"},
3029
- // "commissionType":"Quote",
3030
- // "commissionReserveRate":"0.001",
3031
- // "marketOrderPriceMarkup":"0.03",
3032
- // "marginRequirements":[
3033
- // {"positionNotionalLowerBound":"0","positionNotionalUpperBound":"50000","initialMarginRate":"0.01","maintenanceMarginRate":"0.006"},
3034
- // {"positionNotionalLowerBound":"50000","positionNotionalUpperBound":"200000","initialMarginRate":"0.02","maintenanceMarginRate":"0.012"},
3035
- // {"positionNotionalLowerBound":"200000","positionNotionalUpperBound":"2000000","initialMarginRate":"0.04","maintenanceMarginRate":"0.024"},
3036
- // {"positionNotionalLowerBound":"2000000","positionNotionalUpperBound":"20000000","initialMarginRate":"0.1","maintenanceMarginRate":"0.06"},
3037
- // {"positionNotionalLowerBound":"20000000","positionNotionalUpperBound":"40000000","initialMarginRate":"0.2","maintenanceMarginRate":"0.12"},
3038
- // {"positionNotionalLowerBound":"40000000","positionNotionalUpperBound":"1000000000","initialMarginRate":"0.333333","maintenanceMarginRate":"0.2"}
3039
- // ]
3040
- // }
3041
- //
3042
- const marginRequirements = this.safeValue(info, 'marginRequirements', []);
3043
- const id = this.safeString(info, 'symbol');
3044
- market = this.safeMarket(id, market);
3045
- const tiers = [];
3046
- for (let i = 0; i < marginRequirements.length; i++) {
3047
- const tier = marginRequirements[i];
3048
- const initialMarginRate = this.safeString(tier, 'initialMarginRate');
3049
- tiers.push({
3050
- 'tier': this.sum(i, 1),
3051
- 'currency': market['quote'],
3052
- 'minNotional': this.safeNumber(tier, 'positionNotionalLowerBound'),
3053
- 'maxNotional': this.safeNumber(tier, 'positionNotionalUpperBound'),
3054
- 'maintenanceMarginRate': this.safeNumber(tier, 'maintenanceMarginRate'),
3055
- 'maxLeverage': this.parseNumber(Precise["default"].stringDiv('1', initialMarginRate)),
3056
- 'info': tier,
3057
- });
3058
- }
3059
- return tiers;
3060
- }
3061
- parseDepositWithdrawFee(fee, currency = undefined) {
3062
- //
3063
- // {
3064
- // "assetCode": "USDT",
3065
- // "assetName": "Tether",
3066
- // "precisionScale": 9,
3067
- // "nativeScale": 4,
3068
- // "blockChain": [
3069
- // {
3070
- // "chainName": "Omni",
3071
- // "withdrawFee": "30.0",
3072
- // "allowDeposit": true,
3073
- // "allowWithdraw": true,
3074
- // "minDepositAmt": "0.0",
3075
- // "minWithdrawal": "50.0",
3076
- // "numConfirmations": 3
3077
- // },
3078
- // ]
3079
- // }
3080
- //
3081
- const blockChains = this.safeValue(fee, 'blockChain', []);
3082
- const blockChainsLength = blockChains.length;
3083
- const result = {
3084
- 'info': fee,
3085
- 'withdraw': {
3086
- 'fee': undefined,
3087
- 'percentage': undefined,
3088
- },
3089
- 'deposit': {
3090
- 'fee': undefined,
3091
- 'percentage': undefined,
3092
- },
3093
- 'networks': {},
3094
- };
3095
- for (let i = 0; i < blockChainsLength; i++) {
3096
- const blockChain = blockChains[i];
3097
- const networkId = this.safeString(blockChain, 'chainName');
3098
- const currencyCode = this.safeString(currency, 'code');
3099
- const networkCode = this.networkIdToCode(networkId, currencyCode);
3100
- result['networks'][networkCode] = {
3101
- 'deposit': { 'fee': undefined, 'percentage': undefined },
3102
- 'withdraw': { 'fee': this.safeNumber(blockChain, 'withdrawFee'), 'percentage': false },
3103
- };
3104
- if (blockChainsLength === 1) {
3105
- result['withdraw']['fee'] = this.safeNumber(blockChain, 'withdrawFee');
3106
- result['withdraw']['percentage'] = false;
3107
- }
3108
- }
3109
- return result;
3110
- }
3111
- async fetchDepositWithdrawFees(codes = undefined, params = {}) {
3112
- /**
3113
- * @method
3114
- * @name ascendex#fetchDepositWithdrawFees
3115
- * @description fetch deposit and withdraw fees
3116
- * @see https://ascendex.github.io/ascendex-pro-api/#list-all-assets
3117
- * @param {string[]|undefined} codes list of unified currency codes
3118
- * @param {object} [params] extra parameters specific to the exchange API endpoint
3119
- * @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure}
3120
- */
3121
- await this.loadMarkets();
3122
- const response = await this.v2PublicGetAssets(params);
3123
- const data = this.safeValue(response, 'data');
3124
- return this.parseDepositWithdrawFees(data, codes, 'assetCode');
3125
- }
3126
- async transfer(code, amount, fromAccount, toAccount, params = {}) {
3127
- /**
3128
- * @method
3129
- * @name ascendex#transfer
3130
- * @description transfer currency internally between wallets on the same account
3131
- * @param {string} code unified currency code
3132
- * @param {float} amount amount to transfer
3133
- * @param {string} fromAccount account to transfer from
3134
- * @param {string} toAccount account to transfer to
3135
- * @param {object} [params] extra parameters specific to the exchange API endpoint
3136
- * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/#/?id=transfer-structure}
3137
- */
3138
- await this.loadMarkets();
3139
- await this.loadAccounts();
3140
- const account = this.safeValue(this.accounts, 0, {});
3141
- const accountGroup = this.safeString(account, 'id');
3142
- const currency = this.currency(code);
3143
- amount = this.currencyToPrecision(code, amount);
3144
- const accountsByType = this.safeValue(this.options, 'accountsByType', {});
3145
- const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
3146
- const toId = this.safeString(accountsByType, toAccount, toAccount);
3147
- if (fromId !== 'cash' && toId !== 'cash') {
3148
- throw new errors.ExchangeError(this.id + ' transfer() only supports direct balance transfer between spot and swap, spot and margin');
3149
- }
3150
- const request = {
3151
- 'account-group': accountGroup,
3152
- 'amount': amount,
3153
- 'asset': currency['id'],
3154
- 'fromAccount': fromId,
3155
- 'toAccount': toId,
3156
- };
3157
- const response = await this.v1PrivateAccountGroupPostTransfer(this.extend(request, params));
3158
- //
3159
- // { "code": "0" }
3160
- //
3161
- const transferOptions = this.safeValue(this.options, 'transfer', {});
3162
- const fillResponseFromRequest = this.safeValue(transferOptions, 'fillResponseFromRequest', true);
3163
- const transfer = this.parseTransfer(response, currency);
3164
- if (fillResponseFromRequest) {
3165
- transfer['fromAccount'] = fromAccount;
3166
- transfer['toAccount'] = toAccount;
3167
- transfer['amount'] = amount;
3168
- transfer['currency'] = code;
3169
- }
3170
- return transfer;
3171
- }
3172
- parseTransfer(transfer, currency = undefined) {
3173
- //
3174
- // { "code": "0" }
3175
- //
3176
- const status = this.safeInteger(transfer, 'code');
3177
- const currencyCode = this.safeCurrencyCode(undefined, currency);
3178
- const timestamp = this.milliseconds();
3179
- return {
3180
- 'info': transfer,
3181
- 'id': undefined,
3182
- 'timestamp': timestamp,
3183
- 'datetime': this.iso8601(timestamp),
3184
- 'currency': currencyCode,
3185
- 'amount': undefined,
3186
- 'fromAccount': undefined,
3187
- 'toAccount': undefined,
3188
- 'status': this.parseTransferStatus(status),
3189
- };
3190
- }
3191
- parseTransferStatus(status) {
3192
- if (status === 0) {
3193
- return 'ok';
3194
- }
3195
- return 'failed';
3196
- }
3197
- async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3198
- /**
3199
- * @method
3200
- * @name ascendex#fetchFundingHistory
3201
- * @description fetch the history of funding payments paid and received on this account
3202
- * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#funding-payment-history
3203
- * @param {string} [symbol] unified market symbol
3204
- * @param {int} [since] the earliest time in ms to fetch funding history for
3205
- * @param {int} [limit] the maximum number of funding history structures to retrieve
3206
- * @param {object} [params] extra parameters specific to the exchange API endpoint
3207
- * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3208
- * @returns {object} a [funding history structure]{@link https://docs.ccxt.com/#/?id=funding-history-structure}
3209
- */
3210
- await this.loadMarkets();
3211
- await this.loadAccounts();
3212
- let paginate = false;
3213
- [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingHistory', 'paginate');
3214
- if (paginate) {
3215
- return await this.fetchPaginatedCallIncremental('fetchFundingHistory', symbol, since, limit, params, 'page', 25);
3216
- }
3217
- const account = this.safeValue(this.accounts, 0, {});
3218
- const accountGroup = this.safeString(account, 'id');
3219
- const request = {
3220
- 'account-group': accountGroup,
3221
- };
3222
- let market = undefined;
3223
- if (symbol !== undefined) {
3224
- market = this.market(symbol);
3225
- request['symbol'] = market['id'];
3226
- }
3227
- if (limit !== undefined) {
3228
- request['pageSize'] = limit;
3229
- }
3230
- const response = await this.v2PrivateAccountGroupGetFuturesFundingPayments(this.extend(request, params));
3231
- //
3232
- // {
3233
- // "code": 0,
3234
- // "data": {
3235
- // "data": [
3236
- // {
3237
- // "timestamp": 1640476800000,
3238
- // "symbol": "BTC-PERP",
3239
- // "paymentInUSDT": "-0.013991178",
3240
- // "fundingRate": "0.000173497"
3241
- // },
3242
- // ],
3243
- // "page": 1,
3244
- // "pageSize": 3,
3245
- // "hasNext": true
3246
- // }
3247
- // }
3248
- //
3249
- const data = this.safeValue(response, 'data', {});
3250
- const rows = this.safeValue(data, 'data', []);
3251
- return this.parseIncomes(rows, market, since, limit);
3252
- }
3253
- parseIncome(income, market = undefined) {
3254
- //
3255
- // {
3256
- // "timestamp": 1640476800000,
3257
- // "symbol": "BTC-PERP",
3258
- // "paymentInUSDT": "-0.013991178",
3259
- // "fundingRate": "0.000173497"
3260
- // }
3261
- //
3262
- const marketId = this.safeString(income, 'symbol');
3263
- const timestamp = this.safeInteger(income, 'timestamp');
3264
- return {
3265
- 'info': income,
3266
- 'symbol': this.safeSymbol(marketId, market, '-', 'swap'),
3267
- 'code': 'USDT',
3268
- 'timestamp': timestamp,
3269
- 'datetime': this.iso8601(timestamp),
3270
- 'id': undefined,
3271
- 'amount': this.safeNumber(income, 'paymentInUSDT'),
3272
- };
3273
- }
3274
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
3275
- const version = api[0];
3276
- const access = api[1];
3277
- const type = this.safeString(api, 2);
3278
- let url = '';
3279
- const accountCategory = (type === 'accountCategory');
3280
- if (accountCategory || (type === 'accountGroup')) {
3281
- url += this.implodeParams('/{account-group}', params);
3282
- params = this.omit(params, 'account-group');
3283
- }
3284
- let request = this.implodeParams(path, params);
3285
- url += '/api/pro/';
3286
- if (version === 'v2') {
3287
- if (type === 'data') {
3288
- request = 'data/' + version + '/' + request;
3289
- }
3290
- else {
3291
- request = version + '/' + request;
3292
- }
3293
- }
3294
- else {
3295
- url += version + '/';
3296
- }
3297
- if (accountCategory) {
3298
- url += this.implodeParams('{account-category}/', params);
3299
- }
3300
- params = this.omit(params, 'account-category');
3301
- url += request;
3302
- if ((version === 'v1') && (request === 'cash/balance') || (request === 'margin/balance')) {
3303
- request = 'balance';
3304
- }
3305
- if ((version === 'v1') && (request === 'spot/fee')) {
3306
- request = 'fee';
3307
- }
3308
- if (request.indexOf('subuser') >= 0) {
3309
- const parts = request.split('/');
3310
- request = parts[2];
3311
- }
3312
- params = this.omit(params, this.extractParams(path));
3313
- if (access === 'public') {
3314
- if (Object.keys(params).length) {
3315
- url += '?' + this.urlencode(params);
3316
- }
3317
- }
3318
- else {
3319
- this.checkRequiredCredentials();
3320
- const timestamp = this.milliseconds().toString();
3321
- const payload = timestamp + '+' + request;
3322
- const hmac = this.hmac(this.encode(payload), this.encode(this.secret), sha256.sha256, 'base64');
3323
- headers = {
3324
- 'x-auth-key': this.apiKey,
3325
- 'x-auth-timestamp': timestamp,
3326
- 'x-auth-signature': hmac,
3327
- };
3328
- if (method === 'GET') {
3329
- if (Object.keys(params).length) {
3330
- url += '?' + this.urlencode(params);
3331
- }
3332
- }
3333
- else {
3334
- headers['Content-Type'] = 'application/json';
3335
- body = this.json(params);
3336
- }
3337
- }
3338
- url = this.urls['api']['rest'] + url;
3339
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
3340
- }
3341
- handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3342
- if (response === undefined) {
3343
- return undefined; // fallback to default error handler
3344
- }
3345
- //
3346
- // {"code": 6010, "message": "Not enough balance."}
3347
- // {"code": 60060, "message": "The order is already filled or canceled."}
3348
- // {"code":2100,"message":"ApiKeyFailure"}
3349
- // {"code":300001,"message":"Price is too low from market price.","reason":"INVALID_PRICE","accountId":"cshrHKLZCjlZ2ejqkmvIHHtPmLYqdnda","ac":"CASH","action":"place-order","status":"Err","info":{"symbol":"BTC/USDT"}}
3350
- //
3351
- const code = this.safeString(response, 'code');
3352
- const message = this.safeString(response, 'message');
3353
- const error = (code !== undefined) && (code !== '0');
3354
- if (error || (message !== undefined)) {
3355
- const feedback = this.id + ' ' + body;
3356
- this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback);
3357
- this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
3358
- this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
3359
- throw new errors.ExchangeError(feedback); // unknown message
3360
- }
3361
- return undefined;
3362
- }
3363
- }
3364
-
3365
- module.exports = ascendex;