ccxt 4.5.62 → 4.5.64

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