I have equity time series and I am trying to update the high of the daya based on the recent trade. For example, if the last trade is higher than the known high, than update the high of the day to be the last trade etc.
I have tried to implement the solution here and read few other solutions to update raw by raw with an IF function but I am failing and getting an error after running this code:
df = pd.read_csv('C:/2017-11-20.csv')
df.set_index('dateTime', inplace=True)
df['high'] = 0
high = 0
for dateTime, row in enumerate(df.iterrows()):
if df['tradePrice'] > df['high']:
df['high'] = df['tradePrice']
else:
df['high'] = df['high']
the error is:
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
the data (top 5 lines) is:
SecurityID,dateTime,ask1,ask1Volume,bid1,bid1Volume,ask2,ask2Volume,bid2,bid2Volume,ask3,ask3Volume,bid3,bid3Volume,tradePrice,tradeVolume,isTrade 2318276,2017-11-20 08:00:09.052240,12869.0,1,12868.0,3,12870.0,19,12867.5,2,12872.5,2,12867.0,1,0.0,0,0 2318276,2017-11-20 08:00:09.052260,12869.0,1,12868.0,3,12870.0,19,12867.5,2,12872.5,2,12867.0,1,12868.0,1,1 2318276,2017-11-20 08:00:09.052260,12869.0,1,12868.0,2,12870.0,19,12867.5,2,12872.5,2,12867.0,1,12868.0,1,0 2318276,2017-11-20 08:00:09.052270,12869.0,1,12868.0,2,12870.0,19,12867.5,2,12872.5,2,12867.0,1,12868.0,1,1 2318276,2017-11-20 08:00:09.052270,12869.0,1,12868.0,1,12870.0,19,12867.5,2,12872.5,2,12867.0,1,12868.0,1,0