ccxt 4.3.88 → 4.3.90

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 (126) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/ace.js +1 -0
  5. package/dist/cjs/src/alpaca.js +3 -2
  6. package/dist/cjs/src/ascendex.js +102 -116
  7. package/dist/cjs/src/bigone.js +1 -0
  8. package/dist/cjs/src/bingx.js +32 -17
  9. package/dist/cjs/src/bit2c.js +1 -0
  10. package/dist/cjs/src/bitbank.js +1 -0
  11. package/dist/cjs/src/bitfinex.js +1 -0
  12. package/dist/cjs/src/bitfinex2.js +21 -22
  13. package/dist/cjs/src/bitflyer.js +1 -0
  14. package/dist/cjs/src/bitget.js +3 -2
  15. package/dist/cjs/src/bitmart.js +6 -9
  16. package/dist/cjs/src/bitmex.js +1 -0
  17. package/dist/cjs/src/bitopro.js +1 -0
  18. package/dist/cjs/src/bitrue.js +62 -71
  19. package/dist/cjs/src/bitso.js +1 -0
  20. package/dist/cjs/src/bitstamp.js +1 -0
  21. package/dist/cjs/src/bitvavo.js +1 -0
  22. package/dist/cjs/src/blockchaincom.js +1 -0
  23. package/dist/cjs/src/btcalpha.js +1 -0
  24. package/dist/cjs/src/btcbox.js +1 -0
  25. package/dist/cjs/src/btcmarkets.js +1 -0
  26. package/dist/cjs/src/bybit.js +2 -0
  27. package/dist/cjs/src/cex.js +1 -0
  28. package/dist/cjs/src/coinbaseexchange.js +1 -0
  29. package/dist/cjs/src/coinbaseinternational.js +2 -1
  30. package/dist/cjs/src/coinex.js +1 -17
  31. package/dist/cjs/src/cryptocom.js +0 -12
  32. package/dist/cjs/src/hitbtc.js +1 -0
  33. package/dist/cjs/src/htx.js +49 -49
  34. package/dist/cjs/src/huobijp.js +0 -9
  35. package/dist/cjs/src/kraken.js +48 -48
  36. package/dist/cjs/src/latoken.js +1 -0
  37. package/dist/cjs/src/mexc.js +1 -61
  38. package/dist/cjs/src/okcoin.js +4 -9
  39. package/dist/cjs/src/okx.js +1 -8
  40. package/dist/cjs/src/onetrading.js +1 -0
  41. package/dist/cjs/src/phemex.js +1 -0
  42. package/dist/cjs/src/poloniexfutures.js +1 -0
  43. package/dist/cjs/src/pro/binance.js +323 -0
  44. package/dist/cjs/src/pro/bingx.js +263 -91
  45. package/dist/cjs/src/pro/bithumb.js +5 -1
  46. package/dist/cjs/src/pro/bitvavo.js +1 -0
  47. package/dist/cjs/src/pro/bybit.js +291 -2
  48. package/dist/cjs/src/pro/cex.js +1 -0
  49. package/dist/cjs/src/pro/coinex.js +994 -679
  50. package/dist/cjs/src/pro/lbank.js +2 -3
  51. package/dist/cjs/src/pro/okx.js +159 -3
  52. package/dist/cjs/src/probit.js +1 -0
  53. package/dist/cjs/src/vertex.js +1 -0
  54. package/dist/cjs/src/whitebit.js +5 -3
  55. package/dist/cjs/src/woo.js +1 -0
  56. package/dist/cjs/src/woofipro.js +1 -0
  57. package/js/ccxt.d.ts +1 -1
  58. package/js/ccxt.js +1 -1
  59. package/js/src/ace.js +1 -0
  60. package/js/src/alpaca.js +3 -2
  61. package/js/src/ascendex.d.ts +0 -1
  62. package/js/src/ascendex.js +102 -116
  63. package/js/src/bigone.js +1 -0
  64. package/js/src/bingx.js +32 -17
  65. package/js/src/bit2c.js +1 -0
  66. package/js/src/bitbank.js +1 -0
  67. package/js/src/bitfinex.js +1 -0
  68. package/js/src/bitfinex2.d.ts +0 -1
  69. package/js/src/bitfinex2.js +21 -22
  70. package/js/src/bitflyer.js +1 -0
  71. package/js/src/bitget.js +3 -2
  72. package/js/src/bitmart.d.ts +0 -1
  73. package/js/src/bitmart.js +6 -9
  74. package/js/src/bitmex.js +1 -0
  75. package/js/src/bitopro.js +1 -0
  76. package/js/src/bitrue.d.ts +0 -1
  77. package/js/src/bitrue.js +62 -71
  78. package/js/src/bitso.js +1 -0
  79. package/js/src/bitstamp.js +1 -0
  80. package/js/src/bitvavo.js +1 -0
  81. package/js/src/blockchaincom.js +1 -0
  82. package/js/src/btcalpha.js +1 -0
  83. package/js/src/btcbox.js +1 -0
  84. package/js/src/btcmarkets.js +1 -0
  85. package/js/src/bybit.js +2 -0
  86. package/js/src/cex.js +1 -0
  87. package/js/src/coinbaseexchange.js +1 -0
  88. package/js/src/coinbaseinternational.js +2 -1
  89. package/js/src/coinex.d.ts +0 -2
  90. package/js/src/coinex.js +1 -17
  91. package/js/src/cryptocom.d.ts +0 -1
  92. package/js/src/cryptocom.js +0 -12
  93. package/js/src/hitbtc.js +1 -0
  94. package/js/src/htx.js +49 -49
  95. package/js/src/huobijp.d.ts +0 -1
  96. package/js/src/huobijp.js +0 -9
  97. package/js/src/kraken.js +48 -48
  98. package/js/src/latoken.js +1 -0
  99. package/js/src/mexc.js +1 -61
  100. package/js/src/okcoin.d.ts +0 -1
  101. package/js/src/okcoin.js +4 -9
  102. package/js/src/okx.d.ts +0 -1
  103. package/js/src/okx.js +1 -8
  104. package/js/src/onetrading.js +1 -0
  105. package/js/src/phemex.js +1 -0
  106. package/js/src/poloniexfutures.js +1 -0
  107. package/js/src/pro/binance.d.ts +9 -1
  108. package/js/src/pro/binance.js +327 -1
  109. package/js/src/pro/bingx.d.ts +2 -2
  110. package/js/src/pro/bingx.js +263 -91
  111. package/js/src/pro/bithumb.js +5 -1
  112. package/js/src/pro/bitvavo.js +1 -0
  113. package/js/src/pro/bybit.d.ts +12 -1
  114. package/js/src/pro/bybit.js +292 -3
  115. package/js/src/pro/cex.js +1 -0
  116. package/js/src/pro/coinex.d.ts +12 -6
  117. package/js/src/pro/coinex.js +996 -681
  118. package/js/src/pro/lbank.js +2 -3
  119. package/js/src/pro/okx.d.ts +7 -0
  120. package/js/src/pro/okx.js +162 -4
  121. package/js/src/probit.js +1 -0
  122. package/js/src/vertex.js +1 -0
  123. package/js/src/whitebit.js +5 -3
  124. package/js/src/woo.js +1 -0
  125. package/js/src/woofipro.js +1 -0
  126. package/package.json +1 -1
