I am trying to loop through all the dates for the given time period with:
disp_start = dt.datetime(2017,1,6) #####START DATE
disp_data = closingprices.loc[disp_start:] #closing prices is data w/ stock prices
for date in disp_data.index:
returns = (closingprices.iloc[-1].divide(closingprices.iloc[date]))-1
But get this error:
TypeError: cannot do positional indexing on <class 'pandas.core.indexes.datetimes.DatetimeIndex'> with these indexers [2017-01-06 00:00:00] of <class 'pandas._libs.tslib.Timestamp'>
Not sure how to loop through all periods from a given start date (disp_start). Thanks