Modern Portfolio Theory and Mean-Variance Optimization › Multi-Asset Portfolio Optimization

Michael BrenndoerferDecember 13, 20257 min read
Quantitative FinanceAll chapters
Part 9 of 15Portfolio Theory and Investment Analysis
Chapter 46Modern Portfolio Theory and Mean-Variance Optimization › Multi-Asset Portfolio Optimization
Reading section 4 of 12 · Multi-Asset Portfolio Optimization · 7 minSection 4 of 12 · 7 min

Book contents

Section 4 of 12 · 7 min read

Modern Portfolio Theory and Mean-Variance Optimization › Multi-Asset Portfolio OptimizationOne section · Sections in this chapter4 / 12 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

With more than two assets, we need the full matrix formulation. The principles remain the same, but the algebra becomes more complex, requiring linear algebra tools to express and solve the optimization problem efficiently. Let w\mathbf{w} be the n×1n \times 1 vector of weights, μ\boldsymbol{\mu} the n×1n \times 1 vector of expected returns, and Σ\Sigma the n×nn \times n covariance matrix.

The optimization problem has two related formulations, each emphasizing a different perspective on the objective:

Formulation 1: Minimize risk for a target return

This formulation starts with a desired level of expected return and asks: what is the least risky way to achieve it?

min⁡w12w⊤Σwsubject tow⊤μ=μtargetw⊤1=1\begin{aligned} \min_{\mathbf{w}} \quad & \frac{1}{2}\mathbf{w}^\top \Sigma \mathbf{w} \\ \text{subject to} \quad & \mathbf{w}^\top \boldsymbol{\mu} = \mu_{\text{target}} \\ & \mathbf{w}^\top \mathbf{1} = 1 \end{aligned}

where:

  • w\mathbf{w}: vector of portfolio weights
  • Σ\Sigma: covariance matrix of asset returns
  • μ\boldsymbol{\mu}: vector of expected returns
  • μtarget\mu_{\text{target}}: required level of expected return
  • 1\mathbf{1}: vector of ones (sum constraint)

The factor of 12\frac{1}{2} in the objective is a mathematical convenience that simplifies the derivatives. It does not change the optimal solution because multiplying an objective by a positive constant does not alter which portfolio minimizes it.

Formulation 2: Maximize utility (mean-variance utility)

This formulation takes a different approach, directly modeling investor preferences through a utility function that trades off return against risk:

max⁡ww⊤μ−γ2w⊤Σwsubject tow⊤1=1\begin{aligned} \max_{\mathbf{w}} \quad & \mathbf{w}^\top \boldsymbol{\mu} - \frac{\gamma}{2}\mathbf{w}^\top \Sigma \mathbf{w} \\ \text{subject to} \quad & \mathbf{w}^\top \mathbf{1} = 1 \end{aligned}

where:

  • γ\gamma: risk aversion parameter (γ>0\gamma > 0)
  • w\mathbf{w}: vector of portfolio weights
  • μ\boldsymbol{\mu}: vector of expected returns
  • Σ\Sigma: covariance matrix of asset returns
  • 1\mathbf{1}: vector of ones

The parameter γ\gamma captures how much you dislike risk. If you are highly risk-averse (large γ\gamma), you penalize variance heavily and will choose a conservative, low-volatility portfolio. If you are risk-tolerant (small γ\gamma), you care more about expected return and will accept higher volatility to chase higher gains. The target-return formulation traces the minimum-variance frontier, including its inefficient lower branch. For targets above the GMV return, its solutions also maximize mean-variance utility for a corresponding γ>0\gamma>0. Varying positive γ\gamma traces the efficient upper branch and approaches the GMV portfolio as γ\gamma tends to infinity.

Analytical Solution: Lagrangian Approach

For the target-return closed forms below, assume that Σ\Sigma is positive definite and that μ\boldsymbol{\mu} is not proportional to 1\mathbf{1}. These conditions make Σ\Sigma invertible and AC−B2>0AC-B^2>0. If the covariance matrix is singular, the inverse formulas do not apply as written; the constrained system must be treated directly.

