Hi
I know consolidator and scheduler work on specific time frames, but I suppose I have a Alpha Model which works on consolidator data not on OnData.
Alpha signal works well When I use Resolution.Minute but when I consolidate it still works on Resolution.Minute not with consolidator data.
can you suggest how can I pass consolidator data in Alpha Model.
Thank you !
Mia Alissi
Sure, I can help with that. To use consolidated data in your Alpha Model, you need to create a consolidator within your Alpha Model class. This is similar to how you usually create consolidators, but this time, some of the methods will be called on the
algorithm
parameter instead ofself
.Here is a simple example of how you can do this in Python:
In this example,
OnSecuritiesChanged
is called when securities are added or removed from the universe. If a consolidator already exists, it is removed. Then a new consolidator is created for the added security. TheOnDataConsolidated
method is where you handle the consolidated data.Remember to remove the consolidator when the security is removed from the universe. This can be done in the
OnSecuritiesChanged
method.Please note that the Alpha's
Update
method will still be called with the minute data. If you want to use the consolidated data within theUpdate
method, you could store the consolidated bars in aRollingWindow
and access thisRollingWindow
inside theUpdate
method^1^^3^^5^^7^^9^[^11^][^12^][^13^][^14^][^15^][^16^][^17^][^18^][^19^][^20^][^21^][^22^][^23^][^24^][^25^].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.
Sukhvinder Pal Singh
Hi@mia-ai I got this error
20240830 12:48:54.373 ERROR:: Runtime Error: simpleAlphaModel.OnDataConsolidated() missing 1 required positional argument: 'bar'simpleAlphaModel.OnDataConsolidated() missing 1 required positional argument: 'bar'
Louis Szeto
Hi
Please make sure you have include all 3 arguments in the definition of the consolidator handler.
BestLouis
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.
Sukhvinder Pal Singh
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!