Appearance
Live prices
ts
export async function streamPrices(render: (symbol: string, bid: string, ask: string) => void) {
const symbols = await trader.symbols.list();
const names = new Map(symbols.map((s) => [s.id, s.name]));
const socket = trader.socket();
socket.on("prices", (prices) => {
for (const p of prices) render(names.get(p.symbolId) ?? String(p.symbolId), p.bid, p.ask); // exact strings
});
await socket.connect();
socket.watch(symbols.slice(0, 50).map((s) => s.id)); // kept across reconnects
return () => socket.close();
}Prices arrive as binary frames; the SDK decodes them into Price objects whose bid, ask and last are exact decimal strings (never floats). Limits: 1000 watched symbols per socket (fewer when the group sets a symbol limit; extra symbols are ignored), 20 messages per second.