-
Notifications
You must be signed in to change notification settings - Fork 59
Subscribing to real time data
NOTE: This Wiki is only for versions < 1.0.0. For 1.0.0 docs, refer to API.md.
The private API also supports subscribing to real-time data.
Follow the example below to get started.
avanza.socket.on('connect', () => {
/**
* 5479 is the instrumentId for Telia.
*/
avanza.socket.subscribe('5479', ['quotes', 'brokertradesummary']);
});
avanza.socket.on('quote', data => {
/**
* Do something with the real-time quote data
*/
console.info(Date.now(), 'Received quote: ', data);
});
/**
* Authenticate as usual
*/
avanza.authenticate({
username: 'draghimario',
password: 'cashisking1337'
}).then(() => {
/**
* Initialize the socket after authentication
*/
avanza.socket.initialize();
})
This channel is mostly used for comparing one instrument with another. Receives minute-wise data regarding the instrument in question, containing current price, change, total volume traded etc.
Updates whenever a new order is received. The data consists of the best five offers, on both sides, as well as the current total volume on each side.
When a new trade is made, this channel updates with information regarding the trade. The data returned contains volume, price and broker, among other things.
Pushes data about which brokers are long/short, and also how big their current net volume is.
Get data about your own positions.
Seems like this channel is currently unused. See orderdepths
instead.
Seems like this channel is currently unused. See trades
instead.