@@ -33,6 +33,7 @@ class bithumb extends bithumb$1 {
33
33
  * @method
34
34
  * @name bithumb#watchTicker
35
35
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
36
+ * @see https://apidocs.bithumb.com/v1.2.0/reference/%EB%B9%97%EC%8D%B8-%EA%B1%B0%EB%9E%98%EC%86%8C-%EC%A0%95%EB%B3%B4-%EC%88%98%EC%8B%A0
36
37
  * @param {string} symbol unified symbol of the market to fetch the ticker for
37
38
  * @param {object} [params] extra parameters specific to the exchange API endpoint
38
39
  * @param {string} [params.channel] the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
@@ -52,8 +53,9 @@ class bithumb extends bithumb$1 {
52
53
  async watchTickers(symbols = undefined, params = {}) {
53
54
  /**
54
55
  * @method
55
- * @name binance#watchTickers
56
+ * @name bithumb#watchTickers
56
57
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
58
+ * @see https://apidocs.bithumb.com/v1.2.0/reference/%EB%B9%97%EC%8D%B8-%EA%B1%B0%EB%9E%98%EC%86%8C-%EC%A0%95%EB%B3%B4-%EC%88%98%EC%8B%A0
57
59
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
58
60
  * @param {object} [params] extra parameters specific to the exchange API endpoint
59
61
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -167,6 +169,7 @@ class bithumb extends bithumb$1 {
167
169
  /**
168
170
  * @method
169
171
  * @name bithumb#watchOrderBook
172
+ * @see https://apidocs.bithumb.com/v1.2.0/reference/%EB%B9%97%EC%8D%B8-%EA%B1%B0%EB%9E%98%EC%86%8C-%EC%A0%95%EB%B3%B4-%EC%88%98%EC%8B%A0
170
173
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
171
174
  * @param {string} symbol unified symbol of the market to fetch the order book for
172
175
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -254,6 +257,7 @@ class bithumb extends bithumb$1 {
254
257
  * @method
255
258
  * @name bithumb#watchTrades
256
259
  * @description get the list of most recent trades for a particular symbol
260
+ * @see https://apidocs.bithumb.com/v1.2.0/reference/%EB%B9%97%EC%8D%B8-%EA%B1%B0%EB%9E%98%EC%86%8C-%EC%A0%95%EB%B3%B4-%EC%88%98%EC%8B%A0
257
261
  * @param {string} symbol unified symbol of the market to fetch trades for
258
262
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
259
263
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -639,6 +639,7 @@ class bitvavo extends bitvavo$1 {
639
639
  * @name bitvavo#fetchOrderWs
640
640
  * @see https://docs.bitvavo.com/#tag/General/paths/~1assets/get
641
641
  * @description fetches information on an order made by the user
642
+ * @param {string} id the order id
642
643
  * @param {string} symbol unified symbol of the market the order was made in
643
644
  * @param {object} [params] extra parameters specific to the bitvavo api endpoint
644
645
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -390,6 +390,49 @@ class bybit extends bybit$1 {
390
390
  }
391
391
  return this.filterByArray(this.tickers, 'symbol', symbols);
392
392
  }
393
+ async unWatchTickers(symbols = undefined, params = {}) {
394
+ /**
395
+ * @method
396
+ * @name bybit#unWatchTickers
397
+ * @description unWatches a price ticker
398
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/ticker
399
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/etp-ticker
400
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
401
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
402
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
403
+ */
404
+ await this.loadMarkets();
405
+ symbols = this.marketSymbols(symbols, undefined, false);
406
+ const options = this.safeValue(this.options, 'watchTickers', {});
407
+ const topic = this.safeString(options, 'name', 'tickers');
408
+ const messageHashes = [];
409
+ const subMessageHashes = [];
410
+ const marketIds = this.marketIds(symbols);
411
+ const topics = [];
412
+ for (let i = 0; i < marketIds.length; i++) {
413
+ const marketId = marketIds[i];
414
+ const symbol = symbols[i];
415
+ topics.push(topic + '.' + marketId);
416
+ subMessageHashes.push('ticker:' + symbol);
417
+ messageHashes.push('unsubscribe:ticker:' + symbol);
418
+ }
419
+ const url = await this.getUrlByMarketType(symbols[0], false, 'watchTickers', params);
420
+ return await this.unWatchTopics(url, 'ticker', symbols, messageHashes, subMessageHashes, topics, params);
421
+ }
422
+ async unWatchTicker(symbols, params = {}) {
423
+ /**
424
+ * @method
425
+ * @name bybit#unWatchTicker
426
+ * @description unWatches a price ticker
427
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/ticker
428
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/etp-ticker
429
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
430
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
431
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
432
+ */
433
+ await this.loadMarkets();
434
+ return await this.unWatchTickers([symbols], params);
435
+ }
393
436
  handleTicker(client, message) {
394
437
  //
395
438
  // linear
@@ -723,6 +766,56 @@ class bybit extends bybit$1 {
723
766
  const orderbook = await this.watchTopics(url, messageHashes, topics, params);
724
767
  return orderbook.limit();
725
768
  }
769
+ async unWatchOrderBookForSymbols(symbols, params = {}) {
770
+ /**
771
+ * @method
772
+ * @name bybit#unWatchOrderBookForSymbols
773
+ * @description unsubscribe from the orderbook channel
774
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/orderbook
775
+ * @param {string[]} symbols unified symbol of the market to unwatch the trades for
776
+ * @param {int} [params.limit] orderbook limit, default is undefined
777
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
778
+ */
779
+ await this.loadMarkets();
780
+ symbols = this.marketSymbols(symbols, undefined, false);
781
+ let channel = 'orderbook.';
782
+ let limit = this.safeInteger(params, 'limit');
783
+ if (limit !== undefined) {
784
+ params = this.omit(params, 'limit');
785
+ }
786
+ else {
787
+ const firstMarket = this.market(symbols[0]);
788
+ limit = firstMarket['spot'] ? 50 : 500;
789
+ }
790
+ channel += limit.toString();
791
+ const subMessageHashes = [];
792
+ const messageHashes = [];
793
+ const topics = [];
794
+ for (let i = 0; i < symbols.length; i++) {
795
+ const symbol = symbols[i];
796
+ const market = this.market(symbol);
797
+ const marketId = market['id'];
798
+ const topic = channel + '.' + marketId;
799
+ messageHashes.push('unsubscribe:orderbook:' + symbol);
800
+ subMessageHashes.push('orderbook:' + symbol);
801
+ topics.push(topic);
802
+ }
803
+ const url = await this.getUrlByMarketType(symbols[0], false, 'watchOrderBook', params);
804
+ return await this.unWatchTopics(url, 'orderbook', symbols, messageHashes, subMessageHashes, topics, params);
805
+ }
806
+ async unWatchOrderBook(symbol, params = {}) {
807
+ /**
808
+ * @method
809
+ * @name bybit#unWatchOrderBook
810
+ * @description unsubscribe from the orderbook channel
811
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/orderbook
812
+ * @param {string[]} symbols unified symbol of the market to unwatch the trades for
813
+ * @param {int} [params.limit] orderbook limit, default is undefined
814
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
815
+ */
816
+ await this.loadMarkets();
817
+ return await this.unWatchOrderBookForSymbols([symbol], params);
818
+ }
726
819
  handleOrderBook(client, message) {
727
820
  //
728
821
  // {
@@ -847,6 +940,44 @@ class bybit extends bybit$1 {
847
940
  }
848
941
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
849
942
  }
943
+ async unWatchTradesForSymbols(symbols, params = {}) {
944
+ /**
945
+ * @method
946
+ * @name bybit#unWatchTradesForSymbols
947
+ * @description unsubscribe from the trades channel
948
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/trade
949
+ * @param {string[]} symbols unified symbol of the market to unwatch the trades for
950
+ * @returns {any} status of the unwatch request
951
+ */
952
+ await this.loadMarkets();
953
+ symbols = this.marketSymbols(symbols, undefined, false, true);
954
+ const url = await this.getUrlByMarketType(symbols[0], false, 'unWatchTradesForSymbols', params);
955
+ const messageHashes = [];
956
+ const topics = [];
957
+ const subMessageHashes = [];
958
+ for (let i = 0; i < symbols.length; i++) {
959
+ const symbol = symbols[i];
960
+ const market = this.market(symbol);
961
+ const topic = 'publicTrade.' + market['id'];
962
+ topics.push(topic);
963
+ const messageHash = 'unsubscribe:trade:' + symbol;
964
+ messageHashes.push(messageHash);
965
+ subMessageHashes.push('trade:' + symbol);
966
+ }
967
+ return await this.unWatchTopics(url, 'trade', symbols, messageHashes, subMessageHashes, topics, params);
968
+ }
969
+ async unWatchTrades(symbol, params = {}) {
970
+ /**
971
+ * @method
972
+ * @name bybit#unWatchTrades
973
+ * @description unsubscribe from the trades channel
974
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/public/trade
975
+ * @param {string} symbol unified symbol of the market to unwatch the trades for
976
+ * @returns {any} status of the unwatch request
977
+ */
978
+ await this.loadMarkets();
979
+ return await this.unWatchTradesForSymbols([symbol], params);
980
+ }
850
981
  handleTrades(client, message) {
851
982
  //
852
983
  // {
@@ -1005,6 +1136,35 @@ class bybit extends bybit$1 {
1005
1136
  }
1006
1137
  return this.filterBySymbolSinceLimit(trades, symbol, since, limit, true);
1007
1138
  }
1139
+ async unWatchMyTrades(symbol = undefined, params = {}) {
1140
+ /**
1141
+ * @method
1142
+ * @name bybit#unWatchMyTrades
1143
+ * @description unWatches information on multiple trades made by the user
1144
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/private/execution
1145
+ * @param {string} symbol unified market symbol of the market orders were made in
1146
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1147
+ * @param {boolean} [params.unifiedMargin] use unified margin account
1148
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1149
+ */
1150
+ const method = 'watchMyTrades';
1151
+ const messageHash = 'unsubscribe:myTrades';
1152
+ let subHash = 'myTrades';
1153
+ await this.loadMarkets();
1154
+ if (symbol !== undefined) {
1155
+ symbol = this.symbol(symbol);
1156
+ subHash += ':' + symbol;
1157
+ }
1158
+ const url = await this.getUrlByMarketType(symbol, true, method, params);
1159
+ await this.authenticate(url);
1160
+ const topicByMarket = {
1161
+ 'spot': 'ticketInfo',
1162
+ 'unified': 'execution',
1163
+ 'usdc': 'user.openapi.perp.trade',
1164
+ };
1165
+ const topic = this.safeValue(topicByMarket, this.getPrivateType(url));
1166
+ return await this.unWatchTopics(url, 'myTrades', [], [messageHash], [subHash], [topic], params);
1167
+ }
1008
1168
  handleMyTrades(client, message) {
1009
1169
  //
1010
1170
  // spot
@@ -1277,7 +1437,7 @@ class bybit extends bybit$1 {
1277
1437
  const topic = 'liquidation.' + market['id'];
1278
1438
  const newLiquidation = await this.watchTopics(url, [messageHash], [topic], params);
1279
1439
  if (this.newUpdates) {
1280
- return [newLiquidation];
1440
+ return newLiquidation;
1281
1441
  }
1282
1442
  return this.filterBySymbolsSinceLimit(this.liquidations, [symbol], since, limit, true);
1283
1443
  }
@@ -1369,6 +1529,35 @@ class bybit extends bybit$1 {
1369
1529
  }
1370
1530
  return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
1371
1531
  }
1532
+ async unWatchOrders(symbol = undefined, params = {}) {
1533
+ /**
1534
+ * @method
1535
+ * @name bybit#unWatchOrders
1536
+ * @description unWatches information on multiple orders made by the user
1537
+ * @see https://bybit-exchange.github.io/docs/v5/websocket/private/order
1538
+ * @param {string} symbol unified market symbol of the market orders were made in
1539
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1540
+ * @param {boolean} [params.unifiedMargin] use unified margin account
1541
+ * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
1542
+ */
1543
+ await this.loadMarkets();
1544
+ const method = 'watchOrders';
1545
+ const messageHash = 'unsubscribe:orders';
1546
+ let subHash = 'orders';
1547
+ if (symbol !== undefined) {
1548
+ symbol = this.symbol(symbol);
1549
+ subHash += ':' + symbol;
1550
+ }
1551
+ const url = await this.getUrlByMarketType(symbol, true, method, params);
1552
+ await this.authenticate(url);
1553
+ const topicsByMarket = {
1554
+ 'spot': ['order', 'stopOrder'],
1555
+ 'unified': ['order'],
1556
+ 'usdc': ['user.openapi.perp.order'],
1557
+ };
1558
+ const topics = this.safeValue(topicsByMarket, this.getPrivateType(url));
1559
+ return await this.unWatchTopics(url, 'orders', [], [messageHash], [subHash], topics, params);
1560
+ }
1372
1561
  handleOrderWs(client, message) {
1373
1562
  //
1374
1563
  // {
@@ -1951,7 +2140,24 @@ class bybit extends bybit$1 {
1951
2140
  'args': topics,
1952
2141
  };
1953
2142
  const message = this.extend(request, params);
1954
- return await this.watchMultiple(url, messageHashes, message, topics);
2143
+ return await this.watchMultiple(url, messageHashes, message, messageHashes);
2144
+ }
2145
+ async unWatchTopics(url, topic, symbols, messageHashes, subMessageHashes, topics, params = {}) {
2146
+ const reqId = this.requestId();
2147
+ const request = {
2148
+ 'op': 'unsubscribe',
2149
+ 'req_id': reqId,
2150
+ 'args': topics,
2151
+ };
2152
+ const subscription = {
2153
+ 'id': reqId,
2154
+ 'topic': topic,
2155
+ 'messageHashes': messageHashes,
2156
+ 'subMessageHashes': subMessageHashes,
2157
+ 'symbols': symbols,
2158
+ };
2159
+ const message = this.extend(request, params);
2160
+ return await this.watchMultiple(url, messageHashes, message, messageHashes, subscription);
1955
2161
  }
1956
2162
  async authenticate(url, params = {}) {
1957
2163
  this.checkRequiredCredentials();
@@ -2102,6 +2308,7 @@ class bybit extends bybit$1 {
2102
2308
  'order.amend': this.handleOrderWs,
2103
2309
  'order.cancel': this.handleOrderWs,
2104
2310
  'auth': this.handleAuthenticate,
2311
+ 'unsubscribe': this.handleUnSubscribe,
2105
2312
  };
2106
2313
  const exacMethod = this.safeValue(methods, topic);
2107
2314
  if (exacMethod !== undefined) {
@@ -2192,6 +2399,88 @@ class bybit extends bybit$1 {
2192
2399
  //
2193
2400
  return message;
2194
2401
  }
2402
+ handleUnSubscribe(client, message) {
2403
+ //
2404
+ // {"success":true,"ret_msg":"","conn_id":"7188110e-6908-41e9-b863-6365127e92ad","req_id":"3","op":"unsubscribe"}
2405
+ //
2406
+ // client.subscription will be something like:
2407
+ // {
2408
+ // "publicTrade.LTCUSDT":true,
2409
+ // "publicTrade.ADAUSDT":true,
2410
+ // "unsubscribe:trade:LTC/USDT:USDT": {
2411
+ // "id":4,
2412
+ // "subHash": "trade:LTC/USDT"
2413
+ // },
2414
+ // }
2415
+ const reqId = this.safeString(message, 'req_id');
2416
+ const keys = Object.keys(client.subscriptions);
2417
+ for (let i = 0; i < keys.length; i++) {
2418
+ const messageHash = keys[i];
2419
+ if (!(messageHash in client.subscriptions)) {
2420
+ continue;
2421
+ // the previous iteration can have deleted the messageHash from the subscriptions
2422
+ }
2423
+ if (messageHash.startsWith('unsubscribe')) {
2424
+ const subscription = client.subscriptions[messageHash];
2425
+ const subId = this.safeString(subscription, 'id');
2426
+ if (reqId !== subId) {
2427
+ continue;
2428
+ }
2429
+ const messageHashes = this.safeList(subscription, 'messageHashes', []);
2430
+ const subMessageHashes = this.safeList(subscription, 'subMessageHashes', []);
2431
+ for (let j = 0; j < messageHashes.length; j++) {
2432
+ const unsubHash = messageHashes[j];
2433
+ const subHash = subMessageHashes[j];
2434
+ if (unsubHash in client.subscriptions) {
2435
+ delete client.subscriptions[unsubHash];
2436
+ }
2437
+ if (subHash in client.subscriptions) {
2438
+ delete client.subscriptions[subHash];
2439
+ }
2440
+ const error = new errors.UnsubscribeError(this.id + ' ' + messageHash);
2441
+ client.reject(error, subHash);
2442
+ client.resolve(true, unsubHash);
2443
+ this.cleanCache(subscription);
2444
+ }
2445
+ }
2446
+ }
2447
+ return message;
2448
+ }
2449
+ cleanCache(subscription) {
2450
+ const topic = this.safeString(subscription, 'topic');
2451
+ const symbols = this.safeList(subscription, 'symbols', []);
2452
+ const symbolsLength = symbols.length;
2453
+ if (symbolsLength > 0) {
2454
+ for (let i = 0; i < symbols.length; i++) {
2455
+ const symbol = symbols[i];
2456
+ if (topic === 'trade') {
2457
+ delete this.trades[symbol];
2458
+ }
2459
+ else if (topic === 'orderbook') {
2460
+ delete this.orderbooks[symbol];
2461
+ }
2462
+ else if (topic === 'ticker') {
2463
+ delete this.tickers[symbol];
2464
+ }
2465
+ }
2466
+ }
2467
+ else {
2468
+ if (topic === 'myTrades') {
2469
+ // don't reset this.myTrades directly here
2470
+ // because in c# we need to use a different object
2471
+ const keys = Object.keys(this.myTrades);
2472
+ for (let i = 0; i < keys.length; i++) {
2473
+ delete this.myTrades[keys[i]];
2474
+ }
2475
+ }
2476
+ else if (topic === 'orders') {
2477
+ const orderSymbols = Object.keys(this.orders);
2478
+ for (let i = 0; i < orderSymbols.length; i++) {
2479
+ delete this.orders[orderSymbols[i]];
2480
+ }
2481
+ }
2482
+ }
2483
+ }
2195
2484
  }
2196
2485
 
2197
2486
  module.exports = bybit;
@@ -1192,6 +1192,7 @@ class cex extends cex$1 {
1192
1192
  * @name cex#fetchOrderWs
1193
1193
  * @description fetches information on an order made by the user
1194
1194
  * @see https://docs.cex.io/#ws-api-get-order
1195
+ * @param {string} id the order id
1195
1196
  * @param {string} symbol not used by cex fetchOrder
1196
1197
  * @param {object} [params] extra parameters specific to the cex api endpoint
1197
1198
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}