Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Error: DataWindowStartsBeforeMinDate
# Import Pipeline class and USEquityPricing dataset  
from quantopian.pipeline import Pipeline  
from quantopian.pipeline.data import USEquityPricing  
from quantopian.pipeline.experimental import QTradableStocksUS  
from quantopian.research import run_pipeline

def make_pipeline():  
    close_price = USEquityPricing.close.latest  
    return Pipeline(  
        columns={  
            'close_price': close_price,  
        },  
        screen =  QTradableStocksUS()  
    )

pipeline_output = run_pipeline(  
    make_pipeline(),  
    start_date='2002-01-03',  
    end_date='2019-07-01'  
)

When attempting to run the code above, I'm getting a DataWindowStartsBeforeMinDate error shown below. The Requested data window doesn't match the inputted start_date='2002-01-03. The error disappears when screen = QTradableStocksUS() is commented and works as expected. Using the screen the code begins to work around '2002-10-. Curious to learn what is causing this error?

DataWindowStartsBeforeMinDate: Requested data window starting on 2001-03-14 00:00:00+00:00 extends before minimum available date 2002-01-02 00:00:00+00:00.  

Thanks in advance

2 responses

The error is basically saying 'no can do because you are requesting data earlier than Quantopian's earliest available date of 2002-01-02'.
The start date is explicitly set to 2002-01-03 so, without screen = QTradableStocksUS(), there isn't an error. However, by adding the screen, the start date is implicitly backed up 200 trading days (to 2001-03-14). Why is this?

Two of the requirements to be in the QTradableStocksUS universe are:

  • The stock must have a 200-day median daily dollar volume that exceeds $2.5 Million USD.
  • The stock must have a valid close price for 180 days out of last 200 days AND have price in each of the last 20 days.

Behind the scenes, these requirements instruct pipeline to fetch data 200 days earlier than the defined start date of 2002-01-03. Therefore, when this filter is applied, it tries to fetch data from 2001-03-14 which is earlier than the earliest available data which causes an error.

Note this behavior isn't unique to the QTradableStocksUS filter. Anytime one defines a filter or factor with a window length greater than 1, pipeline automatically adjusts the dates and fetches the required data needed to get results on the explicitly defined start date. The benefit of doing this is no 'warm up' time. This usually goes undetected behind the scenes but does become an issue (as highlighted in this instance) when running queries near the 2002-01-03 date. Also note, this same behavior impacts backtesting algos in the IDE. There one doesn't explicitly set the start date for running a pipeline, but rather it's set as the simulation date of the backtester. A similar error would be generated when backtesting using QTradableStocksUS filter and starting on 2002-01-03.

For more specifics on all the requirements to be in the QTradableStocksUS universe check the help docs (https://www.quantopian.com/help#built-in-filters).

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Excellent, thank you very much for your response Dan! That makes sense.