Skip to content
All library documents

Optimizing a Portfolio with a Limit on the Number of Assets

Article Quant Q&A · Author: randomwalker

Summary

The document describes how to formulate mean-variance portfolio selection when the portfolio may hold at most a specified number of assets from a larger universe. It introduces a binary inclusion variable for each asset, links that variable to the asset’s allowed weight bounds, and constrains the total number selected. This turns the problem into mixed-integer nonlinear optimization, which is generally difficult and may require specialized commercial solvers.

As a simpler alternative, the document suggests repeatedly optimizing across all assets and removing the smallest position until the desired portfolio size is reached. It also mentions genetic algorithms and other heuristics. These approaches can be workable in practice but do not guarantee the globally optimal portfolio. The discussion emphasizes that estimated tracking error is uncertain, so the practical benefit of finding a mathematically better solution may be small relative to estimation error.

Key ideas

  • A maximum asset count can be modeled with binary variables indicating whether each asset is included.
  • Weight bounds can be linked to inclusion variables so excluded assets receive zero weight.
  • The resulting problem is a mixed-integer nonlinear optimization task that can be difficult to solve.
  • Iteratively removing the smallest position is a heuristic, not a guarantee of optimality.
  • Estimation error in tracking risk can limit the value of pursuing a more exact solution.

Tags

Full text
# Optimal portfolio with only n assets (with n less than total assets)


# Optimal portfolio with only n assets (with n less than total assets)












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?

## Answer by Tim Wilding (score 1)

https://quant.stackexchange.com/a/65463

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.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.