Open fstuelzebach opened 1 year ago
Hi @fstulle,
That kind of stuff is not currently supported, as it requires an additional and complex constraint. I could give you a single line of code for this constraint, but I cannot guarantee the results, so I won’t do that here.
However, I believe this feature (min and/or max number of assets) would be useful for others, especially for practitioners. I’d like to include it in our next version. I hope this will be useful for you and others.
Any update on this? thanks.
In addition to min/max number of assets, it would be great to be able state which ones must be included in the result (which must be < nmax). For example we may want at least 3 assets in our portfolio, but we always want to have GOOGL included.
What are you trying to do? I am optimizing via the pypfopt.efficient_frontier.EfficientCVaR (mainly with efficient_risk() / efficient_return())
I was wondering how one could implement a min. or max. limit regarding the number of assets which the optimized portfolio should hold (as another restriction - like atleast 10 stocks or not more than 30 for example).
In my case efficient_risk() with ratio = 0.2 for example leads to very clumped portfolios for example and even for efficient_return() at ratios between 0.06 und 0.15 out of 52 assets it for example only considers 8 at best.
I am relatively new to python and could really use some help :)
If such a feature already exists i truly am sorry for bringing it up. Thanks in advance for the feedback and of course for the amazing module!
What data are you using? I am using mainly stocks and optimizing the CVaR for a potential list of >50 assets.