Grant is correct. You can do what you want. There is a bit of a learning curve though.
When I said 'the pipeline only accesses the previous days data' this is always relative to the backtest day, and not the day it starts or anything like that.
The pipe should be defined in the initialize
function. This function is automatically called exactly once before the backtest starts. Create all your factors, filters, etc in this function (or in a separate function which is called from there). Then instantiate the pipeline similar to below
universe = Q1500US()
close = USEquityPricing.close.latest
my_pipe = Pipeline(
columns = {
'close' : close,
},
screen = universe,
)
All this does, however, is create the definition for what data you want as columns in the dataframe which the pipeline returns. To actually run the pipeline and get that data use the 'pipeline_output' method. Place this in the before_trading_start
function and it will automatically get called each day before the markets open. It will return all the current data as of the previous day (ie everything that a trader would know before the market opens).
context.output = pipeline_output('my_pipe')
context.output will be a dataframe with all the columns of data you defined for each security which passed the 'screen' filter (or all securities if no screen is specified). The backtest engine executes the before_trading_start
function for you. The data returned from the pipeline will be refreshed each time its run (ie every day).
Typically, if you wanted to run a screen every month then schedule a function to run every month (see https://www.quantopian.com/help#sample-schedule-function). Within that function you can access the context.output dataframe which has all your data. It will be current as of that day of the backtest and have the data as it would have looked on that day back in history (the backtester is designed to eliminate look ahead bias). Technically the pipeline will be running every day and fetching data which you won't be using. You could code some logic to only run the pipeline on certain days but I wouldn't worry about it unless your backtest runs very slow.
To actually run the backtest just enter the start and end date in the backtest screen (see https://www.quantopian.com/help#backtests). The backtest engine works in conjunction with the pipeline definition to get the correct data as of the backtest date.
Hope that makes sense.