ccxt 4.4.1 → 4.4.2

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 (48) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +69 -0
  5. package/dist/cjs/src/binance.js +78 -8
  6. package/dist/cjs/src/cryptocom.js +1 -1
  7. package/dist/cjs/src/currencycom.js +1 -2
  8. package/dist/cjs/src/htx.js +1 -1
  9. package/dist/cjs/src/mexc.js +69 -1
  10. package/dist/cjs/src/pro/binance.js +3 -63
  11. package/dist/cjs/src/pro/bitget.js +1 -9
  12. package/dist/cjs/src/pro/bitmex.js +11 -1
  13. package/dist/cjs/src/pro/bybit.js +2 -54
  14. package/dist/cjs/src/pro/cryptocom.js +2 -40
  15. package/dist/cjs/src/pro/gate.js +1 -9
  16. package/dist/cjs/src/pro/hyperliquid.js +4 -36
  17. package/dist/cjs/src/pro/kucoin.js +2 -59
  18. package/dist/cjs/src/pro/kucoinfutures.js +139 -1
  19. package/dist/cjs/src/pro/okx.js +8 -36
  20. package/dist/cjs/src/xt.js +1 -1
  21. package/examples/js/cli.js +8 -4
  22. package/js/ccxt.d.ts +3 -3
  23. package/js/ccxt.js +1 -1
  24. package/js/src/base/Exchange.d.ts +2 -0
  25. package/js/src/base/Exchange.js +70 -1
  26. package/js/src/base/types.d.ts +5 -4
  27. package/js/src/binance.js +78 -8
  28. package/js/src/cryptocom.js +1 -1
  29. package/js/src/currencycom.js +1 -2
  30. package/js/src/htx.js +1 -1
  31. package/js/src/mexc.js +69 -1
  32. package/js/src/pro/binance.d.ts +0 -1
  33. package/js/src/pro/binance.js +4 -64
  34. package/js/src/pro/bitget.js +1 -9
  35. package/js/src/pro/bitmex.js +11 -1
  36. package/js/src/pro/bybit.d.ts +1 -2
  37. package/js/src/pro/bybit.js +3 -55
  38. package/js/src/pro/cryptocom.d.ts +1 -2
  39. package/js/src/pro/cryptocom.js +3 -41
  40. package/js/src/pro/gate.js +2 -10
  41. package/js/src/pro/hyperliquid.js +5 -37
  42. package/js/src/pro/kucoin.d.ts +0 -1
  43. package/js/src/pro/kucoin.js +3 -60
  44. package/js/src/pro/kucoinfutures.d.ts +7 -1
  45. package/js/src/pro/kucoinfutures.js +139 -1
  46. package/js/src/pro/okx.js +9 -37
  47. package/js/src/xt.js +1 -1
  48. package/package.json +1 -1
