I am trying to create Bollinger Bands in a Custom Factor for my pipeline but I cannot access data from there and I can't pass it either because you can't have data in the def initialize(context) function, which is where make_pipeline is called. Any help would be appreciate, as I need to have historical price data to put into talib.BBands.
Thanks
class CalculateFactors(CustomFactor):
inputs = [USEquityPricing.close]
window_length = 10
outputs = ['upper', 'middle', 'lower']
def compute(self, today, assets, out, close):
hist = data.history(assets, 'price', 10, '1d') #returns NameError: global name 'data' is not defined
upper, middle, lower = talib.BBands(hist, timeperiod = 100, nbdevup = 2, nbdevdn = 2, matype = 0)
out.upper[:] = upper[-1]
out.middle[:] = middle[-1]
out.lower[:] = lower[-1]