'Alpaca API Date (Start, End) Invalid Error with Python for stocks

When I try to generate the **Start ** and **End ** Dates for the API from Today's function and the last business day I get an error

Here is the code:

Symbol=“AAPL”
end= datetime.datetime.today()   
date1= end- pd.tseries.offsets.BDay(1) 
start=(date1.strftime(’%Y-%m-%d’)) 

Alpaca= api.get_bars(Symbol, TimeFrame.Day, start, end  , 
adjustment=‘raw’).df

I get : APIError: invalid start

Thank you for the help in Advance!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source