Skip to content
PharosAbad edited this page Mar 11, 2023 · 17 revisions

Welcome to the EfficientFrontier.jl wiki!

Let $N$ be the number of assets, and $\mathbf{z}$ be the portfolio weights vector. Given the mean vector $\boldsymbol{\mu}\in\mathbb{R}^{N}$ and variance matrix $\mathbf{V}\in\mathbb{R}^{N\times N}$. EfficientFrontier.jl solves the following problem: FP(L)

$$ \begin{array} [c]{cl} \min & \frac{1}{2}\mathbf{z}^{\prime}\mathbf{Vz}-L\mathbf{z}^{\prime}\boldsymbol{\mu}\\ s.t. & \mathbf{Az}=\mathbf{b}\in\mathbb{R}^{M}\\ & \mathbf{Gz}\leq\mathbf{g}\in\mathbb{R}^{J}\\ & \boldsymbol{d}\leq\mathbf{z}\leq\boldsymbol{u}\in\mathbb{R}^{N} \end{array} $$

Since $L$ is sort of trade-off coefficient between return (mean $\mu=\mathbf{z}^{\prime}\boldsymbol{\mu}$) and risk (variance $v=\mathbf{z}^{\prime}\mathbf{Vz}$): $$\frac{\mathrm{d}v}{\mathrm{d}\mu}=2L$$ ${\textcolor{blue}{ Varying\ L\ from\ +\infty\ to\ 0}}$, the entire Efficient Frontier is traced out.

Given an optimal solution $\mathbf{z}$, let $\mathsf{D}$ and $\mathsf{U}$ be the subset of all asset indices $\mathsf{N}=\{1,2,\cdots,N\}$ where the weights lie on one of their downside and upside bounds, respectively. Then $\mathsf{D}=\{i\in\mathsf{N}:z_{i}=d_{i}\}$ and $\mathsf{U}=\{i\in\mathsf{N}:z_{i}=u_{i}\}$. Let $\mathsf{B}=\mathsf{D}\cup\mathsf{U}$ be the assets on the boundary, and $\mathsf{I}=\mathsf{N}\setminus\mathsf{B} =\{i\in\mathsf{N}:d_{i} < z_{i} < u_{i}\}$ be all assets' indices where weights are not on bounds. For convenience, we indicate the assets in $\mathsf{D}$, $\mathsf{U}$, and $\mathsf{I}$ by DN, UP and IN, respectively.

Remark: Noting that $\mathbf{Az}=\mathbf{b}$ does include $\mathbf{z}^{\prime}\mathbf{1}=1$ (and must be the first equality constraint), but NOT include $\mathbf{z}^{\prime}\boldsymbol{\mu}=\mu$. For $\mu=\mu_{o}+qL$ and $q\ge 0$, $\mu$ is determined by $L$.

FP(L) and FP(mu)

We calculate the entire efficient frontier, not just a single frontier portfolio. For an efficient portfolio (single point) with mean $\mu$ and variance $v$, the model is (move the term $\mathbf{z}^{\prime}\boldsymbol{\mu}$ from the objective function to the constrains) FP(mu)

$$ \begin{array} [c]{cl} \min & \frac{1}{2}\mathbf{z}^{\prime}\mathbf{Vz}\\ s.t. & \mathbf{Az}=\mathbf{b}\in\mathbb{R}^{M}\\ & \mathbf{z}^{\prime}\boldsymbol{\mu}=\mu\\ & \mathbf{Gz}\leq\mathbf{g}\in\mathbb{R}^{J}\\ & \boldsymbol{d}\leq\mathbf{z}\leq\boldsymbol{u}\in\mathbb{R}^{N} \end{array} $$

Varying $\mu$ results in parabola segments in the $\mu-v$ plane. On each segment $v=a_{2}\mu^{2}+a_{1}\mu+a_{0}$, there is

$$L=a_{2}(\mu-\mu_{o})$$

where $a_{2} \geq 0$ and $\frac{\mathrm{d}v(\mu_{o})}{\mathrm{d}\mu}=0$. As $a_{1}=-2a_{2}\mu_{o}$ , if $a_{2}=0$, then $a_{1}=0$, the current segment of efficient frontier has only one point. There is a kink (a point at which the slope $\frac{\mathrm{d}v}{\mathrm{d}\mu}$ of the frontier is discontinuous) in the frontier.

Remark: the frontier is on the $\mu-v$ space in $\mathbb{R}^{2}$. The weight of a portfolio, $\mathbf{z}$, is in $\mathbb{R}^{N}$. Even when $a_{2}=0$, such that the frontier segment is a singular point, the Critical Line in $\mathbb{R}^{N+M+1}$ is still a line! And the Efficient Critical Line segments usually have $0 \leq L_0 < L < L_1$, hence we see a kink ( $2L_1 = \frac{\mathrm{d}v(\mu^{+})}{\mathrm{d}\mu} > \frac{\mathrm{d}v(\mu^{-})}{\mathrm{d}\mu}=2L_0$ ) in the frontier. There is a single-valued function $\mathbf{z}=f(\mu)$, not $\mathbf{z}=f(L)$, due to kinks.

The relationship between L version FP(L) and mu version FP(mu)

$$ \mathrm{FP}(\mathrm{mu}=\mu)=\mathrm{FP}(\mathrm{L}=a_{2}(\mu-\mu_{o})) $$

and

$$ \mathrm{FP}(\mathrm{L}=L)=\mathrm{FP}(\mathrm{mu}=\frac{L}{a_{2}}+\mu_{o}) $$

EfficientFrontier.jl using analytical solutions, hence provides the same results. However, when using numerical solvers, such as Clarabel, OSQP, OOQP or its pure Julia implementation LightenQP, L versions do have faster speed, better numerical stability and accuracy, due to fewer constrains.

Clone this wiki locally