For the first formulation, we form the Lagrangian using the techniques from Part I. Its equality multipliers are free variables, not fixed penalties. With differentiable functions and linearly independent constraint gradients, a constrained optimum satisfies stationarity together with the original constraints. We solve that system rather than minimize jointly over weights and multipliers:

L=12w⊤Σw−λ1(w⊤μ−μtarget)−λ2(w⊤1−1)\mathcal{L} = \frac{1}{2}\mathbf{w}^\top \Sigma \mathbf{w} - \lambda_1(\mathbf{w}^\top \boldsymbol{\mu} - \mu_{\text{target}}) - \lambda_2(\mathbf{w}^\top \mathbf{1} - 1)

where:

  • L\mathcal{L}: the Lagrangian function
  • w\mathbf{w}: vector of portfolio weights
  • Σ\Sigma: covariance matrix of asset returns
  • λ1,λ2\lambda_1, \lambda_2: Lagrange multipliers enforcing the return and budget constraints
  • μ\boldsymbol{\mu}: vector of expected returns
  • μtarget\mu_{\text{target}}: target portfolio return
  • 1\mathbf{1}: vector of ones

When the optimal value varies differentiably with a constraint's right-hand side, the multiplier gives its signed local rate of change. With the sign convention used here, ∂V/∂μtarget=λ1\partial V/\partial\mu_{\text{target}}=\lambda_1 for the optimal half-variance VV. A finite change is generally only approximated by this rate times the change. Taking the derivative with respect to w\mathbf{w} and setting it to zero:

∂L∂w=Σw−λ1μ−λ21=0\frac{\partial \mathcal{L}}{\partial \mathbf{w}} = \Sigma \mathbf{w} - \lambda_1 \boldsymbol{\mu} - \lambda_2 \mathbf{1} = 0

where:

  • Σ\Sigma: covariance matrix
  • w\mathbf{w}: vector of portfolio weights
  • λ1,λ2\lambda_1, \lambda_2: Lagrange multipliers
  • μ\boldsymbol{\mu}: vector of expected returns
  • 1\mathbf{1}: vector of ones

This first-order condition states that at the optimum, the marginal increase in risk from adjusting any weight must be exactly offset by the value of that weight in meeting the return and budget constraints. Rearranging terms to solve for w\mathbf{w} explicitly:

Σw=λ1μ+λ21(isolate Σw)w=Σ−1(λ1μ+λ21)(pre-multiply by Σ−1)=λ1Σ−1μ+λ2Σ−11(distribute)\begin{aligned} \Sigma \mathbf{w} &= \lambda_1 \boldsymbol{\mu} + \lambda_2 \mathbf{1} && \text{(isolate } \Sigma \mathbf{w} \text{)} \\ \mathbf{w} &= \Sigma^{-1}(\lambda_1 \boldsymbol{\mu} + \lambda_2 \mathbf{1}) && \text{(pre-multiply by } \Sigma^{-1} \text{)} \\ &= \lambda_1 \Sigma^{-1} \boldsymbol{\mu} + \lambda_2 \Sigma^{-1} \mathbf{1} && \text{(distribute)} \end{aligned}

where:

  • w\mathbf{w}: optimal portfolio weight vector
  • Σ−1\Sigma^{-1}: inverse of the covariance matrix
  • μ\boldsymbol{\mu}: vector of expected returns
  • 1\mathbf{1}: vector of ones
  • λ1,λ2\lambda_1, \lambda_2: Lagrange multipliers

The vector Σ−1μ\Sigma^{-1}\boldsymbol{\mu} is a covariance-adjusted return direction, while Σ−11\Sigma^{-1}\mathbf{1} is proportional to the GMV portfolio. Their coefficients and normalization matter: both terms jointly satisfy the target-return and budget constraints, and λ1\lambda_1 can be negative on the lower branch.

The Lagrange multipliers λ1\lambda_1 and λ2\lambda_2 are determined by the constraints. Substituting back:

