Need api to get multiple quotes with one api call

Currently I have a bot based on Robinhood. There, I can retrieve quotes for ~400 different stocks “live” (as reasonably live as RH quotes are) in about 0.02 seconds in a single api call. (getting just 1 quote from robinhood takes 0.01 seconds, so 400x for only 2x performance impact).
I can make this call quite frequently (every 2 seconds, right now), as robinhood clearly has them all cached in the same place and just returns the latest to me all the time. Its great, very useful for my automation. I need an equivalent from Alpaca, and streaming just 30 isn’t enough for what I’m trying to do. I imagine you store all your quotes in the same cache similar to robinhood, so it would be great to just let us query more than one at once in a single API call. It’ll save a lot of overhead on both sides.

Thanks!
Sincerely, bot-trades-off-of-quotes.

1 Like

There is a Polygon endpoint to fetch the previous minute aggregate data for all tickers. I personally haven’t used this but it may be something to look at. Info from Polygon can be found here.

1 Like

So i tried that polygon api call out. Unfortunately it takes a full 2 seconds just to get the data back to me (which I then need to filter for just the 400 symbols that I want, adding more computation time). So in the end using this API - while it would appear to get me all the data I need at first glance - puts me 2 seconds behind where I would be via robinhood.

Ideally I’d like to be able to get back live quotes for a bunch of tickers at once quickly (or maybe my entire watchlist at once, if that is easier than accepting an arbitrary list of tickers as input?).

I’m trying the polygon websocket method now to see if I can subscribe to a few hundred stocks that way, that could work well too if they allow it.

Polygon has an endpoint for ‘last quote for a symbol’ - if you need to get them at a specific time.

If you need realtime ‘last quotes’, just use their WebSocket.

Hi, you could use this example code as base to your needs:

it demonstrates how to use the data websockets (polygon and alpaca)

Thanks for the responses. Polygon seems nifty, I’ve reached out to them about some bugs I discovered with their aggregates API, but I did test the websockets earlier after Juan’s message and that seems like a good (better, even) alternative to polling robinhood quotes, although will be a significant rewrite over the polling method to tackle.

I just used the polygon lib’s websocketClient when I tested, but I’ll give that example a shot too @Shlomik, any particular reason to use direct StreamConns over the

pWsClient = polygon.WebSocketClient(polygon.STOCKS_CLUSTER, cfg['alpacaKeyId'], my_customer_process_message)
pWsClient.run_async()
tickers = get_quote_tickers_to_monitor()
toSub = []
for ticker in tickers:
    toSub.append("Q."+ticker)
pWsClient.subscribe(*toSub)
time.sleep(30)

pWsClient.close_connection()

method? (I didn’t look too closely at the example yet, but I assume its connecting to this same polygon websocket?)