Here's the example I found on Github showing how to use weekly data. It shows that the weekly data is not ready at the beginning.
self.Consolidate("SPY", Calendar.Weekly, self.CalendarTradeBarHandler)
self.weekly_window = RollingWindow[TradeBar](3)
def CalendarTradeBarHandler(self, tradeBar):
self.Debug(f'{self.Time} :: {tradeBar.Time} {tradeBar.High}')
if self.weekly_window.isReady:
self.Debug("Ready " + str(self.weekly_window[1].High))
And in the documentation, you use the History data to warm up
spy = self.AddEquity("SPY", Resolution.Daily).Symbol
history_trade_bar = self.History[TradeBar](spy, 10, Resolution.Daily)
I tried replacing Resolution.Daily to Calendar.Weekly or Resolution.Weekly but it doesn't compile. Is there any API I can use to warmup the self.weekly_window please? Thank you.
Louis Szeto
Hi William
You could use a consolidator to do so (doc, if you need a history → doc), and use the consolidator handler to handle any trading logic around the aggregated weekly bar.
Best
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.
Philip Cody Pardi
are you setting your backtest's date range to include the week of data you want to use to warm up?
i found that in order to get a 30 day SMA, i had to set my backtest's start date to a month prior to when i wanted to actually test in order to have the SMA ready by that day.
Louis Szeto
Hi Philip
If you use historical data to warm it up, it does not need earlier start date
Best
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.
Williamtong3190
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!