ccxt 4.4.2 → 4.4.3

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.
@@ -17,7 +17,8 @@ export default class cryptocom extends cryptocomRest {
17
17
  'ws': true,
18
18
  'watchBalance': true,
19
19
  'watchTicker': true,
20
- 'watchTickers': false,
20
+ 'watchTickers': true,
21
+ 'watchBidsAsks': true,
21
22
  'watchMyTrades': true,
22
23
  'watchTrades': true,
23
24
  'watchTradesForSymbols': true,
@@ -480,41 +481,210 @@ export default class cryptocom extends cryptocomRest {
480
481
  const messageHash = 'unsubscribe:ticker:' + market['symbol'];
481
482
  return await this.unWatchPublicMultiple('ticker', [market['symbol']], [messageHash], [subMessageHash], [subMessageHash], params);
482
483
  }
484
+ async watchTickers(symbols = undefined, params = {}) {
485
+ /**
486
+ * @method
487
+ * @name cryptocom#watchTickers
488
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
489
+ * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name
490
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
491
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
492
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
493
+ */
494
+ await this.loadMarkets();
495
+ symbols = this.marketSymbols(symbols, undefined, false);
496
+ const messageHashes = [];
497
+ const marketIds = this.marketIds(symbols);
498
+ for (let i = 0; i < marketIds.length; i++) {
499
+ const marketId = marketIds[i];
500
+ messageHashes.push('ticker.' + marketId);
501
+ }
502
+ const url = this.urls['api']['ws']['public'];
503
+ const id = this.nonce();
504
+ const request = {
505
+ 'method': 'subscribe',
506
+ 'params': {
507
+ 'channels': messageHashes,
508
+ },
509
+ 'nonce': id,
510
+ };
511
+ const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
512
+ if (this.newUpdates) {
513
+ const result = {};
514
+ result[ticker['symbol']] = ticker;
515
+ return result;
516
+ }
517
+ return this.filterByArray(this.tickers, 'symbol', symbols);
518
+ }
519
+ async unWatchTickers(symbols = undefined, params = {}) {
520
+ /**
521
+ * @method
522
+ * @name cryptocom#unWatchTickers
523
+ * @description unWatches a price ticker
524
+ * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name
525
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
526
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
527
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
528
+ */
529
+ await this.loadMarkets();
530
+ symbols = this.marketSymbols(symbols, undefined, false);
531
+ const messageHashes = [];
532
+ const subMessageHashes = [];
533
+ const marketIds = this.marketIds(symbols);
534
+ for (let i = 0; i < marketIds.length; i++) {
535
+ const marketId = marketIds[i];
536
+ const symbol = symbols[i];
537
+ subMessageHashes.push('ticker.' + marketId);
538
+ messageHashes.push('unsubscribe:ticker:' + symbol);
539
+ }
540
+ return await this.unWatchPublicMultiple('ticker', symbols, messageHashes, subMessageHashes, subMessageHashes, params);
541
+ }
483
542
  handleTicker(client, message) {
484
543
  //
485
- // {
486
- // "info":{
487
- // "instrument_name":"BTC_USDT",
488
- // "subscription":"ticker.BTC_USDT",
489
- // "channel":"ticker",
490
- // "data":[
491
- // {
492
- // "i":"BTC_USDT",
493
- // "b":43063.19,
494
- // "k":43063.2,
495
- // "a":43063.19,
496
- // "t":1648121165658,
497
- // "v":43573.912409,
498
- // "h":43498.51,
499
- // "l":41876.58,
500
- // "c":1087.43
501
- // }
502
- // ]
544
+ // {
545
+ // "instrument_name": "ETHUSD-PERP",
546
+ // "subscription": "ticker.ETHUSD-PERP",
547
+ // "channel": "ticker",
548
+ // "data": [
549
+ // {
550
+ // "h": "2400.20",
551
+ // "l": "2277.10",
552
+ // "a": "2335.25",
553
+ // "c": "-0.0022",
554
+ // "b": "2335.10",
555
+ // "bs": "5.4000",
556
+ // "k": "2335.16",
557
+ // "ks": "1.9970",
558
+ // "i": "ETHUSD-PERP",
559
+ // "v": "1305697.6462",
560
+ // "vv": "3058704939.17",
561
+ // "oi": "161646.3614",
562
+ // "t": 1726069647560
563
+ // }
564
+ // ]
503
565
  // }
504
- // }
505
566
  //
567
+ this.handleBidAsk(client, message);
506
568
  const messageHash = this.safeString(message, 'subscription');
507
569
  const marketId = this.safeString(message, 'instrument_name');
508
570
  const market = this.safeMarket(marketId);
509
571
  const data = this.safeValue(message, 'data', []);
510
572
  for (let i = 0; i < data.length; i++) {
511
573
  const ticker = data[i];
512
- const parsed = this.parseTicker(ticker, market);
574
+ const parsed = this.parseWsTicker(ticker, market);
513
575
  const symbol = parsed['symbol'];
514
576
  this.tickers[symbol] = parsed;
515
577
  client.resolve(parsed, messageHash);
516
578
  }
517
579
  }
580
+ parseWsTicker(ticker, market = undefined) {
581
+ //
582
+ // {
583
+ // "h": "2400.20",
584
+ // "l": "2277.10",
585
+ // "a": "2335.25",
586
+ // "c": "-0.0022",
587
+ // "b": "2335.10",
588
+ // "bs": "5.4000",
589
+ // "k": "2335.16",
590
+ // "ks": "1.9970",
591
+ // "i": "ETHUSD-PERP",
592
+ // "v": "1305697.6462",
593
+ // "vv": "3058704939.17",
594
+ // "oi": "161646.3614",
595
+ // "t": 1726069647560
596
+ // }
597
+ //
598
+ const timestamp = this.safeInteger(ticker, 't');
599
+ const marketId = this.safeString(ticker, 'i');
600
+ market = this.safeMarket(marketId, market, '_');
601
+ const quote = this.safeString(market, 'quote');
602
+ const last = this.safeString(ticker, 'a');
603
+ return this.safeTicker({
604
+ 'symbol': market['symbol'],
605
+ 'timestamp': timestamp,
606
+ 'datetime': this.iso8601(timestamp),
607
+ 'high': this.safeNumber(ticker, 'h'),
608
+ 'low': this.safeNumber(ticker, 'l'),
609
+ 'bid': this.safeNumber(ticker, 'b'),
610
+ 'bidVolume': this.safeNumber(ticker, 'bs'),
611
+ 'ask': this.safeNumber(ticker, 'k'),
612
+ 'askVolume': this.safeNumber(ticker, 'ks'),
613
+ 'vwap': undefined,
614
+ 'open': undefined,
615
+ 'close': last,
616
+ 'last': last,
617
+ 'previousClose': undefined,
618
+ 'change': undefined,
619
+ 'percentage': this.safeString(ticker, 'c'),
620
+ 'average': undefined,
621
+ 'baseVolume': this.safeString(ticker, 'v'),
622
+ 'quoteVolume': (quote === 'USD') ? this.safeString(ticker, 'vv') : undefined,
623
+ 'info': ticker,
624
+ }, market);
625
+ }
626
+ async watchBidsAsks(symbols = undefined, params = {}) {
627
+ /**
628
+ * @method
629
+ * @name cryptocom#watchBidsAsks
630
+ * @see https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#ticker-instrument_name
631
+ * @description watches best bid & ask for symbols
632
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
633
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
634
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
635
+ */
636
+ await this.loadMarkets();
637
+ symbols = this.marketSymbols(symbols, undefined, false);
638
+ const messageHashes = [];
639
+ const topics = [];
640
+ const marketIds = this.marketIds(symbols);
641
+ for (let i = 0; i < marketIds.length; i++) {
642
+ const marketId = marketIds[i];
643
+ messageHashes.push('bidask.' + symbols[i]);
644
+ topics.push('ticker.' + marketId);
645
+ }
646
+ const url = this.urls['api']['ws']['public'];
647
+ const id = this.nonce();
648
+ const request = {
649
+ 'method': 'subscribe',
650
+ 'params': {
651
+ 'channels': topics,
652
+ },
653
+ 'nonce': id,
654
+ };
655
+ const newTickers = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
656
+ if (this.newUpdates) {
657
+ const tickers = {};
658
+ tickers[newTickers['symbol']] = newTickers;
659
+ return tickers;
660
+ }
661
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
662
+ }
663
+ handleBidAsk(client, message) {
664
+ const data = this.safeList(message, 'data', []);
665
+ const ticker = this.safeDict(data, 0, {});
666
+ const parsedTicker = this.parseWsBidAsk(ticker);
667
+ const symbol = parsedTicker['symbol'];
668
+ this.bidsasks[symbol] = parsedTicker;
669
+ const messageHash = 'bidask.' + symbol;
670
+ client.resolve(parsedTicker, messageHash);
671
+ }
672
+ parseWsBidAsk(ticker, market = undefined) {
673
+ const marketId = this.safeString(ticker, 'i');
674
+ market = this.safeMarket(marketId, market);
675
+ const symbol = this.safeString(market, 'symbol');
676
+ const timestamp = this.safeInteger(ticker, 't');
677
+ return this.safeTicker({
678
+ 'symbol': symbol,
679
+ 'timestamp': timestamp,
680
+ 'datetime': this.iso8601(timestamp),
681
+ 'ask': this.safeString(ticker, 'k'),
682
+ 'askVolume': this.safeString(ticker, 'ks'),
683
+ 'bid': this.safeString(ticker, 'b'),
684
+ 'bidVolume': this.safeString(ticker, 'bs'),
685
+ 'info': ticker,
686
+ }, market);
687
+ }
518
688
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
519
689
  /**
520
690
  * @method
@@ -1,10 +1,12 @@
1
1
  import mexcRest from '../mexc.js';
2
- import type { Int, OHLCV, Str, OrderBook, Order, Trade, Ticker, Balances } from '../base/types.js';
2
+ import type { Int, OHLCV, Str, OrderBook, Order, Trade, Ticker, Balances, Strings, Tickers } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class mexc extends mexcRest {
5
5
  describe(): any;
6
6
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
7
7
  handleTicker(client: Client, message: any): void;
8
+ watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
9
+ handleTickers(client: Client, message: any): void;
8
10
  parseWsTicker(ticker: any, market?: any): Ticker;
9
11
  watchSpotPublic(channel: any, messageHash: any, params?: {}): Promise<any>;
10
12
  watchSpotPrivate(channel: any, messageHash: any, params?: {}): Promise<any>;
@@ -30,7 +30,7 @@ export default class mexc extends mexcRest {
30
30
  'watchOrderBook': true,
31
31
  'watchOrders': true,
32
32
  'watchTicker': true,
33
- 'watchTickers': false,
33
+ 'watchTickers': true,
34
34
  'watchTrades': true,
35
35
  'watchTradesForSymbols': false,
36
36
  },
@@ -128,6 +128,84 @@ export default class mexc extends mexcRest {
128
128
  const messageHash = 'ticker:' + symbol;
129
129
  client.resolve(ticker, messageHash);
130
130
  }
131
+ async watchTickers(symbols = undefined, params = {}) {
132
+ /**
133
+ * @method
134
+ * @name mexc#watchTickers
135
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
136
+ * @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#individual-symbol-book-ticker-streams
137
+ * @see https://mexcdevelop.github.io/apidocs/contract_v1_en/#public-channels
138
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
139
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
140
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
141
+ */
142
+ await this.loadMarkets();
143
+ symbols = this.marketSymbols(symbols, undefined, false);
144
+ const messageHashes = [];
145
+ const marketIds = this.marketIds(symbols);
146
+ const firstMarket = this.market(symbols[0]);
147
+ const isSpot = firstMarket['spot'];
148
+ const url = (isSpot) ? this.urls['api']['ws']['spot'] : this.urls['api']['ws']['swap'];
149
+ const request = {};
150
+ if (isSpot) {
151
+ const topics = [];
152
+ for (let i = 0; i < marketIds.length; i++) {
153
+ const marketId = marketIds[i];
154
+ messageHashes.push('ticker:' + symbols[i]);
155
+ topics.push('spot@public.bookTicker.v3.api@' + marketId);
156
+ }
157
+ request['method'] = 'SUBSCRIPTION';
158
+ request['params'] = topics;
159
+ }
160
+ else {
161
+ request['method'] = 'sub.tickers';
162
+ request['params'] = {};
163
+ messageHashes.push('ticker');
164
+ }
165
+ const ticker = await this.watchMultiple(url, messageHashes, this.extend(request, params), messageHashes);
166
+ if (isSpot && this.newUpdates) {
167
+ const result = {};
168
+ result[ticker['symbol']] = ticker;
169
+ return result;
170
+ }
171
+ return this.filterByArray(this.tickers, 'symbol', symbols);
172
+ }
173
+ handleTickers(client, message) {
174
+ //
175
+ // {
176
+ // "channel": "push.tickers",
177
+ // "data": [
178
+ // {
179
+ // "symbol": "ETH_USDT",
180
+ // "lastPrice": 2324.5,
181
+ // "riseFallRate": 0.0356,
182
+ // "fairPrice": 2324.32,
183
+ // "indexPrice": 2325.44,
184
+ // "volume24": 25868309,
185
+ // "amount24": 591752573.9792,
186
+ // "maxBidPrice": 2557.98,
187
+ // "minAskPrice": 2092.89,
188
+ // "lower24Price": 2239.39,
189
+ // "high24Price": 2332.59,
190
+ // "timestamp": 1725872514111
191
+ // }
192
+ // ],
193
+ // "ts": 1725872514111
194
+ // }
195
+ //
196
+ const data = this.safeList(message, 'data');
197
+ const topic = 'ticker';
198
+ const result = [];
199
+ for (let i = 0; i < data.length; i++) {
200
+ const ticker = this.parseTicker(data[i]);
201
+ const symbol = ticker['symbol'];
202
+ this.tickers[symbol] = ticker;
203
+ result.push(ticker);
204
+ const messageHash = topic + ':' + symbol;
205
+ client.resolve(ticker, messageHash);
206
+ }
207
+ client.resolve(result, topic);
208
+ }
131
209
  parseWsTicker(ticker, market = undefined) {
132
210
  //
133
211
  // spot
@@ -1135,8 +1213,8 @@ export default class mexc extends mexcRest {
1135
1213
  // "code": 0,
1136
1214
  // "msg": "spot@public.increase.depth.v3.api@BTCUSDT"
1137
1215
  // }
1138
- //
1139
- const msg = this.safeString(message, 'msg');
1216
+ // Set the default to an empty string if the message is empty during the test.
1217
+ const msg = this.safeString(message, 'msg', '');
1140
1218
  if (msg === 'PONG') {
1141
1219
  this.handlePong(client, message);
1142
1220
  }
@@ -1180,6 +1258,7 @@ export default class mexc extends mexcRest {
1180
1258
  'push.kline': this.handleOHLCV,
1181
1259
  'public.bookTicker.v3.api': this.handleTicker,
1182
1260
  'push.ticker': this.handleTicker,
1261
+ 'push.tickers': this.handleTickers,
1183
1262
  'public.increase.depth.v3.api': this.handleOrderBook,
1184
1263
  'push.depth': this.handleOrderBook,
1185
1264
  'private.orders.v3.api': this.handleOrder,
package/js/src/pro/okx.js CHANGED
@@ -1445,8 +1445,11 @@ export default class okx extends okxRest {
1445
1445
  },
1446
1446
  ],
1447
1447
  };
1448
- const message = this.extend(request, params);
1449
- this.watch(url, messageHash, message, messageHash);
1448
+ // Only add params['access'] to prevent sending custom parameters, such as extraParams.
1449
+ if ('access' in params) {
1450
+ request['access'] = params['access'];
1451
+ }
1452
+ this.watch(url, messageHash, request, messageHash);
1450
1453
  }
