Hi, I am relatively new to Python and am struggling to get the percentage change of a moving average. I want to apply this to the Sentdex's data, sentiment signal.
def make_pipeline():
sentiment_factor = sentiment.sentiment_signal.latest
universe = (sentiment_factor.notnull())
mavg30 = SimpleMovingAverage(inputs=[sentiment.sentiment_signal], window_length=30)
percent_difference = (mavg30[0] - mavg30[-1]) / mavg30[-1]
return Pipeline(
columns={'mavg30': mavg30,
'percent_difference': percent_difference
},screen=universe)
I get this error 'TypeError: zipline.pipeline.term.getitem() expected a value of type zipline.assets._assets.Asset for argument 'key', but got int instead.'
Any help would be great Thanks!