-
-
Notifications
You must be signed in to change notification settings - Fork 977
Expand file tree
/
Copy pathquote-session.js
More file actions
17 lines (14 loc) 路 664 Bytes
/
Copy pathquote-session.js
File metadata and controls
17 lines (14 loc) 路 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Low-level quote session: several symbols sharing one subscription list.
// Run: npm run build && node examples/quote-session.js
import { TradingViewClient } from '@mathieuc/tradingview';
const client = new TradingViewClient();
const quotes = client.createQuoteSession({ fields: ['lp', 'ch', 'chp', 'volume'] });
for (const symbol of ['BINANCE:BTCEUR', 'BINANCE:ETHEUR']) {
const subscription = quotes.subscribe(symbol);
subscription.on('data', (quote, changes) => console.log(symbol, changes));
subscription.on('error', (error) => console.error(symbol, error.message));
}
setTimeout(async () => {
quotes.delete();
await client.close();
}, 10_000);