Hi,
I've been trying to find some example on using multiple universe selection models. With this code I want to invest 3% of my porfolio in the 10 biggest SWAN constituents and the rest in the 10 biggest stocks in NASDAQ by market cap, I'm having problems when trying to access the self.ETFConstituentsFilter(constituents) in the OnSecuritiesChanged method. I tryied asking MIA but she couldn't give me an answer.
Any help is appreciated.
Here's the project
Mia Alissi
Hmm, I don't know enough to give you a confident answer yet. However, I can provide some general guidance based on the information extracts.
In QuantConnect, you can use multiple universe selection models in your algorithm. You can add these universe selection models in the
Initialize
method of your algorithm. Here is an example of how to add an ETF constituents universe:In this example,
ETFConstituentsFilter
is a method that filters the constituents based on their weight:You can add another universe selection model in a similar way. Just make sure to define a separate filter method for it.
As for accessing
self.ETFConstituentsFilter(constituents)
in theOnSecuritiesChanged
method, it's not clear from the extracts what the specific issue is. However,OnSecuritiesChanged
is typically used to handle events when securities are added or removed from your universe. You might want to use this method to update your portfolio allocations when your universe changes.For more detailed guidance, I recommend checking out the QuantConnect documentation and tutorials. You can also ask for help in the QuantConnect forum.
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.
Pavel Fedorov
Renata you should attach the code
Ashutosh
Hi Renata While reviewing your problem statement, I've devised a simple blueprint.
It's essential to highlight that SWAN holdings consist predominantly of government notes, comprising 90%. This poses a challenge as these constituents are not stocks, making them incompatible with the platform.SWAN had some stock holdings during the 2019 period for a very short time.
The problem statement handles multiple ETF/Universes. Each universe has to be handled individually to get the top 10 tickers as per the desired filtration. Attached is the backtest with SPY and QQQ where SPY gets 3% of the portfolio and QQQ gets the remaining. I have used a simple and basic logic for creating positions and rebalancing. You can tweak these logics accordingly.
Looking forward to your feedback and ideas!
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.
Renata
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!