How to achieve that? My existing universe selection:
def _select_universe_legacy(self, fundamentals):
"""Select US30 constituents"""
if not fundamentals:
return []
selected = [f for f in fundamentals
if f.HasFundamentalData
and f.MarketCap > 0
and f.SecurityReference.ExchangeId in ("NAS", "NAQ")]
selected = sorted(selected, key=lambda f: f.MarketCap, reverse=True)[:100]
self.universe_symbols = set(f.Symbol for f in selected)
return list(self.universe_symbols)
I tried to ask mia, but it either gave me either a History call that is incredibly imperformant, or other answers like some OnData hooks that didn't filter anything out
Mia Alissi
Here’s how to modernize your universe selection using Coarse + Fine selection functions, making your code more efficient and fully compatible with QuantConnect's recommended universe model:
Usage:
self.add_universe(self._select_universe_legacy)call with this new setup.OnData.self._universe_symbolsfor any further logic.Let me know if you want further refinements or portfolio logic integration!
Sources: Coarse Fine Fundamental Combo Algorithm, Coarse Fundamental Top3 Algorithm, Legacy Fundamental Universes - QuantConnect.com, Coarse Fine Fundamental Regression Algorithm, Legacy Fundamental Universes - QuantConnect.com
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.
Linkus
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!