hi everyone,
I want to use the QC500 Universe and filter further by using first fundamental data (ROIC) and then a momentum indicator. So far I found
https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/ConstituentsQC500GeneratorAlgorithm.py
self.AddUniverse(self.Universe.Index.QC500)
and
self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)
But how can I use them in together and filter the qc universe even further? thanks for your help :)
Rahul Chowdhury
Hey FoolishObserver,
We can filter the QC500 universe by first setting the QC500UniverseSelectionModel to our universe. Then we can sort and filter the resulting securities by ROIC and MOM. This is possible because QC500 implements fine universe selection, meaning FineFundamental data is available for our securities through their respective Security objects.
Knowing this, we can create a SecurityData class which will hold our security data and indicators for each symbol. Then in OnData we can sort and filter by those properties.
Alternatively you could also inherit the QC500UniverseSelectionModel in a new UniverseSelection model and override the SelectFine method.
class MyQC500(QC500UniverseSelectionModel): def SelectFine(self, algorithm, fine): symbols = super().SelectFine(algorithm, fine) if symbols == Universe.Unchanged: return Universe.Unchanged # add logic to reduce the universe # symbols = ... retuns symbols
Lukas Malik
Awesome thank you Rahul for the very clear explanation and the code, this helps a lot! :)
Lukas Malik
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!