Back to Community
Price of security N days ahead from within Pipeline

How do I get the price of a security N days ahead from within Pipeline?

3 responses

"How do I get the price of a security N days ahead from within Pipeline?" ...... No can do.

Looking into the future is not an option for us mere mortals. The entire pipeline/backtest environment is set up to eliminate the possibility of look ahead bias . One cannot 'look ahead' at data from within a pipeline.

If you are in the research environment, then one could take the output from multiple days of a pipeline, or better yet use the "get_pricing" method, and analyze any dates one wishes. There is a one caution in doing this with pipeline output. The data returned from a pipeline will not be split adjusted from day to day. The data will be exactly what a trader would have seen on each date returned by the pipeline. It will be split adjusted for that day but not from day to day.

Hmm. I am missing something then.

I would like to see if the last week's return forecasts the next weeks return. I can get the last weeks return using pipeline. But if I cannot get the next week return then he have a problem?

From the discussion I would presume pipeline is then designed for implementing the algo and in that context avoiding lookahead bias makes sense. But what about doing research. Clearly I need to lookahead to answer simple questions like does last weeks return forecast next weeks return.

Within the research environment one can use 'get_pricing' to retrieve split adjusted data for a given time period. One can 'look ahead' into this data simply by indexing ahead or by using one of the methods like 'shift' ( to align current data with some future data.

However, if what you are trying to do is see how well a factor predicts future returns, then use Alphalens. See . Most of the work has already been done for you.