Hi there,
If creating a universe from components of one ETF is straightforward:
class SMHConstituentsUniverseSelectionModel(ETFConstituentsUniverseSelectionModel):
def __init__(self, universe_settings: UniverseSettings = None) -> None:
symbol = Symbol.create("SMH", SecurityType.EQUITY, Market.USA)
super().__init__(symbol, universe_settings, lambda constituents: [c.symbol for c in constituents])
How to create a universe based on 2 ETF or more ?
Thanks in advance
Mia Alissi
To create a universe based on two or more ETFs, you can use the
ManualUniverseSelectionModel
and pass in the symbols of the ETFs you want to include in your universe. Here's an example of how you can do this:In this example, replace "ETF1" and "ETF2" with the tickers of the ETFs you want to include in your universe. You can add as many ETFs as you want to the
symbols
list.Please note that this will create a universe of the ETFs themselves, not their constituents. If you want to create a universe of the constituents of multiple ETFs, you would need to create multiple
ETFConstituentsUniverseSelectionModel
instances, one for each ETF. However, this might not be straightforward as theAddUniverseSelection
method might not support adding multiple universe selection models of the same type.For more information, you can refer to the QuantConnect documentation on Universe Selection.
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.
Sebastien M. Laignel
Thanks
Mia Alissi
You're welcome, Sebastien! If you have any more questions, feel free to ask. Happy coding!
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.
Sebastien M. Laignel
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!