ccxt 4.2.11 → 4.2.13

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 (392) hide show
  1. package/README.md +5 -5
  2. package/build.sh +2 -2
  3. package/dist/ccxt.browser.js +1347 -490
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/_virtual/agent.js +7 -0
  6. package/dist/cjs/_virtual/parse-proxy-response.js +7 -0
  7. package/dist/cjs/_virtual/promisify.js +7 -0
  8. package/dist/cjs/ccxt.js +1 -1
  9. package/dist/cjs/js/ccxt.js +474 -0
  10. package/dist/cjs/js/src/abstract/ace.js +9 -0
  11. package/dist/cjs/js/src/abstract/alpaca.js +9 -0
  12. package/dist/cjs/js/src/abstract/ascendex.js +9 -0
  13. package/dist/cjs/js/src/abstract/bigone.js +9 -0
  14. package/dist/cjs/js/src/abstract/binance.js +9 -0
  15. package/dist/cjs/js/src/abstract/bingx.js +9 -0
  16. package/dist/cjs/js/src/abstract/bit2c.js +9 -0
  17. package/dist/cjs/js/src/abstract/bitbank.js +9 -0
  18. package/dist/cjs/js/src/abstract/bitbns.js +9 -0
  19. package/dist/cjs/js/src/abstract/bitfinex.js +9 -0
  20. package/dist/cjs/js/src/abstract/bitfinex2.js +9 -0
  21. package/dist/cjs/js/src/abstract/bitflyer.js +9 -0
  22. package/dist/cjs/js/src/abstract/bitforex.js +9 -0
  23. package/dist/cjs/js/src/abstract/bitget.js +9 -0
  24. package/dist/cjs/js/src/abstract/bithumb.js +9 -0
  25. package/dist/cjs/js/src/abstract/bitmart.js +9 -0
  26. package/dist/cjs/js/src/abstract/bitmex.js +9 -0
  27. package/dist/cjs/js/src/abstract/bitopro.js +9 -0
  28. package/dist/cjs/js/src/abstract/bitpanda.js +9 -0
  29. package/dist/cjs/js/src/abstract/bitrue.js +9 -0
  30. package/dist/cjs/js/src/abstract/bitso.js +9 -0
  31. package/dist/cjs/js/src/abstract/bitstamp.js +9 -0
  32. package/dist/cjs/js/src/abstract/bitteam.js +9 -0
  33. package/dist/cjs/js/src/abstract/bitvavo.js +9 -0
  34. package/dist/cjs/js/src/abstract/bl3p.js +9 -0
  35. package/dist/cjs/js/src/abstract/blockchaincom.js +9 -0
  36. package/dist/cjs/js/src/abstract/btcalpha.js +9 -0
  37. package/dist/cjs/js/src/abstract/btcbox.js +9 -0
  38. package/dist/cjs/js/src/abstract/btcmarkets.js +9 -0
  39. package/dist/cjs/js/src/abstract/btcturk.js +9 -0
  40. package/dist/cjs/js/src/abstract/bybit.js +9 -0
  41. package/dist/cjs/js/src/abstract/cex.js +9 -0
  42. package/dist/cjs/js/src/abstract/coinbase.js +9 -0
  43. package/dist/cjs/js/src/abstract/coinbasepro.js +9 -0
  44. package/dist/cjs/js/src/abstract/coincheck.js +9 -0
  45. package/dist/cjs/js/src/abstract/coinex.js +9 -0
  46. package/dist/cjs/js/src/abstract/coinlist.js +9 -0
  47. package/dist/cjs/js/src/abstract/coinmate.js +9 -0
  48. package/dist/cjs/js/src/abstract/coinone.js +9 -0
  49. package/dist/cjs/js/src/abstract/coinsph.js +9 -0
  50. package/dist/cjs/js/src/abstract/coinspot.js +9 -0
  51. package/dist/cjs/js/src/abstract/cryptocom.js +9 -0
  52. package/dist/cjs/js/src/abstract/currencycom.js +9 -0
  53. package/dist/cjs/js/src/abstract/delta.js +9 -0
  54. package/dist/cjs/js/src/abstract/deribit.js +9 -0
  55. package/dist/cjs/js/src/abstract/digifinex.js +9 -0
  56. package/dist/cjs/js/src/abstract/exmo.js +9 -0
  57. package/dist/cjs/js/src/abstract/gate.js +9 -0
  58. package/dist/cjs/js/src/abstract/gemini.js +9 -0
  59. package/dist/cjs/js/src/abstract/hitbtc.js +9 -0
  60. package/dist/cjs/js/src/abstract/hollaex.js +9 -0
  61. package/dist/cjs/js/src/abstract/htx.js +9 -0
  62. package/dist/cjs/js/src/abstract/huobijp.js +9 -0
  63. package/dist/cjs/js/src/abstract/idex.js +9 -0
  64. package/dist/cjs/js/src/abstract/independentreserve.js +9 -0
  65. package/dist/cjs/js/src/abstract/indodax.js +9 -0
  66. package/dist/cjs/js/src/abstract/kraken.js +9 -0
  67. package/dist/cjs/js/src/abstract/krakenfutures.js +9 -0
  68. package/dist/cjs/js/src/abstract/kucoin.js +9 -0
  69. package/dist/cjs/js/src/abstract/kucoinfutures.js +9 -0
  70. package/dist/cjs/js/src/abstract/kuna.js +9 -0
  71. package/dist/cjs/js/src/abstract/latoken.js +9 -0
  72. package/dist/cjs/js/src/abstract/lbank.js +9 -0
  73. package/dist/cjs/js/src/abstract/luno.js +9 -0
  74. package/dist/cjs/js/src/abstract/lykke.js +9 -0
  75. package/dist/cjs/js/src/abstract/mercado.js +9 -0
  76. package/dist/cjs/js/src/abstract/mexc.js +9 -0
  77. package/dist/cjs/js/src/abstract/ndax.js +9 -0
  78. package/dist/cjs/js/src/abstract/novadax.js +9 -0
  79. package/dist/cjs/js/src/abstract/oceanex.js +9 -0
  80. package/dist/cjs/js/src/abstract/okcoin.js +9 -0
  81. package/dist/cjs/js/src/abstract/okx.js +9 -0
  82. package/dist/cjs/js/src/abstract/p2b.js +9 -0
  83. package/dist/cjs/js/src/abstract/paymium.js +9 -0
  84. package/dist/cjs/js/src/abstract/phemex.js +9 -0
  85. package/dist/cjs/js/src/abstract/poloniex.js +9 -0
  86. package/dist/cjs/js/src/abstract/poloniexfutures.js +9 -0
  87. package/dist/cjs/js/src/abstract/probit.js +9 -0
  88. package/dist/cjs/js/src/abstract/timex.js +9 -0
  89. package/dist/cjs/js/src/abstract/tokocrypto.js +9 -0
  90. package/dist/cjs/js/src/abstract/upbit.js +9 -0
  91. package/dist/cjs/js/src/abstract/wavesexchange.js +9 -0
  92. package/dist/cjs/js/src/abstract/wazirx.js +9 -0
  93. package/dist/cjs/js/src/abstract/whitebit.js +9 -0
  94. package/dist/cjs/js/src/abstract/woo.js +9 -0
  95. package/dist/cjs/js/src/abstract/yobit.js +9 -0
  96. package/dist/cjs/js/src/abstract/zaif.js +9 -0
  97. package/dist/cjs/js/src/abstract/zonda.js +9 -0
  98. package/dist/cjs/js/src/ace.js +1058 -0
  99. package/dist/cjs/js/src/alpaca.js +1125 -0
  100. package/dist/cjs/js/src/ascendex.js +3360 -0
  101. package/dist/cjs/js/src/base/Exchange.js +5110 -0
  102. package/dist/cjs/js/src/base/Precise.js +263 -0
  103. package/dist/cjs/js/src/base/errors.js +299 -0
  104. package/dist/cjs/js/src/base/functions/crypto.js +78 -0
  105. package/dist/cjs/js/src/base/functions/encode.js +44 -0
  106. package/dist/cjs/js/src/base/functions/generic.js +193 -0
  107. package/dist/cjs/js/src/base/functions/misc.js +96 -0
  108. package/dist/cjs/js/src/base/functions/number.js +297 -0
  109. package/dist/cjs/js/src/base/functions/platform.js +28 -0
  110. package/dist/cjs/js/src/base/functions/rsa.js +34 -0
  111. package/dist/cjs/js/src/base/functions/string.js +48 -0
  112. package/dist/cjs/js/src/base/functions/throttle.js +66 -0
  113. package/dist/cjs/js/src/base/functions/time.js +187 -0
  114. package/dist/cjs/js/src/base/functions/totp.js +24 -0
  115. package/dist/cjs/js/src/base/functions/type.js +162 -0
  116. package/dist/cjs/js/src/base/functions.js +157 -0
  117. package/dist/cjs/js/src/base/ws/Cache.js +254 -0
  118. package/dist/cjs/js/src/base/ws/Client.js +299 -0
  119. package/dist/cjs/js/src/base/ws/Future.js +34 -0
  120. package/dist/cjs/js/src/base/ws/OrderBook.js +107 -0
  121. package/dist/cjs/js/src/base/ws/OrderBookSide.js +281 -0
  122. package/dist/cjs/js/src/base/ws/WsClient.js +69 -0
  123. package/dist/cjs/js/src/bequant.js +33 -0
  124. package/dist/cjs/js/src/bigone.js +2209 -0
  125. package/dist/cjs/js/src/binance.js +9736 -0
  126. package/dist/cjs/js/src/binancecoinm.js +45 -0
  127. package/dist/cjs/js/src/binanceus.js +84 -0
  128. package/dist/cjs/js/src/binanceusdm.js +58 -0
  129. package/dist/cjs/js/src/bingx.js +3807 -0
  130. package/dist/cjs/js/src/bit2c.js +916 -0
  131. package/dist/cjs/js/src/bitbank.js +1000 -0
  132. package/dist/cjs/js/src/bitbay.js +17 -0
  133. package/dist/cjs/js/src/bitbns.js +1220 -0
  134. package/dist/cjs/js/src/bitcoincom.js +17 -0
  135. package/dist/cjs/js/src/bitfinex.js +1670 -0
  136. package/dist/cjs/js/src/bitfinex2.js +2990 -0
  137. package/dist/cjs/js/src/bitflyer.js +1045 -0
  138. package/dist/cjs/js/src/bitforex.js +852 -0
  139. package/dist/cjs/js/src/bitget.js +8291 -0
  140. package/dist/cjs/js/src/bithumb.js +1090 -0
  141. package/dist/cjs/js/src/bitmart.js +4454 -0
  142. package/dist/cjs/js/src/bitmex.js +2884 -0
  143. package/dist/cjs/js/src/bitopro.js +1724 -0
  144. package/dist/cjs/js/src/bitpanda.js +2002 -0
  145. package/dist/cjs/js/src/bitrue.js +3253 -0
  146. package/dist/cjs/js/src/bitso.js +1753 -0
  147. package/dist/cjs/js/src/bitstamp.js +2188 -0
  148. package/dist/cjs/js/src/bitteam.js +2309 -0
  149. package/dist/cjs/js/src/bitvavo.js +1968 -0
  150. package/dist/cjs/js/src/bl3p.js +447 -0
  151. package/dist/cjs/js/src/blockchaincom.js +1160 -0
  152. package/dist/cjs/js/src/btcalpha.js +929 -0
  153. package/dist/cjs/js/src/btcbox.js +565 -0
  154. package/dist/cjs/js/src/btcmarkets.js +1237 -0
  155. package/dist/cjs/js/src/btcturk.js +929 -0
  156. package/dist/cjs/js/src/bybit.js +7646 -0
  157. package/dist/cjs/js/src/cex.js +1693 -0
  158. package/dist/cjs/js/src/coinbase.js +3424 -0
  159. package/dist/cjs/js/src/coinbasepro.js +1866 -0
  160. package/dist/cjs/js/src/coincheck.js +843 -0
  161. package/dist/cjs/js/src/coinex.js +5414 -0
  162. package/dist/cjs/js/src/coinlist.js +2329 -0
  163. package/dist/cjs/js/src/coinmate.js +989 -0
  164. package/dist/cjs/js/src/coinone.js +1185 -0
  165. package/dist/cjs/js/src/coinsph.js +1933 -0
  166. package/dist/cjs/js/src/coinspot.js +548 -0
  167. package/dist/cjs/js/src/cryptocom.js +3007 -0
  168. package/dist/cjs/js/src/currencycom.js +2015 -0
  169. package/dist/cjs/js/src/delta.js +3256 -0
  170. package/dist/cjs/js/src/deribit.js +3306 -0
  171. package/dist/cjs/js/src/digifinex.js +4307 -0
  172. package/dist/cjs/js/src/exmo.js +2645 -0
  173. package/dist/cjs/js/src/fmfwio.js +34 -0
  174. package/dist/cjs/js/src/gate.js +7072 -0
  175. package/dist/cjs/js/src/gateio.js +16 -0
  176. package/dist/cjs/js/src/gemini.js +1801 -0
  177. package/dist/cjs/js/src/hitbtc.js +3660 -0
  178. package/dist/cjs/js/src/hitbtc3.js +19 -0
  179. package/dist/cjs/js/src/hollaex.js +1882 -0
  180. package/dist/cjs/js/src/htx.js +9049 -0
  181. package/dist/cjs/js/src/huobi.js +16 -0
  182. package/dist/cjs/js/src/huobijp.js +1918 -0
  183. package/dist/cjs/js/src/idex.js +1770 -0
  184. package/dist/cjs/js/src/independentreserve.js +761 -0
  185. package/dist/cjs/js/src/indodax.js +1069 -0
  186. package/dist/cjs/js/src/kraken.js +2857 -0
  187. package/dist/cjs/js/src/krakenfutures.js +2407 -0
  188. package/dist/cjs/js/src/kucoin.js +4489 -0
  189. package/dist/cjs/js/src/kucoinfutures.js +2475 -0
  190. package/dist/cjs/js/src/kuna.js +1949 -0
  191. package/dist/cjs/js/src/latoken.js +1729 -0
  192. package/dist/cjs/js/src/lbank.js +2851 -0
  193. package/dist/cjs/js/src/luno.js +1044 -0
  194. package/dist/cjs/js/src/lykke.js +1303 -0
  195. package/dist/cjs/js/src/mercado.js +897 -0
  196. package/dist/cjs/js/src/mexc.js +5407 -0
  197. package/dist/cjs/js/src/ndax.js +2450 -0
  198. package/dist/cjs/js/src/novadax.js +1556 -0
  199. package/dist/cjs/js/src/oceanex.js +964 -0
  200. package/dist/cjs/js/src/okcoin.js +3115 -0
  201. package/dist/cjs/js/src/okx.js +7330 -0
  202. package/dist/cjs/js/src/p2b.js +1243 -0
  203. package/dist/cjs/js/src/paymium.js +597 -0
  204. package/dist/cjs/js/src/phemex.js +4722 -0
  205. package/dist/cjs/js/src/poloniex.js +2356 -0
  206. package/dist/cjs/js/src/poloniexfutures.js +1794 -0
  207. package/dist/cjs/js/src/pro/alpaca.js +714 -0
  208. package/dist/cjs/js/src/pro/ascendex.js +957 -0
  209. package/dist/cjs/js/src/pro/bequant.js +33 -0
  210. package/dist/cjs/js/src/pro/binance.js +2796 -0
  211. package/dist/cjs/js/src/pro/binancecoinm.js +23 -0
  212. package/dist/cjs/js/src/pro/binanceus.js +51 -0
  213. package/dist/cjs/js/src/pro/binanceusdm.js +32 -0
  214. package/dist/cjs/js/src/pro/bingx.js +944 -0
  215. package/dist/cjs/js/src/pro/bitcoincom.js +29 -0
  216. package/dist/cjs/js/src/pro/bitfinex.js +672 -0
  217. package/dist/cjs/js/src/pro/bitfinex2.js +1159 -0
  218. package/dist/cjs/js/src/pro/bitget.js +1733 -0
  219. package/dist/cjs/js/src/pro/bitmart.js +1486 -0
  220. package/dist/cjs/js/src/pro/bitmex.js +1576 -0
  221. package/dist/cjs/js/src/pro/bitopro.js +327 -0
  222. package/dist/cjs/js/src/pro/bitpanda.js +1341 -0
  223. package/dist/cjs/js/src/pro/bitrue.js +462 -0
  224. package/dist/cjs/js/src/pro/bitstamp.js +547 -0
  225. package/dist/cjs/js/src/pro/bitvavo.js +704 -0
  226. package/dist/cjs/js/src/pro/blockchaincom.js +794 -0
  227. package/dist/cjs/js/src/pro/bybit.js +1843 -0
  228. package/dist/cjs/js/src/pro/cex.js +1510 -0
  229. package/dist/cjs/js/src/pro/coinbase.js +561 -0
  230. package/dist/cjs/js/src/pro/coinbasepro.js +968 -0
  231. package/dist/cjs/js/src/pro/coinex.js +1095 -0
  232. package/dist/cjs/js/src/pro/cryptocom.js +1020 -0
  233. package/dist/cjs/js/src/pro/currencycom.js +563 -0
  234. package/dist/cjs/js/src/pro/deribit.js +825 -0
  235. package/dist/cjs/js/src/pro/exmo.js +658 -0
  236. package/dist/cjs/js/src/pro/gate.js +1316 -0
  237. package/dist/cjs/js/src/pro/gateio.js +16 -0
  238. package/dist/cjs/js/src/pro/gemini.js +649 -0
  239. package/dist/cjs/js/src/pro/hitbtc.js +1293 -0
  240. package/dist/cjs/js/src/pro/hollaex.js +597 -0
  241. package/dist/cjs/js/src/pro/htx.js +2383 -0
  242. package/dist/cjs/js/src/pro/huobi.js +16 -0
  243. package/dist/cjs/js/src/pro/huobijp.js +606 -0
  244. package/dist/cjs/js/src/pro/idex.js +714 -0
  245. package/dist/cjs/js/src/pro/independentreserve.js +280 -0
  246. package/dist/cjs/js/src/pro/kraken.js +1364 -0
  247. package/dist/cjs/js/src/pro/krakenfutures.js +1500 -0
  248. package/dist/cjs/js/src/pro/kucoin.js +1052 -0
  249. package/dist/cjs/js/src/pro/kucoinfutures.js +981 -0
  250. package/dist/cjs/js/src/pro/luno.js +322 -0
  251. package/dist/cjs/js/src/pro/mexc.js +1170 -0
  252. package/dist/cjs/js/src/pro/ndax.js +545 -0
  253. package/dist/cjs/js/src/pro/okcoin.js +760 -0
  254. package/dist/cjs/js/src/pro/okx.js +1608 -0
  255. package/dist/cjs/js/src/pro/phemex.js +1511 -0
  256. package/dist/cjs/js/src/pro/poloniex.js +1253 -0
  257. package/dist/cjs/js/src/pro/poloniexfutures.js +1014 -0
  258. package/dist/cjs/js/src/pro/probit.js +586 -0
  259. package/dist/cjs/js/src/pro/upbit.js +234 -0
  260. package/dist/cjs/js/src/pro/wazirx.js +776 -0
  261. package/dist/cjs/js/src/pro/whitebit.js +927 -0
  262. package/dist/cjs/js/src/pro/woo.js +769 -0
  263. package/dist/cjs/js/src/probit.js +1867 -0
  264. package/dist/cjs/js/src/static_dependencies/fflake/browser.js +401 -0
  265. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncrypt.js +195 -0
  266. package/dist/cjs/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +308 -0
  267. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/asn1.js +554 -0
  268. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/base64.js +94 -0
  269. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/hex.js +70 -0
  270. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/asn1js/int10.js +91 -0
  271. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/base64.js +16 -0
  272. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.js +1760 -0
  273. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/prng4.js +52 -0
  274. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rng.js +81 -0
  275. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/rsa.js +376 -0
  276. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsbn/util.js +70 -0
  277. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/asn1-1.0.js +1580 -0
  278. package/dist/cjs/js/src/static_dependencies/jsencrypt/lib/jsrsasign/yahoo.js +74 -0
  279. package/dist/cjs/js/src/static_dependencies/noble-curves/_shortw_utils.js +24 -0
  280. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/curve.js +158 -0
  281. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/edwards.js +429 -0
  282. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/hash-to-curve.js +176 -0
  283. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/modular.js +324 -0
  284. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/montgomery.js +163 -0
  285. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/utils.js +245 -0
  286. package/dist/cjs/js/src/static_dependencies/noble-curves/abstract/weierstrass.js +1018 -0
  287. package/dist/cjs/js/src/static_dependencies/noble-curves/ed25519.js +383 -0
  288. package/dist/cjs/js/src/static_dependencies/noble-curves/secp256k1.js +258 -0
  289. package/dist/cjs/js/src/static_dependencies/noble-hashes/_assert.js +53 -0
  290. package/dist/cjs/js/src/static_dependencies/noble-hashes/_sha2.js +120 -0
  291. package/dist/cjs/js/src/static_dependencies/noble-hashes/_u64.js +69 -0
  292. package/dist/cjs/js/src/static_dependencies/noble-hashes/crypto.js +7 -0
  293. package/dist/cjs/js/src/static_dependencies/noble-hashes/hmac.js +83 -0
  294. package/dist/cjs/js/src/static_dependencies/noble-hashes/md5.js +240 -0
  295. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha1.js +91 -0
  296. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha256.js +130 -0
  297. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha3.js +214 -0
  298. package/dist/cjs/js/src/static_dependencies/noble-hashes/sha512.js +239 -0
  299. package/dist/cjs/js/src/static_dependencies/noble-hashes/utils.js +93 -0
  300. package/dist/cjs/js/src/static_dependencies/node-fetch/body.js +354 -0
  301. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/abort-error.js +16 -0
  302. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/base.js +20 -0
  303. package/dist/cjs/js/src/static_dependencies/node-fetch/errors/fetch-error.js +30 -0
  304. package/dist/cjs/js/src/static_dependencies/node-fetch/headers.js +239 -0
  305. package/dist/cjs/js/src/static_dependencies/node-fetch/index.js +372 -0
  306. package/dist/cjs/js/src/static_dependencies/node-fetch/request.js +273 -0
  307. package/dist/cjs/js/src/static_dependencies/node-fetch/response.js +139 -0
  308. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/get-search.js +14 -0
  309. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is-redirect.js +16 -0
  310. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/is.js +81 -0
  311. package/dist/cjs/js/src/static_dependencies/node-fetch/utils/referrer.js +292 -0
  312. package/dist/cjs/js/src/static_dependencies/proxies/agent-base/index.js +103 -0
  313. package/dist/cjs/js/src/static_dependencies/proxies/http-proxy-agent/index.js +140 -0
  314. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/index.js +175 -0
  315. package/dist/cjs/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.js +95 -0
  316. package/dist/cjs/js/src/static_dependencies/qs/index.cjs.js +7 -0
  317. package/dist/cjs/js/src/static_dependencies/scure-base/index.js +383 -0
  318. package/dist/cjs/js/src/timex.js +1562 -0
  319. package/dist/cjs/js/src/tokocrypto.js +2542 -0
  320. package/dist/cjs/js/src/upbit.js +1844 -0
  321. package/dist/cjs/js/src/wavesexchange.js +2607 -0
  322. package/dist/cjs/js/src/wazirx.js +953 -0
  323. package/dist/cjs/js/src/whitebit.js +2309 -0
  324. package/dist/cjs/js/src/woo.js +2765 -0
  325. package/dist/cjs/js/src/yobit.js +1314 -0
  326. package/dist/cjs/js/src/zaif.js +736 -0
  327. package/dist/cjs/js/src/zonda.js +1883 -0
  328. package/js/ccxt.d.ts +1 -1
  329. package/js/ccxt.js +1 -1
  330. package/js/src/abstract/bigone.d.ts +18 -0
  331. package/js/src/abstract/binance.d.ts +2 -0
  332. package/js/src/abstract/binancecoinm.d.ts +2 -0
  333. package/js/src/abstract/binanceus.d.ts +2 -0
  334. package/js/src/abstract/binanceusdm.d.ts +2 -0
  335. package/js/src/abstract/bingx.d.ts +2 -0
  336. package/js/src/abstract/bybit.d.ts +1 -0
  337. package/js/src/abstract/gate.d.ts +11 -0
  338. package/js/src/abstract/gateio.d.ts +11 -0
  339. package/js/src/abstract/okx.d.ts +1 -0
  340. package/js/src/alpaca.js +18 -18
  341. package/js/src/base/Exchange.d.ts +5 -1
  342. package/js/src/base/Exchange.js +101 -12
  343. package/js/src/bigone.d.ts +3 -2
  344. package/js/src/bigone.js +429 -167
  345. package/js/src/binance.js +48 -34
  346. package/js/src/bingx.js +115 -38
  347. package/js/src/bitfinex.d.ts +2 -2
  348. package/js/src/bitfinex.js +2 -3
  349. package/js/src/bitget.js +33 -13
  350. package/js/src/bitmart.d.ts +2 -2
  351. package/js/src/bitmart.js +5 -5
  352. package/js/src/bitmex.js +1 -0
  353. package/js/src/bybit.js +2 -0
  354. package/js/src/coinbase.d.ts +26 -3
  355. package/js/src/coinbase.js +176 -26
  356. package/js/src/coinlist.js +3 -4
  357. package/js/src/coinone.js +1 -1
  358. package/js/src/coinsph.js +2 -3
  359. package/js/src/deribit.js +1 -0
  360. package/js/src/gate.d.ts +4 -4
  361. package/js/src/gate.js +96 -59
  362. package/js/src/gemini.js +1 -1
  363. package/js/src/hitbtc.d.ts +4 -4
  364. package/js/src/hitbtc.js +2 -3
  365. package/js/src/htx.d.ts +1 -0
  366. package/js/src/htx.js +29 -7
  367. package/js/src/huobijp.js +2 -3
  368. package/js/src/independentreserve.js +7 -5
  369. package/js/src/kraken.js +3 -6
  370. package/js/src/lbank.js +59 -33
  371. package/js/src/mexc.js +2 -1
  372. package/js/src/oceanex.js +1 -1
  373. package/js/src/okx.js +14 -3
  374. package/js/src/phemex.js +9 -2
  375. package/js/src/pro/binance.d.ts +2 -23
  376. package/js/src/pro/binance.js +58 -22
  377. package/js/src/pro/coinbase.d.ts +2 -2
  378. package/js/src/pro/coinbase.js +4 -1
  379. package/js/src/pro/coinbasepro.d.ts +2 -2
  380. package/js/src/pro/hitbtc.d.ts +2 -2
  381. package/js/src/pro/kraken.js +1 -1
  382. package/js/src/pro/okx.d.ts +1 -0
  383. package/js/src/pro/okx.js +52 -2
  384. package/js/src/pro/poloniex.d.ts +2 -2
  385. package/js/src/probit.js +4 -2
  386. package/js/src/upbit.d.ts +3 -101
  387. package/js/src/upbit.js +12 -12
  388. package/js/src/wavesexchange.js +1 -1
  389. package/js/src/woo.d.ts +2 -0
  390. package/js/src/woo.js +52 -0
  391. package/package.json +1 -1
  392. package/skip-tests.json +5 -0
