Skip to content
All library documents

Cardinality Constraints for Portfolio Optimization with Binary Variables

Article Quant Q&A · Author: JSS

Summary

The document explains how to limit the number of assets selected by a linear portfolio optimizer. The motivating case has a large monthly universe, limited trading capacity, and an objective that maximizes the sum of each asset’s score multiplied by its portfolio weight.

It formulates the selection limit as a mixed-integer linear program. A binary variable marks whether each asset is included; upper and lower bounds on its weight force that weight to zero when the asset is excluded. Summing the binary variables and constraining the total to the maximum permitted count enforces portfolio cardinality. The answer names optimization packages that can solve this problem, but gives no performance comparison or discussion of computational scaling. The formulation also depends on sensible weight bounds, and the stated objective and constraints do not address transaction costs, turnover, or other portfolio requirements.

Key ideas

  • Binary decision variables can indicate whether each asset is selected.
  • Weight bounds linked to each binary variable force excluded assets to have zero weight.
  • A constraint on the sum of selection variables imposes a maximum portfolio size.
  • The resulting cardinality-constrained optimization is a mixed-integer linear program.
  • The formulation does not by itself account for transaction costs or turnover.

Tags

Full text
# Portfolio Optimization with maximum number of Trades constraint


# Portfolio Optimization with maximum number of Trades constraint












i am currently running linear optimization and maximizing summation of (weight*score) for each assets.

I am running it on assets that are difficult to trade and the universe is easily about 2000 of them every month. My firm has capacity to trade only about 100 of them..

How do i introduce a max number of trade constraints for the assets ? I am thinking of introducing binary variables to indicate whether to trade for each assets but i am not sure how to link it back to the original objective function

Regards James

## Answer by RRG (score 2, accepted)

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

This is a class of problems called Mixed-Integer Linear Programming (MILP). You can link the limit on the number of assets (cardinality) back to the objective function through boundary constraints on your weights.

Let $w_i$ be the weights and $s_i$ the scores. Let $w_i^{max}$ and $w_i^{min}$ be the maximum and minimum allowed weight for asset $i$. Introduce the variables $z_i\in{0,1}$ to indicate whether asset $i$ is in the portfolio, and let $K$ be the maximum number of assets in the portfolio.

The maximization objective is $$max(w_i) \sum_i w_is_i$$ under the weight constraint $$ z_iw_i^{min}\leq w_i \leq z_iw_i^{max}$$ and the cardinality constraint $$ \sum_i z_i \leq K$$ The weight constraint guarantees that $w_i$ is zero when $z_i$ is zero. There are several numerical packages available to solve this class of optimizations, for example CVXOPT in Python or intlinprog in Matlab.

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.