μtarget=λ1μ⊤Σ−1μ+λ2μ⊤Σ−111=λ11⊤Σ−1μ+λ21⊤Σ−11\begin{aligned} \mu_{\text{target}} &= \lambda_1 \boldsymbol{\mu}^\top \Sigma^{-1} \boldsymbol{\mu} + \lambda_2 \boldsymbol{\mu}^\top \Sigma^{-1} \mathbf{1} \\ 1 &= \lambda_1 \mathbf{1}^\top \Sigma^{-1} \boldsymbol{\mu} + \lambda_2 \mathbf{1}^\top \Sigma^{-1} \mathbf{1} \end{aligned}

where:

  • μtarget\mu_{\text{target}}: target return
  • λ1,λ2\lambda_1, \lambda_2: Lagrange multipliers
  • μ\boldsymbol{\mu}: vector of expected returns
  • Σ−1\Sigma^{-1}: inverse covariance matrix
  • 1\mathbf{1}: vector of ones

These two equations form a linear system in the two unknowns λ1\lambda_1 and λ2\lambda_2. We can solve for λ1\lambda_1 and λ2\lambda_2 in terms of scalar constants derived from the problem parameters:

λ1=Cμtarget−BAC−B2,λ2=A−BμtargetAC−B2\lambda_1 = \frac{C\mu_{\text{target}} - B}{AC - B^2}, \quad \lambda_2 = \frac{A - B\mu_{\text{target}}}{AC - B^2}

where:

  • A=μ⊤Σ−1μA = \boldsymbol{\mu}^\top \Sigma^{-1} \boldsymbol{\mu}
  • B=μ⊤Σ−11=1⊤Σ−1μB = \boldsymbol{\mu}^\top \Sigma^{-1} \mathbf{1} = \mathbf{1}^\top \Sigma^{-1} \boldsymbol{\mu}
  • C=1⊤Σ−11C = \mathbf{1}^\top \Sigma^{-1} \mathbf{1}
  • μtarget\mu_{\text{target}}: target portfolio return

The constants AA, BB, and CC depend only on the assets' expected returns and covariance structure, not on the target return. This means we can precompute them once and then quickly find optimal portfolios for any target return, making efficient frontier construction computationally efficient.

The Global Minimum Variance Portfolio

With positive-definite covariance, setting λ1=0\lambda_1 = 0 (ignoring the return target) gives the global minimum variance (GMV) portfolio. This formula does not require distinct expected returns:

wGMV=Σ−111⊤Σ−11\mathbf{w}_{\text{GMV}} = \frac{\Sigma^{-1} \mathbf{1}}{\mathbf{1}^\top \Sigma^{-1} \mathbf{1}}

where:

  • wGMV\mathbf{w}_{\text{GMV}}: weights of the global minimum variance portfolio
  • Σ−1\Sigma^{-1}: inverse of the covariance matrix
  • 1\mathbf{1}: vector of ones

This formula represents risk minimization in its most basic form. The term Σ−11\Sigma^{-1}\mathbf{1} identifies the portfolio structure that minimizes variance without regard for expected returns, while the denominator normalizes the weights to sum to one. Each weight depends on the full covariance matrix through Σ−11\Sigma^{-1}\mathbf{1}; lower standalone variance or lower correlations do not by themselves guarantee a higher weight. With short selling allowed, some GMV weights can be negative.

This portfolio minimizes variance within the stated asset universe subject to the budget constraint. If variance alone is the objective, it is optimal regardless of expected return. A short investment horizon does not by itself imply that objective; cash needs, liabilities, and available risk-free investments can also matter.

In[7]:
Code
import numpy as np


def global_minimum_variance_portfolio(cov_matrix):
    """
    Compute the global minimum variance portfolio weights.

    Parameters
    ----------
    cov_matrix : ndarray
        n x n positive-definite covariance matrix of asset returns

    Returns
    -------
    weights : ndarray
        One-dimensional array of optimal weights with shape (n,)
    """
    n = cov_matrix.shape[0]
    ones = np.ones(n)

    # Compute inverse covariance matrix
    cov_inv = np.linalg.inv(cov_matrix)

    # GMV weights: Σ⁻¹1 / (1'Σ⁻¹1)
    weights = cov_inv @ ones / (ones @ cov_inv @ ones)

    return weights