I am testing a strategy that holds certain ETNs, but when I run a backtest the price data for these only seems to start in 2018.
Is there a way to query what date ranges are available for a particular symbol's historical data - perhaps something nicer than just running a backtest over a range and seeing when the data first becomes available?
Mia Alissi
Yes, you can check the availability of historical data for a particular symbol by using the
History
method in QuantConnect. However, there isn't a built-in function to directly query the date range of a symbol's historical data.Here is an example of how you can use the
History
method to get historical data for a particular symbol:In this example,
history
will be a pandas DataFrame containing the historical data for the symbol "SPY" from January 1, 2008, to January 1, 2018. If there is no data available for a particular date within this range, it will not be included in the DataFrame.If you want to find out the earliest date for which data is available, you could potentially request a large date range and then check the first date in the returned DataFrame. However, this could be inefficient if the date range is very large.
Please note that the availability of historical data can vary depending on the asset type and market. For example, QuantConnect provides US equities data from 1998, but futures data might not be available that far back. You can check the data library for more information on what data is available.
Also, keep in mind that some symbols might have limitations due to numerical precision issues in the factor file, which could limit the available data to a certain date range. If this is the case, you will see a warning message in your algorithm logs.
Sources:
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Hari Limaye
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!