Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Is there a way to prevent performance from being calculated while my algorithm is gathering two yrs of stats prior to first trade?

I am running an algo that gathers about two years of data before it starts trading (and from then on uses a rolling two year window going forward). I'm mainly using Zipline right now, but porting back to quantopian API soon.
As is, it seems that the performance stats (e.g. the benchmark cumulative return) are running for two years before I make a trade. Is there some way to set a specific date for that data collection to begin?
I can tweak it myself in most cases - there's got to be a better way, but I don't see it in the doc.

TIA

2 responses

Hmmm ... don't all talk at once! Here's a clue (i think) from zipline tradesimulation.py:

See the comment and code right above the ETC:

class AlgorithmSimulator(object):  
    def __init__(self, algo, sim_params):  
      ...  
      self.algo_start = normalize_date(self.sim_params.first_open)  
      ...  
    def transform(self, stream_in):  
        """  
        Main generator work loop.  
        """  
        ...  
        # inject the current algo  
        # snapshot time to any log record generated.  
        with ExitStack() as stack:  
            ...  
            for date, snapshot in stream_in:  
                self.simulation_dt = date  
                self.on_dt_changed(date)  
                # If we're still in the warmup period.  Use the event to  
                # update our universe, but don't yield any perf messages,  
                # and don't send a snapshot to handle_data.  
                if date < self.algo_start:  
                ....  
                ETC  

Duh.
Create a day counter.
Initialize to zero , increment daily before trading.
When it equals 1 on the first day, perform initialization to backfill historical outputs.