ccxt 4.3.85 → 4.3.87

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 (77) hide show
  1. package/README.md +8 -5
  2. package/dist/ccxt.browser.min.js +15 -15
  3. package/dist/cjs/ccxt.js +7 -1
  4. package/dist/cjs/src/abstract/hashkey.js +9 -0
  5. package/dist/cjs/src/base/Exchange.js +1 -1
  6. package/dist/cjs/src/base/errors.js +8 -1
  7. package/dist/cjs/src/binance.js +4 -2
  8. package/dist/cjs/src/bingx.js +7 -1
  9. package/dist/cjs/src/bitfinex.js +2 -2
  10. package/dist/cjs/src/hashkey.js +4327 -0
  11. package/dist/cjs/src/hyperliquid.js +85 -65
  12. package/dist/cjs/src/indodax.js +37 -9
  13. package/dist/cjs/src/kraken.js +37 -6
  14. package/dist/cjs/src/krakenfutures.js +12 -10
  15. package/dist/cjs/src/pro/ascendex.js +45 -5
  16. package/dist/cjs/src/pro/bingx.js +13 -12
  17. package/dist/cjs/src/pro/bitget.js +164 -19
  18. package/dist/cjs/src/pro/hashkey.js +839 -0
  19. package/dist/cjs/src/pro/hyperliquid.js +123 -0
  20. package/dist/cjs/src/pro/mexc.js +13 -7
  21. package/dist/cjs/src/pro/p2b.js +34 -7
  22. package/dist/cjs/src/pro/poloniex.js +36 -3
  23. package/dist/cjs/src/pro/poloniexfutures.js +1 -0
  24. package/dist/cjs/src/pro/probit.js +2 -0
  25. package/dist/cjs/src/pro/upbit.js +48 -3
  26. package/dist/cjs/src/pro/vertex.js +1 -0
  27. package/dist/cjs/src/pro/wazirx.js +3 -0
  28. package/dist/cjs/src/pro/whitebit.js +9 -0
  29. package/dist/cjs/src/pro/woo.js +1 -0
  30. package/dist/cjs/src/pro/woofipro.js +1 -0
  31. package/dist/cjs/src/pro/xt.js +1 -0
  32. package/dist/cjs/src/upbit.js +1 -1
  33. package/js/ccxt.d.ts +9 -3
  34. package/js/ccxt.js +7 -3
  35. package/js/src/abstract/hashkey.d.ts +70 -0
  36. package/js/src/abstract/hashkey.js +11 -0
  37. package/js/src/base/Exchange.js +1 -1
  38. package/js/src/base/errorHierarchy.d.ts +1 -0
  39. package/js/src/base/errorHierarchy.js +1 -0
  40. package/js/src/base/errors.d.ts +5 -1
  41. package/js/src/base/errors.js +8 -2
  42. package/js/src/binance.js +4 -2
  43. package/js/src/bingx.js +7 -1
  44. package/js/src/bitfinex.js +2 -2
  45. package/js/src/hashkey.d.ts +178 -0
  46. package/js/src/hashkey.js +4328 -0
  47. package/js/src/hyperliquid.d.ts +3 -0
  48. package/js/src/hyperliquid.js +85 -65
  49. package/js/src/indodax.js +37 -9
  50. package/js/src/kraken.js +37 -6
  51. package/js/src/krakenfutures.js +12 -10
  52. package/js/src/pro/ascendex.d.ts +2 -0
  53. package/js/src/pro/ascendex.js +45 -5
  54. package/js/src/pro/bingx.js +13 -12
  55. package/js/src/pro/bitget.d.ts +8 -0
  56. package/js/src/pro/bitget.js +165 -20
  57. package/js/src/pro/hashkey.d.ts +34 -0
  58. package/js/src/pro/hashkey.js +840 -0
  59. package/js/src/pro/hyperliquid.d.ts +7 -1
  60. package/js/src/pro/hyperliquid.js +123 -0
  61. package/js/src/pro/mexc.js +13 -7
  62. package/js/src/pro/p2b.d.ts +1 -0
  63. package/js/src/pro/p2b.js +34 -7
  64. package/js/src/pro/poloniex.d.ts +1 -0
  65. package/js/src/pro/poloniex.js +36 -3
  66. package/js/src/pro/poloniexfutures.js +1 -0
  67. package/js/src/pro/probit.js +2 -0
  68. package/js/src/pro/upbit.d.ts +1 -0
  69. package/js/src/pro/upbit.js +48 -3
  70. package/js/src/pro/vertex.js +1 -0
  71. package/js/src/pro/wazirx.js +3 -0
  72. package/js/src/pro/whitebit.js +9 -0
  73. package/js/src/pro/woo.js +1 -0
  74. package/js/src/pro/woofipro.js +1 -0
  75. package/js/src/pro/xt.js +1 -0
  76. package/js/src/upbit.js +1 -1
  77. package/package.json +1 -1
