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.