Hi There,
I am trying to resample the monthly data of the stock SPY by using this code, however the resample is not working properly, when comparing with other sources like yahoo. What I'm doing wrong?
Thanks
schedule_function(monthly_data,
date_rules.month_end(days_offset=0),
time_rules.market_close())
def monthly_data(context, data):
daily_ohlc = data.history(symbol('SPY'), ['open', 'high', 'low', 'close'], 90,'1d')
monthly_ohlc = daily_ohlc.resample('1M').agg({'open': 'first',
'high': 'max',
'low': 'min',
'close': 'last'})
Results
high close open low
2016-11-30 00:00:00+00:00 220.520 219.039 211.682 207.159
2016-12-31 00:00:00+00:00 227.002 223.550 219.437 217.866
2017-01-31 00:00:00+00:00 229.710 227.430 225.040 223.884
Yahoo
Date Open High Low Close Adj Close* Volume
Feb 01, 2017 227.53 237.31 226.82 236.47 236.47 1,365,136,600
Jan 01, 2017 225.04 229.71 223.88 227.53 227.53 1,481,734,100
Dec 01, 2016 220.73 228.34 219.15 223.53 223.53 1,821,910,200