@@ -131,6 +131,19 @@ class bitget extends bitget$1 {
131
131
  };
132
132
  return await this.watchPublic(messageHash, args, params);
133
133
  }
134
+ async unWatchTicker(symbol, params = {}) {
135
+ /**
136
+ * @method
137
+ * @name bitget#unWatchTicker
138
+ * @description unsubscribe from the ticker channel
139
+ * @see https://www.bitget.com/api-doc/spot/websocket/public/Tickers-Channel
140
+ * @see https://www.bitget.com/api-doc/contract/websocket/public/Tickers-Channel
141
+ * @param {string} symbol unified symbol of the market to unwatch the ticker for
142
+ * @returns {any} status of the unwatch request
143
+ */
144
+ await this.loadMarkets();
145
+ return await this.unWatchChannel(symbol, 'ticker', 'ticker', params);
146
+ }
134
147
  async watchTickers(symbols = undefined, params = {}) {
135
148
  /**
136
149
  * @method
@@ -343,6 +356,22 @@ class bitget extends bitget$1 {
343
356
  }
344
357
  return this.filterBySinceLimit(ohlcv, since, limit, 0, true);
345
358
  }
359
+ async unWatchOHLCV(symbol, timeframe = '1m', params = {}) {
360
+ /**
361
+ * @method
362
+ * @name bitget#unWatchOHLCV
363
+ * @description unsubscribe from the ohlcv channel
364
+ * @see https://www.bitget.com/api-doc/spot/websocket/public/Candlesticks-Channel
365
+ * @see https://www.bitget.com/api-doc/contract/websocket/public/Candlesticks-Channel
366
+ * @param {string} symbol unified symbol of the market to unwatch the ohlcv for
367
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
368
+ */
369
+ await this.loadMarkets();
370
+ const timeframes = this.safeDict(this.options, 'timeframes');
371
+ const interval = this.safeString(timeframes, timeframe);
372
+ const channel = 'candle' + interval;
373
+ return await this.unWatchChannel(symbol, channel, 'candles:' + timeframe, params);
374
+ }
346
375
  handleOHLCV(client, message) {
347
376
  //
348
377
  // {
@@ -451,14 +480,18 @@ class bitget extends bitget$1 {
451
480
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
452
481
  */
453
482
  await this.loadMarkets();
454
- const market = this.market(symbol);
455
- const messageHash = 'unsubscribe:orderbook:' + market['symbol'];
456
483
  let channel = 'books';
457
484
  const limit = this.safeInteger(params, 'limit');
458
485
  if ((limit === 1) || (limit === 5) || (limit === 15)) {
459
486
  params = this.omit(params, 'limit');
460
487
  channel += limit.toString();
461
488
  }
489
+ return await this.unWatchChannel(symbol, channel, 'orderbook', params);
490
+ }
491
+ async unWatchChannel(symbol, channel, messageHashTopic, params = {}) {
492
+ await this.loadMarkets();
493
+ const market = this.market(symbol);
494
+ const messageHash = 'unsubscribe:' + messageHashTopic + ':' + market['symbol'];
462
495
  let instType = undefined;
463
496
  [instType, params] = this.getInstType(market, params);
464
497
  const args = {
@@ -682,6 +715,19 @@ class bitget extends bitget$1 {
682
715
  }
683
716
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
684
717
  }
718
+ async unWatchTrades(symbol, params = {}) {
719
+ /**
720
+ * @method
721
+ * @name bitget#unWatchTrades
722
+ * @description unsubscribe from the trades channel
723
+ * @see https://www.bitget.com/api-doc/spot/websocket/public/Trades-Channel
724
+ * @see https://www.bitget.com/api-doc/contract/websocket/public/New-Trades-Channel
725
+ * @param {string} symbol unified symbol of the market to unwatch the trades for
726
+ * @returns {any} status of the unwatch request
727
+ */
728
+ await this.loadMarkets();
729
+ return await this.unWatchChannel(symbol, 'trade', 'trade', params);
730
+ }
685
731
  handleTrades(client, message) {
686
732
  //
687
733
  // {
@@ -1868,6 +1914,112 @@ class bitget extends bitget$1 {
1868
1914
  //
1869
1915
  return message;
1870
1916
  }
1917
+ handleOrderBookUnSubscription(client, message) {
1918
+ //
1919
+ // {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"books","instId":"BTCUSDT"}}
1920
+ //
1921
+ const arg = this.safeDict(message, 'arg', {});
1922
+ const instType = this.safeStringLower(arg, 'instType');
1923
+ const type = (instType === 'spot') ? 'spot' : 'contract';
1924
+ const instId = this.safeString(arg, 'instId');
1925
+ const market = this.safeMarket(instId, undefined, undefined, type);
1926
+ const symbol = market['symbol'];
1927
+ const messageHash = 'unsubscribe:orderbook:' + market['symbol'];
1928
+ const subMessageHash = 'orderbook:' + symbol;
1929
+ if (symbol in this.orderbooks) {
1930
+ delete this.orderbooks[symbol];
1931
+ }
1932
+ if (subMessageHash in client.subscriptions) {
1933
+ delete client.subscriptions[subMessageHash];
1934
+ }
1935
+ if (messageHash in client.subscriptions) {
1936
+ delete client.subscriptions[messageHash];
1937
+ }
1938
+ const error = new errors.UnsubscribeError(this.id + 'orderbook ' + symbol);
1939
+ client.reject(error, subMessageHash);
1940
+ client.resolve(true, messageHash);
1941
+ }
1942
+ handleTradesUnSubscription(client, message) {
1943
+ //
1944
+ // {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"trade","instId":"BTCUSDT"}}
1945
+ //
1946
+ const arg = this.safeDict(message, 'arg', {});
1947
+ const instType = this.safeStringLower(arg, 'instType');
1948
+ const type = (instType === 'spot') ? 'spot' : 'contract';
1949
+ const instId = this.safeString(arg, 'instId');
1950
+ const market = this.safeMarket(instId, undefined, undefined, type);
1951
+ const symbol = market['symbol'];
1952
+ const messageHash = 'unsubscribe:trade:' + market['symbol'];
1953
+ const subMessageHash = 'trade:' + symbol;
1954
+ if (symbol in this.trades) {
1955
+ delete this.trades[symbol];
1956
+ }
1957
+ if (subMessageHash in client.subscriptions) {
1958
+ delete client.subscriptions[subMessageHash];
1959
+ }
1960
+ if (messageHash in client.subscriptions) {
1961
+ delete client.subscriptions[messageHash];
1962
+ }
1963
+ const error = new errors.UnsubscribeError(this.id + 'trades ' + symbol);
1964
+ client.reject(error, subMessageHash);
1965
+ client.resolve(true, messageHash);
1966
+ }
1967
+ handleTickerUnSubscription(client, message) {
1968
+ //
1969
+ // {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"trade","instId":"BTCUSDT"}}
1970
+ //
1971
+ const arg = this.safeDict(message, 'arg', {});
1972
+ const instType = this.safeStringLower(arg, 'instType');
1973
+ const type = (instType === 'spot') ? 'spot' : 'contract';
1974
+ const instId = this.safeString(arg, 'instId');
1975
+ const market = this.safeMarket(instId, undefined, undefined, type);
1976
+ const symbol = market['symbol'];
1977
+ const messageHash = 'unsubscribe:ticker:' + market['symbol'];
1978
+ const subMessageHash = 'ticker:' + symbol;
1979
+ if (symbol in this.tickers) {
1980
+ delete this.tickers[symbol];
1981
+ }
1982
+ if (subMessageHash in client.subscriptions) {
1983
+ delete client.subscriptions[subMessageHash];
1984
+ }
1985
+ if (messageHash in client.subscriptions) {
1986
+ delete client.subscriptions[messageHash];
1987
+ }
1988
+ const error = new errors.UnsubscribeError(this.id + 'ticker ' + symbol);
1989
+ client.reject(error, subMessageHash);
1990
+ client.resolve(true, messageHash);
1991
+ }
1992
+ handleOHLCVUnSubscription(client, message) {
1993
+ //
1994
+ // {"event":"unsubscribe","arg":{"instType":"SPOT","channel":"candle1m","instId":"BTCUSDT"}}
1995
+ //
1996
+ const arg = this.safeDict(message, 'arg', {});
1997
+ const instType = this.safeStringLower(arg, 'instType');
1998
+ const type = (instType === 'spot') ? 'spot' : 'contract';
1999
+ const instId = this.safeString(arg, 'instId');
2000
+ const channel = this.safeString(arg, 'channel');
2001
+ const interval = channel.replace('candle', '');
2002
+ const timeframes = this.safeValue(this.options, 'timeframes');
2003
+ const timeframe = this.findTimeframe(interval, timeframes);
2004
+ const market = this.safeMarket(instId, undefined, undefined, type);
2005
+ const symbol = market['symbol'];
2006
+ const messageHash = 'unsubscribe:candles:' + timeframe + ':' + market['symbol'];
2007
+ const subMessageHash = 'candles:' + timeframe + ':' + symbol;
2008
+ if (symbol in this.ohlcvs) {
2009
+ if (timeframe in this.ohlcvs[symbol]) {
2010
+ delete this.ohlcvs[symbol][timeframe];
2011
+ }
2012
+ }
2013
+ if (subMessageHash in client.subscriptions) {
2014
+ delete client.subscriptions[subMessageHash];
2015
+ }
2016
+ if (messageHash in client.subscriptions) {
2017
+ delete client.subscriptions[messageHash];
2018
+ }
2019
+ const error = new errors.UnsubscribeError(this.id + ' ohlcv ' + timeframe + ' ' + symbol);
2020
+ client.reject(error, subMessageHash);
2021
+ client.resolve(true, messageHash);
2022
+ }
1871
2023
  handleUnSubscriptionStatus(client, message) {
1872
2024
  //
1873
2025
  // {
@@ -1897,23 +2049,16 @@ class bitget extends bitget$1 {
1897
2049
  const channel = this.safeString(arg, 'channel');
1898
2050
  if (channel === 'books') {
1899
2051
  // for now only unWatchOrderBook is supporteod
1900
- const instType = this.safeStringLower(arg, 'instType');
1901
- const type = (instType === 'spot') ? 'spot' : 'contract';
1902
- const instId = this.safeString(arg, 'instId');
1903
- const market = this.safeMarket(instId, undefined, undefined, type);
1904
- const symbol = market['symbol'];
1905
- const messageHash = 'unsubscribe:orderbook:' + market['symbol'];
1906
- const subMessageHash = 'orderbook:' + symbol;
1907
- if (symbol in this.orderbooks) {
1908
- delete this.orderbooks[symbol];
1909
- }
1910
- if (subMessageHash in client.subscriptions) {
1911
- delete client.subscriptions[subMessageHash];
1912
- }
1913
- if (messageHash in client.subscriptions) {
1914
- delete client.subscriptions[messageHash];
1915
- }
1916
- client.resolve(true, messageHash);
2052
+ this.handleOrderBookUnSubscription(client, message);
2053
+ }
2054
+ else if (channel === 'trade') {
2055
+ this.handleTradesUnSubscription(client, message);
2056
+ }
2057
+ else if (channel === 'ticker') {
2058
+ this.handleTickerUnSubscription(client, message);
2059
+ }
2060
+ else if (channel.startsWith('candle')) {
2061
+ this.handleOHLCVUnSubscription(client, message);
1917
2062
  }
1918
2063
  }
1919
2064
  return message;