I am using alpaca.data.requests.StockBarsRequest to get the stock history of something:
from alpaca.data.requests import StockBarsRequest
from datetime import datetime
from alpaca.data.historical import StockHistoricalDataClient
from alpaca.data.timeframe import TimeFrame
client = StockHistoricalDataClient(API_KEY, SECRET_KEY)
stock_bar_req = StockBarsRequest(symbol_or_symbols=["AAPL"], timeframe=TimeFrame.Day, limit = 100000,
start=datetime(2015, 7, 1), end = datetime(2022, 7, 1), feed="iex")
bars = client.get_stock_bars(stock_bar_req)
However, when I run this the earliest time I get starts in 2020. Why am I not getting data from before 2020?
@Lama IEX bar data is only available from 2020. However, sip data is available from 2016. This will get 7+ years of daily bars
stock_bar_req = StockBarsRequest(symbol_or_symbols=["AAPL"],
limit = 100000,
start=datetime(2015, 7, 1),
end = datetime(2022, 7, 1),
In general, one should always use
feed='sip'. That will give accurate full market data. The IEX data is really provided just for testing.
Thanks for the info. Do you know where in the docs it says this? I was unable to find which feed has what time range of data available.
Also Is it possible to get data from 20+ years ago, or do I need to use something else?