MCPcopy Create free account
hub / github.com/ccxt/node-binance-api / tradesStream

Method tradesStream

src/node-binance-api.ts:6624–6641  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 2

reconnectMethod · 0.95
mainFunction · 0.95

Calls 3

isArrayUniqueMethod · 0.95
subscribeCombinedMethod · 0.95
subscribeMethod · 0.95

Tested by

no test coverage detected