@@ -62,6 +62,7 @@ export default class bitmex extends bitmexRest {
62
62
  * @method
63
63
  * @name bitmex#watchTicker
64
64
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
65
+ * @see https://www.bitmex.com/app/wsAPI#Subscriptions
65
66
  * @param {string} symbol unified symbol of the market to fetch the ticker for
66
67
  * @param {object} [params] extra parameters specific to the exchange API endpoint
67
68
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -76,6 +77,7 @@ export default class bitmex extends bitmexRest {
76
77
  * @method
77
78
  * @name bitmex#watchTickers
78
79
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
80
+ * @see https://www.bitmex.com/app/wsAPI#Subscriptions
79
81
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
80
82
  * @param {object} [params] extra parameters specific to the exchange API endpoint
81
83
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -466,6 +468,7 @@ export default class bitmex extends bitmexRest {
466
468
  * @method
467
469
  * @name bitmex#watchBalance
468
470
  * @description watch balance and get the amount of funds available for trading or funds locked in orders
471
+ * @see https://www.bitmex.com/app/wsAPI#Subscriptions
469
472
  * @param {object} [params] extra parameters specific to the exchange API endpoint
470
473
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
471
474
  */
@@ -673,6 +676,7 @@ export default class bitmex extends bitmexRest {
673
676
  * @method
674
677
  * @name bitmex#watchTrades
675
678
  * @description get the list of most recent trades for a particular symbol
679
+ * @see https://www.bitmex.com/app/wsAPI#Subscriptions
676
680
  * @param {string} symbol unified symbol of the market to fetch trades for
677
681
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
678
682
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -725,8 +729,8 @@ export default class bitmex extends bitmexRest {
725
729
  /**
726
730
  * @method
727
731
  * @name bitmex#watchPositions
728
- * @see https://www.bitmex.com/app/wsAPI
729
732
  * @description watch all open positions
733
+ * @see https://www.bitmex.com/app/wsAPI#Subscriptions
730
734
  * @param {string[]|undefined} symbols list of unified market symbols
731
735
  * @param {object} params extra parameters specific to the exchange API endpoint
732
736
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
@@ -930,6 +934,7 @@ export default class bitmex extends bitmexRest {
930
934
  * @method
931
935
  * @name bitmex#watchOrders
932
936
  * @description watches information on multiple orders made by the user
937
+ * @see https://www.bitmex.com/app/wsAPI#Subscriptions
933
938
  * @param {string} symbol unified market symbol of the market orders were made in
934
939
  * @param {int} [since] the earliest time in ms to fetch orders for
935
940
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1145,6 +1150,7 @@ export default class bitmex extends bitmexRest {
1145
1150
  * @method
1146
1151
  * @name bitmex#watchMyTrades
1147
1152
  * @description watches information on multiple trades made by the user
1153
+ * @see https://www.bitmex.com/app/wsAPI#Subscriptions
1148
1154
  * @param {string} symbol unified market symbol of the market trades were made in
1149
1155
  * @param {int} [since] the earliest time in ms to fetch trades for
1150
1156
  * @param {int} [limit] the maximum number of trade structures to retrieve
@@ -1262,6 +1268,7 @@ export default class bitmex extends bitmexRest {
1262
1268
  * @method
1263
1269
  * @name bitmex#watchOrderBook
1264
1270
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1271
+ * @see https://www.bitmex.com/app/wsAPI#OrderBookL2
1265
1272
  * @param {string} symbol unified symbol of the market to fetch the order book for
1266
1273
  * @param {int} [limit] the maximum amount of order book entries to return
1267
1274
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1274,6 +1281,7 @@ export default class bitmex extends bitmexRest {
1274
1281
  * @method
1275
1282
  * @name bitmex#watchOrderBookForSymbols
1276
1283
  * @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1284
+ * @see https://www.bitmex.com/app/wsAPI#OrderBookL2
1277
1285
  * @param {string[]} symbols unified array of symbols
1278
1286
  * @param {int} [limit] the maximum amount of order book entries to return
1279
1287
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1317,6 +1325,7 @@ export default class bitmex extends bitmexRest {
1317
1325
  * @method
1318
1326
  * @name bitmex#watchTradesForSymbols
1319
1327
  * @description get the list of most recent trades for a list of symbols
1328
+ * @see https://www.bitmex.com/app/wsAPI#Subscriptions
1320
1329
  * @param {string[]} symbols unified symbol of the market to fetch trades for
1321
1330
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
1322
1331
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -1354,6 +1363,7 @@ export default class bitmex extends bitmexRest {
1354
1363
  * @method
1355
1364
  * @name bitmex#watchOHLCV
1356
1365
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
1366
+ * @see https://www.bitmex.com/app/wsAPI#Subscriptions
1357
1367
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1358
1368
  * @param {string} timeframe the length of time each candle represents
1359
1369
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -1,5 +1,5 @@
1
1
  import bybitRest from '../bybit.js';
2
- import type { Int, OHLCV, Str, Strings, Ticker, OrderBook, Order, Trade, Tickers, Position, Balances, OrderType, OrderSide, Num, Dict, Liquidation } from '../base/types.js';
2
+ import type { Int, OHLCV, Str, Strings, Ticker, OrderBook, Order, Trade, Tickers, Position, Balances, OrderType, OrderSide, Num, Liquidation } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class bybit extends bybitRest {
5
5
  describe(): any;
@@ -65,5 +65,4 @@ export default class bybit extends bybitRest {
65
65
  handleAuthenticate(client: Client, message: any): any;
66
66
  handleSubscriptionStatus(client: Client, message: any): any;
67
67
  handleUnSubscribe(client: Client, message: any): any;
68
- cleanCache(subscription: Dict): void;
69
68
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import bybitRest from '../bybit.js';
9
- import { ArgumentsRequired, AuthenticationError, ExchangeError, BadRequest, UnsubscribeError } from '../base/errors.js';
9
+ import { ArgumentsRequired, AuthenticationError, ExchangeError, BadRequest } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide, ArrayCacheByTimestamp } from '../base/ws/Cache.js';
11
11
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
12
12
  // ---------------------------------------------------------------------------
@@ -1019,7 +1019,7 @@ export default class bybit extends bybitRest {
1019
1019
  messageHashes.push(messageHash);
1020
1020
  subMessageHashes.push('trade:' + symbol);
1021
1021
  }
1022
- return await this.unWatchTopics(url, 'trade', symbols, messageHashes, subMessageHashes, topics, params);
1022
+ return await this.unWatchTopics(url, 'trades', symbols, messageHashes, subMessageHashes, topics, params);
1023
1023
  }
1024
1024
  async unWatchTrades(symbol, params = {}) {
1025
1025
  /**
@@ -2486,63 +2486,11 @@ export default class bybit extends bybitRest {
2486
2486
  for (let j = 0; j < messageHashes.length; j++) {
2487
2487
  const unsubHash = messageHashes[j];
2488
2488
  const subHash = subMessageHashes[j];
2489
- if (unsubHash in client.subscriptions) {
2490
- delete client.subscriptions[unsubHash];
2491
- }
2492
- if (subHash in client.subscriptions) {
2493
- delete client.subscriptions[subHash];
2494
- }
2495
- const error = new UnsubscribeError(this.id + ' ' + messageHash);
2496
- client.reject(error, subHash);
2497
- client.resolve(true, unsubHash);
2489
+ this.cleanUnsubscription(client, subHash, unsubHash);
2498
2490
  }
2499
2491
  this.cleanCache(subscription);
2500
2492
  }
2501
2493
  }
2502
2494
  return message;
2503
2495
  }
2504
- cleanCache(subscription) {
2505
- const topic = this.safeString(subscription, 'topic');
2506
- const symbols = this.safeList(subscription, 'symbols', []);
2507
- const symbolsLength = symbols.length;
2508
- if (topic === 'ohlcv') {
2509
- const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
2510
- for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
2511
- const symbolAndTimeFrame = symbolsAndTimeFrames[i];
2512
- const symbol = this.safeString(symbolAndTimeFrame, 0);
2513
- const timeframe = this.safeString(symbolAndTimeFrame, 1);
2514
- delete this.ohlcvs[symbol][timeframe];
2515
- }
2516
- }
2517
- else if (symbolsLength > 0) {
2518
- for (let i = 0; i < symbols.length; i++) {
2519
- const symbol = symbols[i];
2520
- if (topic === 'trade') {
2521
- delete this.trades[symbol];
2522
- }
2523
- else if (topic === 'orderbook') {
2524
- delete this.orderbooks[symbol];
2525
- }
2526
- else if (topic === 'ticker') {
2527
- delete this.tickers[symbol];
2528
- }
2529
- }
2530
- }
2531
- else {
2532
- if (topic === 'myTrades') {
2533
- // don't reset this.myTrades directly here
2534
- // because in c# we need to use a different object
2535
- const keys = Object.keys(this.myTrades);
2536
- for (let i = 0; i < keys.length; i++) {
2537
- delete this.myTrades[keys[i]];
2538
- }
2539
- }
2540
- else if (topic === 'orders') {
2541
- const orderSymbols = Object.keys(this.orders);
2542
- for (let i = 0; i < orderSymbols.length; i++) {
2543
- delete this.orders[orderSymbols[i]];
2544
- }
2545
- }
2546
- }
2547
- }
2548
2496
  }
@@ -1,5 +1,5 @@
1
1
  import cryptocomRest from '../cryptocom.js';
2
- import type { Int, OrderSide, OrderType, Str, Strings, OrderBook, Order, Trade, Ticker, OHLCV, Position, Balances, Num, Dict } from '../base/types.js';
2
+ import type { Int, OrderSide, OrderType, Str, Strings, OrderBook, Order, Trade, Ticker, OHLCV, Position, Balances, Num } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class cryptocom extends cryptocomRest {
5
5
  describe(): any;
@@ -48,5 +48,4 @@ export default class cryptocom extends cryptocomRest {
48
48
  handlePing(client: Client, message: any): void;
49
49
  handleAuthenticate(client: Client, message: any): void;
50
50
  handleUnsubscribe(client: Client, message: any): void;
51
- cleanCache(subscription: Dict): void;
52
51
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import cryptocomRest from '../cryptocom.js';
9
- import { AuthenticationError, ChecksumError, ExchangeError, NetworkError, UnsubscribeError } from '../base/errors.js';
9
+ import { AuthenticationError, ChecksumError, ExchangeError, NetworkError } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
11
11
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
12
12
  // ---------------------------------------------------------------------------
@@ -374,7 +374,7 @@ export default class cryptocom extends cryptocomRest {
374
374
  messageHashes.push('unsubscribe:trades:' + market['symbol']);
375
375
  topics.push(currentTopic);
376
376
  }
377
- return await this.unWatchPublicMultiple('trade', symbols, messageHashes, topics, topics, params);
377
+ return await this.unWatchPublicMultiple('trades', symbols, messageHashes, topics, topics, params);
378
378
  }
379
379
  handleTrades(client, message) {
380
380
  //
@@ -1208,48 +1208,10 @@ export default class cryptocom extends cryptocomRest {
1208
1208
  for (let j = 0; j < messageHashes.length; j++) {
1209
1209
  const unsubHash = messageHashes[j];
1210
1210
  const subHash = subMessageHashes[j];
1211
- if (unsubHash in client.subscriptions) {
1212
- delete client.subscriptions[unsubHash];
1213
- }
1214
- if (subHash in client.subscriptions) {
1215
- delete client.subscriptions[subHash];
1216
- }
1217
- const error = new UnsubscribeError(this.id + ' ' + subHash);
1218
- client.reject(error, subHash);
1219
- client.resolve(true, unsubHash);
1211
+ this.cleanUnsubscription(client, subHash, unsubHash);
1220
1212
  }
1221
1213
  this.cleanCache(subscription);
1222
1214
  }
1223
1215
  }
1224
1216
  }
1225
- cleanCache(subscription) {
1226
- const topic = this.safeString(subscription, 'topic');
1227
- const symbols = this.safeList(subscription, 'symbols', []);
1228
- const symbolsLength = symbols.length;
1229
- if (topic === 'ohlcv') {
1230
- const symbolsAndTimeFrames = this.safeList(subscription, 'symbolsAndTimeframes', []);
1231
- for (let i = 0; i < symbolsAndTimeFrames.length; i++) {
1232
- const symbolAndTimeFrame = symbolsAndTimeFrames[i];
1233
- const symbol = this.safeString(symbolAndTimeFrame, 0);
1234
- const timeframe = this.safeString(symbolAndTimeFrame, 1);
1235
- if (timeframe in this.ohlcvs[symbol]) {
1236
- delete this.ohlcvs[symbol][timeframe];
1237
- }
1238
- }
1239
- }
1240
- else if (symbolsLength > 0) {
1241
- for (let i = 0; i < symbols.length; i++) {
1242
- const symbol = symbols[i];
1243
- if (topic === 'trade') {
1244
- delete this.trades[symbol];
1245
- }
1246
- else if (topic === 'orderbook') {
1247
- delete this.orderbooks[symbol];
1248
- }
1249
- else if (topic === 'ticker') {
1250
- delete this.tickers[symbol];
1251
- }
1252
- }
1253
- }
1254
- }
1255
1217
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import gateRest from '../gate.js';
9
- import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, NotSupported, UnsubscribeError } from '../base/errors.js';
9
+ import { AuthenticationError, BadRequest, ArgumentsRequired, ChecksumError, ExchangeError, NotSupported } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
11
11
  import { sha512 } from '../static_dependencies/noble-hashes/sha512.js';
12
12
  import Precise from '../base/Precise.js';
@@ -1663,15 +1663,7 @@ export default class gate extends gateRest {
1663
1663
  for (let j = 0; j < messageHashes.length; j++) {
1664
1664
  const unsubHash = messageHashes[j];
1665
1665
  const subHash = subMessageHashes[j];
1666
- if (unsubHash in client.subscriptions) {
1667
- delete client.subscriptions[unsubHash];
1668
- }
1669
- if (subHash in client.subscriptions) {
1670
- delete client.subscriptions[subHash];
1671
- }
1672
- const error = new UnsubscribeError(this.id + ' ' + messageHash);
1673
- client.reject(error, subHash);
1674
- client.resolve(true, unsubHash);
1666
+ this.cleanUnsubscription(client, subHash, unsubHash);
1675
1667
  }
1676
1668
  this.cleanCache(subscription);
1677
1669
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import hyperliquidRest from '../hyperliquid.js';
9
- import { ExchangeError, UnsubscribeError } from '../base/errors.js';
9
+ import { ExchangeError } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
11
11
  // ---------------------------------------------------------------------------
12
12
  export default class hyperliquid extends hyperliquidRest {
@@ -844,15 +844,7 @@ export default class hyperliquid extends hyperliquidRest {
844
844
  const symbol = this.safeSymbol(marketId);
845
845
  const subMessageHash = 'orderbook:' + symbol;
846
846
  const messageHash = 'unsubscribe:' + subMessageHash;
847
- if (messageHash in client.subscriptions) {
848
- delete client.subscriptions[messageHash];
849
- }
850
- if (subMessageHash in client.subscriptions) {
851
- delete client.subscriptions[subMessageHash];
852
- }
853
- const error = new UnsubscribeError(this.id + ' ' + subMessageHash);
854
- client.reject(error, subMessageHash);
855
- client.resolve(true, messageHash);
847
+ this.cleanUnsubscription(client, subMessageHash, messageHash);
856
848
  if (symbol in this.orderbooks) {
857
849
  delete this.orderbooks[symbol];
858
850
  }
@@ -864,15 +856,7 @@ export default class hyperliquid extends hyperliquidRest {
864
856
  const symbol = this.safeSymbol(marketId);
865
857
  const subMessageHash = 'trade:' + symbol;
866
858
  const messageHash = 'unsubscribe:' + subMessageHash;
867
- if (messageHash in client.subscriptions) {
868
- delete client.subscriptions[messageHash];
869
- }
870
- if (subMessageHash in client.subscriptions) {
871
- delete client.subscriptions[subMessageHash];
872
- }
873
- const error = new UnsubscribeError(this.id + ' ' + subMessageHash);
874
- client.reject(error, subMessageHash);
875
- client.resolve(true, messageHash);
859
+ this.cleanUnsubscription(client, subMessageHash, messageHash);
876
860
  if (symbol in this.trades) {
877
861
  delete this.trades[symbol];
878
862
  }
@@ -881,15 +865,7 @@ export default class hyperliquid extends hyperliquidRest {
881
865
  //
882
866
  const subMessageHash = 'tickers';
883
867
  const messageHash = 'unsubscribe:' + subMessageHash;
884
- if (messageHash in client.subscriptions) {
885
- delete client.subscriptions[messageHash];
886
- }
887
- if (subMessageHash in client.subscriptions) {
888
- delete client.subscriptions[subMessageHash];
889
- }
890
- const error = new UnsubscribeError(this.id + ' ' + subMessageHash);
891
- client.reject(error, subMessageHash);
892
- client.resolve(true, messageHash);
868
+ this.cleanUnsubscription(client, subMessageHash, messageHash);
893
869
  const symbols = Object.keys(this.tickers);
894
870
  for (let i = 0; i < symbols.length; i++) {
895
871
  delete this.tickers[symbols[i]];
@@ -903,15 +879,7 @@ export default class hyperliquid extends hyperliquidRest {
903
879
  const timeframe = this.findTimeframe(interval);
904
880
  const subMessageHash = 'candles:' + timeframe + ':' + symbol;
905
881
  const messageHash = 'unsubscribe:' + subMessageHash;
906
- if (messageHash in client.subscriptions) {
907
- delete client.subscriptions[messageHash];
908
- }
909
- if (subMessageHash in client.subscriptions) {
910
- delete client.subscriptions[subMessageHash];
911
- }
912
- const error = new UnsubscribeError(this.id + ' ' + subMessageHash);
913
- client.reject(error, subMessageHash);
914
- client.resolve(true, messageHash);
882
+ this.cleanUnsubscription(client, subMessageHash, messageHash);
915
883
  if (symbol in this.ohlcvs) {
916
884
  if (timeframe in this.ohlcvs[symbol]) {
917
885
  delete this.ohlcvs[symbol][timeframe];
@@ -33,7 +33,6 @@ export default class kucoin extends kucoinRest {
33
33
  handleBidAsks(bookSide: any, bidAsks: any): void;
34
34
  handleOrderBookSubscription(client: Client, message: any, subscription: any): void;
35
35
  handleSubscriptionStatus(client: Client, message: any): void;
36
- cleanCache(subscription: Dict): void;
37
36
  handleSystemStatus(client: Client, message: any): any;
38
37
  watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
39
38
  parseWsOrderStatus(status: any): string;
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import kucoinRest from '../kucoin.js';
9
- import { ExchangeError, ArgumentsRequired, UnsubscribeError } from '../base/errors.js';
9
+ import { ExchangeError, ArgumentsRequired } from '../base/errors.js';
10
10
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById } from '../base/ws/Cache.js';
11
11
  // ---------------------------------------------------------------------------
12
12
  export default class kucoin extends kucoinRest {
@@ -538,8 +538,6 @@ export default class kucoin extends kucoinRest {
538
538
  * @description unWatches trades stream
539
539
  * @see https://www.kucoin.com/docs/websocket/spot-trading/public-channels/match-execution-data
540
540
  * @param {string} symbol unified symbol of the market to fetch trades for
541
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
542
- * @param {int} [limit] the maximum amount of trades to fetch
543
541
  * @param {object} [params] extra parameters specific to the exchange API endpoint
544
542
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
545
543
  */
@@ -926,64 +924,9 @@ export default class kucoin extends kucoinRest {
926
924
  for (let i = 0; i < messageHashes.length; i++) {
927
925
  const messageHash = messageHashes[i];
928
926
  const subHash = subMessageHashes[i];
929
- if (messageHash in client.subscriptions) {
930
- delete client.subscriptions[messageHash];
931
- }
932
- if (subHash in client.subscriptions) {
933
- delete client.subscriptions[subHash];
934
- }
935
- const error = new UnsubscribeError(this.id + ' ' + subHash);
936
- client.reject(error, subHash);
937
- client.resolve(true, messageHash);
938
- this.cleanCache(subscription);
939
- }
940
- }
941
- }
942
- cleanCache(subscription) {
943
- const topic = this.safeString(subscription, 'topic');
944
- const symbols = this.safeList(subscription, 'symbols', []);
945
- const symbolsLength = symbols.length;
946
- if (symbolsLength > 0) {
947
- for (let i = 0; i < symbols.length; i++) {
948
- const symbol = symbols[i];
949
- if (topic === 'trades') {
950
- if (symbol in this.trades) {
951
- delete this.trades[symbol];
952
- }
953
- }
954
- else if (topic === 'orderbook') {
955
- if (symbol in this.orderbooks) {
956
- delete this.orderbooks[symbol];
957
- }
958
- }
959
- else if (topic === 'ticker') {
960
- if (symbol in this.tickers) {
961
- delete this.tickers[symbol];
962
- }
963
- }
964
- }
965
- }
966
- else {
967
- if (topic === 'myTrades') {
968
- // don't reset this.myTrades directly here
969
- // because in c# we need to use a different object
970
- const keys = Object.keys(this.myTrades);
971
- for (let i = 0; i < keys.length; i++) {
972
- delete this.myTrades[keys[i]];
973
- }
974
- }
975
- else if (topic === 'orders') {
976
- const orderSymbols = Object.keys(this.orders);
977
- for (let i = 0; i < orderSymbols.length; i++) {
978
- delete this.orders[orderSymbols[i]];
979
- }
980
- }
981
- else if (topic === 'ticker') {
982
- const tickerSymbols = Object.keys(this.tickers);
983
- for (let i = 0; i < tickerSymbols.length; i++) {
984
- delete this.tickers[tickerSymbols[i]];
985
- }
927
+ this.cleanUnsubscription(client, subHash, messageHash);
986
928
  }
929
+ this.cleanCache(subscription);
987
930
  }
988
931
  }
989
932
  handleSystemStatus(client, message) {
@@ -1,5 +1,5 @@
1
1
  import kucoinfuturesRest from '../kucoinfutures.js';
2
- import type { Int, Str, OrderBook, Order, Trade, Ticker, Balances, Position, Strings, Tickers, OHLCV } from '../base/types.js';
2
+ import type { Int, Str, OrderBook, Order, Trade, Ticker, Balances, Position, Strings, Tickers, OHLCV, Dict } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class kucoinfutures extends kucoinfuturesRest {
5
5
  describe(): any;
@@ -8,6 +8,7 @@ export default class kucoinfutures extends kucoinfuturesRest {
8
8
  requestId(): any;
9
9
  subscribe(url: any, messageHash: any, subscriptionHash: any, subscription: any, params?: {}): Promise<any>;
10
10
  subscribeMultiple(url: any, messageHashes: any, topic: any, subscriptionHashes: any, subscriptionArgs: any, params?: {}): Promise<any>;
11
+ unSubscribeMultiple(url: any, messageHashes: any, topic: any, subscriptionHashes: any, params?: {}, subscription?: Dict): Promise<any>;
11
12
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
12
13
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
13
14
  handleTicker(client: Client, message: any): void;
@@ -22,11 +23,15 @@ export default class kucoinfutures extends kucoinfuturesRest {
22
23
  handlePosition(client: Client, message: any): void;
23
24
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
24
25
  watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
26
+ unWatchTrades(symbol: string, params?: {}): Promise<any>;
27
+ unWatchTradesForSymbols(symbols: string[], params?: {}): Promise<any>;
25
28
  handleTrade(client: Client, message: any): any;
26
29
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
27
30
  handleOHLCV(client: Client, message: any): void;
28
31
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
29
32
  watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
33
+ unWatchOrderBook(symbol: string, params?: {}): Promise<any>;
34
+ unWatchOrderBookForSymbols(symbols: string[], params?: {}): Promise<any>;
30
35
  handleDelta(orderbook: any, delta: any): void;
31
36
  handleDeltas(bookside: any, deltas: any): void;
32
37
  handleOrderBook(client: Client, message: any): void;
@@ -48,5 +53,6 @@ export default class kucoinfutures extends kucoinfuturesRest {
48
53
  };
49
54
  handlePong(client: Client, message: any): any;
50
55
  handleErrorMessage(client: Client, message: any): void;
56
+ handleSubscriptionStatus(client: Client, message: any): void;
51
57
  handleMessage(client: Client, message: any): void;
52
58
  }