I used trades stream instead of quotes stream today, and on SPY the steam reported a trade at $621.9 and my bot acted on it, this value was $8 below the current value, not even the low of the day was near that, and it was not reflected on the candle, in short that trade was BS. It doesn’t feel very reliable. Is this normal?
ChatGPT suggest to filter on trade conditions, but the alpaca documentation doesn’t clarify. What “conditions” should I trust or discard?
How are you people filtering invalid values on the stream?
@jnantes You mention seeing trades in the websocket stream which seem incorrect. First, which endpoint are you connecting to wss://stream.data.alpaca.markets/v2/sip or wss://stream.data.alpaca.markets/v2/delayed_sip. The wss://stream.data.alpaca.markets/v2/iex feed is for testing purposes only and contains only data from the IEX exchange which can be misleading. So, first ensure you are not connecting to the iex feed.
Second, it’s true that not all trades are created equal so you must filter some out. You will always want to filter some of the trades. Take a look here in the docs for how bars are calculated and which trades are excluded. The SIPs provide the guidance on which trades should be used for High and Low, Close, and Volume calculations (they mysteriously don’t give guidance on Open trades).
The main two reasons you want to filter trades are 1) some are information only and don’t represent an actual trade (eg 9 “Corrected Consolidated Close” or M “Market Center Official Close” and 2) non-typical trades which your order would never fill at (eg P “Prior Reference Price” or R or “Seller” which gives the seller the right to deliver the shares at some future time and not the regular 1 day settlement) Those aren’t really indicative of the current market.
One condition which is excluded is I or “Odd lot trade”. These are trades under 100 shares (or technically a full lot). This is one condition you may not want to exclude. Your data won’t match provider data, but you may want to get an idea of what small retail investors are doing and include those trades rather than exclude them?