alpacahq / alpaca-py

The Official Python SDK for Alpaca API
https://alpaca.markets/sdks/python/getting_started.html
Apache License 2.0
491 stars 122 forks source link

[Question]: How can I get symbol latest price that same as alpaca web trade dashboard? #475

Closed seedpower closed 2 weeks ago

seedpower commented 2 weeks ago

Question form pre-submit checklist.

Question

I use next code to get symbol's latest price, but it has a large gap with alpaca web trade dashboard. How can I get latest price same as alpaca web trade dashboard ?

req = StockLatestQuoteRequest(symbol_or_symbols=symbol)
res = stock_historical_data_client.get_stock_latest_quote(req)
data = res[symbol]
print(data)
return (data.ask_price + data.bid_price) / 2.0
gnvk commented 1 week ago

@seedpower You need to have a market data subscription to query the latest SIP quote. Without the subscription get_stock_latest_quote returns the latest IEX quote.