Given a time series of a set of N assets (let's say 100), how can I find the optimal portfolio, with the constraint that only n<N assets (let's say 10) can be in the portfolio? With 'optimal portfolio' I mean the 'efficient portfolio' (so minimum variance for a given return, or maximum return for a given variance). Within the modern portfolio theory framework one can find the weights for all the N assets, but what if I want n<N assets only?

  • $\begingroup$ I believe this is a difficult problem, mathematically speaking. And trying all possible subsets of assets would be very slow. But I am not aware of a more clever method. $\endgroup$
    – nbbo2
    Jun 5, 2021 at 20:32
  • $\begingroup$ I think you need an integer programming formulation to do that. Search for some related threads because I wrote something a month or so ago when someone asked a pretty similar question. Unfortunately, I don't remember what the title of the question. I'll check if it's in my users answers list ? $\endgroup$
    – mark leeds
    Jun 6, 2021 at 2:20
  • $\begingroup$ I found it. It's not exactly the same question and it didn't get a check ( it got a 1 but i'm not sure what that means ). but it makes sense to me. I think you could use the same idea with your question. quant.stackexchange.com/questions/64047/… $\endgroup$
    – mark leeds
    Jun 6, 2021 at 2:23
  • 2
    $\begingroup$ Besides @markleeds Ansatz, you could try LASSO methods with a decreasing penalty parameter until a sufficient number of investment-optimal sets with exactly $n$ has been produced. $\endgroup$ Jun 6, 2021 at 5:12
  • $\begingroup$ Do you have more details/references where LASSO method was used? $\endgroup$ Jun 8, 2021 at 18:27

1 Answer 1


This is generally considered a hard problem to solve because it is an example of a Mixed Integer Non-Linear Programming problem, and would typically require access to a commercial optimisation routine to solve. The problem requires the addition of N variables ($v_i, i=1,N$) to the general Markowitz optimization problem. $v_i$ can take the value 0 or 1 depending on whether an asset is included in the final portfolio. Each asset has modified variable bounds $= l_iv_i < x_i < u_iv_i$, and we have a final constraint on the number of total variables $\Sigma_i v_i <= n$.

Mathworks shows some of the theoretical background at https://uk.mathworks.com/help/optim/ug/mixed-integer-quadratic-programming-portfolio-optimization-solver-based.html. MATLAB's solution requires multiple calls to a Mixed Integer Linear Programming routine.

People have also solved this using more ad-hoc methods in the past (genetic algorithms, simple heuristics). So, for example, one can optimise with the full N assets, remove the smallest position, and repeat until there are only n assets left. This approach is not guaranteed to be optimal but may be practically workable. In particular, when you consider that there is significant estimation error on the tracking error, any further improvement to a truly optimal solution may not be worthwhile.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.