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
package/js/src/latoken.js CHANGED
@@ -1544,6 +1544,7 @@ export default class latoken extends Exchange {
1544
1544
  const statuses = {
1545
1545
  'TRANSACTION_STATUS_CONFIRMED': 'ok',
1546
1546
  'TRANSACTION_STATUS_EXECUTED': 'ok',
1547
+ 'TRANSACTION_STATUS_CHECKING': 'pending',
1547
1548
  'TRANSACTION_STATUS_CANCELLED': 'canceled',
1548
1549
  };
1549
1550
  return this.safeString(statuses, status, status);
package/js/src/mexc.js CHANGED
@@ -566,7 +566,7 @@ export default class mexc extends Exchange {
566
566
  'POKT': 'POKT',
567
567
  'QKC': 'QKC',
568
568
  'QTUM': 'QTUM',
569
- 'RAP20': 'RAP20 (Rangers Mainnet)',
569
+ 'RAP20': 'RAP20' + ' ' + '(Rangers Mainnet)',
570
570
  'REI': 'REI',
571
571
  'RSK': 'RBTC',
572
572
  'RVN': 'Ravencoin(RVN)',
@@ -716,69 +716,9 @@ export default class mexc extends Exchange {
716
716
  // OKB <> OKT (for usdt it's exception) for OKC, PMEER, FLARE, STRD, ZEL, FUND, "NONE", CRING, FREETON, QTZ (probably unique network is meant), HT, BSC(RACAV1), BSC(RACAV2), AMBROSUS, BAJUN, NOM. their individual info is at https://www.mexc.com/api/platform/asset/spot/{COINNAME}
717
717
  },
718
718
  'networksById': {
719
- 'Aleph Zero(AZERO)': 'AZERO',
720
- 'Alephium(ALPH)': 'ALPH',
721
- 'Algorand(ALGO)': 'ALGO',
722
- 'APTOS(APT)': 'APT',
723
- 'Arbitrum One(ARB)': 'ARB',
724
- 'Avalanche C Chain(AVAX CCHAIN)': 'AVAXC',
725
- 'Avalanche X Chain(AVAX XCHAIN)': 'AVAXX',
726
- 'BEP20(BSC)': 'BSC',
727
- 'Bitcoin Cash(BCH)': 'BCH',
728
- 'Bitcoin SV(BSV)': 'BSV',
729
- 'Bitcoin(BTC)': 'BTC',
730
- 'Bittensor(TAO)': 'TAO',
731
- 'BNB Beacon Chain(BEP2)': 'BEP2',
732
719
  'BNB Smart Chain(BEP20-RACAV1)': 'BSC',
733
720
  'BNB Smart Chain(BEP20-RACAV2)': 'BSC',
734
721
  'BNB Smart Chain(BEP20)': 'BSC',
735
- 'Cardano(ADA)': 'ADA',
736
- 'Celestia(TIA)': 'TIA',
737
- 'Chia(XCH)': 'XCH',
738
- 'Chiliz Chain(CHZ2)': 'CHZ2',
739
- 'Chiliz Legacy Chain(CHZ)': 'CHZ',
740
- 'Clore.ai(CLORE)': 'CLORE',
741
- 'Cosmos(ATOM)': 'ATOM',
742
- 'Dogechain(DC)': 'DC',
743
- 'Dogecoin(DOGE)': 'DOGE',
744
- 'Dymension(DYM)': 'DYM',
745
- 'Dynex(DNX)': 'DNX',
746
- 'Elysium(LAVA)': 'LAVA',
747
- 'Ethereum Classic(ETC)': 'ETC',
748
- 'Ethereum(ERC20)': 'ERC20',
749
- 'Fantom(FTM)': 'FTM',
750
- 'Hedera(HBAR)': 'HBAR',
751
- 'Index Chain': 'INDEX',
752
- 'Internet Computer(ICP)': 'ICP',
753
- 'Kaspa(KAS)': 'KAS',
754
- 'Klaytn(KLAY)': 'KLAY',
755
- 'Litecoin(LTC)': 'LTC',
756
- 'Mantle(MNT)': 'MNT',
757
- 'Mcoin Network': 'MCOIN',
758
- 'Meter(MTRG)': 'MTRG',
759
- 'Monero(XMR)': 'XMR',
760
- 'NEAR Protocol(NEAR)': 'NEAR',
761
- 'Neoxa Network': 'NEOXA',
762
- 'Neurai(XNA)': 'XNA',
763
- 'Omega Network(OMN)': 'OMN',
764
- 'Optimism(OP)': 'OPTIMISM',
765
- 'Polkadot(DOT)': 'DOT',
766
- 'Polygon(MATIC)': 'MATIC',
767
- 'RAP20 (Rangers Mainnet)': 'RAP20',
768
- 'Ravencoin(RVN)': 'RVN',
769
- 'Ripple(XRP)': 'XRP',
770
- 'Satoxcoin(SATOX)': 'SATOX',
771
- 'Solana(SOL)': 'SOL',
772
- 'Starknet(STARK)': 'STARK',
773
- 'Stellar(XLM)': 'XLM',
774
- 'Terra(LUNA)': 'LUNA',
775
- 'Toncoin(TON)': 'TON',
776
- 'Tron(TRC20)': 'TRC20',
777
- 'UGAS(Ultrain)': 'UGAS',
778
- 'VeChain(VET)': 'VET',
779
- 'Vexanium(VEX)': 'VEX',
780
- 'XPR Network': 'XPR',
781
- 'Zilliqa(ZIL)': 'ZIL',
782
722
  // TODO: uncomment below after deciding unified name
783
723
  // 'PEPE COIN BSC':
784
724
  // 'SMART BLOCKCHAIN':
@@ -9,7 +9,6 @@ export default class okcoin extends Exchange {
9
9
  fetchTime(params?: {}): Promise<number>;
10
10
  fetchMarkets(params?: {}): Promise<Market[]>;
11
11
  parseMarket(market: Dict): Market;
12
- safeNetwork(networkId: any): string;
13
12
  fetchCurrencies(params?: {}): Promise<Currencies>;
14
13
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
15
14
  parseTicker(ticker: Dict, market?: Market): Ticker;
package/js/src/okcoin.js CHANGED
@@ -580,6 +580,9 @@ export default class okcoin extends Exchange {
580
580
  'defaultNetwork': 'ERC20',
581
581
  'networks': {
582
582
  'ERC20': 'Ethereum',
583
+ 'BTC': 'Bitcoin',
584
+ 'OMNI': 'Omni',
585
+ 'TRC20': 'TRON',
583
586
  },
584
587
  },
585
588
  'commonCurrencies': {
@@ -712,14 +715,6 @@ export default class okcoin extends Exchange {
712
715
  'info': market,
713
716
  });
714
717
  }
715
- safeNetwork(networkId) {
716
- const networksById = {
717
- 'Bitcoin': 'BTC',
718
- 'Omni': 'OMNI',
719
- 'TRON': 'TRC20',
720
- };
721
- return this.safeString(networksById, networkId, networkId);
722
- }
723
718
  async fetchCurrencies(params = {}) {
724
719
  /**
725
720
  * @method
@@ -763,7 +758,7 @@ export default class okcoin extends Exchange {
763
758
  if ((networkId !== undefined) && (networkId.indexOf('-') >= 0)) {
764
759
  const parts = networkId.split('-');
765
760
  const chainPart = this.safeString(parts, 1, networkId);
766
- const networkCode = this.safeNetwork(chainPart);
761
+ const networkCode = this.networkIdToCode(chainPart);
767
762
  const precision = this.parsePrecision(this.safeString(chain, 'wdTickSz'));
768
763
  if (maxPrecision === undefined) {
769
764
  maxPrecision = precision;
package/js/src/okx.d.ts CHANGED
@@ -16,7 +16,6 @@ export default class okx extends Exchange {
16
16
  fetchMarkets(params?: {}): Promise<Market[]>;
17
17
  parseMarket(market: Dict): Market;
18
18
  fetchMarketsByType(type: any, params?: {}): Promise<MarketInterface[]>;
19
- safeNetwork(networkId: any): string;
20
19
  fetchCurrencies(params?: {}): Promise<Currencies>;
21
20
  fetchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
22
21
  parseTicker(ticker: Dict, market?: Market): Ticker;
package/js/src/okx.js CHANGED
@@ -1041,6 +1041,7 @@ export default class okx extends Exchange {
1041
1041
  'ZEC': 'Zcash',
1042
1042
  'ZIL': 'Zilliqa',
1043
1043
  'ZKSYNC': 'ZKSYNC',
1044
+ 'OMNI': 'Omni',
1044
1045
  // 'NEON3': 'N3', // tbd
1045
1046
  // undetermined : "CELO-TOKEN", "Digital Cash", Khala
1046
1047
  // todo: uncomment below after consensus
@@ -1595,14 +1596,6 @@ export default class okx extends Exchange {
1595
1596
  const dataResponse = this.safeList(response, 'data', []);
1596
1597
  return this.parseMarkets(dataResponse);
1597
1598
  }
1598
- safeNetwork(networkId) {
1599
- const networksById = {
1600
- 'Bitcoin': 'BTC',
1601
- 'Omni': 'OMNI',
1602
- 'TRON': 'TRC20',
1603
- };
1604
- return this.safeString(networksById, networkId, networkId);
1605
- }
1606
1599
  async fetchCurrencies(params = {}) {
1607
1600
  /**
1608
1601
  * @method
@@ -1644,6 +1644,7 @@ export default class onetrading extends Exchange {
1644
1644
  * @method
1645
1645
  * @name onetrading#fetchOrder
1646
1646
  * @description fetches information on an order made by the user
1647
+ * @param {string} id the order id
1647
1648
  * @param {string} symbol not used by onetrading fetchOrder
1648
1649
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1649
1650
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
package/js/src/phemex.js CHANGED
@@ -2986,6 +2986,7 @@ export default class phemex extends Exchange {
2986
2986
  * @name phemex#fetchOrder
2987
2987
  * @see https://phemex-docs.github.io/#query-orders-by-ids
2988
2988
  * @description fetches information on an order made by the user
2989
+ * @param {string} id the order id
2989
2990
  * @param {string} symbol unified symbol of the market the order was made in
2990
2991
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2991
2992
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1418,6 +1418,7 @@ export default class poloniexfutures extends Exchange {
1418
1418
  * @description fetches information on an order made by the user
1419
1419
  * @see https://api-docs.poloniex.com/futures/api/orders#get-details-of-a-single-order
1420
1420
  * @see https://api-docs.poloniex.com/futures/api/orders#get-single-order-by-clientoid
1421
+ * @param {string} id the order id
1421
1422
  * @param {string} symbol unified symbol of the market the order was made in
1422
1423
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1423
1424
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1,5 +1,5 @@
1
1
  import binanceRest from '../binance.js';
2
- import type { Int, OrderSide, OrderType, Str, Strings, Trade, OrderBook, Order, Ticker, Tickers, OHLCV, Position, Balances, Num, Liquidation } from '../base/types.js';
2
+ import type { Int, OrderSide, OrderType, Str, Strings, Trade, OrderBook, Order, Ticker, Tickers, OHLCV, Position, Balances, Num, Dict, Liquidation } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class binance extends binanceRest {
5
5
  describe(): any;
@@ -14,6 +14,8 @@ export default class binance extends binanceRest {
14
14
  handleMyLiquidation(client: Client, message: any): void;
15
15
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
16
16
  watchOrderBookForSymbols(symbols: string[], limit?: Int, params?: {}): Promise<OrderBook>;
17
+ unWatchOrderBookForSymbols(symbols: string[], params?: {}): Promise<any>;
18
+ unWatchOrderBook(symbol: string, params?: {}): Promise<any>;
17
19
  fetchOrderBookWs(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
18
20
  handleFetchOrderBook(client: Client, message: any): void;
19
21
  fetchOrderBookSnapshot(client: any, message: any, subscription: any): Promise<void>;
@@ -23,7 +25,11 @@ export default class binance extends binanceRest {
23
25
  handleOrderBook(client: Client, message: any): void;
24
26
  handleOrderBookSubscription(client: Client, message: any, subscription: any): void;
25
27
  handleSubscriptionStatus(client: Client, message: any): any;
28
+ handleUnSubscription(client: Client, subscription: Dict): void;
29
+ cleanCache(subscription: Dict): void;
26
30
  watchTradesForSymbols(symbols: string[], since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
31
+ unWatchTradesForSymbols(symbols: string[], params?: {}): Promise<any>;
32
+ unWatchTrades(symbol: string, params?: {}): Promise<any>;
27
33
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
28
34
  parseWsTrade(trade: any, market?: any): Trade;
29
35
  handleTrade(client: Client, message: any): void;
@@ -35,6 +41,8 @@ export default class binance extends binanceRest {
35
41
  handleFetchOHLCV(client: Client, message: any): void;
36
42
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
37
43
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
44
+ unWatchTickers(symbols?: Strings, params?: {}): Promise<any>;
45
+ unWatchTicker(symbol: string, params?: {}): Promise<any>;
38
46
  watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
39
47
  watchMultiTickerHelper(methodName: any, channelName: string, symbols?: Strings, params?: {}): Promise<any>;
40
48
  parseWsTicker(message: any, marketType: any): Ticker;
@@ -7,7 +7,7 @@
7
7
  // ----------------------------------------------------------------------------
8
8
  import binanceRest from '../binance.js';
9
9
  import { Precise } from '../base/Precise.js';
10
- import { ChecksumError, ArgumentsRequired, BadRequest, NotSupported } from '../base/errors.js';
10
+ import { ChecksumError, ArgumentsRequired, BadRequest, NotSupported, UnsubscribeError } from '../base/errors.js';
11
11
  import { ArrayCache, ArrayCacheByTimestamp, ArrayCacheBySymbolById, ArrayCacheBySymbolBySide } from '../base/ws/Cache.js';
12
12
  import { sha256 } from '../static_dependencies/noble-hashes/sha256.js';
13
13
  import { rsa } from '../base/functions/rsa.js';
@@ -652,6 +652,81 @@ export default class binance extends binanceRest {
652
652
  const orderbook = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes, subscription);
653
653
  return orderbook.limit();
654
654
  }
655
+ async unWatchOrderBookForSymbols(symbols, params = {}) {
656
+ /**
657
+ * @method
658
+ * @name binance#unWatchOrderBookForSymbols
659
+ * @see https://binance-docs.github.io/apidocs/spot/en/#partial-book-depth-streams
660
+ * @see https://binance-docs.github.io/apidocs/spot/en/#diff-depth-stream
661
+ * @see https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams
662
+ * @see https://binance-docs.github.io/apidocs/futures/en/#diff-book-depth-streams
663
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#partial-book-depth-streams
664
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#diff-book-depth-streams
665
+ * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
666
+ * @param {string[]} symbols unified array of symbols
667
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
668
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
669
+ */
670
+ await this.loadMarkets();
671
+ symbols = this.marketSymbols(symbols, undefined, false, true, true);
672
+ const firstMarket = this.market(symbols[0]);
673
+ let type = firstMarket['type'];
674
+ if (firstMarket['contract']) {
675
+ type = firstMarket['linear'] ? 'future' : 'delivery';
676
+ }
677
+ const name = 'depth';
678
+ let streamHash = 'multipleOrderbook';
679
+ if (symbols !== undefined) {
680
+ streamHash += '::' + symbols.join(',');
681
+ }
682
+ const watchOrderBookRate = this.safeString(this.options, 'watchOrderBookRate', '100');
683
+ const subParams = [];
684
+ const subMessageHashes = [];
685
+ const messageHashes = [];
686
+ for (let i = 0; i < symbols.length; i++) {
687
+ const symbol = symbols[i];
688
+ const market = this.market(symbol);
689
+ subMessageHashes.push('orderbook::' + symbol);
690
+ messageHashes.push('unsubscribe:orderbook:' + symbol);
691
+ const subscriptionHash = market['lowercaseId'] + '@' + name;
692
+ const symbolHash = subscriptionHash + '@' + watchOrderBookRate + 'ms';
693
+ subParams.push(symbolHash);
694
+ }
695
+ const messageHashesLength = subMessageHashes.length;
696
+ const url = this.urls['api']['ws'][type] + '/' + this.stream(type, streamHash, messageHashesLength);
697
+ const requestId = this.requestId(url);
698
+ const request = {
699
+ 'method': 'UNSUBSCRIBE',
700
+ 'params': subParams,
701
+ 'id': requestId,
702
+ };
703
+ const subscription = {
704
+ 'unsubscribe': true,
705
+ 'id': requestId.toString(),
706
+ 'symbols': symbols,
707
+ 'subMessageHashes': subMessageHashes,
708
+ 'messageHashes': messageHashes,
709
+ 'topic': 'orderbook',
710
+ };
711
+ return await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes, subscription);
712
+ }
713
+ async unWatchOrderBook(symbol, params = {}) {
714
+ /**
715
+ * @method
716
+ * @name binance#unWatchOrderBook
717
+ * @see https://binance-docs.github.io/apidocs/spot/en/#partial-book-depth-streams
718
+ * @see https://binance-docs.github.io/apidocs/spot/en/#diff-depth-stream
719
+ * @see https://binance-docs.github.io/apidocs/futures/en/#partial-book-depth-streams
720
+ * @see https://binance-docs.github.io/apidocs/futures/en/#diff-book-depth-streams
721
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#partial-book-depth-streams
722
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#diff-book-depth-streams
723
+ * @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
724
+ * @param {string} symbol unified array of symbols
725
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
726
+ * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
727
+ */
728
+ return await this.unWatchOrderBookForSymbols([symbol], params);
729
+ }
655
730
  async fetchOrderBookWs(symbol, limit = undefined, params = {}) {
656
731
  /**
657
732
  * @method
@@ -939,8 +1014,71 @@ export default class binance extends binanceRest {
939
1014
  if (method !== undefined) {
940
1015
  method.call(this, client, message, subscription);
941
1016
  }
1017
+ const isUnSubMessage = this.safeBool(subscription, 'unsubscribe', false);
1018
+ if (isUnSubMessage) {
1019
+ this.handleUnSubscription(client, subscription);
1020
+ }
942
1021
  return message;
943
1022
  }
1023
+ handleUnSubscription(client, subscription) {
1024
+ const messageHashes = this.safeList(subscription, 'messageHashes', []);
1025
+ const subMessageHashes = this.safeList(subscription, 'subMessageHashes', []);
1026
+ for (let j = 0; j < messageHashes.length; j++) {
1027
+ const unsubHash = messageHashes[j];
1028
+ const subHash = subMessageHashes[j];
1029
+ if (unsubHash in client.subscriptions) {
1030
+ delete client.subscriptions[unsubHash];
1031
+ }
1032
+ if (subHash in client.subscriptions) {
1033
+ delete client.subscriptions[subHash];
1034
+ }
1035
+ const error = new UnsubscribeError(this.id + ' ' + subHash);
1036
+ client.reject(error, subHash);
1037
+ client.resolve(true, unsubHash);
1038
+ this.cleanCache(subscription);
1039
+ }
1040
+ }
1041
+ cleanCache(subscription) {
1042
+ const topic = this.safeString(subscription, 'topic');
1043
+ const symbols = this.safeList(subscription, 'symbols', []);
1044
+ const symbolsLength = symbols.length;
1045
+ if (symbolsLength > 0) {
1046
+ for (let i = 0; i < symbols.length; i++) {
1047
+ const symbol = symbols[i];
1048
+ if (topic === 'trade') {
1049
+ delete this.trades[symbol];
1050
+ }
1051
+ else if (topic === 'orderbook') {
1052
+ delete this.orderbooks[symbol];
1053
+ }
1054
+ else if (topic === 'ticker') {
1055
+ delete this.tickers[symbol];
1056
+ }
1057
+ }
1058
+ }
1059
+ else {
1060
+ if (topic === 'myTrades') {
1061
+ // don't reset this.myTrades directly here
1062
+ // because in c# we need to use a different object
1063
+ const keys = Object.keys(this.myTrades);
1064
+ for (let i = 0; i < keys.length; i++) {
1065
+ delete this.myTrades[keys[i]];
1066
+ }
1067
+ }
1068
+ else if (topic === 'orders') {
1069
+ const orderSymbols = Object.keys(this.orders);
1070
+ for (let i = 0; i < orderSymbols.length; i++) {
1071
+ delete this.orders[orderSymbols[i]];
1072
+ }
1073
+ }
1074
+ else if (topic === 'ticker') {
1075
+ const tickerSymbols = Object.keys(this.tickers);
1076
+ for (let i = 0; i < tickerSymbols.length; i++) {
1077
+ delete this.tickers[tickerSymbols[i]];
1078
+ }
1079
+ }
1080
+ }
1081
+ }
944
1082
  async watchTradesForSymbols(symbols, since = undefined, limit = undefined, params = {}) {
945
1083
  /**
946
1084
  * @method
@@ -1004,6 +1142,85 @@ export default class binance extends binanceRest {
1004
1142
  }
1005
1143
  return this.filterBySinceLimit(trades, since, limit, 'timestamp', true);
1006
1144
  }
1145
+ async unWatchTradesForSymbols(symbols, params = {}) {
1146
+ /**
1147
+ * @method
1148
+ * @name binance#unWatchTradesForSymbols
1149
+ * @description unsubscribes from the trades channel
1150
+ * @see https://binance-docs.github.io/apidocs/spot/en/#aggregate-trade-streams
1151
+ * @see https://binance-docs.github.io/apidocs/spot/en/#trade-streams
1152
+ * @see https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams
1153
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#aggregate-trade-streams
1154
+ * @param {string[]} symbols unified symbol of the market to fetch trades for
1155
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1156
+ * @param {string} [params.name] the name of the method to call, 'trade' or 'aggTrade', default is 'trade'
1157
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1158
+ */
1159
+ await this.loadMarkets();
1160
+ symbols = this.marketSymbols(symbols, undefined, false, true, true);
1161
+ let streamHash = 'multipleTrades';
1162
+ if (symbols !== undefined) {
1163
+ const symbolsLength = symbols.length;
1164
+ if (symbolsLength > 200) {
1165
+ throw new BadRequest(this.id + ' watchTradesForSymbols() accepts 200 symbols at most. To watch more symbols call watchTradesForSymbols() multiple times');
1166
+ }
1167
+ streamHash += '::' + symbols.join(',');
1168
+ }
1169
+ let name = undefined;
1170
+ [name, params] = this.handleOptionAndParams(params, 'watchTradesForSymbols', 'name', 'trade');
1171
+ params = this.omit(params, 'callerMethodName');
1172
+ const firstMarket = this.market(symbols[0]);
1173
+ let type = firstMarket['type'];
1174
+ if (firstMarket['contract']) {
1175
+ type = firstMarket['linear'] ? 'future' : 'delivery';
1176
+ }
1177
+ const subMessageHashes = [];
1178
+ const subParams = [];
1179
+ const messageHashes = [];
1180
+ for (let i = 0; i < symbols.length; i++) {
1181
+ const symbol = symbols[i];
1182
+ const market = this.market(symbol);
1183
+ subMessageHashes.push('trade::' + symbol);
1184
+ messageHashes.push('unsubscribe:trade:' + symbol);
1185
+ const rawHash = market['lowercaseId'] + '@' + name;
1186
+ subParams.push(rawHash);
1187
+ }
1188
+ const query = this.omit(params, 'type');
1189
+ const subParamsLength = subParams.length;
1190
+ const url = this.urls['api']['ws'][type] + '/' + this.stream(type, streamHash, subParamsLength);
1191
+ const requestId = this.requestId(url);
1192
+ const request = {
1193
+ 'method': 'UNSUBSCRIBE',
1194
+ 'params': subParams,
1195
+ 'id': requestId,
1196
+ };
1197
+ const subscription = {
1198
+ 'unsubscribe': true,
1199
+ 'id': requestId.toString(),
1200
+ 'subMessageHashes': subMessageHashes,
1201
+ 'messageHashes': messageHashes,
1202
+ 'symbols': symbols,
1203
+ 'topic': 'trade',
1204
+ };
1205
+ return await this.watchMultiple(url, messageHashes, this.extend(request, query), messageHashes, subscription);
1206
+ }
1207
+ async unWatchTrades(symbol, params = {}) {
1208
+ /**
1209
+ * @method
1210
+ * @name binance#unWatchTrades
1211
+ * @description unsubscribes from the trades channel
1212
+ * @see https://binance-docs.github.io/apidocs/spot/en/#aggregate-trade-streams
1213
+ * @see https://binance-docs.github.io/apidocs/spot/en/#trade-streams
1214
+ * @see https://binance-docs.github.io/apidocs/futures/en/#aggregate-trade-streams
1215
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#aggregate-trade-streams
1216
+ * @param {string} symbol unified symbol of the market to fetch trades for
1217
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1218
+ * @param {string} [params.name] the name of the method to call, 'trade' or 'aggTrade', default is 'trade'
1219
+ * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1220
+ */
1221
+ await this.loadMarkets();
1222
+ return await this.unWatchTradesForSymbols([symbol], params);
1223
+ }
1007
1224
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1008
1225
  /**
1009
1226
  * @method
@@ -1537,6 +1754,115 @@ export default class binance extends binanceRest {
1537
1754
  }
1538
1755
  return this.filterByArray(this.tickers, 'symbol', symbols);
1539
1756
  }
1757
+ async unWatchTickers(symbols = undefined, params = {}) {
1758
+ /**
1759
+ * @method
1760
+ * @name binance#unWatchTickers
1761
+ * @see https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-mini-ticker-stream
1762
+ * @see https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-ticker-streams
1763
+ * @see https://binance-docs.github.io/apidocs/futures/en/#all-market-mini-tickers-stream
1764
+ * @see https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-ticker-streams
1765
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#all-market-mini-tickers-stream
1766
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#individual-symbol-ticker-streams
1767
+ * @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
1768
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
1769
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1770
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1771
+ */
1772
+ let channelName = undefined;
1773
+ [channelName, params] = this.handleOptionAndParams(params, 'watchTickers', 'name', 'ticker');
1774
+ if (channelName === 'bookTicker') {
1775
+ throw new BadRequest(this.id + ' deprecation notice - to subscribe for bids-asks, use watch_bids_asks() method instead');
1776
+ }
1777
+ await this.loadMarkets();
1778
+ const methodName = 'watchTickers';
1779
+ symbols = this.marketSymbols(symbols, undefined, true, false, true);
1780
+ let firstMarket = undefined;
1781
+ let marketType = undefined;
1782
+ const symbolsDefined = (symbols !== undefined);
1783
+ if (symbolsDefined) {
1784
+ firstMarket = this.market(symbols[0]);
1785
+ }
1786
+ [marketType, params] = this.handleMarketTypeAndParams(methodName, firstMarket, params);
1787
+ let subType = undefined;
1788
+ [subType, params] = this.handleSubTypeAndParams(methodName, firstMarket, params);
1789
+ let rawMarketType = undefined;
1790
+ if (this.isLinear(marketType, subType)) {
1791
+ rawMarketType = 'future';
1792
+ }
1793
+ else if (this.isInverse(marketType, subType)) {
1794
+ rawMarketType = 'delivery';
1795
+ }
1796
+ else if (marketType === 'spot') {
1797
+ rawMarketType = marketType;
1798
+ }
1799
+ else {
1800
+ throw new NotSupported(this.id + ' ' + methodName + '() does not support options markets');
1801
+ }
1802
+ const isBidAsk = (channelName === 'bookTicker');
1803
+ const subscriptionArgs = [];
1804
+ const subMessageHashes = [];
1805
+ const messageHashes = [];
1806
+ if (symbolsDefined) {
1807
+ for (let i = 0; i < symbols.length; i++) {
1808
+ const symbol = symbols[i];
1809
+ const market = this.market(symbol);
1810
+ subscriptionArgs.push(market['lowercaseId'] + '@' + channelName);
1811
+ subMessageHashes.push(this.getMessageHash(channelName, market['symbol'], isBidAsk));
1812
+ messageHashes.push('unsubscribe:ticker:' + symbol);
1813
+ }
1814
+ }
1815
+ else {
1816
+ if (isBidAsk) {
1817
+ if (marketType === 'spot') {
1818
+ throw new ArgumentsRequired(this.id + ' ' + methodName + '() requires symbols for this channel for spot markets');
1819
+ }
1820
+ subscriptionArgs.push('!' + channelName);
1821
+ }
1822
+ else {
1823
+ subscriptionArgs.push('!' + channelName + '@arr');
1824
+ }
1825
+ subMessageHashes.push(this.getMessageHash(channelName, undefined, isBidAsk));
1826
+ messageHashes.push('unsubscribe:ticker');
1827
+ }
1828
+ let streamHash = channelName;
1829
+ if (symbolsDefined) {
1830
+ streamHash = channelName + '::' + symbols.join(',');
1831
+ }
1832
+ const url = this.urls['api']['ws'][rawMarketType] + '/' + this.stream(rawMarketType, streamHash);
1833
+ const requestId = this.requestId(url);
1834
+ const request = {
1835
+ 'method': 'UNSUBSCRIBE',
1836
+ 'params': subscriptionArgs,
1837
+ 'id': requestId,
1838
+ };
1839
+ const subscription = {
1840
+ 'unsubscribe': true,
1841
+ 'id': requestId.toString(),
1842
+ 'subMessageHashes': subMessageHashes,
1843
+ 'messageHashes': subMessageHashes,
1844
+ 'symbols': symbols,
1845
+ 'topic': 'ticker',
1846
+ };
1847
+ return await this.watchMultiple(url, subMessageHashes, this.extend(request, params), subMessageHashes, subscription);
1848
+ }
1849
+ async unWatchTicker(symbol, params = {}) {
1850
+ /**
1851
+ * @method
1852
+ * @name binance#unWatchTicker
1853
+ * @see https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-mini-ticker-stream
1854
+ * @see https://binance-docs.github.io/apidocs/spot/en/#individual-symbol-ticker-streams
1855
+ * @see https://binance-docs.github.io/apidocs/futures/en/#all-market-mini-tickers-stream
1856
+ * @see https://binance-docs.github.io/apidocs/futures/en/#individual-symbol-ticker-streams
1857
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#all-market-mini-tickers-stream
1858
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#individual-symbol-ticker-streams
1859
+ * @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
1860
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
1861
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1862
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1863
+ */
1864
+ return await this.unWatchTickers([symbol], params);
1865
+ }
1540
1866
  async watchBidsAsks(symbols = undefined, params = {}) {
1541
1867
  /**
1542
1868
  * @method
@@ -22,8 +22,8 @@ export default class bingx extends bingxRest {
22
22
  watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
23
23
  watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
24
24
  watchBalance(params?: {}): Promise<Balances>;
25
- setBalanceCache(client: Client, type: any, subscriptionHash: any, params: any): void;
26
- loadBalanceSnapshot(client: any, messageHash: any, type: any): Promise<void>;
25
+ setBalanceCache(client: Client, type: any, subType: any, subscriptionHash: any, params: any): void;
26
+ loadBalanceSnapshot(client: any, messageHash: any, type: any, subType: any): Promise<void>;
27
27
  handleErrorMessage(client: any, message: any): boolean;
28
28
  keepAliveListenKey(params?: {}): Promise<void>;
29
29
  authenticate(params?: {}): Promise<void>;