This README describes a realistic active portfolio optimization problem formulated as a convex quadratic program (QP). The goal is to build a portfolio that tracks a benchmark closely while earning at least 60 bps of expected active return (alpha), and respecting simple diversification rules.
You manage a portfolio of 5 assets against a benchmark. Let:
- 
$w \in \mathbb{R}^5$ be the portfolio weights (decision variables),
- 
$b \in \mathbb{R}^5$ be the benchmark weights (given),
- 
$\alpha \in \mathbb{R}^5$ be the expected active returns (alphas),
- 
$\Sigma \in \mathbb{R}^{5 \times 5}$ be the return covariance matrix.
The optimization minimizes tracking error variance 
Assets: Tech, Health, Industrials, Utilities, Consumer
Benchmark weights (
- Tech: $0.30$ , Health:$0.20$ , Industrials:$0.20$ , Utilities:$0.10$ , Consumer:$0.20$ 
Expected active returns (alphas, 
- Tech: $0.012$ , Health:$0.006$ , Industrials:$0.004$ , Utilities:$-0.001$ , Consumer:$0.005$ 
Volatilities (annual stdev, 
- Tech: $0.25$ , Health:$0.18$ , Industrials:$0.20$ , Utilities:$0.12$ , Consumer:$0.16$ 
Correlations (
| Tech | Health | Ind | Util | Cons | |
|---|---|---|---|---|---|
| Tech | 1.00 | 0.60 | 0.50 | 0.20 | 0.40 | 
| Health | 0.60 | 1.00 | 0.40 | 0.20 | 0.30 | 
| Ind | 0.50 | 0.40 | 1.00 | 0.20 | 0.30 | 
| Util | 0.20 | 0.20 | 0.20 | 1.00 | 0.10 | 
| Cons | 0.40 | 0.30 | 0.30 | 0.10 | 1.00 | 
Covariance (
- Portfolio weights $w_a$ for each asset$a \in {\text{Tech, Health, Ind, Util, Cons}}$ .
- 
Box bounds: $0 \le w_a \le 0.50$ .
Minimize tracking error variance: $$ \min_{w} (w-b)^{\top} \Sigma (w-b) $$
(Note: tracking error stdev is $\sqrt{(w-b)^\top \Sigma (w-b)}$; minimizing variance is equivalent and keeps the problem quadratic.)
- 
Expected active return target (alpha): $$ \sum_{a} \alpha_a,(w_a - b_a) \ge 0.006 $$ 
- 
Fully invested: $$ \sum_{a} w_a = 1 $$ 
- 
Box bounds: $$ 0 \le w_a \le 0.50 \quad \forall a $$ 
- 
Cyclicals cap: $$ w_{\mathrm{Tech}} + w_{\mathrm{Ind}} + w_{\mathrm{Cons}} \le 0.75 $$ 
- 
Defensives floor: $$ w_{\mathrm{Health}} + w_{\mathrm{Util}} \ge 0.20 $$ 
- The objective $(w-b)^\top \Sigma (w-b)$ is quadratic and convex because$\Sigma$ is a covariance matrix (positive semidefinite).
- All constraints are linear.
- There are no integer variables.
- 
$w$ : portfolio weights (decision vector).
- 
$b$ : benchmark weights (given).
- 
$\alpha$ : expected active returns (per asset) — i.e., expected excess return vs. the benchmark.
- 
$\Sigma$ : covariance matrix computed from volatilities and correlations.
- Tracking error variance: $(w-b)^\top \Sigma (w-b)$ .
- 
Frontier: sweep the target active return level, e.g. $0$ to$0.02$ , to trace a TE–alpha efficient frontier.
- 
Absolute return version: replace the alpha constraint with a target on total expected return, $\sum_a \mu_a w_a \ge R_{\text{target}}$ (requires expected returns$\mu$ ).
- 
Tracking error budget: maximize $\alpha^\top (w-b)$ subject to$(w-b)^\top \Sigma (w-b) \le \tau^2$ .