Hi,
Below you can find the backtest and code from the 7th part of my algorithmic trading video series. Simply click the "Clone Algorithm" button to copy the code and play around with it yourself.
If you're new to the series, you can get an overview of all the videos here.
Let me know if you have any questions or comments.
Cheers,
Louis
Mitch Christow
Hi Louis,
Thanks a lot for the amazing video series. I have a question on this chapter. Could you explain why you set up the SPY with a minute resolution in
while the consolidator that you created has a daily resolution?
Are you doing this so that you have minute data for SPY, but you want to add the minute data only once a day to the consolidator? If you used Resolution.Minute for the consolidator, would that mean that the customeBarHandler is called every minute? I assume if that is the case, you would still have the same results (2 one-minute bars in the rollingWindow) but you just call the custombarhandler every minute which is wasteful. Is that the right way to think about this? Thanks for your help.
Cheers,
Mitch
Louis
Hi Mitch,
Thanks for the question. I just used this as an example for how you can consolidate data to another resolution. Since we want the bot to open and close trades intraday, we need a resolution lower than daily (e.g. minutely), but to identify the gap up or down, we don't need to save all the minutely bars. Instead, we just need the closing price in daily resolution which is why I went with daily resolution here. I hope this makes sense. Otherwise, let me know.
Louis Szeto
Hi Mitch
The method CustomBarHandler will only be called once a bar is consolidated (EndTime), in this case, 09:31:00 since it is the next Slice data received not for the previous consolidated bar. So it would only be adding the consolidated tradebar (daily resolution one) into the self.rollingWindow once a day. By using Resolution.Minute, we can
but an equal or lower frequency (e.g. daily) is applicable to indicators.
Best
Louis Szeto
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.
Mitch Christow
Thank you both for your replies and the explanations you have provided.Â
Chad Castanheiro
Hi, I'm going through this video and QuantConnect keeps giving me this error. I can't find any documentation that shows me a different way to do this. Can someone point me in the right direction. Even the current documentation shows this implementation of RollingWindow.Â
During the algorithm initialization, the following exception has occurred: cannot instantiate an open generic type
  at Initialize
    self.rw = RollingWindow(TradeBars)[2]
              ^^^^^^^^^^^^^^^^^^^^^^^^
Ashutosh
Hey Chad CastanheiroÂ
You need to use:
Attached backtest for reference.
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.
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.
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!