ccxt 4.1.84 → 4.1.86

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 (301) hide show
  1. package/README.md +5 -4
  2. package/dist/ccxt.browser.js +1939 -806
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/ace.js +1 -1
  6. package/dist/cjs/src/alpaca.js +2 -2
  7. package/dist/cjs/src/ascendex.js +2 -2
  8. package/dist/cjs/src/base/Exchange.js +53 -20
  9. package/dist/cjs/src/bigone.js +1 -1
  10. package/dist/cjs/src/binance.js +2 -2
  11. package/dist/cjs/src/bingx.js +11 -9
  12. package/dist/cjs/src/bit2c.js +1 -1
  13. package/dist/cjs/src/bitbank.js +1 -1
  14. package/dist/cjs/src/bitbns.js +1 -1
  15. package/dist/cjs/src/bitfinex.js +1 -1
  16. package/dist/cjs/src/bitfinex2.js +1 -1
  17. package/dist/cjs/src/bitflyer.js +1 -1
  18. package/dist/cjs/src/bitforex.js +1 -1
  19. package/dist/cjs/src/bitget.js +2 -3
  20. package/dist/cjs/src/bithumb.js +3 -3
  21. package/dist/cjs/src/bitmart.js +91 -74
  22. package/dist/cjs/src/bitmex.js +2 -2
  23. package/dist/cjs/src/bitopro.js +3 -3
  24. package/dist/cjs/src/bitpanda.js +1 -1
  25. package/dist/cjs/src/bitrue.js +1 -1
  26. package/dist/cjs/src/bitso.js +1 -1
  27. package/dist/cjs/src/bitstamp.js +1 -1
  28. package/dist/cjs/src/bittrex.js +1 -1
  29. package/dist/cjs/src/bitvavo.js +1 -1
  30. package/dist/cjs/src/bl3p.js +1 -1
  31. package/dist/cjs/src/blockchaincom.js +1 -1
  32. package/dist/cjs/src/btcalpha.js +1 -1
  33. package/dist/cjs/src/btcbox.js +1 -1
  34. package/dist/cjs/src/btcmarkets.js +1 -1
  35. package/dist/cjs/src/btcturk.js +1 -1
  36. package/dist/cjs/src/bybit.js +3 -5
  37. package/dist/cjs/src/cex.js +1 -1
  38. package/dist/cjs/src/coinbase.js +1 -1
  39. package/dist/cjs/src/coinbasepro.js +1 -1
  40. package/dist/cjs/src/coincheck.js +1 -1
  41. package/dist/cjs/src/coinex.js +3 -2
  42. package/dist/cjs/src/coinlist.js +1 -1
  43. package/dist/cjs/src/coinmate.js +1 -1
  44. package/dist/cjs/src/coinone.js +1 -1
  45. package/dist/cjs/src/coinsph.js +1 -1
  46. package/dist/cjs/src/coinspot.js +1 -1
  47. package/dist/cjs/src/cryptocom.js +3 -3
  48. package/dist/cjs/src/currencycom.js +1 -1
  49. package/dist/cjs/src/delta.js +1 -1
  50. package/dist/cjs/src/deribit.js +1 -1
  51. package/dist/cjs/src/digifinex.js +160 -112
  52. package/dist/cjs/src/exmo.js +1 -1
  53. package/dist/cjs/src/gate.js +1 -1
  54. package/dist/cjs/src/gemini.js +1 -1
  55. package/dist/cjs/src/hitbtc.js +2 -2
  56. package/dist/cjs/src/hitbtc3.js +1 -1
  57. package/dist/cjs/src/hollaex.js +1 -1
  58. package/dist/cjs/src/htx.js +2 -2
  59. package/dist/cjs/src/huobijp.js +1 -1
  60. package/dist/cjs/src/idex.js +1 -1
  61. package/dist/cjs/src/independentreserve.js +1 -1
  62. package/dist/cjs/src/indodax.js +1 -1
  63. package/dist/cjs/src/kraken.js +2 -2
  64. package/dist/cjs/src/krakenfutures.js +3 -3
  65. package/dist/cjs/src/kucoin.js +2 -6
  66. package/dist/cjs/src/kucoinfutures.js +0 -3
  67. package/dist/cjs/src/kuna.js +1 -1
  68. package/dist/cjs/src/latoken.js +2 -2
  69. package/dist/cjs/src/lbank.js +1 -1
  70. package/dist/cjs/src/luno.js +1 -1
  71. package/dist/cjs/src/lykke.js +1 -1
  72. package/dist/cjs/src/mercado.js +1 -1
  73. package/dist/cjs/src/mexc.js +102 -53
  74. package/dist/cjs/src/ndax.js +1 -1
  75. package/dist/cjs/src/novadax.js +1 -1
  76. package/dist/cjs/src/oceanex.js +1 -1
  77. package/dist/cjs/src/okcoin.js +1 -1
  78. package/dist/cjs/src/okx.js +4 -4
  79. package/dist/cjs/src/p2b.js +1 -3
  80. package/dist/cjs/src/paymium.js +1 -1
  81. package/dist/cjs/src/phemex.js +1 -1
  82. package/dist/cjs/src/poloniex.js +51 -51
  83. package/dist/cjs/src/poloniexfutures.js +1 -1
  84. package/dist/cjs/src/pro/bitget.js +1 -1
  85. package/dist/cjs/src/pro/bitmart.js +1026 -250
  86. package/dist/cjs/src/pro/bitmex.js +206 -0
  87. package/dist/cjs/src/pro/krakenfutures.js +6 -6
  88. package/dist/cjs/src/pro/mexc.js +1 -1
  89. package/dist/cjs/src/pro/poloniex.js +1 -1
  90. package/dist/cjs/src/pro/poloniexfutures.js +3 -3
  91. package/dist/cjs/src/probit.js +27 -19
  92. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncrypt.js +1 -1
  93. package/dist/cjs/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +3 -3
  94. package/dist/cjs/src/timex.js +1 -1
  95. package/dist/cjs/src/tokocrypto.js +8 -4
  96. package/dist/cjs/src/upbit.js +1 -1
  97. package/dist/cjs/src/wavesexchange.js +1 -1
  98. package/dist/cjs/src/wazirx.js +1 -1
  99. package/dist/cjs/src/whitebit.js +1 -1
  100. package/dist/cjs/src/woo.js +1 -1
  101. package/dist/cjs/src/yobit.js +1 -1
  102. package/dist/cjs/src/zaif.js +1 -1
  103. package/dist/cjs/src/zonda.js +1 -1
  104. package/js/ccxt.d.ts +1 -1
  105. package/js/ccxt.js +1 -1
  106. package/js/src/ace.d.ts +1 -1
  107. package/js/src/ace.js +1 -1
  108. package/js/src/alpaca.d.ts +1 -1
  109. package/js/src/alpaca.js +2 -2
  110. package/js/src/ascendex.d.ts +1 -1
  111. package/js/src/ascendex.js +2 -2
  112. package/js/src/base/Exchange.d.ts +5 -0
  113. package/js/src/base/Exchange.js +53 -20
  114. package/js/src/base/types.d.ts +1 -0
  115. package/js/src/bigone.d.ts +1 -1
  116. package/js/src/bigone.js +1 -1
  117. package/js/src/binance.d.ts +1 -1
  118. package/js/src/binance.js +2 -2
  119. package/js/src/bingx.js +11 -9
  120. package/js/src/bit2c.d.ts +1 -1
  121. package/js/src/bit2c.js +1 -1
  122. package/js/src/bitbank.d.ts +1 -1
  123. package/js/src/bitbank.js +1 -1
  124. package/js/src/bitbns.d.ts +1 -1
  125. package/js/src/bitbns.js +1 -1
  126. package/js/src/bitfinex.d.ts +1 -1
  127. package/js/src/bitfinex.js +1 -1
  128. package/js/src/bitfinex2.d.ts +1 -1
  129. package/js/src/bitfinex2.js +1 -1
  130. package/js/src/bitflyer.d.ts +1 -1
  131. package/js/src/bitflyer.js +1 -1
  132. package/js/src/bitforex.d.ts +1 -1
  133. package/js/src/bitforex.js +1 -1
  134. package/js/src/bitget.d.ts +1 -1
  135. package/js/src/bitget.js +2 -3
  136. package/js/src/bithumb.d.ts +1 -1
  137. package/js/src/bithumb.js +3 -3
  138. package/js/src/bitmart.d.ts +1 -1
  139. package/js/src/bitmart.js +91 -74
  140. package/js/src/bitmex.d.ts +1 -1
  141. package/js/src/bitmex.js +2 -2
  142. package/js/src/bitopro.d.ts +1 -1
  143. package/js/src/bitopro.js +3 -3
  144. package/js/src/bitpanda.d.ts +1 -1
  145. package/js/src/bitpanda.js +1 -1
  146. package/js/src/bitrue.d.ts +1 -1
  147. package/js/src/bitrue.js +1 -1
  148. package/js/src/bitso.d.ts +1 -1
  149. package/js/src/bitso.js +1 -1
  150. package/js/src/bitstamp.d.ts +1 -1
  151. package/js/src/bitstamp.js +1 -1
  152. package/js/src/bittrex.d.ts +1 -1
  153. package/js/src/bittrex.js +1 -1
  154. package/js/src/bitvavo.d.ts +1 -1
  155. package/js/src/bitvavo.js +1 -1
  156. package/js/src/bl3p.d.ts +1 -1
  157. package/js/src/bl3p.js +1 -1
  158. package/js/src/blockchaincom.d.ts +1 -1
  159. package/js/src/blockchaincom.js +1 -1
  160. package/js/src/btcalpha.d.ts +1 -1
  161. package/js/src/btcalpha.js +1 -1
  162. package/js/src/btcbox.d.ts +1 -1
  163. package/js/src/btcbox.js +1 -1
  164. package/js/src/btcmarkets.d.ts +1 -1
  165. package/js/src/btcmarkets.js +1 -1
  166. package/js/src/btcturk.d.ts +1 -1
  167. package/js/src/btcturk.js +1 -1
  168. package/js/src/bybit.d.ts +1 -1
  169. package/js/src/bybit.js +3 -5
  170. package/js/src/cex.d.ts +1 -1
  171. package/js/src/cex.js +1 -1
  172. package/js/src/coinbase.d.ts +1 -1
  173. package/js/src/coinbase.js +1 -1
  174. package/js/src/coinbasepro.d.ts +1 -1
  175. package/js/src/coinbasepro.js +1 -1
  176. package/js/src/coincheck.d.ts +1 -1
  177. package/js/src/coincheck.js +1 -1
  178. package/js/src/coinex.d.ts +1 -1
  179. package/js/src/coinex.js +3 -2
  180. package/js/src/coinlist.d.ts +1 -1
  181. package/js/src/coinlist.js +1 -1
  182. package/js/src/coinmate.d.ts +1 -1
  183. package/js/src/coinmate.js +1 -1
  184. package/js/src/coinone.d.ts +1 -1
  185. package/js/src/coinone.js +1 -1
  186. package/js/src/coinsph.d.ts +1 -1
  187. package/js/src/coinsph.js +1 -1
  188. package/js/src/coinspot.d.ts +1 -1
  189. package/js/src/coinspot.js +1 -1
  190. package/js/src/cryptocom.d.ts +1 -1
  191. package/js/src/cryptocom.js +3 -3
  192. package/js/src/currencycom.d.ts +1 -1
  193. package/js/src/currencycom.js +1 -1
  194. package/js/src/delta.d.ts +1 -1
  195. package/js/src/delta.js +1 -1
  196. package/js/src/deribit.d.ts +1 -1
  197. package/js/src/deribit.js +1 -1
  198. package/js/src/digifinex.d.ts +1 -1
  199. package/js/src/digifinex.js +160 -112
  200. package/js/src/exmo.d.ts +1 -1
  201. package/js/src/exmo.js +1 -1
  202. package/js/src/gate.d.ts +1 -1
  203. package/js/src/gate.js +1 -1
  204. package/js/src/gemini.d.ts +1 -1
  205. package/js/src/gemini.js +1 -1
  206. package/js/src/hitbtc.d.ts +1 -1
  207. package/js/src/hitbtc.js +2 -2
  208. package/js/src/hitbtc3.d.ts +1 -1
  209. package/js/src/hitbtc3.js +1 -1
  210. package/js/src/hollaex.d.ts +1 -1
  211. package/js/src/hollaex.js +1 -1
  212. package/js/src/htx.d.ts +1 -1
  213. package/js/src/htx.js +2 -2
  214. package/js/src/huobijp.d.ts +1 -1
  215. package/js/src/huobijp.js +1 -1
  216. package/js/src/idex.d.ts +1 -1
  217. package/js/src/idex.js +1 -1
  218. package/js/src/independentreserve.d.ts +1 -1
  219. package/js/src/independentreserve.js +1 -1
  220. package/js/src/indodax.d.ts +1 -1
  221. package/js/src/indodax.js +1 -1
  222. package/js/src/kraken.d.ts +1 -1
  223. package/js/src/kraken.js +2 -2
  224. package/js/src/krakenfutures.d.ts +1 -1
  225. package/js/src/krakenfutures.js +3 -3
  226. package/js/src/kucoin.d.ts +1 -1
  227. package/js/src/kucoin.js +2 -6
  228. package/js/src/kucoinfutures.d.ts +0 -1
  229. package/js/src/kucoinfutures.js +0 -3
  230. package/js/src/kuna.d.ts +1 -1
  231. package/js/src/kuna.js +1 -1
  232. package/js/src/latoken.d.ts +1 -1
  233. package/js/src/latoken.js +2 -2
  234. package/js/src/lbank.d.ts +1 -1
  235. package/js/src/lbank.js +1 -1
  236. package/js/src/luno.d.ts +1 -1
  237. package/js/src/luno.js +1 -1
  238. package/js/src/lykke.d.ts +1 -1
  239. package/js/src/lykke.js +1 -1
  240. package/js/src/mercado.d.ts +1 -1
  241. package/js/src/mercado.js +1 -1
  242. package/js/src/mexc.d.ts +1 -1
  243. package/js/src/mexc.js +102 -53
  244. package/js/src/ndax.d.ts +1 -1
  245. package/js/src/ndax.js +1 -1
  246. package/js/src/novadax.d.ts +1 -1
  247. package/js/src/novadax.js +1 -1
  248. package/js/src/oceanex.d.ts +1 -1
  249. package/js/src/oceanex.js +1 -1
  250. package/js/src/okcoin.d.ts +1 -1
  251. package/js/src/okcoin.js +1 -1
  252. package/js/src/okx.d.ts +1 -1
  253. package/js/src/okx.js +4 -4
  254. package/js/src/p2b.d.ts +1 -1
  255. package/js/src/p2b.js +1 -3
  256. package/js/src/paymium.d.ts +1 -1
  257. package/js/src/paymium.js +1 -1
  258. package/js/src/phemex.d.ts +1 -1
  259. package/js/src/phemex.js +1 -1
  260. package/js/src/poloniex.d.ts +1 -1
  261. package/js/src/poloniex.js +51 -51
  262. package/js/src/poloniexfutures.d.ts +1 -1
  263. package/js/src/poloniexfutures.js +1 -1
  264. package/js/src/pro/bitget.d.ts +1 -1
  265. package/js/src/pro/bitget.js +1 -1
  266. package/js/src/pro/bitmart.d.ts +17 -6
  267. package/js/src/pro/bitmart.js +1028 -252
  268. package/js/src/pro/bitmex.d.ts +3 -1
  269. package/js/src/pro/bitmex.js +207 -1
  270. package/js/src/pro/krakenfutures.js +6 -6
  271. package/js/src/pro/mexc.js +1 -1
  272. package/js/src/pro/poloniex.js +1 -1
  273. package/js/src/pro/poloniexfutures.js +3 -3
  274. package/js/src/probit.d.ts +1 -1
  275. package/js/src/probit.js +27 -19
  276. package/js/src/static_dependencies/jsencrypt/JSEncrypt.d.ts +1 -1
  277. package/js/src/static_dependencies/jsencrypt/JSEncrypt.js +1 -1
  278. package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.d.ts +3 -3
  279. package/js/src/static_dependencies/jsencrypt/JSEncryptRSAKey.js +3 -3
  280. package/js/src/timex.d.ts +1 -1
  281. package/js/src/timex.js +1 -1
  282. package/js/src/tokocrypto.d.ts +1 -1
  283. package/js/src/tokocrypto.js +8 -4
  284. package/js/src/upbit.d.ts +1 -1
  285. package/js/src/upbit.js +1 -1
  286. package/js/src/wavesexchange.d.ts +1 -1
  287. package/js/src/wavesexchange.js +1 -1
  288. package/js/src/wazirx.d.ts +1 -1
  289. package/js/src/wazirx.js +1 -1
  290. package/js/src/whitebit.d.ts +1 -1
  291. package/js/src/whitebit.js +1 -1
  292. package/js/src/woo.d.ts +1 -1
  293. package/js/src/woo.js +1 -1
  294. package/js/src/yobit.d.ts +1 -1
  295. package/js/src/yobit.js +1 -1
  296. package/js/src/zaif.d.ts +1 -1
  297. package/js/src/zaif.js +1 -1
  298. package/js/src/zonda.d.ts +1 -1
  299. package/js/src/zonda.js +1 -1
  300. package/package.json +4 -3
  301. package/skip-tests.json +4 -0
@@ -1430,7 +1430,7 @@ class Exchange extends _base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchang
1430
1430
  // ---------------------------------------------------------------------------
1431
1431
  /**
1432
1432
  * @class ace
1433
- * @extends Exchange
1433
+ * @augments Exchange
1434
1434
  */
1435
1435
  class ace extends _abstract_ace_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
