simul8or-agent-sdk
v1.0.0
Published
Real-time Yahoo Finance price streaming for simul8or trading agents
Downloads
9
Readme
simul8or-agent-sdk
Real-time Yahoo Finance price streaming for simul8or trading agents.
Install
npm install simul8or-agent-sdkUsage
const { YahooStreamer } = require('simul8or-agent-sdk');
const stream = new YahooStreamer({
symbols: ['AAPL', 'NVDA', 'TSLA'],
onTick: (tick) => {
console.log(`${tick.id} $${tick.priceRounded} ${new Date(tick.time).toLocaleTimeString()}`);
},
onError: (err) => console.error('Error:', err.message || err),
onState: (state) => console.log('State:', state)
});
stream.connect();
// Subscribe to more symbols later
stream.subscribe('MSFT');
stream.subscribe(['GOOG', 'AMZN']);
// Unsubscribe
stream.unsubscribe('TSLA');API
new YahooStreamer(opts)
| Option | Type | Default | Description |
|---|---|---|---|
| symbols | string[] | [] | Initial symbols to subscribe to |
| onTick | function | no-op | Called on each price update with { id, price, priceRounded, time } |
| onError | function | console.error | Called on errors |
| onState | function | no-op | Called with 'connecting', 'open', or 'closed' |
| url | string | Yahoo Finance WSS | Custom WebSocket endpoint |
stream.connect()
Opens the WebSocket connection and begins streaming.
stream.subscribe(symbols)
Add symbols. Accepts a string or array of strings.
stream.unsubscribe(symbols)
Remove symbols. Accepts a string or array of strings.
Tick Object
{
id: 'AAPL', // Symbol
price: 198.52000427, // Raw float from Yahoo
priceRounded: 198.52, // Rounded to 2 decimals
time: 1738729104000 // Unix timestamp ms
}