I am looking for some help to better understand how to implement a rolling window with a universe of stocks that I am looking to trade. I have been able to get both (rolling window and universe) of them to work individually but I feel that I am missing something to get them to work together. Is there any documentation or videos that are able that could better explain how this can be done?
Louis Szeto
Hi Chad
I would suggest your create a dictionary in your backtest algo class, and a class SymbolData to store the rolling window for each selected symbol. So when OnSecuritiesChanged method you can create a dict key of the symbol and value as the SymbolClass object which contains rolling window to use, yet you would still need to call history data at the rolling window creation to fill up the empty window.
Simple example:
Cheers
Louis
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.
Chad Bett
Thanks Louis,
I will give it a try and see how I make out with building a dictionary in my backtest.
Would I access the data the same I do now (eg. self.Bars[0].Close) ?
Chad
Louis Szeto
Hi Chad
Nope, self.Bars would only be accessible in SymbolData class. In OnData method in youralgo class, you would call self.Data[symbol].Bars[0].Close. In the above example, since the dictionary value has been called as a variable, you can call symbolData.Bars[0].Close in the line that I hashtaged # your actions
Cheers
Louis
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.
Chad Bett
Thanks again Louis,
I will try and get it to work.
Chad
Chad Bett
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!