I have a dataFrame (df) which looks like the follow:
index ticker start_date
0 CRON 2020-10-27
1 DS 2020-10-27
I would like to create a new column return a 3 day return for that ticker given the start_date. The start_date is datetime64
I created a function:
def three_day_return(date_col, ticker_col):
end_date = np.busday_offset(dates=date_col.strftime("%Y-%m-%d"), holidays=nyse.holidays().holidays, offsets=3)
price_df = yf.download(ticker_col,
start=date_col,
end=end_date,
progress=False)
open_price = price_df.iloc[1]['Open']
close_price = price_df.iloc[3]['Close']
return open_price/close_price-1
when I apply the function, I get an errorcode. Would love some help on this. Thanks in advance
df['three_day_return']= three_day_return(df['start_date'], df['ticker'])
AttributeError: 'Series' object has no attribute 'strftime'