1451
1454
  return await future;
1452
1455
  }
@@ -1616,7 +1619,7 @@ export default class okx extends okxRest {
1616
1619
  'channel': 'positions',
1617
1620
  'instType': 'ANY',
1618
1621
  };
1619
- const args = [arg];
1622
+ const args = [this.extend(arg, params)];
1620
1623
  const nonSymbolRequest = {
1621
1624
  'op': 'subscribe',
1622
1625
  'args': args,
@@ -18,6 +18,9 @@ export default class oxfun extends oxfunRest {
18
18
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
19
19
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
20
20
  handleTicker(client: Client, message: any): void;
21
+ watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
22
+ handleBidAsk(client: Client, message: any): void;
23
+ parseWsBidAsk(ticker: any, market?: any): Ticker;
21
24
  watchBalance(params?: {}): Promise<Balances>;
22
25
  handleBalance(client: any, message: any): void;
23
26
  watchPositions(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
@@ -25,6 +25,7 @@ export default class oxfun extends oxfunRest {
25
25
  'watchMyTrades': false,
26
26
  'watchTicker': true,
27
27
  'watchTickers': true,
28
+ 'watchBidsAsks': true,
28
29
  'watchBalance': true,
29
30
  'createOrderWs': true,
30
31
  'editOrderWs': true,
@@ -499,6 +500,77 @@ export default class oxfun extends oxfunRest {
499
500
  client.resolve(ticker, messageHash);
500
501
  }
501
502
  }
503
+ async watchBidsAsks(symbols = undefined, params = {}) {
504
+ /**
505
+ * @method
506
+ * @name oxfun#watchBidsAsks
507
+ * @see https://docs.ox.fun/?json#best-bid-ask
508
+ * @description watches best bid & ask for symbols
509
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
510
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
511
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
512
+ */
513
+ await this.loadMarkets();
514
+ symbols = this.marketSymbols(symbols, undefined, false);
515
+ const messageHashes = [];
516
+ const args = [];
517
+ for (let i = 0; i < symbols.length; i++) {
518
+ const market = this.market(symbols[i]);
519
+ args.push('bestBidAsk:' + market['id']);
520
+ messageHashes.push('bidask:' + market['symbol']);
521
+ }
522
+ const newTickers = await this.subscribeMultiple(messageHashes, args, params);
523
+ if (this.newUpdates) {
524
+ const tickers = {};
525
+ tickers[newTickers['symbol']] = newTickers;
526
+ return tickers;
527
+ }
528
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
529
+ }
530
+ handleBidAsk(client, message) {
531
+ //
532
+ // {
533
+ // "table": "bestBidAsk",
534
+ // "data": {
535
+ // "ask": [
536
+ // 19045.0,
537
+ // 1.0
538
+ // ],
539
+ // "checksum": 3790706311,
540
+ // "marketCode": "BTC-USD-SWAP-LIN",
541
+ // "bid": [
542
+ // 19015.0,
543
+ // 1.0
544
+ // ],
545
+ // "timestamp": "1665456882928"
546
+ // }
547
+ // }
548
+ //
549
+ const data = this.safeDict(message, 'data', {});
550
+ const parsedTicker = this.parseWsBidAsk(data);
551
+ const symbol = parsedTicker['symbol'];
552
+ this.bidsasks[symbol] = parsedTicker;
553
+ const messageHash = 'bidask:' + symbol;
554
+ client.resolve(parsedTicker, messageHash);
555
+ }
556
+ parseWsBidAsk(ticker, market = undefined) {
557
+ const marketId = this.safeString(ticker, 'marketCode');
558
+ market = this.safeMarket(marketId, market);
559
+ const symbol = this.safeString(market, 'symbol');
560
+ const timestamp = this.safeInteger(ticker, 'timestamp');
561
+ const ask = this.safeList(ticker, 'ask', []);
562
+ const bid = this.safeList(ticker, 'bid', []);
563
+ return this.safeTicker({
564
+ 'symbol': symbol,
565
+ 'timestamp': timestamp,
566
+ 'datetime': this.iso8601(timestamp),
567
+ 'ask': this.safeNumber(ask, 0),
568
+ 'askVolume': this.safeNumber(ask, 1),
569
+ 'bid': this.safeNumber(bid, 0),
570
+ 'bidVolume': this.safeNumber(bid, 1),
571
+ 'info': ticker,
572
+ }, market);
573
+ }
502
574
  async watchBalance(params = {}) {
503
575
  /**
504
576
  * @method
@@ -1022,6 +1094,9 @@ export default class oxfun extends oxfunRest {
1022
1094
  if (table.indexOf('order') > -1) {
1023
1095
  this.handleOrders(client, message);
1024
1096
  }
1097
+ if (table === 'bestBidAsk') {
1098
+ this.handleBidAsk(client, message);
1099
+ }
1025
1100
  }
1026
1101
  else {
1027
1102
  if (event === 'login') {
@@ -1,5 +1,5 @@
1
1
  import phemexRest from '../phemex.js';
2
- import type { Int, Str, OrderBook, Order, Trade, Ticker, OHLCV, Balances, Dict } from '../base/types.js';
2
+ import type { Int, Str, OrderBook, Order, Trade, Ticker, OHLCV, Balances, Dict, Strings, Tickers } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class phemex extends phemexRest {
5
5
  describe(): any;
@@ -16,6 +16,7 @@ export default class phemex extends phemexRest {
16
16
  handleTrades(client: Client, message: any): void;
17
17
  handleOHLCV(client: Client, message: any): void;
18
18
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
19
+ watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
19
20
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
20
21
  watchOrderBook(symbol: string, limit?: Int, params?: {}): Promise<OrderBook>;
21
22
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
@@ -17,7 +17,7 @@ export default class phemex extends phemexRest {
17
17
  'has': {
18
18
  'ws': true,
19
19
  'watchTicker': true,
20
- 'watchTickers': false,
20
+ 'watchTickers': true,
21
21
  'watchTrades': true,
22
22
  'watchMyTrades': true,
23
23
  'watchOrders': true,
@@ -526,6 +526,50 @@ export default class phemex extends phemexRest {
526
526
  const request = this.deepExtend(subscribe, params);
527
527
  return await this.watch(url, messageHash, request, subscriptionHash);
528
528
  }
529
+ async watchTickers(symbols = undefined, params = {}) {
530
+ /**
531
+ * @method
532
+ * @name phemex#watchTickers
533
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Hedged-Perpetual-API.md#subscribe-24-hours-ticker
534
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#subscribe-24-hours-ticker
535
+ * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Spot-API-en.md#subscribe-24-hours-ticker
536
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
537
+ * @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
538
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
539
+ * @param {string} [params.channel] the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
540
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
541
+ */
542
+ await this.loadMarkets();
543
+ symbols = this.marketSymbols(symbols, undefined, false);
544
+ const first = symbols[0];
545
+ const market = this.market(first);
546
+ const isSwap = market['swap'];
547
+ const settleIsUSDT = market['settle'] === 'USDT';
548
+ let name = 'spot_market24h';
549
+ if (isSwap) {
550
+ name = settleIsUSDT ? 'perp_market24h_pack_p' : 'market24h';
551
+ }
552
+ const url = this.urls['api']['ws'];
553
+ const requestId = this.requestId();
554
+ const subscriptionHash = name + '.subscribe';
555
+ const messageHashes = [];
556
+ for (let i = 0; i < symbols.length; i++) {
557
+ messageHashes.push('ticker:' + symbols[i]);
558
+ }
559
+ const subscribe = {
560
+ 'method': subscriptionHash,
561
+ 'id': requestId,
562
+ 'params': [],
563
+ };
564
+ const request = this.deepExtend(subscribe, params);
565
+ const ticker = await this.watchMultiple(url, messageHashes, request, messageHashes);
566
+ if (this.newUpdates) {
567
+ const result = {};
568
+ result[ticker['symbol']] = ticker;
569
+ return result;
570
+ }
571
+ return this.filterByArray(this.tickers, 'symbol', symbols);
572
+ }
529
573
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
530
574
  /**
531
575
  * @method
@@ -12,6 +12,9 @@ export default class woofipro extends woofiproRest {
12
12
  handleTicker(client: Client, message: any): any;
13
13
  watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
14
14
  handleTickers(client: Client, message: any): void;
15
+ watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
16
+ handleBidAsk(client: Client, message: any): void;
17
+ parseWsBidAsk(ticker: any, market?: any): Ticker;
15
18
  watchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
16
19
  handleOHLCV(client: Client, message: any): void;
17
20
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;