Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Standard deviation of factset fundamentals?

Can anyone help me figure out how to compute the percentage standard deviation of trailing 12 month sales over the last 20 quarters (5 years)? So far I have,

import numpy as np  
from quantopian.pipeline.data.factset import Fundamentals

class StdDev(CustomFactor):  
    window_safe = True  
    def compute(self, today, asset_ids, out, values):  
        out[:] = np.nanstd(values, axis=0)

sales_growth_ltm = Fundamentals.sales_gr_ltm  
sales_growth_stddev = StdDev(inputs=[sales_growth_ltm], window_length=1260)