@@ -0,0 +1,1095 @@
1
+ 'use strict';
2
+
3
+ var Precise = require('../base/Precise.js');
4
+ var coinex$1 = require('../coinex.js');
5
+ var errors = require('../base/errors.js');
6
+ var Cache = require('../base/ws/Cache.js');
7
+ var sha256 = require('../static_dependencies/noble-hashes/sha256.js');
8
+ var md5 = require('../static_dependencies/noble-hashes/md5.js');
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // ---------------------------------------------------------------------------
12
+ class coinex extends coinex$1 {
13
+ describe() {
14
+ return this.deepExtend(super.describe(), {
15
+ 'has': {
16
+ 'ws': true,
17
+ 'watchBalance': true,
18
+ 'watchTicker': true,
19
+ 'watchTickers': true,
20
+ 'watchTrades': true,
21
+ 'watchMyTrades': false,
22
+ 'watchOrders': true,
23
+ 'watchOrderBook': true,
24
+ 'watchOHLCV': true,
25
+ 'fetchOHLCVWs': true,
26
+ },
27
+ 'urls': {
28
+ 'api': {
29
+ 'ws': {
30
+ 'spot': 'wss://socket.coinex.com/',
31
+ 'swap': 'wss://perpetual.coinex.com/',
32
+ },
33
+ },
34
+ },
35
+ 'options': {
36
+ 'watchOHLCVWarning': true,
37
+ 'timeframes': {
38
+ '1m': 60,
39
+ '3m': 180,
40
+ '5m': 300,
41
+ '15m': 900,
42
+ '30m': 1800,
43
+ '1h': 3600,
44
+ '2h': 7200,
45
+ '4h': 14400,
46
+ '6h': 21600,
47
+ '12h': 43200,
48
+ '1d': 86400,
49
+ '3d': 259200,
50
+ '1w': 604800,
51
+ },
52
+ 'account': 'spot',
53
+ 'watchOrderBook': {
54
+ 'limits': [5, 10, 20, 50],
55
+ 'defaultLimit': 50,
56
+ 'aggregations': ['10', '1', '0', '0.1', '0.01'],
57
+ 'defaultAggregation': '0',
58
+ },
59
+ },
60
+ 'streaming': {},
61
+ 'exceptions': {
62
+ 'codes': {
63
+ '1': errors.BadRequest,
64
+ '2': errors.ExchangeError,
65
+ '3': errors.ExchangeNotAvailable,
66
+ '4': errors.NotSupported,
67
+ '5': errors.RequestTimeout,
68
+ '6': errors.AuthenticationError, // Permission denied
69
+ },
70
+ },
71
+ });
72
+ }
73
+ requestId() {
74
+ const requestId = this.sum(this.safeInteger(this.options, 'requestId', 0), 1);
75
+ this.options['requestId'] = requestId;
76
+ return requestId;
77
+ }
78
+ handleTicker(client, message) {
79
+ //
80
+ // spot
81
+ //
82
+ // {
83
+ // "method": "state.update",
84
+ // "params": [{
85
+ // "BTCUSDT": {
86
+ // "last": "31577.89",
87
+ // "open": "29318.36",
88
+ // "close": "31577.89",
89
+ // "high": "32222.19",
90
+ // "low": "29317.21",
91
+ // "volume": "630.43024965",
92
+ // "sell_total": "13.66143951",
93
+ // "buy_total": "2.76410939",
94
+ // "period": 86400,
95
+ // "deal": "19457487.84611409070000000000"
96
+ // }
97
+ // }]
98
+ // }
99
+ //
100
+ // swap
101
+ //
102
+ // {
103
+ // "method": "state.update",
104
+ // "params": [{
105
+ // "BTCUSDT": {
106
+ // "period": 86400,
107
+ // "funding_time": 422,
108
+ // "position_amount": "285.6246",
109
+ // "funding_rate_last": "-0.00097933",
110
+ // "funding_rate_next": "0.00022519",
111
+ // "funding_rate_predict": "0.00075190",
112
+ // "insurance": "17474289.49925859030905338270",
113
+ // "last": "31570.08",
114
+ // "sign_price": "31568.09",
115
+ // "index_price": "31561.85000000",
116
+ // "open": "29296.11",
117
+ // "close": "31570.08",
118
+ // "high": "32463.40",
119
+ // "low": "29296.11",
120
+ // "volume": "8774.7318",
121
+ // "deal": "270675177.827928219109030017258398",
122
+ // "sell_total": "19.2230",
123
+ // "buy_total": "25.7814"
124
+ // }
125
+ // }]
126
+ // }
127
+ //
128
+ const defaultType = this.safeString(this.options, 'defaultType');
129
+ const params = this.safeValue(message, 'params', []);
130
+ const rawTickers = this.safeValue(params, 0, {});
131
+ const keys = Object.keys(rawTickers);
132
+ const newTickers = [];
133
+ for (let i = 0; i < keys.length; i++) {
134
+ const marketId = keys[i];
135
+ const rawTicker = rawTickers[marketId];
136
+ const symbol = this.safeSymbol(marketId, undefined, undefined, defaultType);
137
+ const market = this.safeMarket(marketId, undefined, undefined, defaultType);
138
+ const parsedTicker = this.parseWSTicker(rawTicker, market);
139
+ this.tickers[symbol] = parsedTicker;
140
+ newTickers.push(parsedTicker);
141
+ }
142
+ const messageHashes = this.findMessageHashes(client, 'tickers::');
143
+ for (let i = 0; i < messageHashes.length; i++) {
144
+ const messageHash = messageHashes[i];
145
+ const parts = messageHash.split('::');
146
+ const symbolsString = parts[1];
147
+ const symbols = symbolsString.split(',');
148
+ const tickers = this.filterByArray(newTickers, 'symbol', symbols);
149
+ const tickersSymbols = Object.keys(tickers);
150
+ const numTickers = tickersSymbols.length;
151
+ if (numTickers > 0) {
152
+ client.resolve(tickers, messageHash);
153
+ }
154
+ }
155
+ client.resolve(newTickers, 'tickers');
156
+ }
157
+ parseWSTicker(ticker, market = undefined) {
158
+ //
159
+ // spot
160
+ //
161
+ // {
162
+ // "last": "31577.89",
163
+ // "open": "29318.36",
164
+ // "close": "31577.89",
165
+ // "high": "32222.19",
166
+ // "low": "29317.21",
167
+ // "volume": "630.43024965",
168
+ // "sell_total": "13.66143951",
169
+ // "buy_total": "2.76410939",
170
+ // "period": 86400,
171
+ // "deal": "19457487.84611409070000000000"
172
+ // }
173
+ //
174
+ // swap
175
+ //
176
+ // {
177
+ // "period": 86400,
178
+ // "funding_time": 422,
179
+ // "position_amount": "285.6246",
180
+ // "funding_rate_last": "-0.00097933",
181
+ // "funding_rate_next": "0.00022519",
182
+ // "funding_rate_predict": "0.00075190",
183
+ // "insurance": "17474289.49925859030905338270",
184
+ // "last": "31570.08",
185
+ // "sign_price": "31568.09",
186
+ // "index_price": "31561.85000000",
187
+ // "open": "29296.11",
188
+ // "close": "31570.08",
189
+ // "high": "32463.40",
190
+ // "low": "29296.11",
191
+ // "volume": "8774.7318",
192
+ // "deal": "270675177.827928219109030017258398",
193
+ // "sell_total": "19.2230",
194
+ // "buy_total": "25.7814"
195
+ // }
196
+ //
197
+ const defaultType = this.safeString(this.options, 'defaultType');
198
+ return this.safeTicker({
199
+ 'symbol': this.safeSymbol(undefined, market, undefined, defaultType),
200
+ 'timestamp': undefined,
201
+ 'datetime': undefined,
202
+ 'high': this.safeString(ticker, 'high'),
203
+ 'low': this.safeString(ticker, 'low'),
204
+ 'bid': undefined,
205
+ 'bidVolume': this.safeString(ticker, 'buy_total'),
206
+ 'ask': undefined,
207
+ 'askVolume': this.safeString(ticker, 'sell_total'),
208
+ 'vwap': undefined,
209
+ 'open': this.safeString(ticker, 'open'),
210
+ 'close': this.safeString(ticker, 'close'),
211
+ 'last': this.safeString(ticker, 'last'),
212
+ 'previousClose': undefined,
213
+ 'change': undefined,
214
+ 'percentage': undefined,
215
+ 'average': undefined,
216
+ 'baseVolume': this.safeString(ticker, 'volume'),
217
+ 'quoteVolume': this.safeString(ticker, 'deal'),
218
+ 'info': ticker,
219
+ }, market);
220
+ }
221
+ async watchBalance(params = {}) {
222
+ /**
223
+ * @method
224
+ * @name coinex#watchBalance
225
+ * @description watch balance and get the amount of funds available for trading or funds locked in orders
226
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
227
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
228
+ */
229
+ await this.loadMarkets();
230
+ await this.authenticate(params);
231
+ const messageHash = 'balance';
232
+ let type = undefined;
233
+ [type, params] = this.handleMarketTypeAndParams('watchBalance', undefined, params);
234
+ const url = this.urls['api']['ws'][type];
235
+ const currencies = Object.keys(this.currencies_by_id);
236
+ const subscribe = {
237
+ 'method': 'asset.subscribe',
238
+ 'params': currencies,
239
+ 'id': this.requestId(),
240
+ };
241
+ const request = this.deepExtend(subscribe, params);
242
+ return await this.watch(url, messageHash, request, messageHash);
243
+ }
244
+ handleBalance(client, message) {
245
+ //
246
+ // {
247
+ // "method": "asset.update",
248
+ // "params": [
249
+ // {
250
+ // "BTC": {
251
+ // "available": "250",
252
+ // "frozen": "10",
253
+ // }
254
+ // }
255
+ // ],
256
+ // "id": null
257
+ // }
258
+ //
259
+ const params = this.safeValue(message, 'params', []);
260
+ const first = this.safeValue(params, 0, {});
261
+ this.balance['info'] = first;
262
+ const currencies = Object.keys(first);
263
+ for (let i = 0; i < currencies.length; i++) {
264
+ const currencyId = currencies[i];
265
+ const code = this.safeCurrencyCode(currencyId);
266
+ const available = this.safeString(first[currencyId], 'available');
267
+ const frozen = this.safeString(first[currencyId], 'frozen');
268
+ const account = this.account();
269
+ account['free'] = available;
270
+ account['used'] = frozen;
271
+ this.balance[code] = account;
272
+ this.balance = this.safeBalance(this.balance);
273
+ }
274
+ const messageHash = 'balance';
275
+ client.resolve(this.balance, messageHash);
276
+ }
277
+ handleTrades(client, message) {
278
+ //
279
+ // {
280
+ // "method": "deals.update",
281
+ // "params": [
282
+ // "BTCUSD",
283
+ // [{
284
+ // "type": "sell",
285
+ // "time": 1496458040.059284,
286
+ // "price ": "46444.74",
287
+ // "id": 29433,
288
+ // "amount": "0.00120000"
289
+ // }]
290
+ // ],
291
+ // "id": null
292
+ // }
293
+ //
294
+ const params = this.safeValue(message, 'params', []);
295
+ const marketId = this.safeString(params, 0);
296
+ const trades = this.safeValue(params, 1, []);
297
+ const defaultType = this.safeString(this.options, 'defaultType');
298
+ const market = this.safeMarket(marketId, undefined, undefined, defaultType);
299
+ const symbol = market['symbol'];
300
+ const messageHash = 'trades:' + symbol;
301
+ let stored = this.safeValue(this.trades, symbol);
302
+ if (stored === undefined) {
303
+ const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
304
+ stored = new Cache.ArrayCache(limit);
305
+ this.trades[symbol] = stored;
306
+ }
307
+ for (let i = 0; i < trades.length; i++) {
308
+ const trade = trades[i];
309
+ const parsed = this.parseWsTrade(trade, market);
310
+ stored.append(parsed);
311
+ }
312
+ this.trades[symbol] = stored;
313
+ client.resolve(this.trades[symbol], messageHash);
314
+ }
315
+ parseWsTrade(trade, market = undefined) {
316
+ //
317
+ // {
318
+ // "type": "sell",
319
+ // "time": 1496458040.059284,
320
+ // "price ": "46444.74",
321
+ // "id": 29433,
322
+ // "amount": "0.00120000"
323
+ // }
324
+ //
325
+ const timestamp = this.safeTimestamp(trade, 'time');
326
+ const defaultType = this.safeString(this.options, 'defaultType');
327
+ return this.safeTrade({
328
+ 'id': this.safeString(trade, 'id'),
329
+ 'info': trade,
330
+ 'timestamp': timestamp,
331
+ 'datetime': this.iso8601(timestamp),
332
+ 'symbol': this.safeSymbol(undefined, market, undefined, defaultType),
333
+ 'order': undefined,
334
+ 'type': undefined,
335
+ 'side': this.safeString(trade, 'type'),
336
+ 'takerOrMaker': undefined,
337
+ 'price': this.safeString(trade, 'price'),
338
+ 'amount': this.safeString(trade, 'amount'),
339
+ 'cost': undefined,
340
+ 'fee': undefined,
341
+ }, market);
342
+ }
343
+ handleOHLCV(client, message) {
344
+ //
345
+ // spot
346
+ // {
347
+ // "error": null,
348
+ // "result": [
349
+ // [
350
+ // 1673846940,
351
+ // "21148.74",
352
+ // "21148.38",
353
+ // "21148.75",
354
+ // "21138.66",
355
+ // "1.57060173",
356
+ // "33214.9138778914"
357
+ // ],
358
+ // ]
359
+ // "id": 1,
360
+ // }
361
+ // swap
362
+ // {
363
+ // "method": "kline.update",
364
+ // "params": [
365
+ // [
366
+ // 1654019640, // timestamp
367
+ // "32061.99", // open
368
+ // "32061.28", // close
369
+ // "32061.99", // high
370
+ // "32061.28", // low
371
+ // "0.1285", // amount base
372
+ // "4119.943736" // amount quote
373
+ // ]
374
+ // ],
375
+ // "id": null
376
+ // }
377
+ //
378
+ const candles = this.safeValue2(message, 'params', 'result', []);
379
+ const messageHash = 'ohlcv';
380
+ const id = this.safeString(message, 'id');
381
+ const ohlcvs = this.parseOHLCVs(candles);
382
+ if (id !== undefined) {
383
+ // spot subscription response
384
+ client.resolve(ohlcvs, messageHash);
385
+ return;
386
+ }
387
+ const keys = Object.keys(this.ohlcvs);
388
+ const keysLength = keys.length;
389
+ if (keysLength === 0) {
390
+ const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
391
+ this.ohlcvs = new Cache.ArrayCacheByTimestamp(limit);
392
+ }
393
+ for (let i = 0; i < ohlcvs.length; i++) {
394
+ const candle = ohlcvs[i];
395
+ this.ohlcvs.append(candle);
396
+ }
397
+ client.resolve(this.ohlcvs, messageHash);
398
+ }
399
+ async watchTicker(symbol, params = {}) {
400
+ /**
401
+ * @method
402
+ * @name coinex#watchTicker
403
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot004_websocket007_state_subscribe
404
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
405
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
406
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
407
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
408
+ */
409
+ const tickers = await this.watchTickers([symbol], params);
410
+ return this.safeValue(tickers, symbol);
411
+ }
412
+ async watchTickers(symbols = undefined, params = {}) {
413
+ /**
414
+ * @method
415
+ * @name coinex#watchTickers
416
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot004_websocket007_state_subscribe
417
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
418
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
419
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
420
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
421
+ */
422
+ await this.loadMarkets();
423
+ symbols = this.marketSymbols(symbols);
424
+ let type = undefined;
425
+ [type, params] = this.handleMarketTypeAndParams('watchTickers', undefined, params);
426
+ const url = this.urls['api']['ws'][type];
427
+ let messageHash = 'tickers';
428
+ if (symbols !== undefined) {
429
+ messageHash = 'tickers::' + symbols.join(',');
430
+ }
431
+ const subscribe = {
432
+ 'method': 'state.subscribe',
433
+ 'id': this.requestId(),
434
+ 'params': [],
435
+ };
436
+ const request = this.deepExtend(subscribe, params);
437
+ const newTickers = await this.watch(url, messageHash, request, messageHash);
438
+ if (this.newUpdates) {
439
+ return newTickers;
440
+ }
441
+ return this.filterByArray(this.tickers, 'symbol', symbols);
442
+ }
443
+ async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
444
+ /**
445
+ * @method
446
+ * @name coinex#watchTrades
447
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot004_websocket012_deal_subcribe
448
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures002_websocket019_deal_subcribe
449
+ * @description get the list of most recent trades for a particular symbol
450
+ * @param {string} symbol unified symbol of the market to fetch trades for
451
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
452
+ * @param {int} [limit] the maximum amount of trades to fetch
453
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
454
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
455
+ */
456
+ await this.loadMarkets();
457
+ const market = this.market(symbol);
458
+ let type = undefined;
459
+ [type, params] = this.handleMarketTypeAndParams('watchTrades', market, params);
460
+ const url = this.urls['api']['ws'][type];
461
+ const messageHash = 'trades:' + symbol;
462
+ const subscriptionHash = 'trades';
463
+ const subscribedSymbols = this.safeValue(this.options, 'watchTradesSubscriptions', []);
464
+ subscribedSymbols.push(market['id']);
465
+ const message = {
466
+ 'method': 'deals.subscribe',
467
+ 'params': subscribedSymbols,
468
+ 'id': this.requestId(),
469
+ };
470
+ this.options['watchTradesSubscriptions'] = subscribedSymbols;
471
+ const request = this.deepExtend(message, params);
472
+ const trades = await this.watch(url, messageHash, request, subscriptionHash);
473
+ return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
474
+ }
475
+ async watchOrderBook(symbol, limit = undefined, params = {}) {
476
+ /**
477
+ * @method
478
+ * @name coinex#watchOrderBook
479
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot004_websocket017_depth_subscribe_multi
480
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures002_websocket011_depth_subscribe_multi
481
+ * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
482
+ * @param {string} symbol unified symbol of the market to fetch the order book for
483
+ * @param {int} [limit] the maximum amount of order book entries to return
484
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
485
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
486
+ */
487
+ await this.loadMarkets();
488
+ const market = this.market(symbol);
489
+ symbol = market['symbol'];
490
+ let type = undefined;
491
+ [type, params] = this.handleMarketTypeAndParams('watchOrderBook', market, params);
492
+ const url = this.urls['api']['ws'][type];
493
+ const name = 'orderbook';
494
+ const messageHash = name + ':' + symbol;
495
+ const options = this.safeValue(this.options, 'watchOrderBook', {});
496
+ const limits = this.safeValue(options, 'limits', []);
497
+ if (limit === undefined) {
498
+ limit = this.safeValue(options, 'defaultLimit', 50);
499
+ }
500
+ if (!this.inArray(limit, limits)) {
501
+ throw new errors.NotSupported(this.id + ' watchOrderBook() limit must be one of ' + limits.join(', '));
502
+ }
503
+ const defaultAggregation = this.safeString(options, 'defaultAggregation', '0');
504
+ const aggregations = this.safeValue(options, 'aggregations', []);
505
+ const aggregation = this.safeString(params, 'aggregation', defaultAggregation);
506
+ if (!this.inArray(aggregation, aggregations)) {
507
+ throw new errors.NotSupported(this.id + ' watchOrderBook() aggregation must be one of ' + aggregations.join(', '));
508
+ }
509
+ params = this.omit(params, 'aggregation');
510
+ const watchOrderBookSubscriptions = this.safeValue(this.options, 'watchOrderBookSubscriptions', {});
511
+ watchOrderBookSubscriptions[symbol] = [market['id'], limit, aggregation, true];
512
+ const subscribe = {
513
+ 'method': 'depth.subscribe_multi',
514
+ 'id': this.requestId(),
515
+ 'params': Object.values(watchOrderBookSubscriptions),
516
+ };
517
+ this.options['watchOrderBookSubscriptions'] = watchOrderBookSubscriptions;
518
+ const subscriptionHash = this.hash(this.encode(this.json(watchOrderBookSubscriptions)), sha256.sha256);
519
+ const request = this.deepExtend(subscribe, params);
520
+ const orderbook = await this.watch(url, messageHash, request, subscriptionHash, request);
521
+ return orderbook.limit();
522
+ }
523
+ async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
524
+ /**
525
+ * @method
526
+ * @name coinex#watchOHLCV
527
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures002_websocket023_kline_subscribe
528
+ * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
529
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
530
+ * @param {string} timeframe the length of time each candle represents
531
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
532
+ * @param {int} [limit] the maximum amount of candles to fetch
533
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
534
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
535
+ */
536
+ await this.loadMarkets();
537
+ const market = this.market(symbol);
538
+ symbol = market['symbol'];
539
+ let type = undefined;
540
+ [type, params] = this.handleMarketTypeAndParams('watchOHLCV', market, params);
541
+ if (type !== 'swap') {
542
+ throw new errors.NotSupported(this.id + ' watchOHLCV() is only supported for swap markets. Try using fetchOHLCV () instead');
543
+ }
544
+ const url = this.urls['api']['ws'][type];
545
+ const messageHash = 'ohlcv';
546
+ const watchOHLCVWarning = this.safeValue(this.options, 'watchOHLCVWarning', true);
547
+ const client = this.safeValue(this.clients, url, {});
548
+ const clientSub = this.safeValue(client, 'subscriptions', {});
549
+ const existingSubscription = this.safeValue(clientSub, messageHash);
550
+ const subSymbol = this.safeString(existingSubscription, 'symbol');
551
+ const subTimeframe = this.safeString(existingSubscription, 'timeframe');
552
+ // due to nature of coinex response can only watch one symbol at a time
553
+ if (watchOHLCVWarning && existingSubscription !== undefined && (subSymbol !== symbol || subTimeframe !== timeframe)) {
554
+ throw new errors.ExchangeError(this.id + ' watchOHLCV() can only watch one symbol and timeframe at a time. To supress this warning set watchOHLCVWarning to false in options');
555
+ }
556
+ const timeframes = this.safeValue(this.options, 'timeframes', {});
557
+ const subscribe = {
558
+ 'method': 'kline.subscribe',
559
+ 'id': this.requestId(),
560
+ 'params': [
561
+ market['id'],
562
+ this.safeInteger(timeframes, timeframe),
563
+ ],
564
+ };
565
+ const subscription = {
566
+ 'symbol': symbol,
567
+ 'timeframe': timeframe,
568
+ };
569
+ const request = this.deepExtend(subscribe, params);
570
+ const ohlcvs = await this.watch(url, messageHash, request, messageHash, subscription);
571
+ if (this.newUpdates) {
572
+ limit = ohlcvs.getLimit(symbol, limit);
573
+ }
574
+ return this.filterBySinceLimit(ohlcvs, since, limit, 0);
575
+ }
576
+ async fetchOHLCVWs(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
577
+ /**
578
+ * @method
579
+ * @name coinex#fetchOHLCV
580
+ * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot004_websocket005_kline_query
581
+ * @description query historical candlestick data containing the open, high, low, and close price, and the volume of a market
582
+ * @param {string} symbol unified symbol of the market to query OHLCV data for
583
+ * @param {string} timeframe the length of time each candle represents
584
+ * @param {int|undefined} since timestamp in ms of the earliest candle to fetch
585
+ * @param {int|undefined} limit the maximum amount of candles to fetch
586
+ * @param {object} params extra parameters specific to the exchange API endpoint
587
+ * @param {int|undefined} params.end the end time for spot markets, this.seconds () is set as default
588
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
589
+ */
590
+ await this.loadMarkets();
591
+ const market = this.market(symbol);
592
+ const [type, query] = this.handleMarketTypeAndParams('fetchOHLCV', market, params);
593
+ const url = this.urls['api']['ws'][type];
594
+ symbol = market['symbol'];
595
+ const messageHash = 'ohlcv';
596
+ const timeframes = this.safeValue(this.options, 'timeframes', {});
597
+ timeframe = this.safeString(timeframes, timeframe, timeframe);
598
+ if (since === undefined) {
599
+ since = 1640995200; // January 1, 2022
600
+ }
601
+ const id = this.requestId();
602
+ const subscribe = {
603
+ 'method': 'kline.query',
604
+ 'params': [
605
+ market['id'],
606
+ this.parseToInt(since / 1000),
607
+ this.safeInteger(params, 'end', this.seconds()),
608
+ this.parseToInt(timeframe),
609
+ ],
610
+ 'id': id,
611
+ };
612
+ const subscription = {
613
+ 'id': id,
614
+ 'future': messageHash,
615
+ };
616
+ const subscriptionHash = id;
617
+ const request = this.deepExtend(subscribe, query);
618
+ const ohlcvs = await this.watch(url, messageHash, request, subscriptionHash, subscription);
619
+ return this.filterBySinceLimit(ohlcvs, since, limit, 0);
620
+ }
621
+ handleDelta(bookside, delta) {
622
+ const bidAsk = this.parseBidAsk(delta, 0, 1);
623
+ bookside.storeArray(bidAsk);
624
+ }
625
+ handleDeltas(bookside, deltas) {
626
+ for (let i = 0; i < deltas.length; i++) {
627
+ this.handleDelta(bookside, deltas[i]);
628
+ }
629
+ }
630
+ handleOrderBook(client, message) {
631
+ //
632
+ // {
633
+ // "method": "depth.update",
634
+ // "params": [
635
+ // false,
636
+ // {
637
+ // "asks": [
638
+ // ["46350.52", "1.07871851"],
639
+ // ...
640
+ // ],
641
+ // "bids": [
642
+ // ["46349.61", "0.04000000"],
643
+ // ...
644
+ // ],
645
+ // "last": "46349.93",
646
+ // "time": 1639987469166,
647
+ // "checksum": 1533284725
648
+ // },
649
+ // "BTCUSDT"
650
+ // ],
651
+ // "id": null
652
+ // }
653
+ //
654
+ const params = this.safeValue(message, 'params', []);
655
+ const fullOrderBook = this.safeValue(params, 0);
656
+ let orderBook = this.safeValue(params, 1);
657
+ const marketId = this.safeString(params, 2);
658
+ const defaultType = this.safeString(this.options, 'defaultType');
659
+ const market = this.safeMarket(marketId, undefined, undefined, defaultType);
660
+ const symbol = market['symbol'];
661
+ const name = 'orderbook';
662
+ const messageHash = name + ':' + symbol;
663
+ const timestamp = this.safeInteger(orderBook, 'time');
664
+ const currentOrderBook = this.safeValue(this.orderbooks, symbol);
665
+ if (fullOrderBook) {
666
+ const snapshot = this.parseOrderBook(orderBook, symbol, timestamp);
667
+ if (currentOrderBook === undefined) {
668
+ orderBook = this.orderBook(snapshot);
669
+ this.orderbooks[symbol] = orderBook;
670
+ }
671
+ else {
672
+ orderBook = this.orderbooks[symbol];
673
+ orderBook.reset(snapshot);
674
+ }
675
+ }
676
+ else {
677
+ const asks = this.safeValue(orderBook, 'asks', []);
678
+ const bids = this.safeValue(orderBook, 'bids', []);
679
+ this.handleDeltas(currentOrderBook['asks'], asks);
680
+ this.handleDeltas(currentOrderBook['bids'], bids);
681
+ currentOrderBook['nonce'] = timestamp;
682
+ currentOrderBook['timestamp'] = timestamp;
683
+ currentOrderBook['datetime'] = this.iso8601(timestamp);
684
+ this.orderbooks[symbol] = currentOrderBook;
685
+ }
686
+ // this.checkOrderBookChecksum (this.orderbooks[symbol]);
687
+ client.resolve(this.orderbooks[symbol], messageHash);
688
+ }
689
+ async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
690
+ await this.loadMarkets();
691
+ await this.authenticate(params);
692
+ let messageHash = 'orders';
693
+ let market = undefined;
694
+ const [type, query] = this.handleMarketTypeAndParams('watchOrders', market, params);
695
+ const message = {
696
+ 'method': 'order.subscribe',
697
+ 'id': this.requestId(),
698
+ };
699
+ if (symbol !== undefined) {
700
+ market = this.market(symbol);
701
+ symbol = market['symbol'];
702
+ message['params'] = [market['id']];
703
+ messageHash += ':' + symbol;
704
+ }
705
+ else {
706
+ message['params'] = [];
707
+ }
708
+ const url = this.urls['api']['ws'][type];
709
+ const request = this.deepExtend(message, query);
710
+ const orders = await this.watch(url, messageHash, request, messageHash, request);
711
+ if (this.newUpdates) {
712
+ limit = orders.getLimit(symbol, limit);
713
+ }
714
+ return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
715
+ }
716
+ handleOrders(client, message) {
717
+ //
718
+ // spot
719
+ //
720
+ // {
721
+ // "method": "order.update",
722
+ // "params": [
723
+ // 1,
724
+ // {
725
+ // "id": 77782469357,
726
+ // "type": 1,
727
+ // "side": 2,
728
+ // "user": 1849116,
729
+ // "account": 0,
730
+ // "option": 2,
731
+ // "ctime": 1653961043.048967,
732
+ // "mtime": 1653961043.048967,
733
+ // "market": "BTCUSDT",
734
+ // "source": "web",
735
+ // "client_id": '',
736
+ // "price": "1.00",
737
+ // "amount": "1.00000000",
738
+ // "taker_fee": "0.0020",
739
+ // "maker_fee": "0.0020",
740
+ // "left": "1.00000000",
741
+ // "deal_stock": "0",
742
+ // "deal_money": "0",
743
+ // "money_fee": "0",
744
+ // "stock_fee": "0",
745
+ // "asset_fee": "0",
746
+ // "fee_discount": "1",
747
+ // "last_deal_amount": "0",
748
+ // "last_deal_price": "0",
749
+ // "last_deal_time": 0,
750
+ // "last_deal_id": 0,
751
+ // "last_role": 0,
752
+ // "fee_asset": null,
753
+ // "stop_id": 0
754
+ // }
755
+ // ],
756
+ // "id": null
757
+ // }
758
+ //
759
+ // swap
760
+ //
761
+ // {
762
+ // "method": "order.update",
763
+ // "params": [
764
+ // 1,
765
+ // {
766
+ // "order_id": 23423462821,
767
+ // "position_id": 0,
768
+ // "stop_id": 0,
769
+ // "market": "BTCUSDT",
770
+ // "type": 1,
771
+ // "side": 2,
772
+ // "target": 0,
773
+ // "effect_type": 1,
774
+ // "user_id": 1849116,
775
+ // "create_time": 1653961509.25049,
776
+ // "update_time": 1653961509.25049,
777
+ // "source": "web",
778
+ // "price": "1.00",
779
+ // "amount": "1.0000",
780
+ // "taker_fee": "0.00050",
781
+ // "maker_fee": "0.00030",
782
+ // "left": "1.0000",
783
+ // "deal_stock": "0.00000000000000000000",
784
+ // "deal_fee": "0.00000000000000000000",
785
+ // "deal_profit": "0.00000000000000000000",
786
+ // "last_deal_amount": "0.00000000000000000000",
787
+ // "last_deal_price": "0.00000000000000000000",
788
+ // "last_deal_time": 0,
789
+ // "last_deal_id": 0,
790
+ // "last_deal_type": 0,
791
+ // "last_deal_role": 0,
792
+ // "client_id": '',
793
+ // "fee_asset": '',
794
+ // "fee_discount": "0.00000000000000000000",
795
+ // "deal_asset_fee": "0.00000000000000000000",
796
+ // "leverage": "3",
797
+ // "position_type": 2
798
+ // }
799
+ // ],
800
+ // "id": null
801
+ // }
802
+ //
803
+ const params = this.safeValue(message, 'params', []);
804
+ const order = this.safeValue(params, 1, {});
805
+ const parsedOrder = this.parseWsOrder(order);
806
+ if (this.orders === undefined) {
807
+ const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
808
+ this.orders = new Cache.ArrayCacheBySymbolById(limit);
809
+ }
810
+ const orders = this.orders;
811
+ orders.append(parsedOrder);
812
+ let messageHash = 'orders';
813
+ client.resolve(this.orders, messageHash);
814
+ messageHash += ':' + parsedOrder['symbol'];
815
+ client.resolve(this.orders, messageHash);
816
+ }
817
+ parseWsOrder(order, market = undefined) {
818
+ //
819
+ // spot
820
+ //
821
+ // {
822
+ // "id": 77782469357,
823
+ // "type": 1,
824
+ // "side": 2,
825
+ // "user": 1849116,
826
+ // "account": 0,
827
+ // "option": 2,
828
+ // "ctime": 1653961043.048967,
829
+ // "mtime": 1653961043.048967,
830
+ // "market": "BTCUSDT",
831
+ // "source": "web",
832
+ // "client_id": '',
833
+ // "price": "1.00",
834
+ // "amount": "1.00000000",
835
+ // "taker_fee": "0.0020",
836
+ // "maker_fee": "0.0020",
837
+ // "left": "1.00000000",
838
+ // "deal_stock": "0",
839
+ // "deal_money": "0",
840
+ // "money_fee": "0",
841
+ // "stock_fee": "0",
842
+ // "asset_fee": "0",
843
+ // "fee_discount": "1",
844
+ // "last_deal_amount": "0",
845
+ // "last_deal_price": "0",
846
+ // "last_deal_time": 0,
847
+ // "last_deal_id": 0,
848
+ // "last_role": 0,
849
+ // "fee_asset": null,
850
+ // "stop_id": 0
851
+ // }
852
+ //
853
+ // swap
854
+ //
855
+ // {
856
+ // "order_id": 23423462821,
857
+ // "position_id": 0,
858
+ // "stop_id": 0,
859
+ // "market": "BTCUSDT",
860
+ // "type": 1,
861
+ // "side": 2,
862
+ // "target": 0,
863
+ // "effect_type": 1,
864
+ // "user_id": 1849116,
865
+ // "create_time": 1653961509.25049,
866
+ // "update_time": 1653961509.25049,
867
+ // "source": "web",
868
+ // "price": "1.00",
869
+ // "amount": "1.0000",
870
+ // "taker_fee": "0.00050",
871
+ // "maker_fee": "0.00030",
872
+ // "left": "1.0000",
873
+ // "deal_stock": "0.00000000000000000000",
874
+ // "deal_fee": "0.00000000000000000000",
875
+ // "deal_profit": "0.00000000000000000000",
876
+ // "last_deal_amount": "0.00000000000000000000",
877
+ // "last_deal_price": "0.00000000000000000000",
878
+ // "last_deal_time": 0,
879
+ // "last_deal_id": 0,
880
+ // "last_deal_type": 0,
881
+ // "last_deal_role": 0,
882
+ // "client_id": '',
883
+ // "fee_asset": '',
884
+ // "fee_discount": "0.00000000000000000000",
885
+ // "deal_asset_fee": "0.00000000000000000000",
886
+ // "leverage": "3",
887
+ // "position_type": 2
888
+ // }
889
+ //
890
+ // order.update_stop
891
+ //
892
+ // {
893
+ // "id": 78006745870,
894
+ // "type": 1,
895
+ // "side": 2,
896
+ // "user": 1849116,
897
+ // "account": 1,
898
+ // "option": 70,
899
+ // "direction": 1,
900
+ // "ctime": 1654171725.131976,
901
+ // "mtime": 1654171725.131976,
902
+ // "market": "BTCUSDT",
903
+ // "source": "web",
904
+ // "client_id": '',
905
+ // "stop_price": "1.00",
906
+ // "price": "1.00",
907
+ // "amount": "1.00000000",
908
+ // "taker_fee": "0.0020",
909
+ // "maker_fee": "0.0020",
910
+ // "fee_discount": "1",
911
+ // "fee_asset": null,
912
+ // "status": 0
913
+ // }
914
+ //
915
+ const timestamp = this.safeTimestamp2(order, 'update_time', 'mtime');
916
+ const marketId = this.safeString(order, 'market');
917
+ const typeCode = this.safeString(order, 'type');
918
+ const type = this.safeString({
919
+ '1': 'limit',
920
+ '2': 'market',
921
+ }, typeCode);
922
+ const sideCode = this.safeString(order, 'side');
923
+ const side = this.safeString({
924
+ '1': 'sell',
925
+ '2': 'buy',
926
+ }, sideCode);
927
+ const remaining = this.safeString(order, 'left');
928
+ const amount = this.safeString(order, 'amount');
929
+ const status = this.safeString(order, 'status');
930
+ const defaultType = this.safeString(this.options, 'defaultType');
931
+ market = this.safeMarket(marketId, market, undefined, defaultType);
932
+ let cost = this.safeString(order, 'deal_money');
933
+ let filled = this.safeString(order, 'deal_stock');
934
+ let average = undefined;
935
+ if (market['swap']) {
936
+ const leverage = this.safeString(order, 'leverage');
937
+ cost = Precise["default"].stringDiv(filled, leverage);
938
+ average = Precise["default"].stringDiv(filled, amount);
939
+ filled = undefined;
940
+ }
941
+ let fee = undefined;
942
+ const feeCost = this.omitZero(this.safeString(order, 'money_fee'));
943
+ if (feeCost !== undefined) {
944
+ const feeCurrencyId = this.safeString(order, 'fee_asset', market['quote']);
945
+ fee = {
946
+ 'currency': this.safeCurrencyCode(feeCurrencyId),
947
+ 'cost': feeCost,
948
+ };
949
+ }
950
+ return this.safeOrder({
951
+ 'info': order,
952
+ 'id': this.safeString2(order, 'order_id', 'id'),
953
+ 'clientOrderId': this.safeString(order, 'client_id'),
954
+ 'datetime': this.iso8601(timestamp),
955
+ 'timestamp': timestamp,
956
+ 'lastTradeTimestamp': this.safeTimestamp(order, 'last_deal_time'),
957
+ 'symbol': market['symbol'],
958
+ 'type': type,
959
+ 'timeInForce': undefined,
960
+ 'postOnly': undefined,
961
+ 'side': side,
962
+ 'price': this.safeString(order, 'price'),
963
+ 'stopPrice': this.safeString(order, 'stop_price'),
964
+ 'triggerPrice': this.safeString(order, 'stop_price'),
965
+ 'amount': amount,
966
+ 'filled': filled,
967
+ 'remaining': remaining,
968
+ 'cost': cost,
969
+ 'average': average,
970
+ 'status': this.parseWsOrderStatus(status),
971
+ 'fee': fee,
972
+ 'trades': undefined,
973
+ }, market);
974
+ }
975
+ parseWsOrderStatus(status) {
976
+ const statuses = {
977
+ '0': 'pending',
978
+ '1': 'ok',
979
+ };
980
+ return this.safeString(statuses, status, status);
981
+ }
982
+ handleMessage(client, message) {
983
+ const error = this.safeValue(message, 'error');
984
+ if (error !== undefined) {
985
+ throw new errors.ExchangeError(this.id + ' ' + this.json(error));
986
+ }
987
+ const method = this.safeString(message, 'method');
988
+ const handlers = {
989
+ 'state.update': this.handleTicker,
990
+ 'asset.update': this.handleBalance,
991
+ 'deals.update': this.handleTrades,
992
+ 'depth.update': this.handleOrderBook,
993
+ 'order.update': this.handleOrders,
994
+ 'kline.update': this.handleOHLCV,
995
+ 'order.update_stop': this.handleOrders,
996
+ };
997
+ const handler = this.safeValue(handlers, method);
998
+ if (handler !== undefined) {
999
+ return handler.call(this, client, message);
1000
+ }
1001
+ return this.handleSubscriptionStatus(client, message);
1002
+ }
1003
+ handleAuthenticationMessage(client, message) {
1004
+ //
1005
+ // {
1006
+ // "error": null,
1007
+ // "result": {
1008
+ // "status": "success"
1009
+ // },
1010
+ // "id": 1
1011
+ // }
1012
+ //
1013
+ const messageHashSpot = 'authenticated:spot';
1014
+ const messageHashSwap = 'authenticated:swap';
1015
+ client.resolve(message, messageHashSpot);
1016
+ client.resolve(message, messageHashSwap);
1017
+ return message;
1018
+ }
1019
+ handleSubscriptionStatus(client, message) {
1020
+ const id = this.safeInteger(message, 'id');
1021
+ const subscription = this.safeValue(client.subscriptions, id);
1022
+ if (subscription !== undefined) {
1023
+ const futureIndex = this.safeString(subscription, 'future');
1024
+ if (futureIndex === 'ohlcv') {
1025
+ return this.handleOHLCV(client, message);
1026
+ }
1027
+ const future = this.safeValue(client.futures, futureIndex);
1028
+ if (future !== undefined) {
1029
+ future.resolve(true);
1030
+ }
1031
+ delete client.subscriptions[id];
1032
+ }
1033
+ }
1034
+ authenticate(params = {}) {
1035
+ let type = undefined;
1036
+ [type, params] = this.handleMarketTypeAndParams('authenticate', undefined, params);
1037
+ const url = this.urls['api']['ws'][type];
1038
+ const client = this.client(url);
1039
+ const time = this.milliseconds();
1040
+ if (type === 'spot') {
1041
+ const messageHash = 'authenticated:spot';
1042
+ let future = this.safeValue(client.subscriptions, messageHash);
1043
+ if (future !== undefined) {
1044
+ return future;
1045
+ }
1046
+ const requestId = this.requestId();
1047
+ const subscribe = {
1048
+ 'id': requestId,
1049
+ 'future': 'authenticated:spot',
1050
+ };
1051
+ const signData = 'access_id=' + this.apiKey + '&tonce=' + this.numberToString(time) + '&secret_key=' + this.secret;
1052
+ const hash = this.hash(this.encode(signData), md5.md5);
1053
+ const request = {
1054
+ 'method': 'server.sign',
1055
+ 'params': [
1056
+ this.apiKey,
1057
+ hash.toUpperCase(),
1058
+ time,
1059
+ ],
1060
+ 'id': requestId,
1061
+ };
1062
+ future = this.watch(url, messageHash, request, requestId, subscribe);
1063
+ client.subscriptions[messageHash] = future;
1064
+ return future;
1065
+ }
1066
+ else {
1067
+ const messageHash = 'authenticated:swap';
1068
+ let future = this.safeValue(client.subscriptions, messageHash);
1069
+ if (future !== undefined) {
1070
+ return future;
1071
+ }
1072
+ const requestId = this.requestId();
1073
+ const subscribe = {
1074
+ 'id': requestId,
1075
+ 'future': 'authenticated:swap',
1076
+ };
1077
+ const signData = 'access_id=' + this.apiKey + '&timestamp=' + this.numberToString(time) + '&secret_key=' + this.secret;
1078
+ const hash = this.hash(this.encode(signData), sha256.sha256, 'hex');
1079
+ const request = {
1080
+ 'method': 'server.sign',
1081
+ 'params': [
1082
+ this.apiKey,
1083
+ hash.toLowerCase(),
1084
+ time,
1085
+ ],
1086
+ 'id': requestId,
1087
+ };
1088
+ future = this.watch(url, messageHash, request, requestId, subscribe);
1089
+ client.subscriptions[messageHash] = future;
1090
+ return future;
1091
+ }
1092
+ }
1093
+ }
1094
+
1095
+ module.exports = coinex;