alpacahq / alpaca-py

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

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

Closed seedpower closed 5 months ago

seedpower commented 5 months 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 4 months 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.