Hi Team,
I recently looked into the portfolio construction through universes. I am very impressed by this work, but I would like to add an additional constraint to the MinimumVariancePortfolioOptimizer. I would like to enforce that if I have a universe of N securities, I only select up to M securities. For example, if I have a universe of size 10, I might pick the 3 that yield me with the lowest mean variance. I am a bit stumped as to how to approach this. Can anyone help me through this?
Thank you,
Jec
Fred Painchaud
Hi Jec,
Well. You would need an indicator for variance. There's one in QC: Variance.
So you need one of those per asset. You update it with Close, most likely, well, if you want variance on price.
And then, every time you are rebalancing, you sort assets from lowest current variance to highest and you take the first M ones (like 3 in your example) which you keep and you liquidate the N-M others (7 in your example).
MinimumVariancePortfolioOptimizer does something else. It minimized your overall portfolio variance, not per asset. I am not sure right off the bat I would start with that class as a starting point…
This is all high level but hope it still helps. Maybe someone else already implemented it and will share. Or you can start some code and we help along. Or I may end up coding it, I've done it in the past, but right now, I can't.
Fred
Jec The Jackal
Hi Fred,
Thank you for your suggestions. You spurred an idea I recall from a statistics course I took in college. When dealing with a model with many variables, we removed parameters one by one using a given metric. In my class it was multi-colinearility, but in this case I could start with my full basket and remove the security with the lowest weight and repeat the optimization until I am at the desired portfolio size.
Thanks,
Jec
Fred Painchaud
I now better see what you wanted to do 😊. You wanted the optimal selection of say 3 assets out of 10. I'm not 100% sure (it is not trivial) but yes, I believe the optimal selection could have that “compositional property”, i.e., you have assets 1, 2, 3 and 4, you remove the lowest weight one, say 3, then you repeat with 1, 2 and 4, you remove the lowest again, say 2, you end up with 1 and 4. 1 and 4 needs to be better than, say, 1 and 3 (like if you had removed 2 instead of 3 the first time and when you optimize with 1, 3 and 4, you end up with removing 4 the second time and end up with a better result overall)………………………………………….
Fred
Jec The Jackal
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!