Websocket Stream - Minute bar messages double up

Do any of you come across occurrences when the websocket delivers one messages for 2 separate tickers on minute bar streams?

for instance, If I were subscribed to 10 tickers, I would normally get a socket message every minute for each ticker. However, I will also occasionally get a message that includes 2 tickers under one message delivered over the websocket

1-ticker example (1 Websocket Message): [{“ev”:“AM”,“sym”:“CSCW”,“v”:2010249,“av”:94468220,“op”:1.47,“vw”:1.8079,“o”:1.7501,“c”:1.83,“h”:1.84,“l”:1.75,“a”:1.6804,“z”:707,“s”:1616596140000,“e”:1616596200000}]

2-ticker example (1 Websocket Message):
[{“ev”:“AM”,“sym”:“DLPN”,“v”:188419,“av”:22187129,“op”:29.02,“vw”:29.1763,“o”:29.245,“c”:29.0281,“h”:29.5,“l”:28.9,“a”:29.7476,“z”:125,“s”:1616596140000,“e”:1616596200000},{“ev”:“AM”,“sym”:“ZKIN”,“v”:28810,“av”:14951720,“op”:14.59,“vw”:12.092,“o”:12.0887,“c”:12.12,“h”:12.1299,“l”:12.04,“a”:13.9626,“z”:175,“s”:1616596140000,“e”:1616596200000}]

I imagine I can a loop through the message to identify potential double ups but was curious why this happens some times when normally it just delivers a single message per ticker

The document here clearly says
“Multiple data points may arrive in each message received from the server”

So you must handle the case when there are multiple message in same response. “Multiple data points” means 1 or many. So it is working as intended.

I wasn’t doubting it wasn’t intentional by the alpaca servers. I’m just asking how other users tackle the problem and if they experience it often (i.e indexing or loops or etc). plus, the docs show examples of multiple data points on the same ticker so I wasn’t sure if different tickers would result in different messages. I assumed different tickers = different messages so no it was not perfectly clear.

I experience the same issue. The bars tend to contain slightly different volume data but everything else is identical. My script compares the timestamp of new bars to the previous bar received and disregards any bar with identical timestamps.

Sorry, just reread your post and realised you are having a different issue.

@Beauj34 This is working as intended.

“Multiple data points may arrive in each message received from the server. These data points have the following formats, depending on their type.”

I would recommend using ‘logging’ instead of prints for better organization.

1 Like