I feel a bit confused reading through the documentation of indicator and consolidators. On consolidator page it says “consolidators with indicators” but in the code example it doesn't seem to have a consolidator. While on indicator page there is a more complex code snippet with explicit consolidator.
In API document it looks like there is built-in consolidator in RegisterIndicator().
Does it mean the following two snippets have same effect on creating a 10 SMA of 7min bars (consolidated from minutely bars), while the 2nd snippets has some redundancy in using explicit consolidator rather than the built-in consolidator in RegisterIndicator?
self.AddEquity("SPY", Resolution.Minute)
self.sma = SimpleMovingAverage(10)
self.RegisterIndicator("SPY", self.sma, timedelta(minutes=7))
self.AddEquity("SPY", Resolution.Minute)
self.sma = SimpleMovingAverage(10)
sevenMinuteConsolidator = TradeBarConsolidator(timedelta(minutes=7))
self.SubscriptionManager.AddConsolidator("SPY", sevenMinuteConsolidator)
self.RegisterIndicator("SPY", self.sma, sevenMinuteConsolidator)
Thanks
Varad Kabade
Hi Ruming Jiang,
Both methods to register the indicator are correct. If we register the indicator with a Resolution or a timedelta, a consolidator is created internally. So creating explicit consolidators comes in handy when we have multiple indicators and we wish to perform further operations on the consolidated bar.
Best,
Varad Kabade
Ruming Jiang
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!