Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Passing self data as input to custom factor

I want to make a generic custom factor (chain_factor) that accepts a self serv data as input. Inside the custom factor, I like to chain several calls like this:

class Window_Safe(CustomFactor):  
        window_length = 1  
        window_safe = True  
        def compute(self, today, assets, out, value):  
            out[:] = value  

class chain_factor(CustomFactor):  
        def compute(self, today, asset_ids, out,  
                    data, len1, len2):  
            ret = Returns(inputs=[data], window_length= len1)[symbol('SPY')]  
            ma = SimpleMovingAverage(inputs=[ret], window_length=len2)  
            sliced = Window_Safe(inputs=[ma])  
            out[:] = sliced[-1]  

cf = chain_factor (my_self_serv_data, 252, 5)

I got an error by doing this:
TypeError: zipline.pipeline.term.getitem() expected a value of type zipline.assets._assets.Asset for argument 'key', but got int instead.

Is this possible? Or am I doing it wrong somewhere?