Portfolio optimization (source code)

= Portfolio optimization
{title2=$\min_w w^T\Sigma w$}

<Portfolio optimization> chooses asset allocations to optimize an objective under specified constraints. In a one-period <mean-variance optimization> model, the return <vector> $R$ has mean $\mu$ and <covariance matrix> $\Sigma$. Portfolio weights $w$ give expected return $\mu^Tw$ and return <variance> $w^T\Sigma w$. A standard problem is
$$
\min_w w^T\Sigma w\quad\text{subject to}\quad\mathbf1^Tw=1,\quad\mu^Tw\ge r_*,\quad w_i\ge0.
$$
The constraints describe a fully invested portfolio, a target expected return and no short selling. Different assumptions produce different optimization problems. <Harry Markowitz> made the dependence on covariance and the tradeoff between mean and variance central to portfolio selection.<Portfolio Selection by Harry Markowitz>[1952, printed pages 80–82: weighted returns, covariance, budget and efficient portfolios]{ref}

For two uncorrelated assets with expected returns $4\%$ and $8\%$, each with standard deviation $20\%$, a weight $w$ in the first gives variance $0.04(w^2+(1-w)^2)$. Its unconstrained minimum is at $w=1/2$, yielding mean $6\%$ and standard deviation $\sqrt{0.02}\simeq14.14\%$. A target of at least $7\%$ instead requires $w\le1/4$, making the constrained minimum $w=1/4$. The same covariance matrix therefore gives a different solution when the objective's feasible set changes.

Estimated means and covariances are model inputs, rather than known future outcomes. Sampling uncertainty, transaction costs and additional allocation restrictions can materially change the resulting weights.