One of the green notifications I get during my backtest is:
'Data for symbol XYZ has been limited due to numerical precision issues in the factor file. The starting date has been set to 11/4/2008.'
Now, looking ahead I want like 10 years of history or whatever and sometimes an asset will have a starting date of like 2013. In which case the backtest today in 2021 will only pull 8 years. But if this algorithm is doing well and 2023 comes around I still want the previous 10 years. So is there a dynamic way to pull the maximum amount of history so I can use a max() function to pull 10 years or the max amount of years available?
All of this is irrelevant if the current feature where the starting date gets automatically set is memory effecient. If its already stable and doesn't cost much then I don't need to fix what isn't broken. I just want to start trimming ineffeciencies where I can.
Derek Melchin
Hi Stephen,
The start date of a security is not yet available in the backtesting environment. Although, it's listed in the data library.
To get the maximum amount of data available (up to a max of 10 years), we can use
years = 10 symbol = self.AddEquity("SPY", Resolution.Minute).Symbol history = self.History(symbol, years*252, Resolution.Daily).iloc[:years*252]
See the attached backtest for reference.
Best,
Derek Melchin
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.
Stephen Hyer
Thank you, Derek. I understand I can pass an arbitraritly large history call. My concern is this:
For examle, say an asset was recently IPO 4 years ago. If I call a 10 year history, will that cause a memory inefficiency?
If yes, then I believe I can gain from finding a way to extract the exact amount of history that exists for that asset, up to my desired call. If it isn't an inefficiency then there's no concern.
Derek Melchin
Hi Stephen,
Thanks for clarifying. It's not inefficient to request data that exceeds the start date of history for a security.
Best,
Derek Melchin
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.
Stephen Hyer
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!