Hi,
I am trying to work with either Weekly or Monthly OHLC bars. However, I am not sure how to do it. Is it possible to use data in this time-frequency?
Thanks,
John
Hi,
I am trying to work with either Weekly or Monthly OHLC bars. However, I am not sure how to do it. Is it possible to use data in this time-frequency?
Thanks,
John
This may help
def initialize(context):
schedule_function(resampled_data, date_rules.week_end(), time_rules.market_close())
def resampled_data(context, data):
stock = symbol('SPY')
OHLC = data.history(stock, ['open', 'high', 'low', 'close'], 5, '1d')
OHLC_W = OHLC.resample('1W-FRI').agg({'open': 'first', 'high': 'max', 'low': 'min', 'close': 'last'})
print(OHLC_W)