Back to Community
A Dynamic Window Length For Returns Factor

Hey quantopians

My algo uses a pipeline to calculate returns on increasing window lengths like so:

def make_pipeline(window):  
    if window == 1:  
        returns_builtin = Returns(  
            window_length = 2,  
        window += 1  
        returns_builtin = Returns(  
            window_length = window,  
        window += 1  
    return Pipeline(  
            'Builtin_returns': returns_builtin,  
        }, screen = StaticAssets(symbols('AMZN', 'MSFT', 'ADBE'))  

Obviously it doesn't work because the algo state can't be shared with the pipeline. I was wondering if there are other ways to dynamically compute window length in a pipeline or pass it externally?

I'm trying to calculate returns , for a list of stocks, from start of the backtest to the current simulation date, every day.

Is there another way to achieve this without using a pipeline?

thanks in advance