Additional informations on real-time data strweams : Trades/Quotes Schema

Dear Alpaca Community,

Maybe this topic has already been discussed, but I couldn’t find any clarification on the relationship between Trades/Quotes streams (Data Points: Real-time Data | Alpaca Docs) and limit order book (LOB) and its matching algorithm:

For quote schema in real-time data point: What does the bid/ask/size correspond to in the order book? Is it the updated best bid/ask following a new limit order? If yes, does the size correspond to the volume available at a quoted price? Is it just a bid/ask quoted by a market participant?

For trades schema in real-time data point: What do trade price and trade size correspond to in the LOB? Is it the middle of the best bid/ask price (Best Bid + Best Ask / 2.0) after an executed market order? Is it the micro-price e.g the volume-weighted bid/ask price after an executed market order? Or simply is it the average filled price of the last executed market order?

Additionally, it is possible to know the direction of the market order for the last trade? E.g buy market order against sell limit order OR sell market order against buy limit order.

It would be amazing to have more info about those streams and LOBs, considering that at less than a minute bar, microstructure becomes important for trading.

Best,

1 Like

I’ve the same questions. Anyone from Alpaca can answer? I see many questions in the community are unanswered. Where are Alpaca supports?

Hi Rock,

We are trying our best to keep up with the questions.

The NBBO quotes are the best bid and best ask across the LOB from various exchanges.

The trades does not correspond to any value on the LOB. It is just the price the last transaction took place at.

@rahul Thanks for addressing this. I was playing around with the APIs and found BIG spread from the real time quote callback using StockDataStream:subscribe_quotes. This is compared to StockHistoricalDataClient:get_stock_quotes. You can see from the below screenshot in which the quotes apparently are NOT NBBO (National “Best”). This is frustrating and causing the bot trade wildly with BIG losses! Would you please shed some lights on how to correctly filter the data please? Thanks a million!