Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Insufficient stock history for specified backtest timeframe

If performing a backtest on several stocks, and one or two of those stocks do not have sufficient history to look back, say 5 years, what results in backtester?

For instance, if i specify past 5 years for backtest and include Facebook as one of the stocks, what is the logic for the backtester to manage this? Does it throw an error? Does it run the algo on only the 1 or 2 years of data?

How can i check a basket of stocks (prior to running a backtest) if they have sufficient data history, for a timeperiod i specify?

1 response

Hello Adam,

Run this algo from 01-JAN-2012:

def initialize(context):  
    context.facebook = sid(42950)

def handle_data(context, data):  
    record(FB=data[context.facebook].close_price)  

You should see the algo start data auto amended to the FB first day of trade data 19-MAY-2012 and highlighted in blue. Click on the blue start date and get 'More Info'. Turn off date checking, reset the start date to 01-JAN-2012 and run. You will see the price plot start in May.

If you want to trade multiple securities with date checking off you will need to check for current trade data. See attached backtest which is a terrible example really.

P