1436
1436
  describe() {
@@ -2494,7 +2494,7 @@ class ace extends _abstract_ace_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
2494
2494
  // ---------------------------------------------------------------------------xs
2495
2495
  /**
2496
2496
  * @class alpaca
2497
- * @extends Exchange
2497
+ * @augments Exchange
2498
2498
  */
2499
2499
  class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
2500
2500
  describe() {
@@ -2982,7 +2982,7 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
2982
2982
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2983
2983
  * @param {string} [params.loc] crypto location, default: us
2984
2984
  * @returns {object} A dictionary of [order book structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure} indexed by market symbols
2985
- */
2985
+ */
2986
2986
  await this.loadMarkets();
2987
2987
  const market = this.market(symbol);
2988
2988
  const id = market['id'];
@@ -3625,7 +3625,7 @@ class alpaca extends _abstract_alpaca_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
3625
3625
  // ---------------------------------------------------------------------------
3626
3626
  /**
3627
3627
  * @class ascendex
3628
- * @extends Exchange
3628
+ * @augments Exchange
3629
3629
  */
3630
3630
  class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
3631
3631
  describe() {
@@ -5276,7 +5276,7 @@ class ascendex extends _abstract_ascendex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
5276
5276
  * @description create a list of trade orders
5277
5277
  * @see https://ascendex.github.io/ascendex-pro-api/#place-batch-orders
5278
5278
  * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#place-batch-orders
5279
- * @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
5279
+ * @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
5280
5280
  * @param {object} [params] extra parameters specific to the exchange API endpoint
5281
5281
  * @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
5282
5282
  * @param {bool} [params.postOnly] true or false
@@ -7686,6 +7686,26 @@ class Exchange {
7686
7686
  }
7687
7687
  return chosenAgent;
7688
7688
  }
7689
+ async loadHttpProxyAgent() {
7690
+ // for `http://` protocol proxy-urls, we need to load `http` module only on first call
7691
+ if (!this.httpAgent) {
7692
+ const httpModule = await import(/* webpackIgnore: true */ 'node:http');
7693
+ this.httpAgent = new httpModule.Agent();
7694
+ }
7695
+ return this.httpAgent;
7696
+ }
7697
+ getHttpAgentIfNeeded(url) {
7698
+ if (isNode) {
7699
+ // only for non-ssl proxy
7700
+ if (url.substring(0, 5) === 'ws://') {
7701
+ if (this.httpAgent === undefined) {
7702
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' to use proxy with non-ssl ws:// urls, at first run `await exchange.loadHttpProxyAgent()` method');
7703
+ }
7704
+ return this.httpAgent;
7705
+ }
7706
+ }
7707
+ return undefined;
7708
+ }
7689
7709
  async fetch(url, method = 'GET', headers = undefined, body = undefined) {
7690
7710
  // load node-http(s) modules only on first call
7691
7711
  if (isNode) {
@@ -7699,18 +7719,16 @@ class Exchange {
7699
7719
  headers = this.extend(this.headers, headers);
7700
7720
  // proxy-url
7701
7721
  const proxyUrl = this.checkProxyUrlSettings(url, method, headers, body);
7702
- let isHttpAgentNeeded = false;
7722
+ let httpProxyAgent = false;
7703
7723
  if (proxyUrl !== undefined) {
7704
- // in node we need to set header to *
7724
+ // part only for node-js
7705
7725
  if (isNode) {
7726
+ // in node we need to set header to *
7706
7727
  headers = this.extend({ 'Origin': this.origin }, headers);
7707
- if (proxyUrl.substring(0, 5) !== 'https') {
7708
- // for `http://` protocol proxy-urls, we need to load `http` module only on first call
7709
- if (!this.httpAgent) {
7710
- const httpModule = await import(/* webpackIgnore: true */ 'node:http');
7711
- this.httpAgent = new httpModule.Agent();
7712
- }
7713
- isHttpAgentNeeded = true;
7728
+ // only for http proxy
7729
+ if (proxyUrl.substring(0, 5) === 'http:') {
7730
+ await this.loadHttpProxyAgent();
7731
+ httpProxyAgent = this.httpAgent;
7714
7732
  }
7715
7733
  }
7716
7734
  url = proxyUrl + url;
@@ -7763,9 +7781,9 @@ class Exchange {
7763
7781
  params['agent'] = this.agent;
7764
7782
  }
7765
7783
  // override agent, if needed
7766
- if (isHttpAgentNeeded) {
7767
- // if proxyUrl is being used, so we don't overwrite `this.agent` itself
7768
- params['agent'] = this.httpAgent;
7784
+ if (httpProxyAgent) {
7785
+ // if proxyUrl is being used, then specifically in nodejs, we need http module, not https
7786
+ params['agent'] = httpProxyAgent;
7769
7787
  }
7770
7788
  else if (chosenAgent) {
7771
7789
  // if http(s)Proxy is being used
@@ -7974,7 +7992,9 @@ class Exchange {
7974
7992
  // proxy agents
7975
7993
  const [httpProxy, httpsProxy, socksProxy] = this.checkWsProxySettings();
7976
7994
  const chosenAgent = this.setProxyAgents(httpProxy, httpsProxy, socksProxy);
7977
- const finalAgent = chosenAgent ? chosenAgent : this.agent;
7995
+ // part only for node-js
7996
+ const httpProxyAgent = this.getHttpAgentIfNeeded(url);
7997
+ const finalAgent = chosenAgent ? chosenAgent : (httpProxyAgent ? httpProxyAgent : this.agent);
7978
7998
  //
7979
7999
  const options = this.deepExtend(this.streaming, {
7980
8000
  'log': this.log ? this.log.bind(this) : this.log,
@@ -8324,7 +8344,8 @@ class Exchange {
8324
8344
  const usedProxies = [];
8325
8345
  let wsProxy = undefined;
8326
8346
  let wssProxy = undefined;
8327
- // wsProxy
8347
+ let wsSocksProxy = undefined;
8348
+ // ws proxy
8328
8349
  if (this.wsProxy !== undefined) {
8329
8350
  usedProxies.push('wsProxy');
8330
8351
  wsProxy = this.wsProxy;
@@ -8333,7 +8354,7 @@ class Exchange {
8333
8354
  usedProxies.push('ws_proxy');
8334
8355
  wsProxy = this.ws_proxy;
8335
8356
  }
8336
- // wsProxy
8357
+ // wss proxy
8337
8358
  if (this.wssProxy !== undefined) {
8338
8359
  usedProxies.push('wssProxy');
8339
8360
  wssProxy = this.wssProxy;
@@ -8342,13 +8363,22 @@ class Exchange {
8342
8363
  usedProxies.push('wss_proxy');
8343
8364
  wssProxy = this.wss_proxy;
8344
8365
  }
8366
+ // ws socks proxy
8367
+ if (this.wsSocksProxy !== undefined) {
8368
+ usedProxies.push('wsSocksProxy');
8369
+ wsSocksProxy = this.wsSocksProxy;
8370
+ }
8371
+ if (this.ws_socks_proxy !== undefined) {
8372
+ usedProxies.push('ws_socks_proxy');
8373
+ wsSocksProxy = this.ws_socks_proxy;
8374
+ }
8345
8375
  // check
8346
8376
  const length = usedProxies.length;
8347
8377
  if (length > 1) {
8348
8378
  const joinedProxyNames = usedProxies.join(',');
8349
- throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeError(this.id + ' you have multiple conflicting settings (' + joinedProxyNames + '), please use only one from: wsProxy, wssProxy');
8379
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeError(this.id + ' you have multiple conflicting settings (' + joinedProxyNames + '), please use only one from: wsProxy, wssProxy, socksProxy');
8350
8380
  }
8351
- return [wsProxy, wssProxy];
8381
+ return [wsProxy, wssProxy, wsSocksProxy];
8352
8382
  }
8353
8383
  checkConflictingProxies(proxyAgentSet, proxyUrlSet) {
8354
8384
  if (proxyAgentSet && proxyUrlSet) {
@@ -10689,6 +10719,9 @@ class Exchange {
10689
10719
  async closeAllPositions(params = {}) {
10690
10720
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' closeAllPositions() is not supported yet');
10691
10721
  }
10722
+ async fetchL3OrderBook(symbol, limit = undefined, params = {}) {
10723
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' fetchL3OrderBook() is not supported yet');
10724
+ }
10692
10725
  parseLastPrice(price, market = undefined) {
10693
10726
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' parseLastPrice() is not supported yet');
10694
10727
  }
@@ -11255,8 +11288,8 @@ class Exchange {
11255
11288
  /**
11256
11289
  * @ignore
11257
11290
  * @method
11258
- * * Must add timeInForce to this.options to use this method
11259
- * @return {string} returns the exchange specific value for timeInForce
11291
+ * Must add timeInForce to this.options to use this method
11292
+ * @returns {string} returns the exchange specific value for timeInForce
11260
11293
  */
11261
11294
  const timeInForce = this.safeStringUpper(params, 'timeInForce'); // supported values GTC, IOC, PO
11262
11295
  if (timeInForce !== undefined) {
@@ -11272,7 +11305,7 @@ class Exchange {
11272
11305
  /**
11273
11306
  * @ignore
11274
11307
  * @method
11275
- * * Must add accountsByType to this.options to use this method
11308
+ * Must add accountsByType to this.options to use this method
11276
11309
  * @param {string} account key for account name in this.options['accountsByType']
11277
11310
  * @returns the exchange specific account name or the isolated margin id for transfers
11278
11311
  */
@@ -15041,7 +15074,7 @@ class bequant extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .
15041
15074
  // ---------------------------------------------------------------------------
15042
15075
  /**
15043
15076
  * @class bigone
15044
- * @extends Exchange
15077
+ * @augments Exchange
15045
15078
  */
15046
15079
  class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
15047
15080
  describe() {
@@ -16996,7 +17029,7 @@ class bigone extends _abstract_bigone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
16996
17029
  // ---------------------------------------------------------------------------
16997
17030
  /**
16998
17031
  * @class binance
16999
- * @extends Exchange
17032
+ * @augments Exchange
17000
17033
  */
17001
17034
  class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
17002
17035
  describe() {
@@ -21376,7 +21409,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21376
21409
  * @name binance#createOrders
21377
21410
  * @description *contract only* create a list of trade orders
21378
21411
  * @see https://binance-docs.github.io/apidocs/futures/en/#place-multiple-orders-trade
21379
- * @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
21412
+ * @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
21380
21413
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
21381
21414
  */
21382
21415
  await this.loadMarkets();
@@ -28725,7 +28758,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28725
28758
  * @description create a list of trade orders
28726
28759
  * @see https://bingx-api.github.io/docs/#/spot/trade-api.html#Batch%20Placing%20Orders
28727
28760
  * @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Bulk%20order
28728
- * @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
28761
+ * @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
28729
28762
  * @param {object} [params] extra parameters specific to the exchange API endpoint
28730
28763
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
28731
28764
  */
@@ -28922,6 +28955,9 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28922
28955
  const positionSide = this.safeString2(order, 'positionSide', 'ps');
28923
28956
  const marketType = (positionSide === undefined) ? 'spot' : 'swap';
28924
28957
  const marketId = this.safeString2(order, 'symbol', 's');
28958
+ if (market === undefined) {
28959
+ market = this.safeMarket(marketId, undefined, undefined, marketType);
28960
+ }
28925
28961
  const symbol = this.safeSymbol(marketId, market, '-', marketType);
28926
28962
  const orderId = this.safeString2(order, 'orderId', 'i');
28927
28963
  const side = this.safeStringLower2(order, 'side', 'S');
@@ -29287,16 +29323,15 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
29287
29323
  * @param {object} [params] extra parameters specific to the exchange API endpoint
29288
29324
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
29289
29325
  */
29290
- if (symbol === undefined) {
29291
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
29292
- }
29293
29326
  await this.loadMarkets();
29294
- const market = this.market(symbol);
29295
- const request = {
29296
- 'symbol': market['id'],
29297
- };
29327
+ let market = undefined;
29328
+ const request = {};
29329
+ if (symbol !== undefined) {
29330
+ market = this.market(symbol);
29331
+ request['symbol'] = market['id'];
29332
+ }
29298
29333
  let response = undefined;
29299
- const [marketType, query] = this.handleMarketTypeAndParams('fetchOrder', market, params);
29334
+ const [marketType, query] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
29300
29335
  if (marketType === 'spot') {
29301
29336
  response = await this.spotV1PrivateGetTradeOpenOrders(this.extend(request, query));
29302
29337
  }
@@ -30409,7 +30444,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
30409
30444
  // ---------------------------------------------------------------------------
30410
30445
  /**
30411
30446
  * @class bit2c
30412
- * @extends Exchange
30447
+ * @augments Exchange
30413
30448
  */
30414
30449
  class bit2c extends _abstract_bit2c_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
30415
30450
  describe() {
@@ -31328,7 +31363,7 @@ class bit2c extends _abstract_bit2c_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
31328
31363
  // ---------------------------------------------------------------------------
31329
31364
  /**
31330
31365
  * @class bitbank
31331
- * @extends Exchange
31366
+ * @augments Exchange
31332
31367
  */
31333
31368
  class bitbank extends _abstract_bitbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
31334
31369
  describe() {
@@ -32362,7 +32397,7 @@ class bitbay extends _zonda_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
32362
32397
  // ---------------------------------------------------------------------------
32363
32398
  /**
32364
32399
  * @class bitbns
32365
- * @extends Exchange
32400
+ * @augments Exchange
32366
32401
  */
32367
32402
  class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
32368
32403
  describe() {
@@ -33615,7 +33650,7 @@ class bitcoincom extends _fmfwio_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
33615
33650
  // ---------------------------------------------------------------------------
33616
33651
  /**
33617
33652
  * @class bitfinex
33618
- * @extends Exchange
33653
+ * @augments Exchange
33619
33654
  */
33620
33655
  class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
33621
33656
  describe() {
@@ -35296,7 +35331,7 @@ class bitfinex extends _abstract_bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
35296
35331
  // ---------------------------------------------------------------------------
35297
35332
  /**
35298
35333
  * @class bitfinex2
35299
- * @extends Exchange
35334
+ * @augments Exchange
35300
35335
  */
35301
35336
  class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
35302
35337
  describe() {
@@ -38297,7 +38332,7 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
38297
38332
  // ---------------------------------------------------------------------------
38298
38333
  /**
38299
38334
  * @class bitflyer
38300
- * @extends Exchange
38335
+ * @augments Exchange
38301
38336
  */
38302
38337
  class bitflyer extends _abstract_bitflyer_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
38303
38338
  describe() {
@@ -39350,7 +39385,7 @@ class bitflyer extends _abstract_bitflyer_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
39350
39385
  // ---------------------------------------------------------------------------
39351
39386
  /**
39352
39387
  * @class bitforex
39353
- * @extends Exchange
39388
+ * @augments Exchange
39354
39389
  */
39355
39390
  class bitforex extends _abstract_bitforex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
39356
39391
  describe() {
@@ -40213,7 +40248,7 @@ class bitforex extends _abstract_bitforex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
40213
40248
  // ---------------------------------------------------------------------------
40214
40249
  /**
40215
40250
  * @class bitget
40216
- * @extends Exchange
40251
+ * @augments Exchange
40217
40252
  */
40218
40253
  class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
40219
40254
  describe() {
@@ -43930,7 +43965,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
43930
43965
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#batch-order
43931
43966
  * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-batch-order
43932
43967
  * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-batch-order
43933
- * @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
43968
+ * @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
43934
43969
  * @param {object} [params] extra parameters specific to the api endpoint
43935
43970
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
43936
43971
  */
@@ -46184,7 +46219,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
46184
46219
  * @param {string} symbol not used by bitget setPositionMode ()
46185
46220
  * @param {object} [params] extra parameters specific to the exchange API endpoint
46186
46221
  * @returns {object} response from the exchange
46187
- *
46188
46222
  */
46189
46223
  await this.loadMarkets();
46190
46224
  const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
@@ -47390,7 +47424,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
47390
47424
  // ---------------------------------------------------------------------------
47391
47425
  /**
47392
47426
  * @class bithumb
47393
- * @extends Exchange
47427
+ * @augments Exchange
47394
47428
  */
47395
47429
  class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
47396
47430
  describe() {
@@ -48325,11 +48359,11 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
48325
48359
  };
48326
48360
  return await this.privatePostTradeCancel(this.extend(request, params));
48327
48361
  }
48328
- cancelUnifiedOrder(order, params = {}) {
48362
+ async cancelUnifiedOrder(order, params = {}) {
48329
48363
  const request = {
48330
48364
  'side': order['side'],
48331
48365
  };
48332
- return this.cancelOrder(order['id'], order['symbol'], this.extend(request, params));
48366
+ return await this.cancelOrder(order['id'], order['symbol'], this.extend(request, params));
48333
48367
  }
48334
48368
  async withdraw(code, amount, address, tag = undefined, params = {}) {
48335
48369
  /**
@@ -48490,7 +48524,7 @@ class bithumb extends _abstract_bithumb_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
48490
48524
  // ---------------------------------------------------------------------------
48491
48525
  /**
48492
48526
  * @class bitmart
48493
- * @extends Exchange
48527
+ * @augments Exchange
48494
48528
  */
48495
48529
  class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
48496
48530
  describe() {
@@ -49814,48 +49848,58 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
49814
49848
  //
49815
49849
  // public fetchTrades spot ( amount = count * price )
49816
49850
  //
49817
- // {
49818
- // "amount": "818.94",
49819
- // "order_time": "1637601839035", // ETH/USDT
49820
- // "price": "4221.99",
49821
- // "count": "0.19397",
49822
- // "type": "buy"
49823
- // }
49851
+ // {
49852
+ // "amount": "818.94",
49853
+ // "order_time": "1637601839035", // ETH/USDT
49854
+ // "price": "4221.99",
49855
+ // "count": "0.19397",
49856
+ // "type": "buy"
49857
+ // }
49824
49858
  //
49825
49859
  // spot: fetchMyTrades
49826
49860
  //
49827
- // {
49828
- // "tradeId":"182342999769370687",
49829
- // "orderId":"183270218784142990",
49830
- // "clientOrderId":"183270218784142990",
49831
- // "symbol":"ADA_USDT",
49832
- // "side":"buy",
49833
- // "orderMode":"spot",
49834
- // "type":"market",
49835
- // "price":"0.245948",
49836
- // "size":"20.71",
49837
- // "notional":"5.09358308",
49838
- // "fee":"0.00509358",
49839
- // "feeCoinName":"USDT",
49840
- // "tradeRole":"taker",
49841
- // "createTime":1695658457836,
49842
- // }
49861
+ // {
49862
+ // "tradeId":"182342999769370687",
49863
+ // "orderId":"183270218784142990",
49864
+ // "clientOrderId":"183270218784142990",
49865
+ // "symbol":"ADA_USDT",
49866
+ // "side":"buy",
49867
+ // "orderMode":"spot",
49868
+ // "type":"market",
49869
+ // "price":"0.245948",
49870
+ // "size":"20.71",
49871
+ // "notional":"5.09358308",
49872
+ // "fee":"0.00509358",
49873
+ // "feeCoinName":"USDT",
49874
+ // "tradeRole":"taker",
49875
+ // "createTime":1695658457836,
49876
+ // }
49843
49877
  //
49844
49878
  // swap: fetchMyTrades
49845
49879
  //
49846
- // {
49847
- // "order_id": "230930336848609",
49848
- // "trade_id": "6212604014",
49849
- // "symbol": "BTCUSDT",
49850
- // "side": 3,
49851
- // "price": "26910.4",
49852
- // "vol": "1",
49853
- // "exec_type": "Taker",
49854
- // "profit": false,
49855
- // "create_time": 1695961596692,
49856
- // "realised_profit": "-0.0003",
49857
- // "paid_fees": "0.01614624"
49858
- // }
49880
+ // {
49881
+ // "order_id": "230930336848609",
49882
+ // "trade_id": "6212604014",
49883
+ // "symbol": "BTCUSDT",
49884
+ // "side": 3,
49885
+ // "price": "26910.4",
49886
+ // "vol": "1",
49887
+ // "exec_type": "Taker",
49888
+ // "profit": false,
49889
+ // "create_time": 1695961596692,
49890
+ // "realised_profit": "-0.0003",
49891
+ // "paid_fees": "0.01614624"
49892
+ // }
49893
+ //
49894
+ // ws swap
49895
+ //
49896
+ // {
49897
+ // 'fee': '-0.000044502',
49898
+ // 'feeCcy': 'USDT',
49899
+ // 'fillPrice': '74.17',
49900
+ // 'fillQty': '1',
49901
+ // 'lastTradeID': 6802340762
49902
+ // }
49859
49903
  //
49860
49904
  const timestamp = this.safeIntegerN(trade, ['order_time', 'createTime', 'create_time']);
49861
49905
  const isPublicTrade = ('order_time' in trade);
@@ -49869,7 +49913,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
49869
49913
  side = this.safeString(trade, 'type');
49870
49914
  }
49871
49915
  else {
49872
- amount = this.safeString2(trade, 'size', 'vol');
49916
+ amount = this.safeStringN(trade, ['size', 'vol', 'fillQty']);
49873
49917
  cost = this.safeString(trade, 'notional');
49874
49918
  type = this.safeString(trade, 'type');
49875
49919
  side = this.parseOrderSide(this.safeString(trade, 'side'));
@@ -49891,14 +49935,14 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
49891
49935
  }
49892
49936
  return this.safeTrade({
49893
49937
  'info': trade,
49894
- 'id': this.safeString2(trade, 'tradeId', 'trade_id'),
49938
+ 'id': this.safeStringN(trade, ['tradeId', 'trade_id', 'lastTradeID']),
49895
49939
  'order': this.safeString2(trade, 'orderId', 'order_id'),
49896
49940
  'timestamp': timestamp,
49897
49941
  'datetime': this.iso8601(timestamp),
49898
49942
  'symbol': market['symbol'],
49899
49943
  'type': type,
49900
49944
  'side': side,
49901
- 'price': this.safeString(trade, 'price'),
49945
+ 'price': this.safeString2(trade, 'price', 'fillPrice'),
49902
49946
  'amount': amount,
49903
49947
  'cost': cost,
49904
49948
  'takerOrMaker': this.safeStringLower2(trade, 'tradeRole', 'exec_type'),
@@ -49952,38 +49996,45 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
49952
49996
  parseOHLCV(ohlcv, market = undefined) {
49953
49997
  //
49954
49998
  // spot
49955
- //
49956
- // [
49957
- // "1699512060", // timestamp
49958
- // "36746.49", // open
49959
- // "36758.71", // high
49960
- // "36736.13", // low
49961
- // "36755.99", // close
49962
- // "2.83965", // base volume
49963
- // "104353.57" // quote volume
49964
- // ]
49999
+ // [
50000
+ // "1699512060", // timestamp
50001
+ // "36746.49", // open
50002
+ // "36758.71", // high
50003
+ // "36736.13", // low
50004
+ // "36755.99", // close
50005
+ // "2.83965", // base volume
50006
+ // "104353.57" // quote volume
50007
+ // ]
49965
50008
  //
49966
50009
  // swap
49967
- //
49968
- // {
49969
- // "low_price": "20090.3",
49970
- // "high_price": "20095.5",
49971
- // "open_price": "20092.6",
49972
- // "close_price": "20091.4",
49973
- // "volume": "8748",
49974
- // "timestamp": 1665002281
49975
- // }
50010
+ // {
50011
+ // "low_price": "20090.3",
50012
+ // "high_price": "20095.5",
50013
+ // "open_price": "20092.6",
50014
+ // "close_price": "20091.4",
50015
+ // "volume": "8748",
50016
+ // "timestamp": 1665002281
50017
+ // }
49976
50018
  //
49977
50019
  // ws
50020
+ // [
50021
+ // 1631056350, // timestamp
50022
+ // "46532.83", // open
50023
+ // "46555.71", // high
50024
+ // "46511.41", // low
50025
+ // "46555.71", // close
50026
+ // "0.25", // volume
50027
+ // ]
49978
50028
  //
49979
- // [
49980
- // 1631056350, // timestamp
49981
- // "46532.83", // open
49982
- // "46555.71", // high
49983
- // "46511.41", // low
49984
- // "46555.71", // close
49985
- // "0.25", // volume
49986
- // ]
50029
+ // ws swap
50030
+ // {
50031
+ // "symbol":"BTCUSDT",
50032
+ // "o":"146.24",
50033
+ // "h":"146.24",
50034
+ // "l":"146.24",
50035
+ // "c":"146.24",
50036
+ // "v":"146"
50037
+ // }
49987
50038
  //
49988
50039
  if (Array.isArray(ohlcv)) {
49989
50040
  return [
@@ -49997,12 +50048,12 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
49997
50048
  }
49998
50049
  else {
49999
50050
  return [
50000
- this.safeTimestamp(ohlcv, 'timestamp'),
50001
- this.safeNumber(ohlcv, 'open_price'),
50002
- this.safeNumber(ohlcv, 'high_price'),
50003
- this.safeNumber(ohlcv, 'low_price'),
50004
- this.safeNumber(ohlcv, 'close_price'),
50005
- this.safeNumber(ohlcv, 'volume'),
50051
+ this.safeTimestamp2(ohlcv, 'timestamp', 'ts'),
50052
+ this.safeNumber2(ohlcv, 'open_price', 'o'),
50053
+ this.safeNumber2(ohlcv, 'high_price', 'h'),
50054
+ this.safeNumber2(ohlcv, 'low_price', 'l'),
50055
+ this.safeNumber2(ohlcv, 'close_price', 'c'),
50056
+ this.safeNumber2(ohlcv, 'volume', 'v'),
50006
50057
  ];
50007
50058
  }
50008
50059
  }
@@ -52768,7 +52819,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
52768
52819
  // ---------------------------------------------------------------------------
52769
52820
  /**
52770
52821
  * @class bitmex
52771
- * @extends Exchange
52822
+ * @augments Exchange
52772
52823
  */
52773
52824
  class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
52774
52825
  describe() {
@@ -55003,7 +55054,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
55003
55054
  const datetime = this.safeString(position, 'timestamp');
55004
55055
  const crossMargin = this.safeValue(position, 'crossMargin');
55005
55056
  const marginMode = (crossMargin === true) ? 'cross' : 'isolated';
55006
- const notionalString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(this.safeString(position, 'foreignNotional', 'homeNotional'));
55057
+ const notionalString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringAbs(this.safeString2(position, 'foreignNotional', 'homeNotional'));
55007
55058
  const settleCurrencyCode = this.safeString(market, 'settle');
55008
55059
  const maintenanceMargin = this.convertToRealAmount(settleCurrencyCode, this.safeString(position, 'maintMargin'));
55009
55060
  const unrealisedPnl = this.convertToRealAmount(settleCurrencyCode, this.safeString(position, 'unrealisedPnl'));
@@ -55597,7 +55648,7 @@ class bitmex extends _abstract_bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
55597
55648
  // ---------------------------------------------------------------------------
55598
55649
  /**
55599
55650
  * @class bitopro
55600
- * @extends Exchange
55651
+ * @augments Exchange
55601
55652
  */
55602
55653
  class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
55603
55654
  describe() {
@@ -56840,11 +56891,11 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
56840
56891
  //
56841
56892
  return this.parseOrders(orders, market, since, limit);
56842
56893
  }
56843
- fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
56894
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
56844
56895
  const request = {
56845
56896
  'statusKind': 'OPEN',
56846
56897
  };
56847
- return this.fetchOrders(symbol, since, limit, this.extend(request, params));
56898
+ return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
56848
56899
  }
56849
56900
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
56850
56901
  /**
@@ -57329,7 +57380,7 @@ class bitopro extends _abstract_bitopro_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
57329
57380
  // ---------------------------------------------------------------------------
57330
57381
  /**
57331
57382
  * @class bitpanda
57332
- * @extends Exchange
57383
+ * @augments Exchange
57333
57384
  */
57334
57385
  class bitpanda extends _abstract_bitpanda_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
57335
57386
  describe() {
@@ -59342,7 +59393,7 @@ class bitpanda extends _abstract_bitpanda_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
59342
59393
  // ---------------------------------------------------------------------------
59343
59394
  /**
59344
59395
  * @class bitrue
59345
- * @extends Exchange
59396
+ * @augments Exchange
59346
59397
  */
59347
59398
  class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
59348
59399
  describe() {
@@ -62614,7 +62665,7 @@ class bitrue extends _abstract_bitrue_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
62614
62665
  // ---------------------------------------------------------------------------
62615
62666
  /**
62616
62667
  * @class bitso
62617
- * @extends Exchange
62668
+ * @augments Exchange
62618
62669
  */
62619
62670
  class bitso extends _abstract_bitso_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
62620
62671
  describe() {
@@ -64377,7 +64428,7 @@ class bitso extends _abstract_bitso_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
64377
64428
  // ---------------------------------------------------------------------------
64378
64429
  /**
64379
64430
  * @class bitstamp
64380
- * @extends Exchange
64431
+ * @augments Exchange
64381
64432
  */
64382
64433
  class bitstamp extends _abstract_bitstamp_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
64383
64434
  describe() {
@@ -66549,7 +66600,7 @@ class bitstamp extends _abstract_bitstamp_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
66549
66600
  // ---------------------------------------------------------------------------
66550
66601
  /**
66551
66602
  * @class bittrex
66552
- * @extends Exchange
66603
+ * @augments Exchange
66553
66604
  */
66554
66605
  class bittrex extends _abstract_bittrex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
66555
66606
  describe() {
@@ -68868,7 +68919,7 @@ class bittrex extends _abstract_bittrex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
68868
68919
  // ----------------------------------------------------------------------------
68869
68920
  /**
68870
68921
  * @class bitvavo
68871
- * @extends Exchange
68922
+ * @augments Exchange
68872
68923
  */
68873
68924
  class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
68874
68925
  describe() {
@@ -70806,7 +70857,7 @@ class bitvavo extends _abstract_bitvavo_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
70806
70857
  // ---------------------------------------------------------------------------
70807
70858
  /**
70808
70859
  * @class bl3p
70809
- * @extends Exchange
70860
+ * @augments Exchange
70810
70861
  */
70811
70862
  class bl3p extends _abstract_bl3p_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
70812
70863
  describe() {
@@ -71262,7 +71313,7 @@ class bl3p extends _abstract_bl3p_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
71262
71313
  // ---------------------------------------------------------------------------
71263
71314
  /**
71264
71315
  * @class blockchaincom
71265
- * @extends Exchange
71316
+ * @augments Exchange
71266
71317
  */
71267
71318
  class blockchaincom extends _abstract_blockchaincom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
71268
71319
  describe() {
@@ -72474,7 +72525,7 @@ class blockchaincom extends _abstract_blockchaincom_js__WEBPACK_IMPORTED_MODULE_
72474
72525
  // ---------------------------------------------------------------------------
72475
72526
  /**
72476
72527
  * @class btcalpha
72477
- * @extends Exchange
72528
+ * @augments Exchange
72478
72529
  */
72479
72530
  class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
72480
72531
  describe() {
@@ -73413,7 +73464,7 @@ class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
73413
73464
  // ---------------------------------------------------------------------------
73414
73465
  /**
73415
73466
  * @class btcbox
73416
- * @extends Exchange
73467
+ * @augments Exchange
73417
73468
  */
73418
73469
  class btcbox extends _abstract_btcbox_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
73419
73470
  describe() {
@@ -73989,7 +74040,7 @@ class btcbox extends _abstract_btcbox_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
73989
74040
  // ---------------------------------------------------------------------------
73990
74041
  /**
73991
74042
  * @class btcmarkets
73992
- * @extends Exchange
74043
+ * @augments Exchange
73993
74044
  */
73994
74045
  class btcmarkets extends _abstract_btcmarkets_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
73995
74046
  describe() {
@@ -75236,7 +75287,7 @@ class btcmarkets extends _abstract_btcmarkets_js__WEBPACK_IMPORTED_MODULE_0__/*
75236
75287
  // ---------------------------------------------------------------------------
75237
75288
  /**
75238
75289
  * @class btcturk
75239
- * @extends Exchange
75290
+ * @augments Exchange
75240
75291
  */
75241
75292
  class btcturk extends _abstract_btcturk_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
75242
75293
  describe() {
@@ -76177,7 +76228,7 @@ class btcturk extends _abstract_btcturk_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
76177
76228
  // ---------------------------------------------------------------------------
76178
76229
  /**
76179
76230
  * @class bybit
76180
- * @extends Exchange
76231
+ * @augments Exchange
76181
76232
  */
76182
76233
  class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
76183
76234
  describe() {
@@ -79856,7 +79907,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
79856
79907
  * @name bybit#createOrders
79857
79908
  * @description create a list of trade orders
79858
79909
  * @see https://bybit-exchange.github.io/docs/v5/order/batch-place
79859
- * @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
79910
+ * @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
79860
79911
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
79861
79912
  */
79862
79913
  await this.loadMarkets();
@@ -80894,7 +80945,6 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
80894
80945
  * @param {int} [limit] the maximum number of trades to retrieve
80895
80946
  * @param {object} [params] extra parameters specific to the exchange API endpoint
80896
80947
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
80897
- *
80898
80948
  */
80899
80949
  const request = {};
80900
80950
  const clientOrderId = this.safeString2(params, 'clientOrderId', 'orderLinkId');
@@ -81180,12 +81230,11 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
81180
81230
  * @param {int} [limit] the maximum number of deposits structures to retrieve, default = 50, max = 50
81181
81231
  * @param {object} [params] extra parameters specific to the exchange API endpoint
81182
81232
  * @param {int} [params.until] the latest time in ms to fetch deposits for, default = 30 days after since
81183
- *
81184
81233
  * EXCHANGE SPECIFIC PARAMETERS
81185
81234
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
81186
81235
  * @param {string} [params.cursor] used for pagination
81187
81236
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
81188
- */
81237
+ */
81189
81238
  await this.loadMarkets();
81190
81239
  let paginate = false;
81191
81240
  [paginate, params] = this.handleOptionAndParams(params, 'fetchDeposits', 'paginate');
@@ -83796,7 +83845,7 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
83796
83845
  // ---------------------------------------------------------------------------
83797
83846
  /**
83798
83847
  * @class cex
83799
- * @extends Exchange
83848
+ * @augments Exchange
83800
83849
  */
83801
83850
  class cex extends _abstract_cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
83802
83851
  describe() {
@@ -85498,7 +85547,7 @@ class cex extends _abstract_cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
85498
85547
  // ----------------------------------------------------------------------------
85499
85548
  /**
85500
85549
  * @class coinbase
85501
- * @extends Exchange
85550
+ * @augments Exchange
85502
85551
  */
85503
85552
  class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
85504
85553
  describe() {
@@ -88769,7 +88818,7 @@ class coinbaseprime extends _coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/* ["def
88769
88818
  // ----------------------------------------------------------------------------
88770
88819
  /**
88771
88820
  * @class coinbasepro
88772
- * @extends Exchange
88821
+ * @augments Exchange
88773
88822
  */
88774
88823
  class coinbasepro extends _abstract_coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
88775
88824
  describe() {
@@ -90686,7 +90735,7 @@ class coinbasepro extends _abstract_coinbasepro_js__WEBPACK_IMPORTED_MODULE_0__/
90686
90735
  // ---------------------------------------------------------------------------
90687
90736
  /**
90688
90737
  * @class coincheck
90689
- * @extends Exchange
90738
+ * @augments Exchange
90690
90739
  */
90691
90740
  class coincheck extends _abstract_coincheck_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
90692
90741
  describe() {
@@ -91542,7 +91591,7 @@ class coincheck extends _abstract_coincheck_js__WEBPACK_IMPORTED_MODULE_0__/* ["
91542
91591
  // ---------------------------------------------------------------------------
91543
91592
  /**
91544
91593
  * @class coinex
91545
- * @extends Exchange
91594
+ * @augments Exchange
91546
91595
  */
91547
91596
  class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
91548
91597
  describe() {
@@ -91561,6 +91610,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
91561
91610
  // 20 per 2 seconds => 10 per second => weight = 40
91562
91611
  'rateLimit': 2.5,
91563
91612
  'pro': true,
91613
+ 'certified': true,
91564
91614
  'has': {
91565
91615
  'CORS': undefined,
91566
91616
  'spot': true,
@@ -93801,7 +93851,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
93801
93851
  * @name coinex#createOrders
93802
93852
  * @description create a list of trade orders (all orders should be of the same symbol)
93803
93853
  * @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade002_batch_limit_orders
93804
- * @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
93854
+ * @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
93805
93855
  * @param {object} [params] extra parameters specific to the api endpoint
93806
93856
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
93807
93857
  */
@@ -96912,7 +96962,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
96912
96962
 
96913
96963
  /**
96914
96964
  * @class coinlist
96915
- * @extends Exchange
96965
+ * @augments Exchange
96916
96966
  */
96917
96967
  class coinlist extends _abstract_coinlist_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
96918
96968
  describe() {
@@ -99254,7 +99304,7 @@ class coinlist extends _abstract_coinlist_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
99254
99304
  // ---------------------------------------------------------------------------
99255
99305
  /**
99256
99306
  * @class coinmate
99257
- * @extends Exchange
99307
+ * @augments Exchange
99258
99308
  */
99259
99309
  class coinmate extends _abstract_coinmate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
99260
99310
  describe() {
@@ -100253,7 +100303,7 @@ class coinmate extends _abstract_coinmate_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
100253
100303
  // ---------------------------------------------------------------------------
100254
100304
  /**
100255
100305
  * @class coinone
100256
- * @extends Exchange
100306
+ * @augments Exchange
100257
100307
  */
100258
100308
  class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
100259
100309
  describe() {
@@ -101195,7 +101245,7 @@ class coinone extends _abstract_coinone_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
101195
101245
 
101196
101246
  /**
101197
101247
  * @class coinsph
101198
- * @extends Exchange
101248
+ * @augments Exchange
101199
101249
  */
101200
101250
  class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
101201
101251
  describe() {
@@ -103152,7 +103202,7 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
103152
103202
  // ---------------------------------------------------------------------------
103153
103203
  /**
103154
103204
  * @class coinspot
103155
- * @extends Exchange
103205
+ * @augments Exchange
103156
103206
  */
103157
103207
  class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
103158
103208
  describe() {
@@ -103709,7 +103759,7 @@ class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
103709
103759
 
103710
103760
  /**
103711
103761
  * @class cryptocom
103712
- * @extends Exchange
103762
+ * @augments Exchange
103713
103763
  */
103714
103764
  class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
103715
103765
  describe() {
@@ -104866,7 +104916,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
104866
104916
  * @description create a list of trade orders
104867
104917
  * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-list
104868
104918
  * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#private-create-order-list-oco
104869
- * @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
104919
+ * @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
104870
104920
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
104871
104921
  */
104872
104922
  await this.loadMarkets();
@@ -105928,7 +105978,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
105928
105978
  * @method
105929
105979
  * @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
105930
105980
  * @param {object} [params] extra parameters specific to the exchange API endpoint
105931
- * @returns {array} the marginMode in lowercase
105981
+ * @returns {Array} the marginMode in lowercase
105932
105982
  */
105933
105983
  const defaultType = this.safeString(this.options, 'defaultType');
105934
105984
  const isMargin = this.safeValue(params, 'margin', false);
@@ -106712,7 +106762,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
106712
106762
  // ---------------------------------------------------------------------------
106713
106763
  /**
106714
106764
  * @class currencycom
106715
- * @extends Exchange
106765
+ * @augments Exchange
106716
106766
  */
106717
106767
  class currencycom extends _abstract_currencycom_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
106718
106768
  describe() {
@@ -108737,7 +108787,7 @@ class currencycom extends _abstract_currencycom_js__WEBPACK_IMPORTED_MODULE_0__/
108737
108787
  // ---------------------------------------------------------------------------
108738
108788
  /**
108739
108789
  * @class delta
108740
- * @extends Exchange
108790
+ * @augments Exchange
108741
108791
  */
108742
108792
  class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
108743
108793
  describe() {
@@ -111980,7 +112030,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
111980
112030
  // ---------------------------------------------------------------------------
111981
112031
  /**
111982
112032
  * @class deribit
111983
- * @extends Exchange
112033
+ * @augments Exchange
111984
112034
  */
111985
112035
  class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
111986
112036
  describe() {
@@ -115265,7 +115315,7 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
115265
115315
  // ---------------------------------------------------------------------------
115266
115316
  /**
115267
115317
  * @class digifinex
115268
- * @extends Exchange
115318
+ * @augments Exchange
115269
115319
  */
115270
115320
  class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
115271
115321
  describe() {
@@ -115785,9 +115835,15 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
115785
115835
  async fetchMarketsV2(params = {}) {
115786
115836
  const defaultType = this.safeString(this.options, 'defaultType');
115787
115837
  const [marginMode, query] = this.handleMarginModeAndParams('fetchMarketsV2', params);
115788
- const method = (marginMode !== undefined) ? 'publicSpotGetMarginSymbols' : 'publicSpotGetTradesSymbols';
115789
- let promises = [this[method](query), this.publicSwapGetPublicInstruments(params)];
115790
- promises = await Promise.all(promises);
115838
+ const promisesRaw = [];
115839
+ if (marginMode !== undefined) {
115840
+ promisesRaw.push(this.publicSpotGetMarginSymbols(query));
115841
+ }
115842
+ else {
115843
+ promisesRaw.push(this.publicSpotGetTradesSymbols(query));
115844
+ }
115845
+ promisesRaw.push(this.publicSwapGetPublicInstruments(params));
115846
+ const promises = await Promise.all(promisesRaw);
115791
115847
  const spotMarkets = promises[0];
115792
115848
  const swapMarkets = promises[1];
115793
115849
  //
@@ -116065,17 +116121,21 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
116065
116121
  await this.loadMarkets();
116066
116122
  let marketType = undefined;
116067
116123
  [marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
116068
- let method = this.getSupportedMapping(marketType, {
116069
- 'spot': 'privateSpotGetSpotAssets',
116070
- 'margin': 'privateSpotGetMarginAssets',
116071
- 'swap': 'privateSwapGetAccountBalance',
116072
- });
116073
116124
  const [marginMode, query] = this.handleMarginModeAndParams('fetchBalance', params);
116074
- if (marginMode !== undefined) {
116075
- method = 'privateSpotGetMarginAssets';
116125
+ let response = undefined;
116126
+ if (marginMode !== undefined || marketType === 'margin') {
116076
116127
  marketType = 'margin';
116128
+ response = await this.privateSpotGetMarginAssets(query);
116129
+ }
116130
+ else if (marketType === 'spot') {
116131
+ response = await this.privateSpotGetSpotAssets(query);
116132
+ }
116133
+ else if (marketType === 'swap') {
116134
+ response = await this.privateSwapGetAccountBalance(query);
116135
+ }
116136
+ else {
116137
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchBalance() not support this market type');
116077
116138
  }
116078
- const response = await this[method](query);
116079
116139
  //
116080
116140
  // spot and margin
116081
116141
  //
@@ -116132,19 +116192,18 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
116132
116192
  const market = this.market(symbol);
116133
116193
  const [marketType, query] = this.handleMarketTypeAndParams('fetchOrderBook', market, params);
116134
116194
  const request = {};
116135
- let method = undefined;
116195
+ if (limit !== undefined) {
116196
+ request['limit'] = limit;
116197
+ }
116198
+ let response = undefined;
116136
116199
  if (marketType === 'swap') {
116137
- method = 'publicSwapGetPublicDepth';
116138
116200
  request['instrument_id'] = market['id'];
116201
+ response = await this.publicSwapGetPublicDepth(this.extend(request, query));
116139
116202
  }
116140
116203
  else {
116141
- method = 'publicSpotGetOrderBook';
116142
116204
  request['symbol'] = market['id'];
116205
+ response = await this.publicSpotGetOrderBook(this.extend(request, query));
116143
116206
  }
116144
- if (limit !== undefined) {
116145
- request['limit'] = limit;
116146
- }
116147
- const response = await this[method](this.extend(request, query));
116148
116207
  //
116149
116208
  // spot
116150
116209
  //
@@ -116215,12 +116274,14 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
116215
116274
  }
116216
116275
  let type = undefined;
116217
116276
  [type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params);
116218
- let method = 'publicSpotGetTicker';
116219
116277
  const request = {};
116278
+ let response = undefined;
116220
116279
  if (type === 'swap') {
116221
- method = 'publicSwapGetPublicTickers';
116280
+ response = await this.publicSwapGetPublicTickers(this.extend(request, params));
116281
+ }
116282
+ else {
116283
+ response = await this.publicSpotGetTicker(this.extend(request, params));
116222
116284
  }
116223
- const response = await this[method](this.extend(request, params));
116224
116285
  //
116225
116286
  // spot
116226
116287
  //
@@ -116295,16 +116356,16 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
116295
116356
  */
116296
116357
  await this.loadMarkets();
116297
116358
  const market = this.market(symbol);
116298
- let method = 'publicSpotGetTicker';
116299
116359
  const request = {};
116360
+ let response = undefined;
116300
116361
  if (market['swap']) {
116301
- method = 'publicSwapGetPublicTicker';
116302
116362
  request['instrument_id'] = market['id'];
116363
+ response = await this.publicSwapGetPublicTicker(this.extend(request, params));
116303
116364
  }
116304
116365
  else {
116305
116366
  request['symbol'] = market['id'];
116367
+ response = await this.publicSpotGetTicker(this.extend(request, params));
116306
116368
  }
116307
- const response = await this[method](this.extend(request, params));
116308
116369
  //
116309
116370
  // spot
116310
116371
  //
@@ -116633,19 +116694,19 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
116633
116694
  */
116634
116695
  await this.loadMarkets();
116635
116696
  const market = this.market(symbol);
116636
- let method = 'publicSpotGetTrades';
116637
116697
  const request = {};
116698
+ if (limit !== undefined) {
116699
+ request['limit'] = market['swap'] ? Math.min(limit, 100) : limit;
116700
+ }
116701
+ let response = undefined;
116638
116702
  if (market['swap']) {
116639
- method = 'publicSwapGetPublicTrades';
116640
116703
  request['instrument_id'] = market['id'];
116704
+ response = await this.publicSwapGetPublicTrades(this.extend(request, params));
116641
116705
  }
116642
116706
  else {
116643
116707
  request['symbol'] = market['id'];
116708
+ response = await this.publicSpotGetTrades(this.extend(request, params));
116644
116709
  }
116645
- if (limit !== undefined) {
116646
- request['limit'] = market['swap'] ? Math.min(limit, 100) : limit;
116647
- }
116648
- const response = await this[method](this.extend(request, params));
116649
116710
  //
116650
116711
  // spot
116651
116712
  //
@@ -116738,15 +116799,15 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
116738
116799
  */
116739
116800
  await this.loadMarkets();
116740
116801
  const market = this.market(symbol);
116741
- let method = 'publicSpotGetKline';
116742
116802
  const request = {};
116803
+ let response = undefined;
116743
116804
  if (market['swap']) {
116744
- method = 'publicSwapGetPublicCandles';
116745
116805
  request['instrument_id'] = market['id'];
116746
116806
  request['granularity'] = timeframe;
116747
116807
  if (limit !== undefined) {
116748
116808
  request['limit'] = limit;
116749
116809
  }
116810
+ response = await this.publicSwapGetPublicCandles(this.extend(request, params));
116750
116811
  }
116751
116812
  else {
116752
116813
  request['symbol'] = market['id'];
@@ -116764,8 +116825,8 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
116764
116825
  const duration = this.parseTimeframe(timeframe);
116765
116826
  request['start_time'] = this.sum(endTime, -limit * duration);
116766
116827
  }
116828
+ response = await this.publicSpotGetKline(this.extend(request, params));
116767
116829
  }
116768
- const response = await this[method](this.extend(request, params));
116769
116830
  //
116770
116831
  // spot
116771
116832
  //
@@ -116870,7 +116931,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
116870
116931
  * @description create a list of trade orders (all orders should be of the same symbol)
116871
116932
  * @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#create-multiple-order
116872
116933
  * @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#batchorder
116873
- * @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
116934
+ * @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
116874
116935
  * @param {object} [params] extra parameters specific to the exchange API endpoint
116875
116936
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
116876
116937
  */
@@ -117113,19 +117174,9 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117113
117174
  if (symbol !== undefined) {
117114
117175
  market = this.market(symbol);
117115
117176
  }
117177
+ id = id.toString();
117116
117178
  let marketType = undefined;
117117
117179
  [marketType, params] = this.handleMarketTypeAndParams('cancelOrder', market, params);
117118
- let method = this.getSupportedMapping(marketType, {
117119
- 'spot': 'privateSpotPostSpotOrderCancel',
117120
- 'margin': 'privateSpotPostMarginOrderCancel',
117121
- 'swap': 'privateSwapPostTradeCancelOrder',
117122
- });
117123
- const [marginMode, query] = this.handleMarginModeAndParams('cancelOrder', params);
117124
- if (marginMode !== undefined) {
117125
- method = 'privateSpotPostMarginOrderCancel';
117126
- marketType = 'margin';
117127
- }
117128
- id = id.toString();
117129
117180
  const request = {
117130
117181
  'order_id': id,
117131
117182
  };
@@ -117138,7 +117189,21 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117138
117189
  else {
117139
117190
  request['market'] = marketType;
117140
117191
  }
117141
- const response = await this[method](this.extend(request, query));
117192
+ const [marginMode, query] = this.handleMarginModeAndParams('cancelOrder', params);
117193
+ let response = undefined;
117194
+ if (marginMode !== undefined || marketType === 'margin') {
117195
+ marketType = 'margin';
117196
+ response = await this.privateSpotPostMarginOrderCancel(this.extend(request, query));
117197
+ }
117198
+ else if (marketType === 'spot') {
117199
+ response = await this.privateSpotPostSpotOrderCancel(this.extend(request, query));
117200
+ }
117201
+ else if (marketType === 'swap') {
117202
+ response = await this.privateSwapPostTradeCancelOrder(this.extend(request, query));
117203
+ }
117204
+ else {
117205
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' cancelOrder() not support this market type');
117206
+ }
117142
117207
  //
117143
117208
  // spot and margin
117144
117209
  //
@@ -117385,16 +117450,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117385
117450
  }
117386
117451
  let marketType = undefined;
117387
117452
  [marketType, params] = this.handleMarketTypeAndParams('fetchOpenOrders', market, params);
117388
- let method = this.getSupportedMapping(marketType, {
117389
- 'spot': 'privateSpotGetSpotOrderCurrent',
117390
- 'margin': 'privateSpotGetMarginOrderCurrent',
117391
- 'swap': 'privateSwapGetTradeOpenOrders',
117392
- });
117393
117453
  const [marginMode, query] = this.handleMarginModeAndParams('fetchOpenOrders', params);
117394
- if (marginMode !== undefined) {
117395
- method = 'privateSpotGetMarginOrderCurrent';
117396
- marketType = 'margin';
117397
- }
117398
117454
  const request = {};
117399
117455
  const swap = (marketType === 'swap');
117400
117456
  if (swap) {
@@ -117412,7 +117468,20 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117412
117468
  const marketIdRequest = swap ? 'instrument_id' : 'symbol';
117413
117469
  request[marketIdRequest] = market['id'];
117414
117470
  }
117415
- const response = await this[method](this.extend(request, query));
117471
+ let response = undefined;
117472
+ if (marginMode !== undefined || marketType === 'margin') {
117473
+ marketType = 'margin';
117474
+ response = await this.privateSpotGetMarginOrderCurrent(this.extend(request, query));
117475
+ }
117476
+ else if (marketType === 'spot') {
117477
+ response = await this.privateSpotGetSpotOrderCurrent(this.extend(request, query));
117478
+ }
117479
+ else if (marketType === 'swap') {
117480
+ response = await this.privateSwapGetTradeOpenOrders(this.extend(request, query));
117481
+ }
117482
+ else {
117483
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOpenOrders() not support this market type');
117484
+ }
117416
117485
  //
117417
117486
  // spot and margin
117418
117487
  //
@@ -117487,16 +117556,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117487
117556
  }
117488
117557
  let marketType = undefined;
117489
117558
  [marketType, params] = this.handleMarketTypeAndParams('fetchOrders', market, params);
117490
- let method = this.getSupportedMapping(marketType, {
117491
- 'spot': 'privateSpotGetSpotOrderHistory',
117492
- 'margin': 'privateSpotGetMarginOrderHistory',
117493
- 'swap': 'privateSwapGetTradeHistoryOrders',
117494
- });
117495
117559
  const [marginMode, query] = this.handleMarginModeAndParams('fetchOrders', params);
117496
- if (marginMode !== undefined) {
117497
- method = 'privateSpotGetMarginOrderHistory';
117498
- marketType = 'margin';
117499
- }
117500
117560
  const request = {};
117501
117561
  if (marketType === 'swap') {
117502
117562
  if (since !== undefined) {
@@ -117516,102 +117576,119 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117516
117576
  if (limit !== undefined) {
117517
117577
  request['limit'] = limit;
117518
117578
  }
117519
- const response = await this[method](this.extend(request, query));
117520
- //
117521
- // spot and margin
117522
- //
117523
- // {
117524
- // "code": 0,
117525
- // "data": [
117526
- // {
117527
- // "symbol": "BTC_USDT",
117528
- // "order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
117529
- // "created_date": 1562303547,
117530
- // "finished_date": 0,
117531
- // "price": 0.1,
117532
- // "amount": 1,
117533
- // "cash_amount": 1,
117534
- // "executed_amount": 0,
117535
- // "avg_price": 0,
117536
- // "status": 1,
117537
- // "type": "buy",
117538
- // "kind": "margin"
117539
- // }
117540
- // ]
117541
- // }
117542
- //
117543
- // swap
117544
- //
117545
- // {
117546
- // "code": 0,
117547
- // "data": [
117548
- // {
117549
- // "order_id": "1590136768156405760",
117550
- // "instrument_id": "BTCUSDTPERP",
117551
- // "margin_mode": "crossed",
117552
- // "contract_val": "0.001",
117553
- // "type": 1,
117554
- // "order_type": 8,
117555
- // "price": "18660.2",
117556
- // "size": "1",
117557
- // "filled_qty": "1",
117558
- // "price_avg": "18514.5",
117559
- // "fee": "0.00925725",
117560
- // "state": 2,
117561
- // "leverage": "20",
117562
- // "turnover": "18.5145",
117563
- // "has_stop": 0,
117564
- // "insert_time": 1667953123526,
117565
- // "time_stamp": 1667953123596
117566
- // },
117567
- // ...
117568
- // ]
117569
- // }
117570
- //
117571
- const data = this.safeValue(response, 'data', []);
117572
- return this.parseOrders(data, market, since, limit);
117573
- }
117574
- async fetchOrder(id, symbol = undefined, params = {}) {
117575
- /**
117576
- * @method
117577
- * @name digifinex#fetchOrder
117578
- * @description fetches information on an order made by the user
117579
- * @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-order-status
117580
- * @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderinfo
117581
- * @param {string} id order id
117582
- * @param {string} symbol unified symbol of the market the order was made in
117583
- * @param {object} [params] extra parameters specific to the exchange API endpoint
117584
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
117585
- */
117586
- await this.loadMarkets();
117587
- let market = undefined;
117588
- if (symbol !== undefined) {
117589
- market = this.market(symbol);
117590
- }
117591
- let marketType = undefined;
117592
- [marketType, params] = this.handleMarketTypeAndParams('fetchOrder', market, params);
117593
- let method = this.getSupportedMapping(marketType, {
117594
- 'spot': 'privateSpotGetSpotOrder',
117595
- 'margin': 'privateSpotGetMarginOrder',
117596
- 'swap': 'privateSwapGetTradeOrderInfo',
117597
- });
117598
- const [marginMode, query] = this.handleMarginModeAndParams('fetchOrder', params);
117599
- if (marginMode !== undefined) {
117600
- method = 'privateSpotGetMarginOrder';
117579
+ let response = undefined;
117580
+ if (marginMode !== undefined || marketType === 'margin') {
117601
117581
  marketType = 'margin';
117582
+ response = await this.privateSpotGetMarginOrderHistory(this.extend(request, query));
117602
117583
  }
117603
- const request = {
117604
- 'order_id': id,
117605
- };
117606
- if (marketType === 'swap') {
117607
- if (market !== undefined) {
117608
- request['instrument_id'] = market['id'];
117609
- }
117584
+ else if (marketType === 'spot') {
117585
+ response = await this.privateSpotGetSpotOrderHistory(this.extend(request, query));
117586
+ }
117587
+ else if (marketType === 'swap') {
117588
+ response = await this.privateSwapGetTradeHistoryOrders(this.extend(request, query));
117610
117589
  }
117611
117590
  else {
117612
- request['market'] = marketType;
117591
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOrders() not support this market type');
117592
+ }
117593
+ //
117594
+ // spot and margin
117595
+ //
117596
+ // {
117597
+ // "code": 0,
117598
+ // "data": [
117599
+ // {
117600
+ // "symbol": "BTC_USDT",
117601
+ // "order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
117602
+ // "created_date": 1562303547,
117603
+ // "finished_date": 0,
117604
+ // "price": 0.1,
117605
+ // "amount": 1,
117606
+ // "cash_amount": 1,
117607
+ // "executed_amount": 0,
117608
+ // "avg_price": 0,
117609
+ // "status": 1,
117610
+ // "type": "buy",
117611
+ // "kind": "margin"
117612
+ // }
117613
+ // ]
117614
+ // }
117615
+ //
117616
+ // swap
117617
+ //
117618
+ // {
117619
+ // "code": 0,
117620
+ // "data": [
117621
+ // {
117622
+ // "order_id": "1590136768156405760",
117623
+ // "instrument_id": "BTCUSDTPERP",
117624
+ // "margin_mode": "crossed",
117625
+ // "contract_val": "0.001",
117626
+ // "type": 1,
117627
+ // "order_type": 8,
117628
+ // "price": "18660.2",
117629
+ // "size": "1",
117630
+ // "filled_qty": "1",
117631
+ // "price_avg": "18514.5",
117632
+ // "fee": "0.00925725",
117633
+ // "state": 2,
117634
+ // "leverage": "20",
117635
+ // "turnover": "18.5145",
117636
+ // "has_stop": 0,
117637
+ // "insert_time": 1667953123526,
117638
+ // "time_stamp": 1667953123596
117639
+ // },
117640
+ // ...
117641
+ // ]
117642
+ // }
117643
+ //
117644
+ const data = this.safeValue(response, 'data', []);
117645
+ return this.parseOrders(data, market, since, limit);
117646
+ }
117647
+ async fetchOrder(id, symbol = undefined, params = {}) {
117648
+ /**
117649
+ * @method
117650
+ * @name digifinex#fetchOrder
117651
+ * @description fetches information on an order made by the user
117652
+ * @see https://docs.digifinex.com/en-ww/spot/v3/rest.html#get-order-status
117653
+ * @see https://docs.digifinex.com/en-ww/swap/v2/rest.html#orderinfo
117654
+ * @param {string} id order id
117655
+ * @param {string} symbol unified symbol of the market the order was made in
117656
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
117657
+ * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
117658
+ */
117659
+ await this.loadMarkets();
117660
+ let market = undefined;
117661
+ if (symbol !== undefined) {
117662
+ market = this.market(symbol);
117663
+ }
117664
+ let marketType = undefined;
117665
+ [marketType, params] = this.handleMarketTypeAndParams('fetchOrder', market, params);
117666
+ const [marginMode, query] = this.handleMarginModeAndParams('fetchOrder', params);
117667
+ const request = {
117668
+ 'order_id': id,
117669
+ };
117670
+ if (marketType === 'swap') {
117671
+ if (market !== undefined) {
117672
+ request['instrument_id'] = market['id'];
117673
+ }
117674
+ }
117675
+ else {
117676
+ request['market'] = marketType;
117677
+ }
117678
+ let response = undefined;
117679
+ if ((marginMode !== undefined) || (marketType === 'margin')) {
117680
+ marketType = 'margin';
117681
+ response = await this.privateSpotGetMarginOrder(this.extend(request, query));
117682
+ }
117683
+ else if (marketType === 'spot') {
117684
+ response = await this.privateSpotGetSpotOrder(this.extend(request, query));
117685
+ }
117686
+ else if (marketType === 'swap') {
117687
+ response = await this.privateSwapGetTradeOrderInfo(this.extend(request, query));
117688
+ }
117689
+ else {
117690
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOrder() not support this market type');
117613
117691
  }
117614
- const response = await this[method](this.extend(request, query));
117615
117692
  //
117616
117693
  // spot and margin
117617
117694
  //
@@ -117688,16 +117765,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117688
117765
  }
117689
117766
  let marketType = undefined;
117690
117767
  [marketType, params] = this.handleMarketTypeAndParams('fetchMyTrades', market, params);
117691
- let method = this.getSupportedMapping(marketType, {
117692
- 'spot': 'privateSpotGetSpotMytrades',
117693
- 'margin': 'privateSpotGetMarginMytrades',
117694
- 'swap': 'privateSwapGetTradeHistoryTrades',
117695
- });
117696
117768
  const [marginMode, query] = this.handleMarginModeAndParams('fetchMyTrades', params);
117697
- if (marginMode !== undefined) {
117698
- method = 'privateSpotGetMarginMytrades';
117699
- marketType = 'margin';
117700
- }
117701
117769
  if (marketType === 'swap') {
117702
117770
  if (since !== undefined) {
117703
117771
  request['start_timestamp'] = since;
@@ -117716,7 +117784,20 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117716
117784
  if (limit !== undefined) {
117717
117785
  request['limit'] = limit;
117718
117786
  }
117719
- const response = await this[method](this.extend(request, query));
117787
+ let response = undefined;
117788
+ if (marginMode !== undefined || marketType === 'margin') {
117789
+ marketType = 'margin';
117790
+ response = await this.privateSpotGetMarginMytrades(this.extend(request, query));
117791
+ }
117792
+ else if (marketType === 'spot') {
117793
+ response = await this.privateSpotGetSpotMytrades(this.extend(request, query));
117794
+ }
117795
+ else if (marketType === 'swap') {
117796
+ response = await this.privateSwapGetTradeHistoryTrades(this.extend(request, query));
117797
+ }
117798
+ else {
117799
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchMyTrades() not support this market type');
117800
+ }
117720
117801
  //
117721
117802
  // spot and margin
117722
117803
  //
@@ -117834,16 +117915,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117834
117915
  const request = {};
117835
117916
  let marketType = undefined;
117836
117917
  [marketType, params] = this.handleMarketTypeAndParams('fetchLedger', undefined, params);
117837
- let method = this.getSupportedMapping(marketType, {
117838
- 'spot': 'privateSpotGetSpotFinancelog',
117839
- 'margin': 'privateSpotGetMarginFinancelog',
117840
- 'swap': 'privateSwapGetAccountFinanceRecord',
117841
- });
117842
117918
  const [marginMode, query] = this.handleMarginModeAndParams('fetchLedger', params);
117843
- if (marginMode !== undefined) {
117844
- method = 'privateSpotGetMarginFinancelog';
117845
- marketType = 'margin';
117846
- }
117847
117919
  if (marketType === 'swap') {
117848
117920
  if (since !== undefined) {
117849
117921
  request['start_timestamp'] = since;
@@ -117864,7 +117936,20 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117864
117936
  if (limit !== undefined) {
117865
117937
  request['limit'] = limit;
117866
117938
  }
117867
- const response = await this[method](this.extend(request, query));
117939
+ let response = undefined;
117940
+ if (marginMode !== undefined || marketType === 'margin') {
117941
+ marketType = 'margin';
117942
+ response = await this.privateSpotGetMarginFinancelog(this.extend(request, query));
117943
+ }
117944
+ else if (marketType === 'spot') {
117945
+ response = await this.privateSpotGetSpotFinancelog(this.extend(request, query));
117946
+ }
117947
+ else if (marketType === 'swap') {
117948
+ response = await this.privateSwapGetAccountFinanceRecord(this.extend(request, query));
117949
+ }
117950
+ else {
117951
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLedger() not support this market type');
117952
+ }
117868
117953
  //
117869
117954
  // spot and margin
117870
117955
  //
@@ -117981,8 +118066,13 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
117981
118066
  if (limit !== undefined) {
117982
118067
  request['size'] = Math.min(500, limit);
117983
118068
  }
117984
- const method = (type === 'deposit') ? 'privateSpotGetDepositHistory' : 'privateSpotGetWithdrawHistory';
117985
- const response = await this[method](this.extend(request, params));
118069
+ let response = undefined;
118070
+ if (type === 'deposit') {
118071
+ response = await this.privateSpotGetDepositHistory(this.extend(request, params));
118072
+ }
118073
+ else {
118074
+ response = await this.privateSpotGetWithdrawHistory(this.extend(request, params));
118075
+ }
117986
118076
  //
117987
118077
  // {
117988
118078
  // "code": 200,
@@ -118616,12 +118706,16 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
118616
118706
  const marketIdRequest = (marketType === 'swap') ? 'instrument_id' : 'symbol';
118617
118707
  request[marketIdRequest] = market['id'];
118618
118708
  }
118619
- const method = this.getSupportedMapping(marketType, {
118620
- 'spot': 'privateSpotGetMarginPositions',
118621
- 'margin': 'privateSpotGetMarginPositions',
118622
- 'swap': 'privateSwapGetAccountPositions',
118623
- });
118624
- const response = await this[method](this.extend(request, query));
118709
+ let response = undefined;
118710
+ if (marketType === 'spot' || marketType === 'margin') {
118711
+ response = await this.privateSpotGetMarginPositions(this.extend(request, query));
118712
+ }
118713
+ else if (marketType === 'swap') {
118714
+ response = await this.privateSwapGetAccountPositions(this.extend(request, query));
118715
+ }
118716
+ else {
118717
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPositions() not support this market type');
118718
+ }
118625
118719
  //
118626
118720
  // swap
118627
118721
  //
@@ -118703,14 +118797,18 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
118703
118797
  if (marginMode !== undefined) {
118704
118798
  marketType = 'margin';
118705
118799
  }
118706
- const method = this.getSupportedMapping(marketType, {
118707
- 'spot': 'privateSpotGetMarginPositions',
118708
- 'margin': 'privateSpotGetMarginPositions',
118709
- 'swap': 'privateSwapGetAccountPositions',
118710
- });
118711
118800
  const marketIdRequest = (marketType === 'swap') ? 'instrument_id' : 'symbol';
118712
118801
  request[marketIdRequest] = market['id'];
118713
- const response = await this[method](this.extend(request, query));
118802
+ let response = undefined;
118803
+ if (marketType === 'spot' || marketType === 'margin') {
118804
+ response = await this.privateSpotGetMarginPositions(this.extend(request, query));
118805
+ }
118806
+ else if (marketType === 'swap') {
118807
+ response = await this.privateSwapGetAccountPositions(this.extend(request, query));
118808
+ }
118809
+ else {
118810
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchPosition() not support this market type');
118811
+ }
118714
118812
  //
118715
118813
  // swap
118716
118814
  //
@@ -119152,7 +119250,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
119152
119250
  * @method
119153
119251
  * @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
119154
119252
  * @param {object} [params] extra parameters specific to the exchange API endpoint
119155
- * @returns {array} the marginMode in lowercase
119253
+ * @returns {Array} the marginMode in lowercase
119156
119254
  */
119157
119255
  const defaultType = this.safeString(this.options, 'defaultType');
119158
119256
  const isMargin = this.safeValue(params, 'margin', false);
@@ -119561,7 +119659,7 @@ class digifinex extends _abstract_digifinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["
119561
119659
  // ---------------------------------------------------------------------------
119562
119660
  /**
119563
119661
  * @class exmo
119564
- * @extends Exchange
119662
+ * @augments Exchange
119565
119663
  */
119566
119664
  class exmo extends _abstract_exmo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
119567
119665
  describe() {
@@ -122255,7 +122353,7 @@ class fmfwio extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
122255
122353
 
122256
122354
  /**
122257
122355
  * @class gate
122258
- * @extends Exchange
122356
+ * @augments Exchange
122259
122357
  */
122260
122358
  class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
122261
122359
  describe() {
@@ -129270,7 +129368,7 @@ class gateio extends _gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
129270
129368
  // ---------------------------------------------------------------------------
129271
129369
  /**
129272
129370
  * @class gemini
129273
- * @extends Exchange
129371
+ * @augments Exchange
129274
129372
  */
129275
129373
  class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
129276
129374
  describe() {
@@ -131078,7 +131176,7 @@ class gemini extends _abstract_gemini_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
131078
131176
 
131079
131177
  /**
131080
131178
  * @class hitbtc
131081
- * @extends Exchange
131179
+ * @augments Exchange
131082
131180
  */
131083
131181
  class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
131084
131182
  describe() {
@@ -134604,7 +134702,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
134604
134702
  * @method
134605
134703
  * @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
134606
134704
  * @param {object} [params] extra parameters specific to the exchange API endpoint
134607
- * @returns {array} the marginMode in lowercase
134705
+ * @returns {Array} the marginMode in lowercase
134608
134706
  */
134609
134707
  const defaultType = this.safeString(this.options, 'defaultType');
134610
134708
  const isMargin = this.safeValue(params, 'margin', false);
@@ -134701,7 +134799,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
134701
134799
  // ---------------------------------------------------------------------------
134702
134800
  /**
134703
134801
  * @class hitbtc3
134704
- * @extends Exchange
134802
+ * @augments Exchange
134705
134803
  */
134706
134804
  class hitbtc3 extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
134707
134805
  describe() {
@@ -134735,7 +134833,7 @@ class hitbtc3 extends _hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .
134735
134833
  // ---------------------------------------------------------------------------
134736
134834
  /**
134737
134835
  * @class hollaex
134738
- * @extends Exchange
134836
+ * @augments Exchange
134739
134837
  */
134740
134838
  class hollaex extends _abstract_hollaex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
134741
134839
  describe() {
@@ -136627,7 +136725,7 @@ class hollaex extends _abstract_hollaex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
136627
136725
  // ---------------------------------------------------------------------------
136628
136726
  /**
136629
136727
  * @class huobi
136630
- * @extends Exchange
136728
+ * @augments Exchange
136631
136729
  */
136632
136730
  class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
136633
136731
  describe() {
@@ -141873,7 +141971,7 @@ class htx extends _abstract_htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
141873
141971
  * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#place-a-batch-of-orders
141874
141972
  * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-a-batch-of-orders
141875
141973
  * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-a-batch-of-orders
141876
- * @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
141974
+ * @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
141877
141975
  * @param {object} [params] extra parameters specific to the exchange API endpoint
141878
141976
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
141879
141977
  */
@@ -145422,7 +145520,7 @@ class huobi extends _htx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
145422
145520
  // ---------------------------------------------------------------------------
145423
145521
  /**
145424
145522
  * @class huobijp
145425
- * @extends Exchange
145523
+ * @augments Exchange
145426
145524
  */
145427
145525
  class huobijp extends _abstract_huobijp_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
145428
145526
  describe() {
@@ -147357,7 +147455,7 @@ class huobijp extends _abstract_huobijp_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
147357
147455
  // ---------------------------------------------------------------------------
147358
147456
  /**
147359
147457
  * @class idex
147360
- * @extends Exchange
147458
+ * @augments Exchange
147361
147459
  */
147362
147460
  class idex extends _abstract_idex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
147363
147461
  describe() {
@@ -149132,7 +149230,7 @@ class idex extends _abstract_idex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
149132
149230
  // ---------------------------------------------------------------------------
149133
149231
  /**
149134
149232
  * @class independentreserve
149135
- * @extends Exchange
149233
+ * @augments Exchange
149136
149234
  */
149137
149235
  class independentreserve extends _abstract_independentreserve_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
149138
149236
  describe() {
@@ -149900,7 +149998,7 @@ class independentreserve extends _abstract_independentreserve_js__WEBPACK_IMPORT
149900
149998
  // ---------------------------------------------------------------------------
149901
149999
  /**
149902
150000
  * @class indodax
149903
- * @extends Exchange
150001
+ * @augments Exchange
149904
150002
  */
149905
150003
  class indodax extends _abstract_indodax_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
149906
150004
  describe() {
@@ -150982,7 +151080,7 @@ class indodax extends _abstract_indodax_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
150982
151080
  // ---------------------------------------------------------------------------
150983
151081
  /**
150984
151082
  * @class kraken
150985
- * @extends Exchange
151083
+ * @augments Exchange
150986
151084
  */
150987
151085
  class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
150988
151086
  describe() {
@@ -153326,7 +153424,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
153326
153424
  * @param {object} [params.end] End timestamp, withdrawals created strictly after will be not be included in the response
153327
153425
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times
153328
153426
  * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
153329
- */
153427
+ */
153330
153428
  await this.loadMarkets();
153331
153429
  let paginate = false;
153332
153430
  [paginate, params] = this.handleOptionAndParams(params, 'fetchWithdrawals', 'paginate');
@@ -153847,7 +153945,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
153847
153945
  // ---------------------------------------------------------------------------
153848
153946
  /**
153849
153947
  * @class krakenfutures
153850
- * @extends Exchange
153948
+ * @augments Exchange
153851
153949
  */
153852
153950
  class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
153853
153951
  describe() {
@@ -154505,7 +154603,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
154505
154603
  * @method
154506
154604
  * @name krakenfutures#fetchTrades
154507
154605
  * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-market-data-get-trade-history
154508
- * @descriptions Fetch a history of filled trades that this account has made
154606
+ * @description Fetch a history of filled trades that this account has made
154509
154607
  * @param {string} symbol Unified CCXT market symbol
154510
154608
  * @param {int} [since] Timestamp in ms of earliest trade. Not used by krakenfutures except in combination with params.until
154511
154609
  * @param {int} [limit] Total number of trades, cannot exceed 100
@@ -154777,7 +154875,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
154777
154875
  * @name krakenfutures#createOrders
154778
154876
  * @description create a list of trade orders
154779
154877
  * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-batch-order-management
154780
- * @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
154878
+ * @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
154781
154879
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
154782
154880
  */
154783
154881
  await this.loadMarkets();
@@ -156236,7 +156334,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
156236
156334
  // ---------------------------------------------------------------------------
156237
156335
  /**
156238
156336
  * @class kucoin
156239
- * @extends Exchange
156337
+ * @augments Exchange
156240
156338
  */
156241
156339
  class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
156242
156340
  describe() {
@@ -156715,11 +156813,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
156715
156813
  },
156716
156814
  'commonCurrencies': {
156717
156815
  'BIFI': 'BIFIF',
156718
- 'EDGE': 'DADI',
156719
- 'HOT': 'HOTNOW',
156720
- 'TRY': 'Trias',
156721
156816
  'VAI': 'VAIOT',
156722
- 'WAX': 'WAXP',
156723
156817
  },
156724
156818
  'options': {
156725
156819
  'version': 'v1',
@@ -158163,7 +158257,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
158163
158257
  * @description create a list of trade orders
158164
158258
  * @see https://www.kucoin.com/docs/rest/spot-trading/orders/place-multiple-orders
158165
158259
  * @see https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/place-multiple-hf-orders
158166
- * @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
158260
+ * @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
158167
158261
  * @param {object} [params] extra parameters specific to the exchange API endpoint
158168
158262
  * @param {bool} [params.hf] false, // true for hf orders
158169
158263
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -161337,9 +161431,6 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
161337
161431
  orderbook['nonce'] = this.safeInteger(data, 'sequence');
161338
161432
  return orderbook;
161339
161433
  }
161340
- async fetchL3OrderBook(symbol, limit = undefined, params = {}) {
161341
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchL3OrderBook() is not supported yet');
161342
- }
161343
161434
  async fetchTicker(symbol, params = {}) {
161344
161435
  /**
161345
161436
  * @method
@@ -163075,7 +163166,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
163075
163166
  // ---------------------------------------------------------------------------
163076
163167
  /**
163077
163168
  * @class kuna
163078
- * @extends Exchange
163169
+ * @augments Exchange
163079
163170
  * @description Use the public-key as your apiKey
163080
163171
  */
163081
163172
  class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
@@ -165031,7 +165122,7 @@ class kuna extends _abstract_kuna_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
165031
165122
  // ---------------------------------------------------------------------------
165032
165123
  /**
165033
165124
  * @class latoken
165034
- * @extends Exchange
165125
+ * @augments Exchange
165035
165126
  */
165036
165127
  class latoken extends _abstract_latoken_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
165037
165128
  describe() {
@@ -166105,7 +166196,7 @@ class latoken extends _abstract_latoken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
166105
166196
  * @param {object} [params] extra parameters specific to the exchange API endpoint
166106
166197
  * @param {boolean} [params.trigger] true if fetching trigger orders
166107
166198
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
166108
- */
166199
+ */
166109
166200
  if (symbol === undefined) {
166110
166201
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
166111
166202
  }
@@ -166775,7 +166866,7 @@ class latoken extends _abstract_latoken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
166775
166866
  // ---------------------------------------------------------------------------
166776
166867
  /**
166777
166868
  * @class lbank2
166778
- * @extends Exchange
166869
+ * @augments Exchange
166779
166870
  */
166780
166871
  class lbank extends _abstract_lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
166781
166872
  describe() {
@@ -169606,7 +169697,7 @@ class lbank extends _abstract_lbank_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
169606
169697
  // ---------------------------------------------------------------------------
169607
169698
  /**
169608
169699
  * @class luno
169609
- * @extends Exchange
169700
+ * @augments Exchange
169610
169701
  */
169611
169702
  class luno extends _abstract_luno_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
169612
169703
  describe() {
@@ -170659,7 +170750,7 @@ class luno extends _abstract_luno_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
170659
170750
  // ---------------------------------------------------------------------------
170660
170751
  /**
170661
170752
  * @class lykke
170662
- * @extends Exchange
170753
+ * @augments Exchange
170663
170754
  */
170664
170755
  class lykke extends _abstract_lykke_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
170665
170756
  describe() {
@@ -171960,7 +172051,7 @@ class lykke extends _abstract_lykke_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
171960
172051
  // ---------------------------------------------------------------------------
171961
172052
  /**
171962
172053
  * @class mercado
171963
- * @extends Exchange
172054
+ * @augments Exchange
171964
172055
  */
171965
172056
  class mercado extends _abstract_mercado_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
171966
172057
  describe() {
@@ -172868,7 +172959,7 @@ class mercado extends _abstract_mercado_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
172868
172959
  // ---------------------------------------------------------------------------
172869
172960
  /**
172870
172961
  * @class mexc
172871
- * @extends Exchange
172962
+ * @augments Exchange
172872
172963
  */
172873
172964
  class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
172874
172965
  describe() {
@@ -174262,7 +174353,19 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
174262
174353
  }
174263
174354
  let method = this.safeString(this.options, 'fetchTradesMethod', 'spotPublicGetAggTrades');
174264
174355
  method = this.safeString(params, 'method', method); // AggTrades, HistoricalTrades, Trades
174265
- trades = await this[method](this.extend(request, params));
174356
+ params = this.omit(params, ['method']);
174357
+ if (method === 'spotPublicGetAggTrades') {
174358
+ trades = await this.spotPublicGetAggTrades(this.extend(request, params));
174359
+ }
174360
+ else if (method === 'spotPublicGetHistoricalTrades') {
174361
+ trades = await this.spotPublicGetHistoricalTrades(this.extend(request, params));
174362
+ }
174363
+ else if (method === 'spotPublicGetTrades') {
174364
+ trades = await this.spotPublicGetTrades(this.extend(request, params));
174365
+ }
174366
+ else {
174367
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchTrades() not support this method');
174368
+ }
174266
174369
  //
174267
174370
  // /trades, /historicalTrades
174268
174371
  //
@@ -174565,12 +174668,19 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
174565
174668
  }
174566
174669
  const priceType = this.safeString(params, 'price', 'default');
174567
174670
  params = this.omit(params, 'price');
174568
- const method = this.getSupportedMapping(priceType, {
174569
- 'default': 'contractPublicGetKlineSymbol',
174570
- 'index': 'contractPublicGetKlineIndexPriceSymbol',
174571
- 'mark': 'contractPublicGetKlineFairPriceSymbol',
174572
- });
174573
- const response = await this[method](this.extend(request, params));
174671
+ let response = undefined;
174672
+ if (priceType === 'default') {
174673
+ response = await this.contractPublicGetKlineSymbol(this.extend(request, params));
174674
+ }
174675
+ else if (priceType === 'index') {
174676
+ response = await this.contractPublicGetKlineIndexPriceSymbol(this.extend(request, params));
174677
+ }
174678
+ else if (priceType === 'mark') {
174679
+ response = await this.contractPublicGetKlineFairPriceSymbol(this.extend(request, params));
174680
+ }
174681
+ else {
174682
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchOHLCV() not support this price type, [default, index, mark]');
174683
+ }
174574
174684
  //
174575
174685
  // {
174576
174686
  // "success":true,
@@ -174955,6 +175065,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
174955
175065
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
174956
175066
  * @param {object} [params] extra parameters specific to the exchange API endpoint
174957
175067
  * @param {string} [params.marginMode] only 'isolated' is supported for spot-margin trading
175068
+ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
174958
175069
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
174959
175070
  */
174960
175071
  await this.loadMarkets();
@@ -175112,17 +175223,6 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175112
175223
  // 'trend': 1, // Required for trigger order 1: latest price, 2: fair price, 3: index price
175113
175224
  // 'orderType': 1, // Required for trigger order 1: limit order,2:Post Only Maker,3: close or cancel instantly ,4: close or cancel completely,5: Market order
175114
175225
  };
175115
- let method = 'contractPrivatePostOrderSubmit';
175116
- const stopPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
175117
- params = this.omit(params, ['stopPrice', 'triggerPrice']);
175118
- if (stopPrice) {
175119
- method = 'contractPrivatePostPlanorderPlace';
175120
- request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
175121
- request['triggerType'] = this.safeInteger(params, 'triggerType', 1);
175122
- request['executeCycle'] = this.safeInteger(params, 'executeCycle', 1);
175123
- request['trend'] = this.safeInteger(params, 'trend', 1);
175124
- request['orderType'] = this.safeInteger(params, 'orderType', 1);
175125
- }
175126
175226
  if ((type !== 5) && (type !== 6) && (type !== 'market')) {
175127
175227
  request['price'] = parseFloat(this.priceToPrecision(symbol, price));
175128
175228
  }
@@ -175143,8 +175243,20 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175143
175243
  if (clientOrderId !== undefined) {
175144
175244
  request['externalOid'] = clientOrderId;
175145
175245
  }
175146
- params = this.omit(params, ['clientOrderId', 'externalOid', 'postOnly']);
175147
- const response = await this[method](this.extend(request, params));
175246
+ const stopPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
175247
+ params = this.omit(params, ['clientOrderId', 'externalOid', 'postOnly', 'stopPrice', 'triggerPrice']);
175248
+ let response = undefined;
175249
+ if (stopPrice) {
175250
+ request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
175251
+ request['triggerType'] = this.safeInteger(params, 'triggerType', 1);
175252
+ request['executeCycle'] = this.safeInteger(params, 'executeCycle', 1);
175253
+ request['trend'] = this.safeInteger(params, 'trend', 1);
175254
+ request['orderType'] = this.safeInteger(params, 'orderType', 1);
175255
+ response = await this.contractPrivatePostPlanorderPlace(this.extend(request, params));
175256
+ }
175257
+ else {
175258
+ response = await this.contractPrivatePostOrderSubmit(this.extend(request, params));
175259
+ }
175148
175260
  //
175149
175261
  // Swap
175150
175262
  // {"code":200,"data":"2ff3163e8617443cb9c6fc19d42b1ca4"}
@@ -175161,7 +175273,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175161
175273
  * @name mexc#createOrders
175162
175274
  * @description *spot only* *all orders must have the same symbol* create a list of trade orders
175163
175275
  * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#batch-orders
175164
- * @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
175276
+ * @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
175165
175277
  * @param {object} [params] extra parameters specific to api endpoint
175166
175278
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
175167
175279
  */
@@ -175248,14 +175360,15 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175248
175360
  request['orderId'] = id;
175249
175361
  }
175250
175362
  const [marginMode, query] = this.handleMarginModeAndParams('fetchOrder', params);
175251
- let method = 'spotPrivateGetOrder';
175252
175363
  if (marginMode !== undefined) {
175253
175364
  if (marginMode !== 'isolated') {
175254
175365
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchOrder() does not support marginMode ' + marginMode + ' for spot-margin trading');
175255
175366
  }
175256
- method = 'spotPrivateGetMarginOrder';
175367
+ data = await this.spotPrivateGetMarginOrder(this.extend(request, query));
175368
+ }
175369
+ else {
175370
+ data = await this.spotPrivateGetOrder(this.extend(request, query));
175257
175371
  }
175258
- data = await this[method](this.extend(request, query));
175259
175372
  //
175260
175373
  // spot
175261
175374
  //
@@ -175365,20 +175478,22 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175365
175478
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument for spot market');
175366
175479
  }
175367
175480
  const [marginMode, queryInner] = this.handleMarginModeAndParams('fetchOrders', params);
175368
- let method = 'spotPrivateGetAllOrders';
175369
- if (marginMode !== undefined) {
175370
- if (marginMode !== 'isolated') {
175371
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchOrders() does not support marginMode ' + marginMode + ' for spot-margin trading');
175372
- }
175373
- method = 'spotPrivateGetMarginAllOrders';
175374
- }
175375
175481
  if (since !== undefined) {
175376
175482
  request['startTime'] = since;
175377
175483
  }
175378
175484
  if (limit !== undefined) {
175379
175485
  request['limit'] = limit;
175380
175486
  }
175381
- const response = await this[method](this.extend(request, queryInner));
175487
+ let response = undefined;
175488
+ if (marginMode !== undefined) {
175489
+ if (marginMode !== 'isolated') {
175490
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchOrders() does not support marginMode ' + marginMode + ' for spot-margin trading');
175491
+ }
175492
+ response = await this.spotPrivateGetMarginAllOrders(this.extend(request, queryInner));
175493
+ }
175494
+ else {
175495
+ response = await this.spotPrivateGetAllOrders(this.extend(request, queryInner));
175496
+ }
175382
175497
  //
175383
175498
  // spot
175384
175499
  //
@@ -175595,15 +175710,17 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175595
175710
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument for spot market');
175596
175711
  }
175597
175712
  request['symbol'] = market['id'];
175598
- let method = 'spotPrivateGetOpenOrders';
175599
175713
  const [marginMode, query] = this.handleMarginModeAndParams('fetchOpenOrders', params);
175714
+ let response = undefined;
175600
175715
  if (marginMode !== undefined) {
175601
175716
  if (marginMode !== 'isolated') {
175602
175717
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchOpenOrders() does not support marginMode ' + marginMode + ' for spot-margin trading');
175603
175718
  }
175604
- method = 'spotPrivateGetMarginOpenOrders';
175719
+ response = await this.spotPrivateGetMarginOpenOrders(this.extend(request, query));
175720
+ }
175721
+ else {
175722
+ response = await this.spotPrivateGetOpenOrders(this.extend(request, query));
175605
175723
  }
175606
- const response = await this[method](this.extend(request, query));
175607
175724
  //
175608
175725
  // spot
175609
175726
  //
@@ -175738,14 +175855,15 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175738
175855
  else {
175739
175856
  requestInner['orderId'] = id;
175740
175857
  }
175741
- let method = 'spotPrivateDeleteOrder';
175742
175858
  if (marginMode !== undefined) {
175743
175859
  if (marginMode !== 'isolated') {
175744
175860
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' cancelOrder() does not support marginMode ' + marginMode + ' for spot-margin trading');
175745
175861
  }
175746
- method = 'spotPrivateDeleteMarginOrder';
175862
+ data = await this.spotPrivateDeleteMarginOrder(this.extend(requestInner, query));
175863
+ }
175864
+ else {
175865
+ data = await this.spotPrivateDeleteOrder(this.extend(requestInner, query));
175747
175866
  }
175748
- data = await this[method](this.extend(requestInner, query));
175749
175867
  //
175750
175868
  // spot
175751
175869
  //
@@ -175785,7 +175903,16 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175785
175903
  // TODO: PlanorderCancel endpoint has bug atm. waiting for fix.
175786
175904
  let method = this.safeString(this.options, 'cancelOrder', 'contractPrivatePostOrderCancel'); // contractPrivatePostOrderCancel, contractPrivatePostPlanorderCancel
175787
175905
  method = this.safeString(query, 'method', method);
175788
- const response = await this[method]([id]); // the request cannot be changed or extended. This is the only way to send.
175906
+ let response = undefined;
175907
+ if (method === 'contractPrivatePostOrderCancel') {
175908
+ response = await this.contractPrivatePostOrderCancel([id]); // the request cannot be changed or extended. This is the only way to send.
175909
+ }
175910
+ else if (method === 'contractPrivatePostPlanorderCancel') {
175911
+ response = await this.contractPrivatePostPlanorderCancel([id]); // the request cannot be changed or extended. This is the only way to send.
175912
+ }
175913
+ else {
175914
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' cancelOrder() not support this method');
175915
+ }
175789
175916
  //
175790
175917
  // {
175791
175918
  // "success": true,
@@ -175864,14 +175991,16 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175864
175991
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol argument on spot');
175865
175992
  }
175866
175993
  request['symbol'] = market['id'];
175867
- let method = 'spotPrivateDeleteOpenOrders';
175994
+ let response = undefined;
175868
175995
  if (marginMode !== undefined) {
175869
175996
  if (marginMode !== 'isolated') {
175870
175997
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' cancelAllOrders() does not support marginMode ' + marginMode + ' for spot-margin trading');
175871
175998
  }
175872
- method = 'spotPrivateDeleteMarginOpenOrders';
175999
+ response = await this.spotPrivateDeleteMarginOpenOrders(this.extend(request, query));
176000
+ }
176001
+ else {
176002
+ response = await this.spotPrivateDeleteOpenOrders(this.extend(request, query));
175873
176003
  }
175874
- const response = await this[method](this.extend(request, query));
175875
176004
  //
175876
176005
  // spot
175877
176006
  //
@@ -175918,7 +176047,13 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
175918
176047
  // the Planorder endpoints work not only for stop-market orders but also for stop-limit orders that are supposed to have separate endpoint
175919
176048
  let method = this.safeString(this.options, 'cancelAllOrders', 'contractPrivatePostOrderCancelAll');
175920
176049
  method = this.safeString(query, 'method', method);
175921
- const response = await this[method](this.extend(request, query));
176050
+ let response = undefined;
176051
+ if (method === 'contractPrivatePostOrderCancelAll') {
176052
+ response = await this.contractPrivatePostOrderCancelAll(this.extend(request, query));
176053
+ }
176054
+ else if (method === 'contractPrivatePostPlanorderCancelAll') {
176055
+ response = await this.contractPrivatePostPlanorderCancelAll(this.extend(request, query));
176056
+ }
175922
176057
  //
175923
176058
  // {
175924
176059
  // "success": true,
@@ -176432,13 +176567,10 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
176432
176567
  let marketType = undefined;
176433
176568
  const request = {};
176434
176569
  [marketType, params] = this.handleMarketTypeAndParams('fetchBalance', undefined, params);
176435
- let method = this.getSupportedMapping(marketType, {
176436
- 'spot': 'spotPrivateGetAccount',
176437
- 'swap': 'contractPrivateGetAccountAssets',
176438
- 'margin': 'spotPrivateGetMarginIsolatedAccount',
176439
- });
176440
176570
  const marginMode = this.safeString(params, 'marginMode');
176441
176571
  const isMargin = this.safeValue(params, 'margin', false);
176572
+ params = this.omit(params, ['margin', 'marginMode']);
176573
+ let response = undefined;
176442
176574
  if ((marginMode !== undefined) || (isMargin) || (marketType === 'margin')) {
176443
176575
  let parsedSymbols = undefined;
176444
176576
  const symbol = this.safeString(params, 'symbol');
@@ -176453,12 +176585,20 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
176453
176585
  parsedSymbols = market['id'];
176454
176586
  }
176455
176587
  this.checkRequiredArgument('fetchBalance', parsedSymbols, 'symbol or symbols');
176456
- method = 'spotPrivateGetMarginIsolatedAccount';
176457
176588
  marketType = 'margin';
176458
176589
  request['symbols'] = parsedSymbols;
176590
+ params = this.omit(params, ['symbol', 'symbols']);
176591
+ response = await this.spotPrivateGetMarginIsolatedAccount(this.extend(request, params));
176592
+ }
176593
+ else if (marketType === 'spot') {
176594
+ response = await this.spotPrivateGetAccount(this.extend(request, params));
176595
+ }
176596
+ else if (marketType === 'swap') {
176597
+ response = await this.contractPrivateGetAccountAssets(this.extend(request, params));
176598
+ }
176599
+ else {
176600
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchBalance() not support this method');
176459
176601
  }
176460
- params = this.omit(params, ['margin', 'marginMode', 'symbol', 'symbols']);
176461
- const response = await this[method](this.extend(request, params));
176462
176602
  //
176463
176603
  // spot
176464
176604
  //
@@ -178103,7 +178243,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
178103
178243
  * @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
178104
178244
  * @param {object} [params] extra parameters specific to the exchange API endpoint
178105
178245
  * @param {bool} [params.margin] true for trading spot-margin
178106
- * @returns {array} the marginMode in lowercase
178246
+ * @returns {Array} the marginMode in lowercase
178107
178247
  */
178108
178248
  const defaultType = this.safeString(this.options, 'defaultType');
178109
178249
  const isMargin = this.safeValue(params, 'margin', false);
@@ -178238,7 +178378,7 @@ class mexc extends _abstract_mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
178238
178378
  // ---------------------------------------------------------------------------
178239
178379
  /**
178240
178380
  * @class ndax
178241
- * @extends Exchange
178381
+ * @augments Exchange
178242
178382
  */
178243
178383
  class ndax extends _abstract_ndax_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
178244
178384
  describe() {
@@ -180697,7 +180837,7 @@ class ndax extends _abstract_ndax_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
180697
180837
  // ---------------------------------------------------------------------------
180698
180838
  /**
180699
180839
  * @class novadax
180700
- * @extends Exchange
180840
+ * @augments Exchange
180701
180841
  */
180702
180842
  class novadax extends _abstract_novadax_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
180703
180843
  describe() {
@@ -182251,7 +182391,7 @@ class novadax extends _abstract_novadax_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
182251
182391
  // ---------------------------------------------------------------------------
182252
182392
  /**
182253
182393
  * @class oceanex
182254
- * @extends Exchange
182394
+ * @augments Exchange
182255
182395
  */
182256
182396
  class oceanex extends _abstract_oceanex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
182257
182397
  describe() {
@@ -183225,7 +183365,7 @@ class oceanex extends _abstract_oceanex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
183225
183365
  // ---------------------------------------------------------------------------
183226
183366
  /**
183227
183367
  * @class okcoin
183228
- * @extends Exchange
183368
+ * @augments Exchange
183229
183369
  */
183230
183370
  class okcoin extends _abstract_okcoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
183231
183371
  describe() {
@@ -186288,7 +186428,7 @@ class okcoin extends _abstract_okcoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
186288
186428
  // ---------------------------------------------------------------------------
186289
186429
  /**
186290
186430
  * @class okx
186291
- * @extends Exchange
186431
+ * @augments Exchange
186292
186432
  */
186293
186433
  class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
186294
186434
  describe() {
@@ -189141,7 +189281,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
189141
189281
  * @name okx#createOrders
189142
189282
  * @description create a list of trade orders
189143
189283
  * @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-multiple-orders
189144
- * @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
189284
+ * @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
189145
189285
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
189146
189286
  */
189147
189287
  await this.loadMarkets();
@@ -189684,7 +189824,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
189684
189824
  * @param {string} symbol unified market symbol
189685
189825
  * @param {object} [params] extra and exchange specific parameters
189686
189826
  * @returns [an order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
189687
- */
189827
+ */
189688
189828
  if (symbol === undefined) {
189689
189829
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchOrder() requires a symbol argument');
189690
189830
  }
@@ -193460,7 +193600,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
193460
193600
  * EXCHANGE SPECIFIC PARAMETERS
193461
193601
  * @param {boolean} [params.autoCxl] whether any pending orders for closing out needs to be automatically canceled when close position via a market order. false or true, the default is false
193462
193602
  * @param {string} [params.tag] order tag a combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters
193463
- * @returns {[object]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
193603
+ * @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
193464
193604
  */
193465
193605
  await this.loadMarkets();
193466
193606
  const market = this.market(symbol);
@@ -193575,7 +193715,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
193575
193715
  // ---------------------------------------------------------------------------
193576
193716
  /**
193577
193717
  * @class p2b
193578
- * @extends Exchange
193718
+ * @augments Exchange
193579
193719
  */
193580
193720
  class p2b extends _abstract_p2b_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
193581
193721
  describe() {
@@ -194096,7 +194236,6 @@ class p2b extends _abstract_p2b_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
194096
194236
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
194097
194237
  * @param {int} [limit] 1-100, default=50
194098
194238
  * @param {object} [params] extra parameters specific to the exchange API endpoint
194099
- *
194100
194239
  * @param {int} params.lastId order id
194101
194240
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
194102
194241
  */
@@ -194215,7 +194354,6 @@ class p2b extends _abstract_p2b_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
194215
194354
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
194216
194355
  * @param {int} [limit] 1-500, default=50
194217
194356
  * @param {object} [params] extra parameters specific to the exchange API endpoint
194218
- *
194219
194357
  * @param {int} [params.offset] default=0, with this value the last candles are returned
194220
194358
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
194221
194359
  */
@@ -194831,7 +194969,7 @@ class p2b extends _abstract_p2b_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
194831
194969
  // ---------------------------------------------------------------------------
194832
194970
  /**
194833
194971
  * @class paymium
194834
- * @extends Exchange
194972
+ * @augments Exchange
194835
194973
  */
194836
194974
  class paymium extends _abstract_paymium_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
194837
194975
  describe() {
@@ -195438,7 +195576,7 @@ class paymium extends _abstract_paymium_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
195438
195576
  // ----------------------------------------------------------------------------
195439
195577
  /**
195440
195578
  * @class phemex
195441
- * @extends Exchange
195579
+ * @augments Exchange
195442
195580
  */
195443
195581
  class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
195444
195582
  describe() {
@@ -199952,7 +200090,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
199952
200090
  // ---------------------------------------------------------------------------
199953
200091
  /**
199954
200092
  * @class poloniex
199955
- * @extends Exchange
200093
+ * @augments Exchange
199956
200094
  */
199957
200095
  class poloniex extends _abstract_poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
199958
200096
  describe() {
@@ -201178,20 +201316,20 @@ class poloniex extends _abstract_poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
201178
201316
  }
201179
201317
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
201180
201318
  /**
201181
- * @method
201182
- * @name poloniex#createOrder
201183
- * @description create a trade order
201184
- * @see https://docs.poloniex.com/#authenticated-endpoints-orders-create-order
201185
- * @see https://docs.poloniex.com/#authenticated-endpoints-smart-orders-create-order // trigger orders
201186
- * @param {string} symbol unified symbol of the market to create an order in
201187
- * @param {string} type 'market' or 'limit'
201188
- * @param {string} side 'buy' or 'sell'
201189
- * @param {float} amount how much of currency you want to trade in units of base currency
201190
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
201191
- * @param {object} [params] extra parameters specific to the exchange API endpoint
201192
- * @param {float} [params.triggerPrice] *spot only* The price at which a trigger order is triggered at
201193
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
201194
- */
201319
+ * @method
201320
+ * @name poloniex#createOrder
201321
+ * @description create a trade order
201322
+ * @see https://docs.poloniex.com/#authenticated-endpoints-orders-create-order
201323
+ * @see https://docs.poloniex.com/#authenticated-endpoints-smart-orders-create-order // trigger orders
201324
+ * @param {string} symbol unified symbol of the market to create an order in
201325
+ * @param {string} type 'market' or 'limit'
201326
+ * @param {string} side 'buy' or 'sell'
201327
+ * @param {float} amount how much of currency you want to trade in units of base currency
201328
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
201329
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
201330
+ * @param {float} [params.triggerPrice] *spot only* The price at which a trigger order is triggered at
201331
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
201332
+ */
201195
201333
  await this.loadMarkets();
201196
201334
  const market = this.market(symbol);
201197
201335
  if (!market['spot']) {
@@ -201261,21 +201399,21 @@ class poloniex extends _abstract_poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
201261
201399
  }
201262
201400
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
201263
201401
  /**
201264
- * @method
201265
- * @name poloniex#editOrder
201266
- * @description edit a trade order
201267
- * @see https://docs.poloniex.com/#authenticated-endpoints-orders-cancel-replace-order
201268
- * @see https://docs.poloniex.com/#authenticated-endpoints-smart-orders-cancel-replace-order
201269
- * @param {string} id order id
201270
- * @param {string} symbol unified symbol of the market to create an order in
201271
- * @param {string} type 'market' or 'limit'
201272
- * @param {string} side 'buy' or 'sell'
201273
- * @param {float} [amount] how much of the currency you want to trade in units of the base currency
201274
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
201275
- * @param {object} [params] extra parameters specific to the exchange API endpoint
201276
- * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
201277
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
201278
- */
201402
+ * @method
201403
+ * @name poloniex#editOrder
201404
+ * @description edit a trade order
201405
+ * @see https://docs.poloniex.com/#authenticated-endpoints-orders-cancel-replace-order
201406
+ * @see https://docs.poloniex.com/#authenticated-endpoints-smart-orders-cancel-replace-order
201407
+ * @param {string} id order id
201408
+ * @param {string} symbol unified symbol of the market to create an order in
201409
+ * @param {string} type 'market' or 'limit'
201410
+ * @param {string} side 'buy' or 'sell'
201411
+ * @param {float} [amount] how much of the currency you want to trade in units of the base currency
201412
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
201413
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
201414
+ * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
201415
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
201416
+ */
201279
201417
  await this.loadMarkets();
201280
201418
  const market = this.market(symbol);
201281
201419
  if (!market['spot']) {
@@ -201347,16 +201485,16 @@ class poloniex extends _abstract_poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
201347
201485
  }
201348
201486
  async cancelAllOrders(symbol = undefined, params = {}) {
201349
201487
  /**
201350
- * @method
201351
- * @name poloniex#cancelAllOrders
201352
- * @description cancel all open orders
201353
- * @see https://docs.poloniex.com/#authenticated-endpoints-orders-cancel-all-orders
201354
- * @see https://docs.poloniex.com/#authenticated-endpoints-smart-orders-cancel-all-orders // trigger orders
201355
- * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
201356
- * @param {object} [params] extra parameters specific to the exchange API endpoint
201357
- * @param {boolean} [params.trigger] true if canceling trigger orders
201358
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
201359
- */
201488
+ * @method
201489
+ * @name poloniex#cancelAllOrders
201490
+ * @description cancel all open orders
201491
+ * @see https://docs.poloniex.com/#authenticated-endpoints-orders-cancel-all-orders
201492
+ * @see https://docs.poloniex.com/#authenticated-endpoints-smart-orders-cancel-all-orders // trigger orders
201493
+ * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
201494
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
201495
+ * @param {boolean} [params.trigger] true if canceling trigger orders
201496
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
201497
+ */
201360
201498
  await this.loadMarkets();
201361
201499
  const request = {
201362
201500
  // 'accountTypes': 'SPOT',
@@ -201399,17 +201537,17 @@ class poloniex extends _abstract_poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
201399
201537
  }
201400
201538
  async fetchOrder(id, symbol = undefined, params = {}) {
201401
201539
  /**
201402
- * @method
201403
- * @name poloniex#fetchOrder
201404
- * @description fetch an order by it's id
201405
- * @see https://docs.poloniex.com/#authenticated-endpoints-orders-order-details
201406
- * @see https://docs.poloniex.com/#authenticated-endpoints-smart-orders-open-orders // trigger orders
201407
- * @param {string} id order id
201408
- * @param {string} symbol unified market symbol, default is undefined
201409
- * @param {object} [params] extra parameters specific to the exchange API endpoint
201410
- * @param {boolean} [params.trigger] true if fetching a trigger order
201411
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
201412
- */
201540
+ * @method
201541
+ * @name poloniex#fetchOrder
201542
+ * @description fetch an order by it's id
201543
+ * @see https://docs.poloniex.com/#authenticated-endpoints-orders-order-details
201544
+ * @see https://docs.poloniex.com/#authenticated-endpoints-smart-orders-open-orders // trigger orders
201545
+ * @param {string} id order id
201546
+ * @param {string} symbol unified market symbol, default is undefined
201547
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
201548
+ * @param {boolean} [params.trigger] true if fetching a trigger order
201549
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
201550
+ */
201413
201551
  await this.loadMarkets();
201414
201552
  id = id.toString();
201415
201553
  const request = {
@@ -202292,7 +202430,7 @@ class poloniex extends _abstract_poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
202292
202430
  // ---------------------------------------------------------------------------
202293
202431
  /**
202294
202432
  * @class poloniexfutures
202295
- * @extends Exchange
202433
+ * @augments Exchange
202296
202434
  */
202297
202435
  class poloniexfutures extends _abstract_poloniexfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
202298
202436
  describe() {
@@ -211682,7 +211820,7 @@ class bitfinex2 extends _bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
211682
211820
  // ---------------------------------------------------------------------------
211683
211821
  /**
211684
211822
  * @class bitget
211685
- * @extends Exchange
211823
+ * @augments Exchange
211686
211824
  * @description watching delivery future markets is not yet implemented (perpertual future / swap is implemented)
211687
211825
  */
211688
211826
  class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
@@ -213368,12 +213506,14 @@ class bitget extends _bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
213368
213506
  /* harmony import */ var _bitmart_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3718);
213369
213507
  /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6689);
213370
213508
  /* harmony import */ var _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3020);
213371
- /* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1372);
213509
+ /* harmony import */ var _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1372);
213510
+ /* harmony import */ var _base_ws_OrderBookSide_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(416);
213372
213511
  // ---------------------------------------------------------------------------
213373
213512
 
213374
213513
 
213375
213514
 
213376
213515
 
213516
+
213377
213517
  // ---------------------------------------------------------------------------
213378
213518
  class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
213379
213519
  describe() {
@@ -213387,24 +213527,38 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213387
213527
  'cancelOrdersWs': false,
213388
213528
  'cancelAllOrdersWs': false,
213389
213529
  'ws': true,
213530
+ 'watchBalance': true,
213390
213531
  'watchTicker': true,
213532
+ 'watchTickers': true,
213391
213533
  'watchOrderBook': true,
213392
213534
  'watchOrders': true,
213393
213535
  'watchTrades': true,
213394
213536
  'watchOHLCV': true,
213537
+ 'watchPosition': 'emulated',
213538
+ 'watchPositions': true,
213395
213539
  },
213396
213540
  'urls': {
213397
213541
  'api': {
213398
213542
  'ws': {
213399
- 'public': 'wss://ws-manager-compress.{hostname}/api?protocol=1.1',
213400
- 'private': 'wss://ws-manager-compress.{hostname}/user?protocol=1.1',
213543
+ 'spot': {
213544
+ 'public': 'wss://ws-manager-compress.{hostname}/api?protocol=1.1',
213545
+ 'private': 'wss://ws-manager-compress.{hostname}/user?protocol=1.1',
213546
+ },
213547
+ 'swap': {
213548
+ 'public': 'wss://openapi-ws.{hostname}/api?protocol=1.1',
213549
+ 'private': 'wss://openapi-ws.{hostname}/user?protocol=1.1',
213550
+ },
213401
213551
  },
213402
213552
  },
213403
213553
  },
213404
213554
  'options': {
213405
213555
  'defaultType': 'spot',
213556
+ 'watchBalance': {
213557
+ 'fetchBalanceSnapshot': true,
213558
+ 'awaitBalanceSnapshot': true, // whether to wait for the balance snapshot before providing updates
213559
+ },
213406
213560
  'watchOrderBook': {
213407
- 'depth': 'depth5', // depth5, depth20, depth50
213561
+ 'depth': 'depth50', // depth5, depth20, depth50
213408
213562
  },
213409
213563
  'ws': {
213410
213564
  'inflate': true,
@@ -213430,33 +213584,166 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213430
213584
  },
213431
213585
  });
213432
213586
  }
213433
- async subscribe(channel, symbol, params = {}) {
213434
- await this.loadMarkets();
213587
+ async subscribe(channel, symbol, type, params = {}) {
213435
213588
  const market = this.market(symbol);
213436
- const url = this.implodeHostname(this.urls['api']['ws']['public']);
213437
- const messageHash = market['type'] + '/' + channel + ':' + market['id'];
213438
- const request = {
213439
- 'op': 'subscribe',
213440
- 'args': [messageHash],
213441
- };
213589
+ const url = this.implodeHostname(this.urls['api']['ws'][type]['public']);
213590
+ let request = {};
213591
+ let messageHash = undefined;
213592
+ if (type === 'spot') {
213593
+ messageHash = 'spot/' + channel + ':' + market['id'];
213594
+ request = {
213595
+ 'op': 'subscribe',
213596
+ 'args': [messageHash],
213597
+ };
213598
+ }
213599
+ else {
213600
+ messageHash = 'futures/' + channel + ':' + market['id'];
213601
+ request = {
213602
+ 'action': 'subscribe',
213603
+ 'args': [messageHash],
213604
+ };
213605
+ }
213442
213606
  return await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
213443
213607
  }
213444
- async subscribePrivate(channel, symbol, params = {}) {
213608
+ async watchBalance(params = {}) {
213609
+ /**
213610
+ * @method
213611
+ * @name bitmart#watchBalance
213612
+ * @see https://developer-pro.bitmart.com/en/spot/#private-balance-change
213613
+ * @see https://developer-pro.bitmart.com/en/futures/#private-assets-channel
213614
+ * @description watch balance and get the amount of funds available for trading or funds locked in orders
213615
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
213616
+ * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
213617
+ */
213445
213618
  await this.loadMarkets();
213446
- const market = this.market(symbol);
213447
- const url = this.implodeHostname(this.urls['api']['ws']['private']);
213448
- const messageHash = channel + ':' + market['id'];
213449
- await this.authenticate();
213450
- const request = {
213451
- 'op': 'subscribe',
213452
- 'args': [messageHash],
213453
- };
213619
+ let type = 'spot';
213620
+ [type, params] = this.handleMarketTypeAndParams('watchBalance', undefined, params);
213621
+ await this.authenticate(type, params);
213622
+ let request = {};
213623
+ if (type === 'spot') {
213624
+ request = {
213625
+ 'op': 'subscribe',
213626
+ 'args': ['spot/user/balance:BALANCE_UPDATE'],
213627
+ };
213628
+ }
213629
+ else {
213630
+ request = {
213631
+ 'action': 'subscribe',
213632
+ 'args': ['futures/asset:USDT', 'futures/asset:BTC', 'futures/asset:ETH'],
213633
+ };
213634
+ }
213635
+ const messageHash = 'balance:' + type;
213636
+ const url = this.implodeHostname(this.urls['api']['ws'][type]['private']);
213637
+ const client = this.client(url);
213638
+ this.setBalanceCache(client, type);
213639
+ const fetchBalanceSnapshot = this.handleOptionAndParams(this.options, 'watchBalance', 'fetchBalanceSnapshot', true);
213640
+ const awaitBalanceSnapshot = this.handleOptionAndParams(this.options, 'watchBalance', 'awaitBalanceSnapshot', false);
213641
+ if (fetchBalanceSnapshot && awaitBalanceSnapshot) {
213642
+ await client.future(type + ':fetchBalanceSnapshot');
213643
+ }
213454
213644
  return await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
213455
213645
  }
213646
+ setBalanceCache(client, type) {
213647
+ if (type in client.subscriptions) {
213648
+ return undefined;
213649
+ }
213650
+ const options = this.safeValue(this.options, 'watchBalance');
213651
+ const fetchBalanceSnapshot = this.handleOptionAndParams(options, 'watchBalance', 'fetchBalanceSnapshot', true);
213652
+ if (fetchBalanceSnapshot) {
213653
+ const messageHash = type + ':fetchBalanceSnapshot';
213654
+ if (!(messageHash in client.futures)) {
213655
+ client.future(messageHash);
213656
+ this.spawn(this.loadBalanceSnapshot, client, messageHash, type);
213657
+ }
213658
+ }
213659
+ else {
213660
+ this.balance[type] = {};
213661
+ }
213662
+ }
213663
+ async loadBalanceSnapshot(client, messageHash, type) {
213664
+ const response = await this.fetchBalance({ 'type': type });
213665
+ this.balance[type] = this.extend(response, this.safeValue(this.balance, type, {}));
213666
+ // don't remove the future from the .futures cache
213667
+ const future = client.futures[messageHash];
213668
+ future.resolve();
213669
+ client.resolve(this.balance[type], 'balance:' + type);
213670
+ }
213671
+ handleBalance(client, message) {
213672
+ //
213673
+ // spot
213674
+ // {
213675
+ // "data":[
213676
+ // {
213677
+ // "balance_details":[
213678
+ // {
213679
+ // "av_bal":"0.206000000000000000000000000000",
213680
+ // "ccy":"LTC",
213681
+ // "fz_bal":"0.100000000000000000000000000000"
213682
+ // }
213683
+ // ],
213684
+ // "event_time":"1701632345415",
213685
+ // "event_type":"TRANSACTION_COMPLETED"
213686
+ // }
213687
+ // ],
213688
+ // "table":"spot/user/balance"
213689
+ // }
213690
+ // swap
213691
+ // {
213692
+ // group: 'futures/asset:USDT',
213693
+ // data: {
213694
+ // currency: 'USDT',
213695
+ // available_balance: '37.19688649135',
213696
+ // position_deposit: '0.788687546',
213697
+ // frozen_balance: '0'
213698
+ // }
213699
+ // }
213700
+ //
213701
+ const channel = this.safeString2(message, 'table', 'group');
213702
+ const data = this.safeValue(message, 'data');
213703
+ if (data === undefined) {
213704
+ return;
213705
+ }
213706
+ const isSpot = (channel.indexOf('spot') >= 0);
213707
+ const type = isSpot ? 'spot' : 'swap';
213708
+ this.balance['info'] = message;
213709
+ if (isSpot) {
213710
+ if (!Array.isArray(data)) {
213711
+ return;
213712
+ }
213713
+ for (let i = 0; i < data.length; i++) {
213714
+ const timestamp = this.safeInteger(message, 'event_time');
213715
+ this.balance['timestamp'] = timestamp;
213716
+ this.balance['datetime'] = this.iso8601(timestamp);
213717
+ const balanceDetails = this.safeValue(data[i], 'balance_details', []);
213718
+ for (let ii = 0; ii < balanceDetails.length; ii++) {
213719
+ const rawBalance = balanceDetails[i];
213720
+ const account = this.account();
213721
+ const currencyId = this.safeString(rawBalance, 'ccy');
213722
+ const code = this.safeCurrencyCode(currencyId);
213723
+ account['free'] = this.safeString(rawBalance, 'av_bal');
213724
+ account['total'] = this.safeString(rawBalance, 'fz_bal');
213725
+ this.balance[code] = account;
213726
+ }
213727
+ }
213728
+ }
213729
+ else {
213730
+ const currencyId = this.safeString(data, 'currency');
213731
+ const code = this.safeCurrencyCode(currencyId);
213732
+ const account = this.account();
213733
+ account['free'] = this.safeString(data, 'available_balance');
213734
+ account['used'] = this.safeString(data, 'frozen_balance');
213735
+ this.balance[type][code] = account;
213736
+ }
213737
+ this.balance[type] = this.safeBalance(this.balance[type]);
213738
+ const messageHash = 'balance:' + type;
213739
+ client.resolve(this.balance[type], messageHash);
213740
+ }
213456
213741
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
213457
213742
  /**
213458
213743
  * @method
213459
213744
  * @name bitmart#watchTrades
213745
+ * @see https://developer-pro.bitmart.com/en/spot/#public-trade-channel
213746
+ * @see https://developer-pro.bitmart.com/en/futures/#public-trade-channel
213460
213747
  * @description get the list of most recent trades for a particular symbol
213461
213748
  * @param {string} symbol unified symbol of the market to fetch trades for
213462
213749
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
@@ -213466,7 +213753,10 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213466
213753
  */
213467
213754
  await this.loadMarkets();
213468
213755
  symbol = this.symbol(symbol);
213469
- const trades = await this.subscribe('trade', symbol, params);
213756
+ const market = this.market(symbol);
213757
+ let type = 'spot';
213758
+ [type, params] = this.handleMarketTypeAndParams('watchTrades', market, params);
213759
+ const trades = await this.subscribe('trade', symbol, type, params);
213470
213760
  if (this.newUpdates) {
213471
213761
  limit = trades.getLimit(symbol, limit);
213472
213762
  }
@@ -213476,17 +213766,64 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213476
213766
  /**
213477
213767
  * @method
213478
213768
  * @name bitmart#watchTicker
213769
+ * @see https://developer-pro.bitmart.com/en/spot/#public-ticker-channel
213479
213770
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
213480
213771
  * @param {string} symbol unified symbol of the market to fetch the ticker for
213481
213772
  * @param {object} [params] extra parameters specific to the exchange API endpoint
213482
213773
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
213483
213774
  */
213484
- return await this.subscribe('ticker', symbol, params);
213775
+ await this.loadMarkets();
213776
+ symbol = this.symbol(symbol);
213777
+ const market = this.market(symbol);
213778
+ let type = 'spot';
213779
+ [type, params] = this.handleMarketTypeAndParams('watchTicker', market, params);
213780
+ if (type === 'swap') {
213781
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' watchTicker() does not support ' + type + ' markets. Use watchTickers() instead');
213782
+ }
213783
+ return await this.subscribe('ticker', symbol, type, params);
213784
+ }
213785
+ async watchTickers(symbols = undefined, params = {}) {
213786
+ /**
213787
+ * @method
213788
+ * @name bitmart#watchTickers
213789
+ * @see https://developer-pro.bitmart.com/en/futures/#overview
213790
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
213791
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
213792
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
213793
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
213794
+ */
213795
+ await this.loadMarkets();
213796
+ const market = this.getMarketFromSymbols(symbols);
213797
+ let type = 'spot';
213798
+ [type, params] = this.handleMarketTypeAndParams('watchTickers', market, params);
213799
+ symbols = this.marketSymbols(symbols);
213800
+ if (type === 'spot') {
213801
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' watchTickers() does not support ' + type + ' markets. Use watchTicker() instead');
213802
+ }
213803
+ const url = this.implodeHostname(this.urls['api']['ws'][type]['public']);
213804
+ if (type === 'swap') {
213805
+ type = 'futures';
213806
+ }
213807
+ let messageHash = 'tickers';
213808
+ if (symbols !== undefined) {
213809
+ messageHash += '::' + symbols.join(',');
213810
+ }
213811
+ const request = {
213812
+ 'action': 'subscribe',
213813
+ 'args': ['futures/ticker'],
213814
+ };
213815
+ const newTickers = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
213816
+ if (this.newUpdates) {
213817
+ return newTickers;
213818
+ }
213819
+ return this.filterByArray(this.tickers, 'symbol', symbols);
213485
213820
  }
213486
213821
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
213487
213822
  /**
213488
213823
  * @method
213489
213824
  * @name bitmart#watchOrders
213825
+ * @see https://developer-pro.bitmart.com/en/spot/#private-order-channel
213826
+ * @see https://developer-pro.bitmart.com/en/futures/#private-order-channel
213490
213827
  * @description watches information on multiple orders made by the user
213491
213828
  * @param {string} symbol unified market symbol of the market orders were made in
213492
213829
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -213494,196 +213831,626 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213494
213831
  * @param {object} [params] extra parameters specific to the exchange API endpoint
213495
213832
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
213496
213833
  */
213497
- if (symbol === undefined) {
213498
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchOrders() requires a symbol argument');
213499
- }
213500
213834
  await this.loadMarkets();
213501
- const market = this.market(symbol);
213502
- symbol = market['symbol'];
213503
- if (market['type'] !== 'spot') {
213504
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchOrders supports spot markets only');
213835
+ let market = undefined;
213836
+ let messageHash = 'orders';
213837
+ if (symbol !== undefined) {
213838
+ symbol = this.symbol(symbol);
213839
+ market = this.market(symbol);
213840
+ messageHash = 'orders::' + symbol;
213841
+ }
213842
+ let type = 'spot';
213843
+ [type, params] = this.handleMarketTypeAndParams('watchOrders', market, params);
213844
+ await this.authenticate(type, params);
213845
+ let request = undefined;
213846
+ if (type === 'spot') {
213847
+ if (symbol === undefined) {
213848
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' watchOrders() requires a symbol argument for spot markets');
213849
+ }
213850
+ request = {
213851
+ 'op': 'subscribe',
213852
+ 'args': ['spot/user/order:' + market['id']],
213853
+ };
213854
+ }
213855
+ else {
213856
+ request = {
213857
+ 'action': 'subscribe',
213858
+ 'args': ['futures/order'],
213859
+ };
213505
213860
  }
213506
- const channel = 'spot/user/order';
213507
- const orders = await this.subscribePrivate(channel, symbol, params);
213861
+ const url = this.implodeHostname(this.urls['api']['ws'][type]['private']);
213862
+ const newOrders = await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
213508
213863
  if (this.newUpdates) {
213509
- limit = orders.getLimit(symbol, limit);
213864
+ return newOrders;
213510
213865
  }
213511
- return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
213866
+ return this.filterBySymbolSinceLimit(this.orders, symbol, since, limit, true);
213512
213867
  }
213513
213868
  handleOrders(client, message) {
213514
213869
  //
213515
- // {
213516
- // "data":[
213517
- // {
213518
- // "symbol": "LTC_USDT",
213519
- // "notional": '',
213520
- // "side": "buy",
213521
- // "last_fill_time": "0",
213522
- // "ms_t": "1646216634000",
213523
- // "type": "limit",
213524
- // "filled_notional": "0.000000000000000000000000000000",
213525
- // "last_fill_price": "0",
213526
- // "size": "0.500000000000000000000000000000",
213527
- // "price": "50.000000000000000000000000000000",
213528
- // "last_fill_count": "0",
213529
- // "filled_size": "0.000000000000000000000000000000",
213530
- // "margin_trading": "0",
213531
- // "state": "8",
213532
- // "order_id": "24807076628",
213533
- // "order_type": "0"
213870
+ // spot
213871
+ // {
213872
+ // "data":[
213873
+ // {
213874
+ // "symbol": "LTC_USDT",
213875
+ // "notional": '',
213876
+ // "side": "buy",
213877
+ // "last_fill_time": "0",
213878
+ // "ms_t": "1646216634000",
213879
+ // "type": "limit",
213880
+ // "filled_notional": "0.000000000000000000000000000000",
213881
+ // "last_fill_price": "0",
213882
+ // "size": "0.500000000000000000000000000000",
213883
+ // "price": "50.000000000000000000000000000000",
213884
+ // "last_fill_count": "0",
213885
+ // "filled_size": "0.000000000000000000000000000000",
213886
+ // "margin_trading": "0",
213887
+ // "state": "8",
213888
+ // "order_id": "24807076628",
213889
+ // "order_type": "0"
213890
+ // }
213891
+ // ],
213892
+ // "table":"spot/user/order"
213893
+ // }
213894
+ // swap
213895
+ // {
213896
+ // "group":"futures/order",
213897
+ // "data":[
213898
+ // {
213899
+ // "action":2,
213900
+ // "order":{
213901
+ // "order_id":"2312045036986775",
213902
+ // "client_order_id":"",
213903
+ // "price":"71.61707928",
213904
+ // "size":"1",
213905
+ // "symbol":"LTCUSDT",
213906
+ // "state":1,
213907
+ // "side":4,
213908
+ // "type":"market",
213909
+ // "leverage":"1",
213910
+ // "open_type":"cross",
213911
+ // "deal_avg_price":"0",
213912
+ // "deal_size":"0",
213913
+ // "create_time":1701625324646,
213914
+ // "update_time":1701625324640,
213915
+ // "plan_order_id":"",
213916
+ // "last_trade":null
213917
+ // }
213534
213918
  // }
213535
- // ],
213536
- // "table":"spot/user/order"
213537
- // }
213919
+ // ]
213920
+ // }
213538
213921
  //
213539
- const channel = this.safeString(message, 'table');
213540
- const orders = this.safeValue(message, 'data', []);
213922
+ const orders = this.safeValue(message, 'data');
213923
+ if (orders === undefined) {
213924
+ return;
213925
+ }
213541
213926
  const ordersLength = orders.length;
213927
+ const newOrders = [];
213928
+ const symbols = {};
213542
213929
  if (ordersLength > 0) {
213543
213930
  const limit = this.safeInteger(this.options, 'ordersLimit', 1000);
213544
213931
  if (this.orders === undefined) {
213545
213932
  this.orders = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolById */ .hl(limit);
213546
213933
  }
213547
213934
  const stored = this.orders;
213548
- const marketIds = [];
213549
213935
  for (let i = 0; i < orders.length; i++) {
213550
213936
  const order = this.parseWsOrder(orders[i]);
213551
213937
  stored.append(order);
213938
+ newOrders.push(order);
213552
213939
  const symbol = order['symbol'];
213553
- const market = this.market(symbol);
213554
- marketIds.push(market['id']);
213555
- }
213556
- for (let i = 0; i < marketIds.length; i++) {
213557
- const messageHash = channel + ':' + marketIds[i];
213558
- client.resolve(this.orders, messageHash);
213940
+ symbols[symbol] = true;
213559
213941
  }
213560
213942
  }
213943
+ const newOrderSymbols = Object.keys(symbols);
213944
+ for (let i = 0; i < newOrderSymbols.length; i++) {
213945
+ const symbol = newOrderSymbols[i];
213946
+ this.resolvePromiseIfMessagehashMatches(client, 'orders::', symbol, newOrders);
213947
+ }
213948
+ client.resolve(newOrders, 'orders');
213561
213949
  }
213562
213950
  parseWsOrder(order, market = undefined) {
213563
213951
  //
213564
- // {
213565
- // "symbol": "LTC_USDT",
213566
- // "notional": '',
213567
- // "side": "buy",
213568
- // "last_fill_time": "0",
213569
- // "ms_t": "1646216634000",
213570
- // "type": "limit",
213571
- // "filled_notional": "0.000000000000000000000000000000",
213572
- // "last_fill_price": "0",
213573
- // "size": "0.500000000000000000000000000000",
213574
- // "price": "50.000000000000000000000000000000",
213575
- // "last_fill_count": "0",
213576
- // "filled_size": "0.000000000000000000000000000000",
213577
- // "margin_trading": "0",
213578
- // "state": "8",
213579
- // "order_id": "24807076628",
213580
- // "order_type": "0"
213581
- // }
213952
+ // spot
213953
+ // {
213954
+ // "symbol": "LTC_USDT",
213955
+ // "notional": '',
213956
+ // "side": "buy",
213957
+ // "last_fill_time": "0",
213958
+ // "ms_t": "1646216634000",
213959
+ // "type": "limit",
213960
+ // "filled_notional": "0.000000000000000000000000000000",
213961
+ // "last_fill_price": "0",
213962
+ // "size": "0.500000000000000000000000000000",
213963
+ // "price": "50.000000000000000000000000000000",
213964
+ // "last_fill_count": "0",
213965
+ // "filled_size": "0.000000000000000000000000000000",
213966
+ // "margin_trading": "0",
213967
+ // "state": "8",
213968
+ // "order_id": "24807076628",
213969
+ // "order_type": "0"
213970
+ // }
213971
+ // swap
213972
+ // {
213973
+ // "action":2,
213974
+ // "order":{
213975
+ // "order_id":"2312045036986775",
213976
+ // "client_order_id":"",
213977
+ // "price":"71.61707928",
213978
+ // "size":"1",
213979
+ // "symbol":"LTCUSDT",
213980
+ // "state":1,
213981
+ // "side":4,
213982
+ // "type":"market",
213983
+ // "leverage":"1",
213984
+ // "open_type":"cross",
213985
+ // "deal_avg_price":"0",
213986
+ // "deal_size":"0",
213987
+ // "create_time":1701625324646,
213988
+ // "update_time":1701625324640,
213989
+ // "plan_order_id":"",
213990
+ // "last_trade":null
213991
+ // }
213992
+ // }
213582
213993
  //
213583
- const marketId = this.safeString(order, 'symbol');
213584
- market = this.safeMarket(marketId, market);
213585
- const id = this.safeString(order, 'order_id');
213586
- const clientOrderId = this.safeString(order, 'clientOid');
213587
- const price = this.safeString(order, 'price');
213588
- const filled = this.safeString(order, 'filled_size');
213589
- const amount = this.safeString(order, 'size');
213590
- const type = this.safeString(order, 'type');
213591
- const rawState = this.safeString(order, 'state');
213592
- const status = this.parseOrderStatusByType(market['type'], rawState);
213593
- const timestamp = this.safeInteger(order, 'ms_t');
213994
+ const action = this.safeNumber(order, 'action');
213995
+ const isSpot = (action === undefined);
213996
+ if (isSpot) {
213997
+ const marketId = this.safeString(order, 'symbol');
213998
+ market = this.safeMarket(marketId, market, '_', 'spot');
213999
+ const id = this.safeString(order, 'order_id');
214000
+ const clientOrderId = this.safeString(order, 'clientOid');
214001
+ const price = this.safeString(order, 'price');
214002
+ const filled = this.safeString(order, 'filled_size');
214003
+ const amount = this.safeString(order, 'size');
214004
+ const type = this.safeString(order, 'type');
214005
+ const rawState = this.safeString(order, 'state');
214006
+ const status = this.parseOrderStatusByType(market['type'], rawState);
214007
+ const timestamp = this.safeInteger(order, 'ms_t');
214008
+ const symbol = market['symbol'];
214009
+ const side = this.safeStringLower(order, 'side');
214010
+ return this.safeOrder({
214011
+ 'info': order,
214012
+ 'symbol': symbol,
214013
+ 'id': id,
214014
+ 'clientOrderId': clientOrderId,
214015
+ 'timestamp': undefined,
214016
+ 'datetime': undefined,
214017
+ 'lastTradeTimestamp': timestamp,
214018
+ 'type': type,
214019
+ 'timeInForce': undefined,
214020
+ 'postOnly': undefined,
214021
+ 'side': side,
214022
+ 'price': price,
214023
+ 'stopPrice': undefined,
214024
+ 'triggerPrice': undefined,
214025
+ 'amount': amount,
214026
+ 'cost': undefined,
214027
+ 'average': undefined,
214028
+ 'filled': filled,
214029
+ 'remaining': undefined,
214030
+ 'status': status,
214031
+ 'fee': undefined,
214032
+ 'trades': undefined,
214033
+ }, market);
214034
+ }
214035
+ else {
214036
+ const orderInfo = this.safeValue(order, 'order');
214037
+ const marketId = this.safeString(orderInfo, 'symbol');
214038
+ const symbol = this.safeSymbol(marketId, market, '', 'swap');
214039
+ const orderId = this.safeString(orderInfo, 'order_id');
214040
+ const timestamp = this.safeInteger(orderInfo, 'create_time');
214041
+ const updatedTimestamp = this.safeInteger(orderInfo, 'update_time');
214042
+ const lastTrade = this.safeValue(orderInfo, 'last_trade');
214043
+ const cachedOrders = this.orders;
214044
+ const orders = this.safeValue(cachedOrders.hashmap, symbol, {});
214045
+ const cachedOrder = this.safeValue(orders, orderId);
214046
+ let trades = undefined;
214047
+ if (cachedOrder !== undefined) {
214048
+ trades = this.safeValue(order, 'trades');
214049
+ }
214050
+ if (lastTrade !== undefined) {
214051
+ if (trades === undefined) {
214052
+ trades = [];
214053
+ }
214054
+ trades.push(lastTrade);
214055
+ }
214056
+ return this.safeOrder({
214057
+ 'info': order,
214058
+ 'symbol': symbol,
214059
+ 'id': orderId,
214060
+ 'clientOrderId': this.safeString(orderInfo, 'client_order_id'),
214061
+ 'timestamp': timestamp,
214062
+ 'datetime': this.iso8601(timestamp),
214063
+ 'lastTradeTimestamp': updatedTimestamp,
214064
+ 'type': this.safeString(orderInfo, 'type'),
214065
+ 'timeInForce': undefined,
214066
+ 'postOnly': undefined,
214067
+ 'side': this.parseWsOrderSide(this.safeString(orderInfo, 'side')),
214068
+ 'price': this.safeString(orderInfo, 'price'),
214069
+ 'stopPrice': undefined,
214070
+ 'triggerPrice': undefined,
214071
+ 'amount': this.safeString(orderInfo, 'size'),
214072
+ 'cost': undefined,
214073
+ 'average': this.safeString(orderInfo, 'deal_avg_price'),
214074
+ 'filled': this.safeString(orderInfo, 'deal_size'),
214075
+ 'remaining': undefined,
214076
+ 'status': this.parseWsOrderStatus(this.safeString(order, 'action')),
214077
+ 'fee': undefined,
214078
+ 'trades': trades,
214079
+ }, market);
214080
+ }
214081
+ }
214082
+ parseWsOrderStatus(statusId) {
214083
+ const statuses = {
214084
+ '1': 'closed',
214085
+ '2': 'open',
214086
+ '3': 'canceled',
214087
+ '4': 'closed',
214088
+ '5': 'canceled',
214089
+ '6': 'open',
214090
+ '7': 'open',
214091
+ '8': 'closed',
214092
+ '9': 'closed', // active adl match deal
214093
+ };
214094
+ return this.safeString(statuses, statusId, statusId);
214095
+ }
214096
+ parseWsOrderSide(sideId) {
214097
+ const sides = {
214098
+ '1': 'buy',
214099
+ '2': 'buy',
214100
+ '3': 'sell',
214101
+ '4': 'sell', // sell_open_short
214102
+ };
214103
+ return this.safeString(sides, sideId, sideId);
214104
+ }
214105
+ async watchPositions(symbols = undefined, since = undefined, limit = undefined, params = {}) {
214106
+ /**
214107
+ * @method
214108
+ * @name bitmart#watchPositions
214109
+ * @see https://developer-pro.bitmart.com/en/futures/#private-position-channel
214110
+ * @description watch all open positions
214111
+ * @param {string[]|undefined} symbols list of unified market symbols
214112
+ * @param {object} params extra parameters specific to the exchange API endpoint
214113
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
214114
+ */
214115
+ await this.loadMarkets();
214116
+ const type = 'swap';
214117
+ await this.authenticate(type, params);
214118
+ symbols = this.marketSymbols(symbols, 'swap', true, true, false);
214119
+ let messageHash = 'positions';
214120
+ if (symbols !== undefined) {
214121
+ messageHash += '::' + symbols.join(',');
214122
+ }
214123
+ const subscriptionHash = 'futures/position';
214124
+ const request = {
214125
+ 'action': 'subscribe',
214126
+ 'args': ['futures/position'],
214127
+ };
214128
+ const url = this.implodeHostname(this.urls['api']['ws'][type]['private']);
214129
+ const newPositions = await this.watch(url, messageHash, this.deepExtend(request, params), subscriptionHash);
214130
+ if (this.newUpdates) {
214131
+ return newPositions;
214132
+ }
214133
+ return this.filterBySymbolsSinceLimit(this.positions, symbols, since, limit);
214134
+ }
214135
+ handlePositions(client, message) {
214136
+ //
214137
+ // {
214138
+ // "group":"futures/position",
214139
+ // "data":[
214140
+ // {
214141
+ // "symbol":"LTCUSDT",
214142
+ // "hold_volume":"5",
214143
+ // "position_type":2,
214144
+ // "open_type":2,
214145
+ // "frozen_volume":"0",
214146
+ // "close_volume":"0",
214147
+ // "hold_avg_price":"71.582",
214148
+ // "close_avg_price":"0",
214149
+ // "open_avg_price":"71.582",
214150
+ // "liquidate_price":"0",
214151
+ // "create_time":1701623327513,
214152
+ // "update_time":1701627620439
214153
+ // },
214154
+ // {
214155
+ // "symbol":"LTCUSDT",
214156
+ // "hold_volume":"6",
214157
+ // "position_type":1,
214158
+ // "open_type":2,
214159
+ // "frozen_volume":"0",
214160
+ // "close_volume":"0",
214161
+ // "hold_avg_price":"71.681666666666666667",
214162
+ // "close_avg_price":"0",
214163
+ // "open_avg_price":"71.681666666666666667",
214164
+ // "liquidate_price":"0",
214165
+ // "create_time":1701621167225,
214166
+ // "update_time":1701628152614
214167
+ // }
214168
+ // ]
214169
+ // }
214170
+ //
214171
+ const data = this.safeValue(message, 'data', []);
214172
+ const cache = this.positions;
214173
+ if (this.positions === undefined) {
214174
+ this.positions = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolBySide */ .tU();
214175
+ }
214176
+ const newPositions = [];
214177
+ for (let i = 0; i < data.length; i++) {
214178
+ const rawPosition = data[i];
214179
+ const position = this.parseWsPosition(rawPosition);
214180
+ newPositions.push(position);
214181
+ cache.append(position);
214182
+ }
214183
+ const messageHashes = this.findMessageHashes(client, 'positions::');
214184
+ for (let i = 0; i < messageHashes.length; i++) {
214185
+ const messageHash = messageHashes[i];
214186
+ const parts = messageHash.split('::');
214187
+ const symbolsString = parts[1];
214188
+ const symbols = symbolsString.split(',');
214189
+ const positions = this.filterByArray(newPositions, 'symbol', symbols, false);
214190
+ if (!this.isEmpty(positions)) {
214191
+ client.resolve(positions, messageHash);
214192
+ }
214193
+ }
214194
+ client.resolve(newPositions, 'positions');
214195
+ }
214196
+ parseWsPosition(position, market = undefined) {
214197
+ //
214198
+ // {
214199
+ // "symbol":"LTCUSDT",
214200
+ // "hold_volume":"6",
214201
+ // "position_type":1,
214202
+ // "open_type":2,
214203
+ // "frozen_volume":"0",
214204
+ // "close_volume":"0",
214205
+ // "hold_avg_price":"71.681666666666666667",
214206
+ // "close_avg_price":"0",
214207
+ // "open_avg_price":"71.681666666666666667",
214208
+ // "liquidate_price":"0",
214209
+ // "create_time":1701621167225,
214210
+ // "update_time":1701628152614
214211
+ // }
214212
+ //
214213
+ const marketId = this.safeString(position, 'symbol');
214214
+ market = this.safeMarket(marketId, market, '', 'swap');
213594
214215
  const symbol = market['symbol'];
213595
- const side = this.safeStringLower(order, 'side');
213596
- return this.safeOrder({
213597
- 'info': order,
214216
+ const openTimestamp = this.safeInteger(position, 'create_time');
214217
+ const timestamp = this.safeInteger(position, 'update_time');
214218
+ const side = this.safeNumber(position, 'position_type');
214219
+ const marginModeId = this.safeNumber(position, 'open_type');
214220
+ return this.safePosition({
214221
+ 'info': position,
214222
+ 'id': undefined,
213598
214223
  'symbol': symbol,
213599
- 'id': id,
213600
- 'clientOrderId': clientOrderId,
213601
- 'timestamp': undefined,
213602
- 'datetime': undefined,
213603
- 'lastTradeTimestamp': timestamp,
213604
- 'type': type,
213605
- 'timeInForce': undefined,
213606
- 'postOnly': undefined,
213607
- 'side': side,
213608
- 'price': price,
213609
- 'stopPrice': undefined,
213610
- 'triggerPrice': undefined,
213611
- 'amount': amount,
213612
- 'cost': undefined,
213613
- 'average': undefined,
213614
- 'filled': filled,
213615
- 'remaining': undefined,
213616
- 'status': status,
213617
- 'fee': undefined,
213618
- 'trades': undefined,
213619
- }, market);
214224
+ 'timestamp': openTimestamp,
214225
+ 'datetime': this.iso8601(openTimestamp),
214226
+ 'lastUpdateTimestamp': timestamp,
214227
+ 'hedged': undefined,
214228
+ 'side': (side === 1) ? 'long' : 'short',
214229
+ 'contracts': this.safeNumber(position, 'hold_volume'),
214230
+ 'contractSize': this.safeNumber(market, 'contractSize'),
214231
+ 'entryPrice': this.safeNumber(position, 'open_avg_price'),
214232
+ 'markPrice': this.safeNumber(position, 'hold_avg_price'),
214233
+ 'lastPrice': undefined,
214234
+ 'notional': undefined,
214235
+ 'leverage': undefined,
214236
+ 'collateral': undefined,
214237
+ 'initialMargin': undefined,
214238
+ 'initialMarginPercentage': undefined,
214239
+ 'maintenanceMargin': undefined,
214240
+ 'maintenanceMarginPercentage': undefined,
214241
+ 'unrealizedPnl': undefined,
214242
+ 'realizedPnl': undefined,
214243
+ 'liquidationPrice': this.safeNumber(position, 'liquidate_price'),
214244
+ 'marginMode': (marginModeId === 1) ? 'isolated' : 'cross',
214245
+ 'percentage': undefined,
214246
+ 'marginRatio': undefined,
214247
+ 'stopLossPrice': undefined,
214248
+ 'takeProfitPrice': undefined,
214249
+ });
213620
214250
  }
213621
214251
  handleTrade(client, message) {
213622
214252
  //
213623
- // {
213624
- // "table": "spot/trade",
213625
- // "data": [
213626
- // {
213627
- // "price": "52700.50",
213628
- // "s_t": 1630982050,
213629
- // "side": "buy",
213630
- // "size": "0.00112",
213631
- // "symbol": "BTC_USDT"
213632
- // },
213633
- // ]
213634
- // }
214253
+ // spot
214254
+ // {
214255
+ // "table": "spot/trade",
214256
+ // "data": [
214257
+ // {
214258
+ // "price": "52700.50",
214259
+ // "s_t": 1630982050,
214260
+ // "side": "buy",
214261
+ // "size": "0.00112",
214262
+ // "symbol": "BTC_USDT"
214263
+ // },
214264
+ // ]
214265
+ // }
213635
214266
  //
213636
- const table = this.safeString(message, 'table');
213637
- const data = this.safeValue(message, 'data', []);
213638
- const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
214267
+ // swap
214268
+ // {
214269
+ // "group":"futures/trade:BTCUSDT",
214270
+ // "data":[
214271
+ // {
214272
+ // "trade_id":6798697637,
214273
+ // "contract_id":1,
214274
+ // "symbol":"BTCUSDT",
214275
+ // "deal_price":"39735.8",
214276
+ // "deal_vol":"2",
214277
+ // "type":0,
214278
+ // "way":1,
214279
+ // "create_time":1701618503,
214280
+ // "create_time_mill":1701618503517,
214281
+ // "created_at":"2023-12-03T15:48:23.517518538Z"
214282
+ // }
214283
+ // ]
214284
+ // }
214285
+ //
214286
+ const channel = this.safeString2(message, 'table', 'group');
214287
+ const isSpot = (channel.indexOf('spot') >= 0);
214288
+ const data = this.safeValue(message, 'data');
214289
+ if (data === undefined) {
214290
+ return;
214291
+ }
214292
+ let stored = undefined;
213639
214293
  for (let i = 0; i < data.length; i++) {
213640
- const trade = this.parseTrade(data[i]);
214294
+ const trade = this.parseWsTrade(data[i]);
213641
214295
  const symbol = trade['symbol'];
213642
- const marketId = this.safeString(trade['info'], 'symbol');
213643
- const messageHash = table + ':' + marketId;
213644
- let stored = this.safeValue(this.trades, symbol);
214296
+ const tradesLimit = this.safeInteger(this.options, 'tradesLimit', 1000);
214297
+ stored = this.safeValue(this.trades, symbol);
213645
214298
  if (stored === undefined) {
213646
214299
  stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCache */ .ZL(tradesLimit);
213647
214300
  this.trades[symbol] = stored;
213648
214301
  }
213649
214302
  stored.append(trade);
213650
- client.resolve(stored, messageHash);
213651
214303
  }
214304
+ let messageHash = channel;
214305
+ if (isSpot) {
214306
+ messageHash += ':' + this.safeString(data[0], 'symbol');
214307
+ }
214308
+ client.resolve(stored, messageHash);
213652
214309
  return message;
213653
214310
  }
214311
+ parseWsTrade(trade, market = undefined) {
214312
+ // spot
214313
+ // {
214314
+ // "price": "52700.50",
214315
+ // "s_t": 1630982050,
214316
+ // "side": "buy",
214317
+ // "size": "0.00112",
214318
+ // "symbol": "BTC_USDT"
214319
+ // }
214320
+ // swap
214321
+ // {
214322
+ // "trade_id":6798697637,
214323
+ // "contract_id":1,
214324
+ // "symbol":"BTCUSDT",
214325
+ // "deal_price":"39735.8",
214326
+ // "deal_vol":"2",
214327
+ // "type":0,
214328
+ // "way":1,
214329
+ // "create_time":1701618503,
214330
+ // "create_time_mill":1701618503517,
214331
+ // "created_at":"2023-12-03T15:48:23.517518538Z"
214332
+ // }
214333
+ //
214334
+ const contractId = this.safeString(trade, 'contract_id');
214335
+ const marketType = (contractId === undefined) ? 'spot' : 'swap';
214336
+ const marketDelimiter = (marketType === 'spot') ? '_' : '';
214337
+ const timestamp = this.safeInteger(trade, 'create_time_mill', this.safeTimestamp(trade, 's_t'));
214338
+ const marketId = this.safeString(trade, 'symbol');
214339
+ return this.safeTrade({
214340
+ 'info': trade,
214341
+ 'id': this.safeString(trade, 'trade_id'),
214342
+ 'order': undefined,
214343
+ 'timestamp': timestamp,
214344
+ 'datetime': this.iso8601(timestamp),
214345
+ 'symbol': this.safeSymbol(marketId, market, marketDelimiter, marketType),
214346
+ 'type': undefined,
214347
+ 'side': this.safeString(trade, 'side'),
214348
+ 'price': this.safeString2(trade, 'price', 'deal_price'),
214349
+ 'amount': this.safeString2(trade, 'size', 'deal_vol'),
214350
+ 'cost': undefined,
214351
+ 'takerOrMaker': undefined,
214352
+ 'fee': undefined,
214353
+ }, market);
214354
+ }
213654
214355
  handleTicker(client, message) {
213655
214356
  //
213656
- // {
213657
- // "data": [
213658
- // {
213659
- // "base_volume_24h": "78615593.81",
213660
- // "high_24h": "52756.97",
213661
- // "last_price": "52638.31",
213662
- // "low_24h": "50991.35",
213663
- // "open_24h": "51692.03",
213664
- // "s_t": 1630981727,
213665
- // "symbol": "BTC_USDT"
213666
- // }
213667
- // ],
213668
- // "table": "spot/ticker"
213669
- // }
214357
+ // {
214358
+ // "data": [
214359
+ // {
214360
+ // "base_volume_24h": "78615593.81",
214361
+ // "high_24h": "52756.97",
214362
+ // "last_price": "52638.31",
214363
+ // "low_24h": "50991.35",
214364
+ // "open_24h": "51692.03",
214365
+ // "s_t": 1630981727,
214366
+ // "symbol": "BTC_USDT"
214367
+ // }
214368
+ // ],
214369
+ // "table": "spot/ticker"
214370
+ // }
214371
+ // {
214372
+ // "group":"futures/ticker",
214373
+ // "data":{
214374
+ // "symbol":"BTCUSDT",
214375
+ // "volume_24":"117387.58",
214376
+ // "fair_price":"146.24",
214377
+ // "last_price":"146.24",
214378
+ // "range":"147.17",
214379
+ // "ask_price": "147.11",
214380
+ // "ask_vol": "1",
214381
+ // "bid_price": "142.11",
214382
+ // "bid_vol": "1"
214383
+ // }
214384
+ // }
213670
214385
  //
213671
214386
  const table = this.safeString(message, 'table');
213672
- const data = this.safeValue(message, 'data', []);
213673
- for (let i = 0; i < data.length; i++) {
213674
- const ticker = this.parseTicker(data[i]);
213675
- const symbol = ticker['symbol'];
213676
- const marketId = this.safeString(ticker['info'], 'symbol');
213677
- const messageHash = table + ':' + marketId;
214387
+ const isSpot = (table !== undefined);
214388
+ const data = this.safeValue(message, 'data');
214389
+ if (data === undefined) {
214390
+ return;
214391
+ }
214392
+ if (isSpot) {
214393
+ for (let i = 0; i < data.length; i++) {
214394
+ const ticker = this.parseTicker(data[i]);
214395
+ const symbol = ticker['symbol'];
214396
+ const marketId = this.safeString(ticker['info'], 'symbol');
214397
+ const messageHash = table + ':' + marketId;
214398
+ this.tickers[symbol] = ticker;
214399
+ client.resolve(ticker, messageHash);
214400
+ }
214401
+ }
214402
+ else {
214403
+ const ticker = this.parseWsSwapTicker(data);
214404
+ const symbol = this.safeString(ticker, 'symbol');
213678
214405
  this.tickers[symbol] = ticker;
213679
- client.resolve(ticker, messageHash);
214406
+ client.resolve(ticker, 'tickers');
214407
+ this.resolvePromiseIfMessagehashMatches(client, 'tickers::', symbol, ticker);
213680
214408
  }
213681
214409
  return message;
213682
214410
  }
214411
+ parseWsSwapTicker(ticker, market = undefined) {
214412
+ //
214413
+ // {
214414
+ // "symbol":"BTCUSDT",
214415
+ // "volume_24":"117387.58",
214416
+ // "fair_price":"146.24",
214417
+ // "last_price":"146.24",
214418
+ // "range":"147.17",
214419
+ // "ask_price": "147.11",
214420
+ // "ask_vol": "1",
214421
+ // "bid_price": "142.11",
214422
+ // "bid_vol": "1"
214423
+ // }
214424
+ const marketId = this.safeString(ticker, 'symbol');
214425
+ return this.safeTicker({
214426
+ 'symbol': this.safeSymbol(marketId, market, '', 'swap'),
214427
+ 'timestamp': undefined,
214428
+ 'datetime': undefined,
214429
+ 'high': undefined,
214430
+ 'low': undefined,
214431
+ 'bid': this.safeString(ticker, 'bid_price'),
214432
+ 'bidVolume': this.safeString(ticker, 'bid_vol'),
214433
+ 'ask': this.safeString(ticker, 'ask_price'),
214434
+ 'askVolume': this.safeString(ticker, 'ask_vol'),
214435
+ 'vwap': undefined,
214436
+ 'open': undefined,
214437
+ 'close': undefined,
214438
+ 'last': this.safeString(ticker, 'last_price'),
214439
+ 'previousClose': undefined,
214440
+ 'change': undefined,
214441
+ 'percentage': undefined,
214442
+ 'average': this.safeString(ticker, 'fair_price'),
214443
+ 'baseVolume': undefined,
214444
+ 'quoteVolume': this.safeString(ticker, 'volume_24'),
214445
+ 'info': ticker,
214446
+ }, market);
214447
+ }
213683
214448
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
213684
214449
  /**
213685
214450
  * @method
213686
214451
  * @name bitmart#watchOHLCV
214452
+ * @see https://developer-pro.bitmart.com/en/spot/#public-kline-channel
214453
+ * @see https://developer-pro.bitmart.com/en/futures/#public-klinebin-channel
213687
214454
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
213688
214455
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
213689
214456
  * @param {string} timeframe the length of time each candle represents
@@ -213694,10 +214461,19 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213694
214461
  */
213695
214462
  await this.loadMarkets();
213696
214463
  symbol = this.symbol(symbol);
214464
+ const market = this.market(symbol);
214465
+ let type = 'spot';
214466
+ [type, params] = this.handleMarketTypeAndParams('watchOrderBook', market, params);
213697
214467
  const timeframes = this.safeValue(this.options, 'timeframes', {});
213698
214468
  const interval = this.safeString(timeframes, timeframe);
213699
- const name = 'kline' + interval;
213700
- const ohlcv = await this.subscribe(name, symbol, params);
214469
+ let name = undefined;
214470
+ if (type === 'spot') {
214471
+ name = 'kline' + interval;
214472
+ }
214473
+ else {
214474
+ name = 'klineBin' + interval;
214475
+ }
214476
+ const ohlcv = await this.subscribe(name, symbol, type, params);
213701
214477
  if (this.newUpdates) {
213702
214478
  limit = ohlcv.getLimit(symbol, limit);
213703
214479
  }
@@ -213705,40 +214481,82 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213705
214481
  }
213706
214482
  handleOHLCV(client, message) {
213707
214483
  //
213708
- // {
213709
- // "data": [
213710
- // {
213711
- // "candle": [
213712
- // 1631056350,
213713
- // "46532.83",
213714
- // "46555.71",
213715
- // "46511.41",
213716
- // "46555.71",
213717
- // "0.25"
213718
- // ],
213719
- // "symbol": "BTC_USDT"
213720
- // }
213721
- // ],
213722
- // "table": "spot/kline1m"
213723
- // }
214484
+ // {
214485
+ // "data": [
214486
+ // {
214487
+ // "candle": [
214488
+ // 1631056350,
214489
+ // "46532.83",
214490
+ // "46555.71",
214491
+ // "46511.41",
214492
+ // "46555.71",
214493
+ // "0.25"
214494
+ // ],
214495
+ // "symbol": "BTC_USDT"
214496
+ // }
214497
+ // ],
214498
+ // "table": "spot/kline1m"
214499
+ // }
214500
+ // swap
214501
+ // {
214502
+ // "group":"futures/klineBin1m:BTCUSDT",
214503
+ // "data":{
214504
+ // "symbol":"BTCUSDT",
214505
+ // "items":[
214506
+ // {
214507
+ // "o":"39635.8",
214508
+ // "h":"39636",
214509
+ // "l":"39614.4",
214510
+ // "c":"39629.7",
214511
+ // "v":"31852",
214512
+ // "ts":1701617761
214513
+ // }
214514
+ // ]
214515
+ // }
214516
+ // }
213724
214517
  //
213725
- const table = this.safeString(message, 'table');
213726
- const data = this.safeValue(message, 'data', []);
213727
- const parts = table.split('/');
213728
- const part1 = this.safeString(parts, 1);
213729
- const interval = part1.replace('kline', '');
214518
+ const channel = this.safeString2(message, 'table', 'group');
214519
+ const isSpot = (channel.indexOf('spot') >= 0);
214520
+ const data = this.safeValue(message, 'data');
214521
+ if (data === undefined) {
214522
+ return;
214523
+ }
214524
+ const parts = channel.split('/');
214525
+ const part1 = this.safeString(parts, 1, '');
214526
+ let interval = part1.replace('kline', '');
214527
+ interval = interval.replace('Bin', '');
214528
+ const intervalParts = interval.split(':');
214529
+ interval = this.safeString(intervalParts, 0);
213730
214530
  // use a reverse lookup in a static map instead
213731
214531
  const timeframes = this.safeValue(this.options, 'timeframes', {});
213732
214532
  const timeframe = this.findTimeframe(interval, timeframes);
213733
214533
  const duration = this.parseTimeframe(timeframe);
213734
214534
  const durationInMs = duration * 1000;
213735
- for (let i = 0; i < data.length; i++) {
213736
- const marketId = this.safeString(data[i], 'symbol');
213737
- const candle = this.safeValue(data[i], 'candle');
213738
- const market = this.safeMarket(marketId);
214535
+ if (isSpot) {
214536
+ for (let i = 0; i < data.length; i++) {
214537
+ const marketId = this.safeString(data[i], 'symbol');
214538
+ const market = this.safeMarket(marketId);
214539
+ const symbol = market['symbol'];
214540
+ const rawOHLCV = this.safeValue(data[i], 'candle');
214541
+ const parsed = this.parseOHLCV(rawOHLCV, market);
214542
+ parsed[0] = this.parseToInt(parsed[0] / durationInMs) * durationInMs;
214543
+ this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
214544
+ let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
214545
+ if (stored === undefined) {
214546
+ const limit = this.safeInteger(this.options, 'OHLCVLimit', 1000);
214547
+ stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
214548
+ this.ohlcvs[symbol][timeframe] = stored;
214549
+ }
214550
+ stored.append(parsed);
214551
+ const messageHash = channel + ':' + marketId;
214552
+ client.resolve(stored, messageHash);
214553
+ }
214554
+ }
214555
+ else {
214556
+ const marketId = this.safeString(data, 'symbol');
214557
+ const market = this.safeMarket(marketId, undefined, '', 'swap');
213739
214558
  const symbol = market['symbol'];
213740
- const parsed = this.parseOHLCV(candle, market);
213741
- parsed[0] = this.parseToInt(parsed[0] / durationInMs) * durationInMs;
214559
+ const items = this.safeValue(data, 'items', []);
213742
214560
  this.ohlcvs[symbol] = this.safeValue(this.ohlcvs, symbol, {});
213743
214561
  let stored = this.safeValue(this.ohlcvs[symbol], timeframe);
213744
214562
  if (stored === undefined) {
@@ -213746,24 +214564,34 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213746
214564
  stored = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheByTimestamp */ .Py(limit);
213747
214565
  this.ohlcvs[symbol][timeframe] = stored;
213748
214566
  }
213749
- stored.append(parsed);
213750
- const messageHash = table + ':' + marketId;
213751
- client.resolve(stored, messageHash);
214567
+ for (let i = 0; i < items.length; i++) {
214568
+ const candle = items[i];
214569
+ const parsed = this.parseOHLCV(candle, market);
214570
+ stored.append(parsed);
214571
+ }
214572
+ client.resolve(stored, channel);
213752
214573
  }
213753
214574
  }
213754
214575
  async watchOrderBook(symbol, limit = undefined, params = {}) {
213755
214576
  /**
213756
214577
  * @method
213757
214578
  * @name bitmart#watchOrderBook
214579
+ * @see https://developer-pro.bitmart.com/en/spot/#public-depth-all-channel
214580
+ * @see https://developer-pro.bitmart.com/en/futures/#public-depth-channel
213758
214581
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
213759
214582
  * @param {string} symbol unified symbol of the market to fetch the order book for
213760
214583
  * @param {int} [limit] the maximum amount of order book entries to return
213761
214584
  * @param {object} [params] extra parameters specific to the exchange API endpoint
213762
214585
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
213763
214586
  */
214587
+ await this.loadMarkets();
213764
214588
  const options = this.safeValue(this.options, 'watchOrderBook', {});
213765
214589
  const depth = this.safeString(options, 'depth', 'depth50');
213766
- const orderbook = await this.subscribe(depth, symbol, params);
214590
+ symbol = this.symbol(symbol);
214591
+ const market = this.market(symbol);
214592
+ let type = 'spot';
214593
+ [type, params] = this.handleMarketTypeAndParams('watchOrderBook', market, params);
214594
+ const orderbook = await this.subscribe(depth, symbol, type, params);
213767
214595
  return orderbook.limit();
213768
214596
  }
213769
214597
  handleDelta(bookside, delta) {
@@ -213811,22 +214639,19 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213811
214639
  }
213812
214640
  handleOrderBook(client, message) {
213813
214641
  //
214642
+ // spot
213814
214643
  // {
213815
214644
  // "data": [
213816
214645
  // {
213817
214646
  // "asks": [
213818
214647
  // [ '46828.38', "0.21847" ],
213819
214648
  // [ '46830.68', "0.08232" ],
213820
- // [ '46832.08', "0.09285" ],
213821
- // [ '46837.82', "0.02028" ],
213822
- // [ '46839.43', "0.15068" ]
214649
+ // ...
213823
214650
  // ],
213824
214651
  // "bids": [
213825
214652
  // [ '46820.78', "0.00444" ],
213826
214653
  // [ '46814.33', "0.00234" ],
213827
- // [ '46813.50', "0.05021" ],
213828
- // [ '46808.14', "0.00217" ],
213829
- // [ '46808.04', "0.00013" ]
214654
+ // ...
213830
214655
  // ],
213831
214656
  // "ms_t": 1631044962431,
213832
214657
  // "symbol": "BTC_USDT"
@@ -213834,32 +214659,99 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213834
214659
  // ],
213835
214660
  // "table": "spot/depth5"
213836
214661
  // }
214662
+ // swap
214663
+ // {
214664
+ // "group":"futures/depth50:BTCUSDT",
214665
+ // "data":{
214666
+ // "symbol":"BTCUSDT",
214667
+ // "way":1,
214668
+ // "depths":[
214669
+ // {
214670
+ // "price":"39509.8",
214671
+ // "vol":"2379"
214672
+ // },
214673
+ // {
214674
+ // "price":"39509.6",
214675
+ // "vol":"6815"
214676
+ // },
214677
+ // ...
214678
+ // ],
214679
+ // "ms_t":1701566021194
214680
+ // }
214681
+ // }
213837
214682
  //
213838
- const data = this.safeValue(message, 'data', []);
213839
- const table = this.safeString(message, 'table');
214683
+ const data = this.safeValue(message, 'data');
214684
+ if (data === undefined) {
214685
+ return;
214686
+ }
214687
+ const depths = this.safeValue(data, 'depths');
214688
+ const isSpot = (depths === undefined);
214689
+ const table = this.safeString2(message, 'table', 'group');
213840
214690
  const parts = table.split('/');
213841
214691
  const lastPart = this.safeString(parts, 1);
213842
- const limitString = lastPart.replace('depth', '');
213843
- const limit = parseInt(limitString);
213844
- for (let i = 0; i < data.length; i++) {
213845
- const update = data[i];
213846
- const marketId = this.safeString(update, 'symbol');
214692
+ let limitString = lastPart.replace('depth', '');
214693
+ const dotsIndex = limitString.indexOf(':');
214694
+ limitString = limitString.slice(0, dotsIndex);
214695
+ const limit = this.parseToInt(limitString);
214696
+ if (isSpot) {
214697
+ for (let i = 0; i < data.length; i++) {
214698
+ const update = data[i];
214699
+ const marketId = this.safeString(update, 'symbol');
214700
+ const symbol = this.safeSymbol(marketId);
214701
+ let orderbook = this.safeValue(this.orderbooks, symbol);
214702
+ if (orderbook === undefined) {
214703
+ orderbook = this.orderBook({}, limit);
214704
+ orderbook['symbol'] = symbol;
214705
+ this.orderbooks[symbol] = orderbook;
214706
+ }
214707
+ orderbook.reset({});
214708
+ this.handleOrderBookMessage(client, update, orderbook);
214709
+ const timestamp = this.safeInteger(update, 'ms_t');
214710
+ orderbook['timestamp'] = timestamp;
214711
+ orderbook['datetime'] = this.iso8601(timestamp);
214712
+ const messageHash = table + ':' + marketId;
214713
+ client.resolve(orderbook, messageHash);
214714
+ }
214715
+ }
214716
+ else {
214717
+ const marketId = this.safeString(data, 'symbol');
213847
214718
  const symbol = this.safeSymbol(marketId);
213848
214719
  let orderbook = this.safeValue(this.orderbooks, symbol);
213849
214720
  if (orderbook === undefined) {
213850
214721
  orderbook = this.orderBook({}, limit);
214722
+ orderbook['symbol'] = symbol;
213851
214723
  this.orderbooks[symbol] = orderbook;
213852
214724
  }
213853
- orderbook.reset({});
213854
- this.handleOrderBookMessage(client, update, orderbook);
213855
- const messageHash = table + ':' + marketId;
214725
+ const way = this.safeNumber(data, 'way');
214726
+ const side = (way === 1) ? 'bids' : 'asks';
214727
+ if (way === 1) {
214728
+ orderbook[side] = new _base_ws_OrderBookSide_js__WEBPACK_IMPORTED_MODULE_3__/* .Bids */ .T8([], limit);
214729
+ }
214730
+ else {
214731
+ orderbook[side] = new _base_ws_OrderBookSide_js__WEBPACK_IMPORTED_MODULE_3__/* .Asks */ .lB([], limit);
214732
+ }
214733
+ for (let i = 0; i < depths.length; i++) {
214734
+ const depth = depths[i];
214735
+ const price = this.safeNumber(depth, 'price');
214736
+ const amount = this.safeNumber(depth, 'vol');
214737
+ const orderbookSide = this.safeValue(orderbook, side);
214738
+ orderbookSide.store(price, amount);
214739
+ }
214740
+ const bidsLength = orderbook['bids'].length;
214741
+ const asksLength = orderbook['asks'].length;
214742
+ if ((bidsLength === 0) || (asksLength === 0)) {
214743
+ return;
214744
+ }
214745
+ const timestamp = this.safeInteger(data, 'ms_t');
214746
+ orderbook['timestamp'] = timestamp;
214747
+ orderbook['datetime'] = this.iso8601(timestamp);
214748
+ const messageHash = table;
213856
214749
  client.resolve(orderbook, messageHash);
213857
214750
  }
213858
- return message;
213859
214751
  }
213860
- async authenticate(params = {}) {
214752
+ async authenticate(type, params = {}) {
213861
214753
  this.checkRequiredCredentials();
213862
- const url = this.implodeHostname(this.urls['api']['ws']['private']);
214754
+ const url = this.implodeHostname(this.urls['api']['ws'][type]['private']);
213863
214755
  const messageHash = 'authenticated';
213864
214756
  const client = this.client(url);
213865
214757
  const future = client.future(messageHash);
@@ -213869,16 +214761,29 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213869
214761
  const memo = this.uid;
213870
214762
  const path = 'bitmart.WebSocket';
213871
214763
  const auth = timestamp + '#' + memo + '#' + path;
213872
- const signature = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_3__/* .sha256 */ .J);
213873
- const operation = 'login';
213874
- const request = {
213875
- 'op': operation,
213876
- 'args': [
213877
- this.apiKey,
213878
- timestamp,
213879
- signature,
213880
- ],
213881
- };
214764
+ const signature = this.hmac(this.encode(auth), this.encode(this.secret), _static_dependencies_noble_hashes_sha256_js__WEBPACK_IMPORTED_MODULE_4__/* .sha256 */ .J);
214765
+ let request = undefined;
214766
+ if (type === 'spot') {
214767
+ request = {
214768
+ 'op': 'login',
214769
+ 'args': [
214770
+ this.apiKey,
214771
+ timestamp,
214772
+ signature,
214773
+ ],
214774
+ };
214775
+ }
214776
+ else {
214777
+ request = {
214778
+ 'action': 'access',
214779
+ 'args': [
214780
+ this.apiKey,
214781
+ timestamp,
214782
+ signature,
214783
+ 'web',
214784
+ ],
214785
+ };
214786
+ }
213882
214787
  const message = this.extend(request, params);
213883
214788
  this.watch(url, messageHash, message, messageHash);
213884
214789
  }
@@ -213886,13 +214791,16 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213886
214791
  }
213887
214792
  handleSubscriptionStatus(client, message) {
213888
214793
  //
213889
- // {"event":"subscribe","channel":"spot/depth:BTC-USDT"}
214794
+ // {"event":"subscribe","channel":"spot/depth:BTC-USDT"}
213890
214795
  //
213891
214796
  return message;
213892
214797
  }
213893
214798
  handleAuthenticate(client, message) {
213894
214799
  //
213895
- // { event: "login" }
214800
+ // spot
214801
+ // { event: "login" }
214802
+ // swap
214803
+ // { action: 'access', success: true }
213896
214804
  //
213897
214805
  const messageHash = 'authenticated';
213898
214806
  const future = this.safeValue(client.futures, messageHash);
@@ -213900,29 +214808,41 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213900
214808
  }
213901
214809
  handleErrorMessage(client, message) {
213902
214810
  //
213903
- // { event: "error", message: "Invalid sign", errorCode: 30013 }
213904
- // {"event":"error","message":"Unrecognized request: {\"event\":\"subscribe\",\"channel\":\"spot/depth:BTC-USDT\"}","errorCode":30039}
214811
+ // { event: "error", message: "Invalid sign", errorCode: 30013 }
214812
+ // {"event":"error","message":"Unrecognized request: {\"event\":\"subscribe\",\"channel\":\"spot/depth:BTC-USDT\"}","errorCode":30039}
214813
+ // {
214814
+ // action: '',
214815
+ // group: 'futures/trade:BTCUSDT',
214816
+ // success: false,
214817
+ // request: { action: '', args: [ 'futures/trade:BTCUSDT' ] },
214818
+ // error: 'Invalid action [] for group [futures/trade:BTCUSDT]'
214819
+ // }
213905
214820
  //
213906
214821
  const errorCode = this.safeString(message, 'errorCode');
214822
+ const error = this.safeString(message, 'error');
213907
214823
  try {
213908
- if (errorCode !== undefined) {
214824
+ if (errorCode !== undefined || error !== undefined) {
213909
214825
  const feedback = this.id + ' ' + this.json(message);
213910
214826
  this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
213911
- const messageString = this.safeValue(message, 'message');
213912
- if (messageString !== undefined) {
213913
- this.throwBroadlyMatchedException(this.exceptions['broad'], messageString, feedback);
214827
+ const messageString = this.safeValue(message, 'message', error);
214828
+ this.throwBroadlyMatchedException(this.exceptions['broad'], messageString, feedback);
214829
+ const action = this.safeString(message, 'action');
214830
+ if (action === 'access') {
214831
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.AuthenticationError(feedback);
213914
214832
  }
214833
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(feedback);
213915
214834
  }
213916
214835
  return false;
213917
214836
  }
213918
214837
  catch (e) {
213919
- if (e instanceof _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.AuthenticationError) {
214838
+ if ((e instanceof _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.AuthenticationError)) {
213920
214839
  const messageHash = 'authenticated';
213921
214840
  client.reject(e, messageHash);
213922
214841
  if (messageHash in client.subscriptions) {
213923
214842
  delete client.subscriptions[messageHash];
213924
214843
  }
213925
214844
  }
214845
+ client.reject(e);
213926
214846
  return true;
213927
214847
  }
213928
214848
  }
@@ -213955,14 +214875,14 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213955
214875
  //
213956
214876
  // { data: '', table: "spot/user/order" }
213957
214877
  //
213958
- const table = this.safeString(message, 'table');
213959
- if (table === undefined) {
213960
- const event = this.safeString(message, 'event');
214878
+ const channel = this.safeString2(message, 'table', 'group');
214879
+ if (channel === undefined) {
214880
+ const event = this.safeString2(message, 'event', 'action');
213961
214881
  if (event !== undefined) {
213962
214882
  const methods = {
213963
214883
  // 'info': this.handleSystemStatus,
213964
- // 'book': 'handleOrderBook',
213965
214884
  'login': this.handleAuthenticate,
214885
+ 'access': this.handleAuthenticate,
213966
214886
  'subscribe': this.handleSubscriptionStatus,
213967
214887
  };
213968
214888
  const method = this.safeValue(methods, event);
@@ -213975,30 +214895,25 @@ class bitmart extends _bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
213975
214895
  }
213976
214896
  }
213977
214897
  else {
213978
- const parts = table.split('/');
213979
- const name = this.safeString(parts, 1);
213980
214898
  const methods = {
213981
- 'depth': this.handleOrderBook,
213982
214899
  'depth5': this.handleOrderBook,
213983
214900
  'depth20': this.handleOrderBook,
213984
214901
  'depth50': this.handleOrderBook,
213985
214902
  'ticker': this.handleTicker,
213986
214903
  'trade': this.handleTrade,
213987
- // ...
214904
+ 'kline': this.handleOHLCV,
214905
+ 'order': this.handleOrders,
214906
+ 'position': this.handlePositions,
214907
+ 'balance': this.handleBalance,
214908
+ 'asset': this.handleBalance,
213988
214909
  };
213989
- let method = this.safeValue(methods, name);
213990
- if (name.indexOf('kline') >= 0) {
213991
- method = this.handleOHLCV;
213992
- }
213993
- const privateName = this.safeString(parts, 2);
213994
- if (privateName === 'order') {
213995
- method = this.handleOrders;
213996
- }
213997
- if (method === undefined) {
213998
- return message;
213999
- }
214000
- else {
214001
- return method.call(this, client, message);
214910
+ const keys = Object.keys(methods);
214911
+ for (let i = 0; i < keys.length; i++) {
214912
+ const key = keys[i];
214913
+ if (channel.indexOf(key) >= 0) {
214914
+ const method = this.safeValue(methods, key);
214915
+ return method.call(this, client, message);
214916
+ }
214002
214917
  }
214003
214918
  }
214004
214919
  }
@@ -214034,6 +214949,7 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
214034
214949
  'watchOrderBook': true,
214035
214950
  'watchOrderBookForSymbols': true,
214036
214951
  'watchOrders': true,
214952
+ 'watchPostions': true,
214037
214953
  'watchTicker': true,
214038
214954
  'watchTickers': false,
214039
214955
  'watchTrades': true,
@@ -214607,6 +215523,210 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
214607
215523
  }
214608
215524
  }
214609
215525
  }
215526
+ async watchPositions(symbols = undefined, since = undefined, limit = undefined, params = {}) {
215527
+ /**
215528
+ * @method
215529
+ * @name bitmex#watchPositions
215530
+ * @see https://www.bitmex.com/app/wsAPI
215531
+ * @description watch all open positions
215532
+ * @param {string[]|undefined} symbols list of unified market symbols
215533
+ * @param {object} params extra parameters specific to the exchange API endpoint
215534
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
215535
+ */
215536
+ await this.loadMarkets();
215537
+ await this.authenticate();
215538
+ const subscriptionHash = 'position';
215539
+ let messageHash = 'positions';
215540
+ if (!this.isEmpty(symbols)) {
215541
+ messageHash = '::' + symbols.join(',');
215542
+ }
215543
+ const url = this.urls['api']['ws'];
215544
+ const request = {
215545
+ 'op': 'subscribe',
215546
+ 'args': [
215547
+ subscriptionHash,
215548
+ ],
215549
+ };
215550
+ const newPositions = await this.watch(url, messageHash, request, subscriptionHash);
215551
+ if (this.newUpdates) {
215552
+ return newPositions;
215553
+ }
215554
+ return this.filterBySymbolsSinceLimit(this.positions, symbols, since, limit, true);
215555
+ }
215556
+ handlePositions(client, message) {
215557
+ //
215558
+ // partial
215559
+ // {
215560
+ // table: 'position',
215561
+ // action: 'partial',
215562
+ // keys: [ 'account', 'symbol' ],
215563
+ // types: {
215564
+ // account: 'long',
215565
+ // symbol: 'symbol',
215566
+ // currency: 'symbol',
215567
+ // underlying: 'symbol',
215568
+ // quoteCurrency: 'symbol',
215569
+ // commission: 'float',
215570
+ // initMarginReq: 'float',
215571
+ // maintMarginReq: 'float',
215572
+ // riskLimit: 'long',
215573
+ // leverage: 'float',
215574
+ // crossMargin: 'boolean',
215575
+ // deleveragePercentile: 'float',
215576
+ // rebalancedPnl: 'long',
215577
+ // prevRealisedPnl: 'long',
215578
+ // prevUnrealisedPnl: 'long',
215579
+ // openingQty: 'long',
215580
+ // openOrderBuyQty: 'long',
215581
+ // openOrderBuyCost: 'long',
215582
+ // openOrderBuyPremium: 'long',
215583
+ // openOrderSellQty: 'long',
215584
+ // openOrderSellCost: 'long',
215585
+ // openOrderSellPremium: 'long',
215586
+ // currentQty: 'long',
215587
+ // currentCost: 'long',
215588
+ // currentComm: 'long',
215589
+ // realisedCost: 'long',
215590
+ // unrealisedCost: 'long',
215591
+ // grossOpenPremium: 'long',
215592
+ // isOpen: 'boolean',
215593
+ // markPrice: 'float',
215594
+ // markValue: 'long',
215595
+ // riskValue: 'long',
215596
+ // homeNotional: 'float',
215597
+ // foreignNotional: 'float',
215598
+ // posState: 'symbol',
215599
+ // posCost: 'long',
215600
+ // posCross: 'long',
215601
+ // posComm: 'long',
215602
+ // posLoss: 'long',
215603
+ // posMargin: 'long',
215604
+ // posMaint: 'long',
215605
+ // initMargin: 'long',
215606
+ // maintMargin: 'long',
215607
+ // realisedPnl: 'long',
215608
+ // unrealisedPnl: 'long',
215609
+ // unrealisedPnlPcnt: 'float',
215610
+ // unrealisedRoePcnt: 'float',
215611
+ // avgCostPrice: 'float',
215612
+ // avgEntryPrice: 'float',
215613
+ // breakEvenPrice: 'float',
215614
+ // marginCallPrice: 'float',
215615
+ // liquidationPrice: 'float',
215616
+ // bankruptPrice: 'float',
215617
+ // timestamp: 'timestamp'
215618
+ // },
215619
+ // filter: { account: 412475 },
215620
+ // data: [
215621
+ // {
215622
+ // account: 412475,
215623
+ // symbol: 'XBTUSD',
215624
+ // currency: 'XBt',
215625
+ // underlying: 'XBT',
215626
+ // quoteCurrency: 'USD',
215627
+ // commission: 0.00075,
215628
+ // initMarginReq: 0.01,
215629
+ // maintMarginReq: 0.0035,
215630
+ // riskLimit: 20000000000,
215631
+ // leverage: 100,
215632
+ // crossMargin: true,
215633
+ // deleveragePercentile: 1,
215634
+ // rebalancedPnl: 0,
215635
+ // prevRealisedPnl: 0,
215636
+ // prevUnrealisedPnl: 0,
215637
+ // openingQty: 400,
215638
+ // openOrderBuyQty: 0,
215639
+ // openOrderBuyCost: 0,
215640
+ // openOrderBuyPremium: 0,
215641
+ // openOrderSellQty: 0,
215642
+ // openOrderSellCost: 0,
215643
+ // openOrderSellPremium: 0,
215644
+ // currentQty: 400,
215645
+ // currentCost: -912269,
215646
+ // currentComm: 684,
215647
+ // realisedCost: 0,
215648
+ // unrealisedCost: -912269,
215649
+ // grossOpenPremium: 0,
215650
+ // isOpen: true,
215651
+ // markPrice: 43772,
215652
+ // markValue: -913828,
215653
+ // riskValue: 913828,
215654
+ // homeNotional: 0.00913828,
215655
+ // foreignNotional: -400,
215656
+ // posCost: -912269,
215657
+ // posCross: 1559,
215658
+ // posComm: 694,
215659
+ // posLoss: 0,
215660
+ // posMargin: 11376,
215661
+ // posMaint: 3887,
215662
+ // initMargin: 0,
215663
+ // maintMargin: 9817,
215664
+ // realisedPnl: -684,
215665
+ // unrealisedPnl: -1559,
215666
+ // unrealisedPnlPcnt: -0.0017,
215667
+ // unrealisedRoePcnt: -0.1709,
215668
+ // avgCostPrice: 43846.7643,
215669
+ // avgEntryPrice: 43846.7643,
215670
+ // breakEvenPrice: 43880,
215671
+ // marginCallPrice: 20976,
215672
+ // liquidationPrice: 20976,
215673
+ // bankruptPrice: 20941,
215674
+ // timestamp: '2023-12-07T00:09:00.709Z'
215675
+ // }
215676
+ // ]
215677
+ // }
215678
+ // update
215679
+ // {
215680
+ // table: 'position',
215681
+ // action: 'update',
215682
+ // data: [
215683
+ // {
215684
+ // account: 412475,
215685
+ // symbol: 'XBTUSD',
215686
+ // currency: 'XBt',
215687
+ // currentQty: 400,
215688
+ // markPrice: 43772.75,
215689
+ // markValue: -913812,
215690
+ // riskValue: 913812,
215691
+ // homeNotional: 0.00913812,
215692
+ // posCross: 1543,
215693
+ // posComm: 693,
215694
+ // posMargin: 11359,
215695
+ // posMaint: 3886,
215696
+ // maintMargin: 9816,
215697
+ // unrealisedPnl: -1543,
215698
+ // unrealisedRoePcnt: -0.1691,
215699
+ // liquidationPrice: 20976,
215700
+ // timestamp: '2023-12-07T00:09:10.760Z'
215701
+ // }
215702
+ // ]
215703
+ // }
215704
+ //
215705
+ if (this.positions === undefined) {
215706
+ this.positions = new _base_ws_Cache_js__WEBPACK_IMPORTED_MODULE_2__/* .ArrayCacheBySymbolBySide */ .tU();
215707
+ }
215708
+ const cache = this.positions;
215709
+ const rawPositions = this.safeValue(message, 'data', []);
215710
+ const newPositions = [];
215711
+ for (let i = 0; i < rawPositions.length; i++) {
215712
+ const rawPosition = rawPositions[i];
215713
+ const position = this.parsePosition(rawPosition);
215714
+ newPositions.push(position);
215715
+ cache.append(position);
215716
+ }
215717
+ const messageHashes = this.findMessageHashes(client, 'positions::');
215718
+ for (let i = 0; i < messageHashes.length; i++) {
215719
+ const messageHash = messageHashes[i];
215720
+ const parts = messageHash.split('::');
215721
+ const symbolsString = parts[1];
215722
+ const symbols = symbolsString.split(',');
215723
+ const positions = this.filterByArray(newPositions, 'symbol', symbols, false);
215724
+ if (!this.isEmpty(positions)) {
215725
+ client.resolve(positions, messageHash);
215726
+ }
215727
+ }
215728
+ client.resolve(newPositions, 'positions');
215729
+ }
214610
215730
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
214611
215731
  /**
214612
215732
  * @method
@@ -215389,6 +216509,7 @@ class bitmex extends _bitmex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
215389
216509
  'order': this.handleOrders,
215390
216510
  'execution': this.handleMyTrades,
215391
216511
  'margin': this.handleBalance,
216512
+ 'position': this.handlePositions,
215392
216513
  };
215393
216514
  const method = this.safeValue(methods, table);
215394
216515
  if (method === undefined) {
@@ -239242,10 +240363,10 @@ class krakenfutures extends _krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
239242
240363
  * @ignore
239243
240364
  * @method
239244
240365
  * @description Connects to a websocket channel
239245
- * @param {String} name name of the channel
240366
+ * @param {string} name name of the channel
239246
240367
  * @param {string[]} symbols CCXT market symbols
239247
- * @param {Object} [params] extra parameters specific to the krakenfutures api
239248
- * @returns {Object} data from the websocket stream
240368
+ * @param {object} [params] extra parameters specific to the krakenfutures api
240369
+ * @returns {object} data from the websocket stream
239249
240370
  */
239250
240371
  await this.loadMarkets();
239251
240372
  const url = this.urls['api']['ws'];
@@ -239276,10 +240397,10 @@ class krakenfutures extends _krakenfutures_js__WEBPACK_IMPORTED_MODULE_0__/* ["d
239276
240397
  * @ignore
239277
240398
  * @method
239278
240399
  * @description Connects to a websocket channel
239279
- * @param {String} name name of the channel
240400
+ * @param {string} name name of the channel
239280
240401
  * @param {string[]} symbols CCXT market symbols
239281
- * @param {Object} [params] extra parameters specific to the krakenfutures api
239282
- * @returns {Object} data from the websocket stream
240402
+ * @param {object} [params] extra parameters specific to the krakenfutures api
240403
+ * @returns {object} data from the websocket stream
239283
240404
  */
239284
240405
  await this.loadMarkets();
239285
240406
  await this.authenticate();
@@ -243752,7 +244873,7 @@ class mexc extends _mexc_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
243752
244873
  * @param {int} [since] the earliest time in ms to fetch orders for
243753
244874
  * @param {int} [limit] the maximum number of orde structures to retrieve
243754
244875
  * @param {object} [params] extra parameters specific to the exchange API endpoint
243755
- * @params {string|undefined} params.type the type of orders to retrieve, can be 'spot' or 'margin'
244876
+ * @param {string|undefined} params.type the type of orders to retrieve, can be 'spot' or 'margin'
243756
244877
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
243757
244878
  */
243758
244879
  await this.loadMarkets();
@@ -248816,7 +249937,7 @@ class poloniex extends _poloniex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
248816
249937
  * @param {string} [params.stpMode] self-trade prevention, defaults to expire_taker, none: enable self-trade; expire_taker: taker order will be canceled when self-trade happens
248817
249938
  * @param {string} [params.slippageTolerance] used to control the maximum slippage ratio, the value range is greater than 0 and less than 1
248818
249939
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
248819
- */
249940
+ */
248820
249941
  await this.loadMarkets();
248821
249942
  await this.authenticate();
248822
249943
  const market = this.market(symbol);
@@ -249998,9 +251119,9 @@ class poloniexfutures extends _poloniexfutures_js__WEBPACK_IMPORTED_MODULE_0__/*
249998
251119
  * @param {string} name name of the channel and suscriptionHash
249999
251120
  * @param {bool} isPrivate true for the authenticated url, false for the public url
250000
251121
  * @param {string} symbol is required for all public channels, not required for private channels (except position)
250001
- * @param {Object} subscription subscription parameters
250002
- * @param {Object} [params] extra parameters specific to the poloniex api
250003
- * @returns {Object} data from the websocket stream
251122
+ * @param {object} subscription subscription parameters
251123
+ * @param {object} [params] extra parameters specific to the poloniex api
251124
+ * @returns {object} data from the websocket stream
250004
251125
  */
250005
251126
  const url = await this.negotiate(isPrivate);
250006
251127
  if (symbol !== undefined) {
@@ -254241,7 +255362,7 @@ class woo extends _woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
254241
255362
  // ---------------------------------------------------------------------------
254242
255363
  /**
254243
255364
  * @class probit
254244
- * @extends Exchange
255365
+ * @augments Exchange
254245
255366
  */
254246
255367
  class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
254247
255368
  describe() {
@@ -254260,7 +255381,10 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
254260
255381
  'option': false,
254261
255382
  'addMargin': false,
254262
255383
  'cancelOrder': true,
255384
+ 'createMarketBuyOrderWithCost': true,
254263
255385
  'createMarketOrder': true,
255386
+ 'createMarketOrderWithCost': false,
255387
+ 'createMarketSellOrderWithCost': false,
254264
255388
  'createOrder': true,
254265
255389
  'createReduceOnlyOrder': false,
254266
255390
  'createStopLimitOrder': false,
@@ -254547,6 +255671,7 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
254547
255671
  'precision': {
254548
255672
  'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'quantity_precision'))),
254549
255673
  'price': this.safeNumber(market, 'price_increment'),
255674
+ 'cost': this.parseNumber(this.parsePrecision(this.safeString(market, 'cost_precision'))),
254550
255675
  },
254551
255676
  'limits': {
254552
255677
  'leverage': {
@@ -255419,14 +256544,15 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
255419
256544
  /**
255420
256545
  * @method
255421
256546
  * @name probit#createOrder
255422
- * @see https://docs-en.probit.com/reference/order-1
255423
256547
  * @description create a trade order
256548
+ * @see https://docs-en.probit.com/reference/order-1
255424
256549
  * @param {string} symbol unified symbol of the market to create an order in
255425
256550
  * @param {string} type 'market' or 'limit'
255426
256551
  * @param {string} side 'buy' or 'sell'
255427
- * @param {float} amount how much of currency you want to trade in units of base currency
256552
+ * @param {float} amount how much you want to trade in units of the base currency
255428
256553
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
255429
256554
  * @param {object} [params] extra parameters specific to the exchange API endpoint
256555
+ * @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount for market buy orders
255430
256556
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
255431
256557
  */
255432
256558
  await this.loadMarkets();
@@ -255444,7 +256570,7 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
255444
256570
  if (clientOrderId !== undefined) {
255445
256571
  request['client_order_id'] = clientOrderId;
255446
256572
  }
255447
- let costToPrecision = undefined;
256573
+ let quoteAmount = undefined;
255448
256574
  if (type === 'limit') {
255449
256575
  request['limit_price'] = this.priceToPrecision(symbol, price);
255450
256576
  request['quantity'] = this.amountToPrecision(symbol, amount);
@@ -255452,25 +256578,28 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
255452
256578
  else if (type === 'market') {
255453
256579
  // for market buy it requires the amount of quote currency to spend
255454
256580
  if (side === 'buy') {
255455
- let cost = this.safeNumber(params, 'cost');
255456
- const createMarketBuyOrderRequiresPrice = this.safeValue(this.options, 'createMarketBuyOrderRequiresPrice', true);
255457
- if (createMarketBuyOrderRequiresPrice) {
255458
- if (price !== undefined) {
255459
- if (cost === undefined) {
255460
- const amountString = this.numberToString(amount);
255461
- const priceString = this.numberToString(price);
255462
- cost = this.parseNumber(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(amountString, priceString));
255463
- }
256581
+ let createMarketBuyOrderRequiresPrice = true;
256582
+ [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
256583
+ const cost = this.safeString(params, 'cost');
256584
+ params = this.omit(params, 'cost');
256585
+ if (cost !== undefined) {
256586
+ quoteAmount = this.costToPrecision(symbol, cost);
256587
+ }
256588
+ else if (createMarketBuyOrderRequiresPrice) {
256589
+ if (price === undefined) {
256590
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument');
255464
256591
  }
255465
- else if (cost === undefined) {
255466
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount, or, alternatively, add .options["createMarketBuyOrderRequiresPrice"] = false and supply the total cost value in the "amount" argument or in the "cost" extra parameter (the exchange-specific behaviour)');
256592
+ else {
256593
+ const amountString = this.numberToString(amount);
256594
+ const priceString = this.numberToString(price);
256595
+ const costRequest = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise */ .O.stringMul(amountString, priceString);
256596
+ quoteAmount = this.costToPrecision(symbol, costRequest);
255467
256597
  }
255468
256598
  }
255469
256599
  else {
255470
- cost = (cost === undefined) ? amount : cost;
256600
+ quoteAmount = this.costToPrecision(symbol, amount);
255471
256601
  }
255472
- costToPrecision = this.costToPrecision(symbol, cost);
255473
- request['cost'] = costToPrecision;
256602
+ request['cost'] = quoteAmount;
255474
256603
  }
255475
256604
  else {
255476
256605
  request['quantity'] = this.amountToPrecision(symbol, amount);
@@ -255505,7 +256634,7 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
255505
256634
  // returned by the exchange on market buys
255506
256635
  if ((type === 'market') && (side === 'buy')) {
255507
256636
  order['amount'] = undefined;
255508
- order['cost'] = this.parseNumber(costToPrecision);
256637
+ order['cost'] = this.parseNumber(quoteAmount);
255509
256638
  order['remaining'] = undefined;
255510
256639
  }
255511
256640
  return order;
@@ -256104,7 +257233,7 @@ const version = typeof process !== 'undefined'
256104
257233
  : undefined;
256105
257234
  /**
256106
257235
  *
256107
- * @param {Object} [options = {}] - An object to customize JSEncrypt behaviour
257236
+ * @param {object} [options = {}] - An object to customize JSEncrypt behaviour
256108
257237
  * possible parameters are:
256109
257238
  * - default_key_size {number} default: 1024 the key size in bit
256110
257239
  * - default_public_exponent {string} default: '010001' the hexadecimal representation of the public exponent
@@ -256552,7 +257681,7 @@ class JSEncryptRSAKey extends _lib_jsbn_rsa_js__WEBPACK_IMPORTED_MODULE_1__/* .R
256552
257681
  /**
256553
257682
  * Check if the object contains the necessary parameters to populate the rsa modulus
256554
257683
  * and public exponent parameters.
256555
- * @param {Object} [obj={}] - An object that may contain the two public key
257684
+ * @param {object} [obj={}] - An object that may contain the two public key
256556
257685
  * parameters
256557
257686
  * @returns {boolean} true if the object contains both the modulus and the public exponent
256558
257687
  * properties (n and e)
@@ -256566,7 +257695,7 @@ class JSEncryptRSAKey extends _lib_jsbn_rsa_js__WEBPACK_IMPORTED_MODULE_1__/* .R
256566
257695
  }
256567
257696
  /**
256568
257697
  * Check if the object contains ALL the parameters of an RSA key.
256569
- * @param {Object} [obj={}] - An object that may contain nine rsa key
257698
+ * @param {object} [obj={}] - An object that may contain nine rsa key
256570
257699
  * parameters
256571
257700
  * @returns {boolean} true if the object contains all the parameters needed
256572
257701
  * @todo check for types of the parameters all the parameters but the public exponent
@@ -256587,7 +257716,7 @@ class JSEncryptRSAKey extends _lib_jsbn_rsa_js__WEBPACK_IMPORTED_MODULE_1__/* .R
256587
257716
  /**
256588
257717
  * Parse the properties of obj in the current rsa object. Obj should AT LEAST
256589
257718
  * include the modulus and public exponent (n, e) parameters.
256590
- * @param {Object} obj - the object containing rsa parameters
257719
+ * @param {object} obj - the object containing rsa parameters
256591
257720
  * @private
256592
257721
  */
256593
257722
  parsePropertiesFrom(obj) {
@@ -265036,7 +266165,7 @@ const bytes = (/* unused pure expression or super */ null && (stringToBytes));
265036
266165
 
265037
266166
  /**
265038
266167
  * @class timex
265039
- * @extends Exchange
266168
+ * @augments Exchange
265040
266169
  */
265041
266170
  class timex extends _abstract_timex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
265042
266171
  describe() {
@@ -266611,7 +267740,7 @@ class timex extends _abstract_timex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
266611
267740
  // ---------------------------------------------------------------------------
266612
267741
  /**
266613
267742
  * @class tokocrypto
266614
- * @extends Exchange
267743
+ * @augments Exchange
266615
267744
  */
266616
267745
  class tokocrypto extends _abstract_tokocrypto_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
266617
267746
  describe() {
@@ -267616,16 +268745,21 @@ class tokocrypto extends _abstract_tokocrypto_js__WEBPACK_IMPORTED_MODULE_0__/*
267616
268745
  const data = this.safeValue(responseInner, 'data', {});
267617
268746
  return this.parseTrades(data, market, since, limit);
267618
268747
  }
268748
+ if (limit !== undefined) {
268749
+ request['limit'] = limit; // default = 500, maximum = 1000
268750
+ }
267619
268751
  const defaultMethod = 'binanceGetTrades';
267620
268752
  const method = this.safeString(this.options, 'fetchTradesMethod', defaultMethod);
268753
+ let response = undefined;
267621
268754
  if ((method === 'binanceGetAggTrades') && (since !== undefined)) {
267622
268755
  request['startTime'] = since;
267623
268756
  // https://github.com/ccxt/ccxt/issues/6400
267624
268757
  // https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#compressedaggregate-trades-list
267625
268758
  request['endTime'] = this.sum(since, 3600000);
268759
+ response = await this.binanceGetAggTrades(this.extend(request, params));
267626
268760
  }
267627
- if (limit !== undefined) {
267628
- request['limit'] = limit; // default = 500, maximum = 1000
268761
+ else {
268762
+ response = await this.binanceGetTrades(this.extend(request, params));
267629
268763
  }
267630
268764
  //
267631
268765
  // Caveats:
@@ -267636,7 +268770,6 @@ class tokocrypto extends _abstract_tokocrypto_js__WEBPACK_IMPORTED_MODULE_0__/*
267636
268770
  // - 'tradeId' accepted and returned by this method is "aggregate" trade id
267637
268771
  // which is different from actual trade id
267638
268772
  // - setting both fromId and time window results in error
267639
- const response = await this[method](this.extend(request, params));
267640
268773
  //
267641
268774
  // aggregate trades
267642
268775
  //
@@ -269148,7 +270281,7 @@ class tokocrypto extends _abstract_tokocrypto_js__WEBPACK_IMPORTED_MODULE_0__/*
269148
270281
  // ---------------------------------------------------------------------------
269149
270282
  /**
269150
270283
  * @class upbit
269151
- * @extends Exchange
270284
+ * @augments Exchange
269152
270285
  */
269153
270286
  class upbit extends _abstract_upbit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
269154
270287
  describe() {
@@ -270990,7 +272123,7 @@ class upbit extends _abstract_upbit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
270990
272123
  // ---------------------------------------------------------------------------
270991
272124
  /**
270992
272125
  * @class wavesexchange
270993
- * @extends Exchange
272126
+ * @augments Exchange
270994
272127
  */
270995
272128
  class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
270996
272129
  describe() {
@@ -273605,7 +274738,7 @@ class wavesexchange extends _abstract_wavesexchange_js__WEBPACK_IMPORTED_MODULE_
273605
274738
 
273606
274739
  /**
273607
274740
  * @class wazirx
273608
- * @extends Exchange
274741
+ * @augments Exchange
273609
274742
  */
273610
274743
  class wazirx extends _abstract_wazirx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
273611
274744
  describe() {
@@ -274570,7 +275703,7 @@ class wazirx extends _abstract_wazirx_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
274570
275703
  // ---------------------------------------------------------------------------
274571
275704
  /**
274572
275705
  * @class whitebit
274573
- * @extends Exchange
275706
+ * @augments Exchange
274574
275707
  */
274575
275708
  class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
274576
275709
  describe() {
@@ -276889,7 +278022,7 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
276889
278022
  // ---------------------------------------------------------------------------
276890
278023
  /**
276891
278024
  * @class woo
276892
- * @extends Exchange
278025
+ * @augments Exchange
276893
278026
  */
276894
278027
  class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
276895
278028
  describe() {
@@ -279538,7 +280671,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
279538
280671
  // ---------------------------------------------------------------------------
279539
280672
  /**
279540
280673
  * @class yobit
279541
- * @extends Exchange
280674
+ * @augments Exchange
279542
280675
  */
279543
280676
  class yobit extends _abstract_yobit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
279544
280677
  describe() {
@@ -280862,7 +281995,7 @@ class yobit extends _abstract_yobit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
280862
281995
  // ---------------------------------------------------------------------------
280863
281996
  /**
280864
281997
  * @class zaif
280865
- * @extends Exchange
281998
+ * @augments Exchange
280866
281999
  */
280867
282000
  class zaif extends _abstract_zaif_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
280868
282001
  describe() {
@@ -281609,7 +282742,7 @@ class zaif extends _abstract_zaif_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
281609
282742
  // ---------------------------------------------------------------------------
281610
282743
  /**
281611
282744
  * @class zonda
281612
- * @extends Exchange
282745
+ * @augments Exchange
281613
282746
  */
281614
282747
  class zonda extends _abstract_zonda_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
281615
282748
  describe() {
@@ -289039,7 +290172,7 @@ SOFTWARE.
289039
290172
 
289040
290173
  //-----------------------------------------------------------------------------
289041
290174
  // this is updated by vss.js when building
289042
- const version = '4.1.84';
290175
+ const version = '4.1.86';
289043
290176
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
289044
290177
  //-----------------------------------------------------------------------------
289045
290178