Trade Updates Websocket API trade side?

Hello everyone!

I’d like to collect the trade updates using the websocket stream. I managed to connect and now getting the data, however, I could not find the information about the trade sides, like look at the couple of trade updates I receive:

INFO: symbol='CSCO' timestamp=datetime.datetime(2024, 8, 12, 14, 27, 15, 156888, tzinfo=datetime.timezone.utc) exchange='V' price=45.45 size=100.0 id=625 conditions=['@'] tape='C'
INFO: symbol='AAPL' timestamp=datetime.datetime(2024, 8, 12, 14, 27, 15, 178241, tzinfo=datetime.timezone.utc) exchange='V' price=218.44 size=100.0 id=1630 conditions=['@'] tape='C'
INFO: symbol='AMZN' timestamp=datetime.datetime(2024, 8, 12, 14, 27, 15, 309597, tzinfo=datetime.timezone.utc) exchange='V' price=168.45 size=23.0 id=1582 conditions=['@', 'I'] tape='C'

Are those buys or sells?
What are the conditions and tape?

Thanks a lot in advance!

@dantester Trades technically don’t have a ‘side’. A trade represents a buy order and a sell order being matched and executed. A ‘buy’ is executed with an equal and opposite ‘sell’. The trades in the websocket stream represent the price which the buyer and seller agree on and the quantity of shares exchanged.

That said, some exchanges and other trading venues provide proprietary data which add ‘trade aggressor’ information indicating if the trade was adding or removing liquidity. That is sometimes used to indicate the ‘side’ of a trade. That data isn’t provided by Alpaca (or most data providers) and can be expensive.

The trade ‘conditions’ specify information about the trade. The trade stream (contrary to what the name implies) includes more than actual trades. There are a number of ‘informational’ trades such as updates (updating a previously reported trade) or ‘prints’ which are an exchange’s ‘official’ open or close prices. These have special condition codes and typically can be disregarded. Additionally, not all trades are regular ‘market’ trades. Some trades are based upon a previously agreed upon price or allow the seller to deliver shares at some future date (and not the regular 1 day settle time). These of course can trade at different prices than ‘regular’ trades and also are typically disregarded. There is an endpoint which lists all the trade conditions here. Polygon has a good explanation of each here.

The ‘tape’ is which Securities Information Processor (SIP) the symbol reports on. It really isn’t of any use except the different tapes (A, B, or C) use slightly different trade conditions. So, to uniquely identify a trade condition, you need to use the condition+tape pair.

Hello @Dan_Whitnable_Alpaca!
Thank you for the clarification! How can I filter out just the market orders out from the all messages in this scenario?