Hi,
I am fairly new to the community. I am trying to get the 52 week high of the SPY and print the value on a daily basis.
Looking around at some code I found, I decided to go with the following code which seems to work at first:
high_history = history(252,'1d','high')
high = max(high_history[context.spy])
print(high)
This code is part of the before_trading_start() function, therefore it prints the 52 week high every day at 8:45. So far so good...
When i run the code, on 2018-01-29 08:45 PRINT 286.58, this makes sense since on 2018-01-26 (the trading day before) SPY reach a new 52 week high to 286.58 (actually it should be 286.63 according to Yahoo, is there a reason why I can't get the actual high?).
What make less sense however in that on 2018-03-16 08:45 PRINT 285.437035591 this value remains for a couple of days until 2018-06-15 08:45 PRINT 284.161427485 which also remains a couple of days...
However until this day the SPY 52 week high is 286.58, can someone help me with fixing my little code?