Hello.
After I checked what I could do with the different API I learned that all can be done with the alpaca-py APi and even a bit easier than with the alpaca-trading-api. Is that true?
My goal is to get once a second (10 seconds also ok) the most actual quote askprice or the last trade price would be even better because it is fewer data.
pip install alpaca-py
stock_universe = ["TSLA", "MSFT", "AAPL]
from alpaca.data.historical import StockHistoricalDataClient
from alpaca.data.requests import StockLatestQuoteRequest# Create stock historical data client
api_key = "<Your API key>"
api_secret = "<Your API secret>"
client = StockHistoricalDataClient(api_key, api_secret)# Create request
multisymbol_request_params = StockLatestQuoteRequest(symbol_or_symbols=["TSLA"])
latest_multisymbol_quotes = client.get_stock_latest_quote(multisymbol_request_params)
latest_ask_price = latest_multisymbol_quotes["TSLA"].ask_price
print(latest_ask_price)
How i can change the code so that it would request all prices from the “stock_universe” ( so that i can easily extend it later without adding it in the code)
Would this be done by f`strings. I tried to make it work but cant find an example which does it with alpaca-py and the quotes or trades. just with bars.
Would it decrease the performance if I put it into a data frame to work with the prices or can I work with them on the run as they change too?
Every help is welcome.