Hello hello!
I’m consuming minute bars over the web socket and I realised I always have missing bars for some symbols.
I’m opening a connection to get minute bars data for the NASDAQ-100 symbols. Since we are talking about minute bars and not quotes, I would expect to get a bar for each symbol, without exception. So how come I’m not getting data for some symbols?
- I’m using the
@alpacahq/alpaca-trade-api
node package - I’m subscribing to the bars for all nasdaq symbols (total of 101)
- on message, I just update a local variable with the latest bars
Even if I leave the code running for a couple of minutes, I always have a few symbols without any bar.
From the last 4 times I ran the code over the last hour, these are the symbols for which I did not get any bar, in order
Run 1: [ 'ASML', 'BIIB', 'CTAS', 'INTU', 'MELI', 'ODFL', 'REGN', 'ROP']
Run 2: [ 'BKNG', 'AVGO', 'CDW', 'KLAC' ]
Run 3: ['MELI']
Run 4: [ 'CTAS' ]
Stripped down, the code is just:
// tickers.length => 101
const bars = new Set();
const socket = alpaca.data_stream_v2;
socket.onConnect(() => {
socket.subscribeForBars(tickers);
})
socket.onStockBar((quote) => {
bars.add(quote.Symbol);
});
// show what we got every minute
setInterval(() => {
console.log(tickers.filter(t => !bars.has(t)));
}, 1_000 * 60);
I think Alpaca is not sending minute bars for symbols without much movement, but my understanding is that I would be getting a minute bar, for every symbol, no matter what. Is my assumption incorrect? What could the issue be?
Thanks!