I am trying to add a column to my pipeline that contains the rolling z-score of returns and volume, similar to the 1st Lesson of the Tutorial (Getting Started):
aapl_sma20 = aapl_close.rolling(20).mean()
aapl_sma50 = aapl_close.rolling(50).mean()
What would be the simplest approach?
I tried this approach but to no avail:
class Vol_z-score(CustomFactor):
inputs = [USEquityPricing.volume,USEquityPricing.volume.latest]
window_length = 21
def compute(self, today, assets, out, volume):
volume[np.isnan(volume)] = 0
mean = np.mean(volume, 0)#.shift(1)
std = np.std(volume, 0)#.shift(1)
z_score = (latest - mean)/std
out[:] = z_score