Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Window Lengths

Can anyone shed some light in how window lengths affect reported values in pipeline for a company's cash flow statement? For example if I'm looking for the net income of AMZN for 2015 should I set the window length in my custom class (below) to 1 for 1 year, 12, 4, or 252 for trading days? Also which date should I refer to on the pipeline?

My intent is to compare companies based on performance in previous years/quarters.

Thanks.

class Net_Income(CustomFactor):

inputs = [morningstar.cash_flow_statement.net_income]  
window_length = wl  

def compute(self, today, assets, out, net_inc):  
    out[:] = sum(net_inc)  
1 response

I you want to compute the Net Income for the last trailing twelve months (TTM), try this (given than a Quarter has 65 days):

quarter_lenght = 65  
ttm    = [-1, -quarter_lenght, -2*quarter_lenght, -3*quarter_lenght]

class NetIncomeTTM(CustomFactor):  
    window_length = 3*quarter_lenght + 1  
    inputs = [morningstar.income_statement.net_income]

    def compute(self, today, assets, out, net_income):  
        net_income_ttm = np.sum(net_income[ttm], axis=0)        

        out[:] = np.sum(net_income[ttm], axis=0)