Hi all,
I would like to perform some anchored backtesting.
This is something that tradestation and amibroker do, and consist on using in calculations all the historical data before the trade instant, not just a fixed historical window .
It is very useful and realistic, since it is natural to use all available data to train a model, and in principle the more data is used the better the model should be.
When requesting historical data, how can this be achieved? Is there any example?
Thanks
Mia Alissi
In QuantConnect, you can use the
History
method to access historical data. This method returns a pandas DataFrame indexed by time and symbol. You can use this data to train your model. Here is an example of how you can use theHistory
method:In this example,
self.symbols
is a list of symbols you are interested in,30
is the number of days of historical data you want to retrieve, andResolution.Daily
specifies that you want daily data.Remember that in QuantConnect, the algorithm can only access information up to the current time in the backtest, similar to live trading. This is to prevent look-ahead bias, which is when you use information from the future to make decisions in the past.
For more information on how to use historical data in QuantConnect, you can refer to the Understanding Time page in the documentation.
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.
Johnny Cash
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!