Hi there, I’m probably doing something wrong, but I’m getting different results from the websocket bar data and REST call - the websocket sends what appears to be a 1Min bar based on the timestamp (and it sends data only once per minute), but it seems to be a small slice of the minute bar dataset.
I’m using the JS framework, so with the following:
alpaca.data_stream_v2.onConnect(() => {
socket.subscribeForBars(['QQQ'])
})
alpaca.data_stream_v2..onStockBar((bar) => {
console.log(bar)
})
alpaca.data_stream_v2.connect()
output:
{
T: 'b',
Symbol: 'QQQ',
OpenPrice: 398.045,
ClosePrice: 397.985,
HighPrice: 398.045,
LowPrice: 397.985,
Volume: 2842,
Timestamp: 2021-12-07T19:02:00.000Z,
TradeCount: 26,
VWAP: 398.001246
}
Whereas, with the REST call using alpaca.getBarsV2
, I get:
{
Timestamp: '2021-12-07T19:02:00Z',
OpenPrice: 398.015,
HighPrice: 398.05,
LowPrice: 397.835,
ClosePrice: 397.84,
Volume: 79011,
TradeCount: 851,
VWAP: 397.972621
}