Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Rolling Z-Score

Is there a simple function to compute rolling z-scores that accepts say the number of days as input? Say similar to Pandas zscore()?

1 response

This works:

def rollingzscore(x, window):
r = x.rolling(window=window)
m = r.mean().shift(1)
s = r.std(ddof=0).shift(1)
z = (x-m)/s
return z