* Websocket raw trades * @param {array/string} symbols - an array or string of symbols to query * @param {function} callback - callback function * @return {string} the websocket endpoint
(symbols: string[] | string, callback: Callback)
| 6622 | * @return {string} the websocket endpoint |
| 6623 | */ |
| 6624 | tradesStream(symbols: string[] | string, callback: Callback) { |
| 6625 | const reconnect = () => { |
| 6626 | if (this.Options.reconnect) this.tradesStream(symbols, callback); |
| 6627 | }; |
| 6628 | |
| 6629 | let subscription; |
| 6630 | if (Array.isArray(symbols)) { |
| 6631 | if (!this.isArrayUnique(symbols)) throw Error('trades: "symbols" cannot contain duplicate elements.'); |
| 6632 | const streams = symbols.map(function (symbol) { |
| 6633 | return symbol.toLowerCase() + '@trade'; |
| 6634 | }); |
| 6635 | subscription = this.subscribeCombined(streams, callback, reconnect); |
| 6636 | } else { |
| 6637 | const symbol = symbols as string; |
| 6638 | subscription = this.subscribe(symbol.toLowerCase() + '@trade', callback, reconnect); |
| 6639 | } |
| 6640 | return (subscription as any).url; |
| 6641 | } |
| 6642 | |
| 6643 | /** |
| 6644 | * Websocket klines |
no test coverage detected