Unless specific geographical region requirements apply, the base URL of Portfolio Optimizer is: https://api.portfoliooptimizer.io/.

The current version number of Portfolio Optimizer is v1.

Portfolio Optimizer can be used:

Let be:

• $n$, the number of assets
• $T$, the number of time periods
• $P_{t,i} \in \mathbb{R}^{+,*}$, the price of the asset $i$ at the time $t$, $i=1..n$, $t=1..T$

The arithmetic return $R_{t,t+1,i}$ of the asset $i$, $i=1..n$, from the time $t$ to the time $t+1$, $t=1..T-1$, is defined as $$R_{t,t+1,i} = \frac{P_{t+1,i} - P_{t,i}}{P_{t,i}}$$

Let be:

• $n$, the number of assets
• $C \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets correlation matrix
• $\sigma_1,...,\sigma_n$, the assets volatilities
• $\sigma_1^2,...,\sigma_n^2$, the assets variances

The covariance matrix $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$ of the $n$ assets is defined by: $$\Sigma_{i,j} = \sigma_i \sigma_j C_{i,j}, i=1..n, j=1..n$$

Let $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$ be a matrix.

$\Sigma$ is a covariance matrix of $n$ assets if and only if:

• $\Sigma$ is symmetric, i.e. $\Sigma {}^t = \Sigma$
• $\Sigma$ is positive semi-definite, i.e. $x {}^t \Sigma x \geqslant 0, \forall x \in\mathbb{R}^n$

Let be:

• $n$, the number of assets
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $\sigma_1,...,\sigma_n$, the assets volatilities

The assets correlation matrix $C \in \mathcal{M}(\mathbb{R}^{n \times n})$ is defined by: $$C_{i,j} = \frac{\Sigma_{i,j}}{\sigma_i \sigma_j}, i=1..n, j=1..n$$

Let $C \in \mathcal{M}(\mathbb{R}^{n \times n})$ be a matrix.

$C$ is a correlation matrix of $n$ assets if and only if:

• $C$ is symmetric, i.e. $C {}^t = C$
• $C$ is unit diagonal, i.e. $C_{i,i} = 1, i=1..n$
• $C$ is positive semi-definite, i.e. $x {}^t C x \geqslant 0, \forall x \in\mathbb{R}^n$

Let $n$ be the number of assets and $A \in \mathcal{M} \left( \mathbb{R}^{n \times n} \right)$ be an approximate assets correlation matrix (i.e., a matrix with no specific requirements)

Let be:

• $\delta \in [0,1]$
• $S_n^\delta = \{ X \in \mathcal{M} \left( \mathbb{R}^{n \times n} \right)$ such that $X {}^t = X$ and $\lambda_{min}(X) \geq \delta \}$
• $\mathcal{N}$ the optional (so, possibly empty) index set of the fixed off-diagonal elements of the approximate correlation matrix $A$
• $\mathcal{E}_n = \{ X \in \mathcal{M} \left( \mathbb{R}^{n \times n} \right)$ such that $X {}^t = X$ and $x_{ii} = 1, i = 1,...,n$ and $x_{ij}=a_{ij}$ for $(i,j) \in \mathcal{N} \}$

The nearest correlation matrix $C$ to the matrix $A$ is the solution of the problem: $$C = \operatorname{argmin} \left\Vert X - A \right\Vert_F \text{ s.t. } X \in S_n^\delta \cap \mathcal{E}_n$$

Notes:

• The algorithm used internally to solve the optimization problem above is an alternating projection algorithm, similar to the algorithm described in the reference, with $\delta$ taken of order $10^{-4}$ to ensure that the computed correlation matrix $C$ is positive definite.
• If the set $\mathcal{N}$ is not empty, the optimization problem above might not have any solution, which will typically manifest by a response time out of the endpoint.

Let be:

• $n$, the number of assets
• $T$, the number of time periods
• $P_{t,i} \in \mathbb{R}^{+,*}$, the price of the asset $i$ at the time $t$, $i=1..n$, $t=1..T$

• $n_p$, the number of portfolios to simulate
• $w_{p} \in [0,1]^{n}$, the vector of the initial portfolio weights of the $p$-th portfolio to simulate, $p=1..n_p$, with $\sum_{i=1}^{n} w_{p,i} = 1$
• $V_{t, p} \in \mathbb{R}^{+,*}$, the value of the $p$-th portfolio to simulate at the time $t$, $p=1..n_p$, $t=1..T$

Then, for $p=1..n_p$ and $t=1..T$ : $$V_{t, p} = V_{1, p} \sum_{i=1}^{n} w_{p,i} \frac{P_{t,i}}{P_{1,i}}$$

Notes:

• By convention, $V_{1, p} = 100, p = 1..n_p$

Let be:

• $n$, the number of assets
• $T$, the number of time periods
• $P_{t,i} \in \mathbb{R}^{+,*}$, the price of the asset $i$ at the time $t$, $i=1..n$, $t=1..T$

• $n_p$, the number of portfolios to simulate
• $w_{p} \in [0,1]^{n}$, the vector of the fixed portfolio weights of the $p$-th portfolio to simulate, $p=1..n_p$, with $\sum_{i=1}^{n} w_{p,i} = 1$
• $V_{t, p} \in \mathbb{R}^{+,*}$, the value of the $p$-th portfolio to simulate at the time $t$, $p=1..n_p$, $t=1..T$

Then, for $p=1..n_p$ and $t=2..T$ : $$V_{t, p} = V_{t-1, p} \sum_{i=1}^{n} w_{p,i} \frac{P_{t,i}}{P_{t-1,i}}$$

Notes:

• By convention, $V_{1, p} = 100, p = 1..n_p$

Let be:

• $n$, the number of assets
• $T$, the number of time periods
• $P_{t,i} \in \mathbb{R}^{+,*}$, the price of the asset $i$ at the time $t$, $i=1..n$, $t=1..T$

• $n_p$, the number of portfolios to simulate
• $V_{t, p} \in \mathbb{R}^{+,*}$, the value of the $p$-th portfolio to simulate at the time $t$, $p=1..n_p$, $t=1..T$

Then, for $p=1..n_p$ and $t=2..T$: $$V_{t, p} = V_{t-1, p} \sum_{i=1}^{n} w_{t-1,p,i} \frac{P_{t,i}}{P_{t-1,i}}$$

with $w_{t, p} \in [0,1]^{n}$ the vector of the $p$-th portfolio weights at the time $t$, $p=1..n_p$, $t=1..T$, generated at random and satisfying: $$\begin{cases} 0 \leqslant w_{t,p,i} \leqslant 1, i = 1..n \newline \sum_{i=1}^{n} w_{t,p,i} = 1 \end{cases}$$

Notes:

• By convention, $V_{1, p} = 100, p = 1..n_p$

Let be:

• $n$, the number of assets
• $\mu \in \mathbb{R}^{n}$, the vector of the assets arithmetic returns
• $n_p$, the number of portfolios
• $w_p \in [0,1]^{n}$, the vector of portfolio weights of the $p$-th portfolio, $p=1..n_p$

The arithmetic return of the $p$-th portfolio, $p=1..n_p$, is defined as: $$\mu {}^t w_p$$

Alternatively, let be:

• $n$, the number of assets
• $n_p$, the number of portfolios
• $T_p$, the number of time periods of the $p$-th portfolio, $p=1..n_p$
• $V_{t, p} \in \mathbb{R}^{+,*}$, the value of the $p$-th portfolio at the time $t$, $p=1..n_p$, $t=1..T_p$

The arithmetic return of the $p$-th portfolio, $p=1..n_p$, is defined as:$$\frac{V_{T_p,p} - V_{1,p}}{V_{1,p}}$$

Let be:

• $n$, the number of assets
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $n_p$, the number of portfolios
• $w_p \in [0,1]^{n}$, the vector of portfolio weights of the $p$-th portfolio, $p=1..n_p$

The volatility of the $p$-th portfolio, $p=1..n_p$, is defined as: $$\sqrt{ w_p {}^t \Sigma w_p}$$

Alternatively, let be:

• $n_p$, the number of portfolios
• $T_p$, the number of time periods of the $p$-th portfolio, $p=1..n_p$
• $r_p = (r_{p,1},...,r_{p,T_p-1}) \in \mathbb{R}^{T_p-1}$, the arithmetic returns of the portfolio $p$ associated to the $T_p$ time periods, $p=1..n_p$

The volatility of the $p$-th portfolio, $p=1..n_p$, is defined as the standard deviation of the arithmetic returns $r_p$: $$\sqrt{\frac{\sum_{t=1}^{T_p-1} (r_{p,t} - \overline{r_p}) }{T_p-1}}$$

Let be:

• $n$, the number of assets
• $\mu \in \mathbb{R}^{n}$, the vector of the assets arithmetic returns
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $r_f \in \mathbb{R}$, the value of the risk free rate
• $n_p$, the number of portfolios
• $w_p \in [0,1]^{n}$, the vector of portfolio weights of the $p$-th portfolio, $p=1..n_p$

The Sharpe ratio of the $p$-th portfolio, $p=1..n_p$, is defined as: $$\frac{ \mu{}^t w_p - r_f}{\sqrt{ w_p {}^t \Sigma w_p }}$$

Alternatively, let be:

• $r_f \in \mathbb{R}$, the value of the risk free rate
• $n_p$, the number of portfolios
• $T_p$, the number of time periods of the $p$-th portfolio, $p=1..n_p$
• $V_{t, p} \in \mathbb{R}^{+,*}$, the value of the $p$-th portfolio at the time $t$, $p=1..n_p$, $t=1..T_p$
• $\mu_p$, the arithmetic return of the $p$-th portfolio, $p=1..n_p$
• $\sigma_p$, the volatility of the $p$-th portfolio, $p=1..n_p$

The Sharpe ratio of the $p$-th portfolio, $p=1..n_p$, is defined as: $$\frac{\mu_p - r_f}{\sigma_p}$$

Let be:

• $n$, the number of assets
• $\sigma = (\sigma_1,...,\sigma_n)$ the vector of the assets volatilities
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $n_p$, the number of portfolios
• $w_p \in [0,1]^{n}$, the vector of portfolio weights of the $p$-th portfolio, $p=1..n_p$

The Diversification ratio of the $p$-th portfolio $p=1..n_p$, is defined as: $$\frac{ \sigma{}^t w_p}{\sqrt{ w_p {}^t \Sigma w_p }}$$

Let be:

• $n$, the number of assets
• $\mu \in \mathbb{R}^{n}$, the vector of the assets arithmetic returns
• $n_p$, the number of portfolios
• $w_p \in [0,1]^{n}$, the vector of portfolio weights of the $p$-th portfolio, $p=1..n_p$

The return contribution of the $i$-th asset to the return of the $p$-th portfolio, $i=1..n$ and $p=1..n_p$, is defined as: $$w_{p,i} \mu_i$$

• $n_k$, the optional number of groups of assets
• $\mathcal{N}_1,...,\mathcal{N}_{n_k}$ the optional $n_k$ groups of assets

The return contribution of the group of assets $\mathcal{N}_k$ to the return of the $p$-th portfolio, $k=1..n_k$ and $p=1..n_p$, is defined as: $$\sum_{j \in \mathcal{N}_k} w_{p,j} \mu_j$$

Notes:

• Return contribution analysis is also known as absolute return attribution analysis, because there is no reference to a benchmark
• In contribution analysis, a group of assets is also known as a segment, and is usually made of assets sharing common characteristics such as the asset class, the country, the industrial sector, etc.

Let be:

• $n$, the number of assets
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $n_p$, the number of portfolios
• $w_p \in [0,1]^{n}$, the vector of portfolio weights of the $p$-th portfolio, $p=1..n_p$

The risk contribution of the $i$-th asset to the risk of the $p$-th portfolio, $i=1..n$ and $p=1..n_p$, is defined as: $$w_{p,i} \frac{(\Sigma w_p)_i}{\sqrt{w_p {}^t \Sigma w_p}}$$

• $n_k$, the optional number of groups of assets
• $\mathcal{N}_1,...,\mathcal{N}_{n_k}$ the optional $n_k$ groups of assets

The risk contribution of the group of assets $\mathcal{N}_k$ to the risk of the $p$-th portfolio, $k=1..n_k$ and $p=1..n_p$, is defined as: $$\sum_{j \in \mathcal{N}_k} w_{p,j} \frac{(\Sigma w_p)_j}{\sqrt{w_p {}^t \Sigma w_p}}$$

Notes:

• The risk is defined in terms of standard deviation of the returns (i.e., volatility)
• In contribution analysis, a group of assets is also known as a segment, and is usually made of assets sharing common characteristics such as the asset class, the country, the industrial sector, etc.

Let be:

• $n$, the number of assets
• $\mu \in \mathbb{R}^{n}$, the vector of the assets arithmetic returns
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints
• $w_{min} \in [0,1]$, the optional minimum portfolio exposure
• $w_{max} \in [0,1]$, the optional maximal portfolio exposure
• $k$, the optional number of groups of assets
• $G \in \mathcal{M}(\mathbb{R}^{k \times n})$, the optional assets groups matrix defining $k$ group(s) of assets
• $u_g \in \mathbb{R}^{k}$, the optional maximum assets groups weights constraints

The continuous mean-variance efficient frontier is the (infinite) set of portfolios whose weights $w \in [0,1]^{n}$ satisfy: $$w = \operatorname{argmin} \frac{1}{2} w {}^t \Sigma w - \lambda \mu {}^t w \newline \textrm{s.t. } \begin{cases} l \leqslant w \leqslant u \newline Gw \leqslant u_g \newline w_{min} \leqslant \sum_{i=1}^{n} w_i \leqslant w_{max} \end{cases}$$ with $\lambda$ a parameter varying in $[0, +\infty[$.

• $n_p$, the number of portfolios to compute on the mean-variance efficient frontier

The discretized mean-variance efficient frontier is the (finite) set of $n_p$ portfolios belonging to the continuous mean-variance efficient frontier with equally spaced arithmetic returns.

Notes:

• The parameter $1/\lambda$ is usually called the risk aversion parameter
• When no group weights constraints are present, and if numerically possible, the algorithm used internally to solve the linearly constrained quadratic optimization problem above is the Critical Line Method from Harry_Markowitz

Let be:

• $n$, the number of assets
• $\mu \in \mathbb{R}^{n}$, the vector of the assets arithmetic returns
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints
• $w_{min} \in [0,1]$, the optional minimum portfolio exposure
• $w_{max} \in [0,1]$, the optional maximal portfolio exposure
• $k$, the optional number of groups of assets
• $G \in \mathcal{M}(\mathbb{R}^{k \times n})$, the optional assets groups matrix defining $k$ group(s) of assets
• $u_g \in \mathbb{R}^{k}$, the optional maximum assets groups weights constraints

The continuous mean-variance minimum variance frontier is the (infinite) set of portfolios whose weights $w \in [0,1]^{n}$ satisfy: $$w = \operatorname{argmin} \frac{1}{2} w {}^t \Sigma w - \lambda \mu {}^t w \newline \textrm{s.t. } \begin{cases} l \leqslant w \leqslant u \newline Gw \leqslant u_g \newline w_{min} \leqslant \sum_{i=1}^{n} w_i \leqslant w_{max} \end{cases}$$ with $\lambda$ a parameter varying in $]-\infty, +\infty[$.

• $n_p$, the number of portfolios to compute on the mean-variance minimum variance frontier

The discretized mean-variance minimum variance frontier is the (finite) set of $n_p$ portfolios belonging to the continuous mean-variance minimum variance frontier with equally spaced arithmetic returns.

Notes:

• The parameter $1/\lambda$ is usually called the risk aversion parameter
• When no group weights constraints are present, and if numerically possible, the algorithm used internally to solve the linearly constrained quadratic optimization problem above is the Critical Line Method from Harry_Markowitz

Let be:

• $n$, the number of assets
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints
• $w_{min} \in [0,1]$, the optional minimum portfolio exposure
• $w_{max} \in [0,1]$, the optional maximal portfolio exposure

• $n_p$, the number of portfolios to construct

The $p$ vectors of portfolio weights $w_p \in [0,1]^{n}$, $p=1..n_p$, are generated at random and satisfy: $$\begin{cases} l \leqslant w_p \leqslant u \newline w_{min} \leqslant \sum_{i=1}^{n} w_{p,i} \leqslant w_{max} \end{cases}$$

Let be:

• $n$, the number of assets
• $T$, the number of time periods
• $X \in \mathcal{R}^{n \times T}$, the matrix of the assets returns
• $r_b \in \mathbb{R}^{T}$, the returns of the benchmark
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints
• $w_{min} \in [0,1]$, the optional minimum portfolio exposure
• $w_{max} \in [0,1]$, the optional maximal portfolio exposure
• $k$, the optional number of groups of assets
• $G \in \mathcal{M}(\mathbb{R}^{k \times n})$, the optional assets groups matrix defining $k$ group(s) of assets
• $u_g \in \mathbb{R}^{k}$, the optional maximum assets groups weights constraints

The mimicking portfolio weights $w \in [0,1]^{n}$ satisfy: $$w = \operatorname{argmin} \frac{1}{T} \lVert w {}^t X - r_b \rVert_2^2 \newline \textrm{s.t. } \begin{cases} l \leqslant w \leqslant u \newline Gw \leqslant u_g \newline w_{min} \leqslant \sum_{i=1}^{n} w_i \leqslant w_{max} \end{cases}$$

Notes:

• The performance measure that is being minimized above is called the empirical tracking error
• The statistical technique used to construct the mimicking portfolio is called returns-based style analysis

Let be:

• $n$, the number of assets

The equal-weighted portfolio weights $w \in [0,1]^{n}$ satisfy: $$w_i = \frac{1}{n}, i=1..n$$

Let be:

• $n$, the number of assets
• $\sigma_1^2,...,\sigma_n^2$, the assets variances

The inverse variance-weighted portfolio weights $w \in [0,1]^{n}$ satisfy: $$w_i = \frac{1/\sigma_i^2}{\sum_{j=1}^{n} 1/\sigma_j^2}, i=1..n$$

Let be:

• $n$, the number of assets
• $\sigma_1,...,\sigma_n$, the assets volatilities

The inverse volatility-weighted portfolio weights $w \in [0,1]^{n}$ satisfy: $$w_i = \frac{1/\sigma_i}{\sum_{j=1}^{n} 1/\sigma_j}, i=1..n$$

Let be:

• $n$, the number of assets
• $mktcap_1,...,mktcap_n$ the assets market capitalizations

The market capitalization-weighted portfolio weights $w \in [0,1]^{n}$ satisfy: $$w_i = \frac{mktcap_i}{\sum_{j=1}^{n} mktcap_j}, i=1..n$$

Let be:

• $n$, the number of assets
• $\mu \in \mathbb{R}^{n}$, the vector of the assets arithmetic returns
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $r_f \in \mathbb{R}$, the value of the risk free rate

The equal Sharpe ratio contributions portfolio weights $w \in [0,1]^{n}$ satisfy:

• $\forall i,j$ such that $\mu_i - r_f > 0$ and $\mu_j - r_f > 0$ $$w_i \frac{\mu_i - r_f}{\sqrt{ w {}^t \Sigma w}} = w_j \frac{\mu_j - r_f}{\sqrt{ w {}^t \Sigma w}}$$
• $\forall i$ such that $\mu_i - r_f \leq 0$ $$w_i = 0$$

Let be:

• $n$, the number of assets
• $\mu \in \mathbb{R}^{n}$, the vector of the assets arithmetic returns
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints
• $w_{min} \in [0,1]$, the optional minimum portfolio exposure
• $w_{max} \in [0,1]$, the optional maximal portfolio exposure
• $k$, the optional number of groups of assets
• $G \in \mathcal{M}(\mathbb{R}^{k \times n})$, the optional assets groups matrix defining $k$ group(s) of assets
• $u_g \in \mathbb{R}^{k}$, the optional maximum assets groups weights constraints

The maximum return portfolio weights $w \in [0,1]^{n}$ satisfy: $$w = \operatorname{argmax} w {}^t \mu \newline \textrm{s.t. } \begin{cases} l \leqslant w \leqslant u \newline Gw \leqslant u_g \newline w_{min} \leqslant \sum_{i=1}^{n} w_i \leqslant w_{max} \end{cases}$$

Notes:

• If some assets have identical returns, the maximum return portfolio will usually not be unique
• If some assets have identical returns, the maximum return portfolio will usually not be mean-variance efficient

To enforce mean-variance efficiency, the covariance matrix of the assets $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$ must be provided

Let be:

• $n$, the number of assets
• $\mu \in \mathbb{R}^{n}$, the vector of the assets arithmetic returns
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints
• $w_{min} \in [0,1]$, the optional minimum portfolio exposure
• $w_{max} \in [0,1]$, the optional maximal portfolio exposure
• $k$, the optional number of groups of assets
• $G \in \mathcal{M}(\mathbb{R}^{k \times n})$, the optional assets groups matrix defining $k$ group(s) of assets
• $u_g \in \mathbb{R}^{k}$, the optional maximum assets groups weights constraints

The minimum variance portfolio weights $w \in [0,1]^{n}$ satisfy: $$w = \operatorname{argmin} w {}^t \Sigma w \newline \textrm{s.t. } \begin{cases} l \leqslant w \leqslant u \newline Gw \leqslant u_g \newline w_{min} \leqslant \sum_{i=1}^{n} w_i \leqslant w_{max} \end{cases}$$

Notes:

• If the assets covariance matrix is not positive definite, the minimum variance portfolio will usually not be unique
• If the assets covariance matrix is not positive definite, the minimum variance portfolio will usually not be mean-variance efficient

To enforce mean-variance efficiency, the arithmetic returns of the assets $\mu \in \mathbb{R}^{n}$ must be provided

Let be:

• $n$, the number of assets
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints

The equal risk contributions portfolio weights $w \in [0,1]^{n}$ satisfy: $$w = \operatorname{argmin} \sqrt{ w {}^t \Sigma w} - \frac{\lambda}{n} \sum_{i=1}^{n} \ln(w_i) \newline \textrm{s.t. }l \leqslant w \leqslant u$$ with $\lambda \in \mathbb{R}^{+,*}$ a parameter to be determined such that $\sum_{i=1}^{n} w_i = 1$.

Notes:

• Such a $\lambda$ might not exist, in which case the optimization problem is not feasible and the vector $w$ is undefined
• The algorithm used internally to solve the optimization problem above is a cyclical coordinate descent algorithm, similar to the algorithm described in the reference

Let be:

• $n$, the number of assets
• $C \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets correlation matrix
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints
• $w_{min} \in [0,1]$, the optional minimum portfolio exposure
• $w_{max} \in [0,1]$, the optional maximal portfolio exposure
• $k$, the optional number of groups of assets
• $G \in \mathcal{M}(\mathbb{R}^{k \times n})$, the optional assets groups matrix defining $k$ group(s) of assets
• $u_g \in \mathbb{R}^{k}$, the optional maximum assets groups weights constraints

The maximum decorrelation portfolio weights $w \in [0,1]^{n}$ satisfy: $$w = \operatorname{argmax} 1 - w {}^t C w \newline \textrm{s.t. } \begin{cases} l \leqslant w \leqslant u \newline Gw \leqslant u_g \newline w_{min} \leqslant \sum_{i=1}^{n} w_i \leqslant w_{max} \end{cases}$$

Let be:

• $n$, the number of assets
• $\mu \in \mathbb{R}^{n}$, the vector of the assets arithmetic returns
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $r_f \in \mathbb{R}$, the value of the risk free rate
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints
• $w_{min} \in [0,1]$, the optional minimum portfolio exposure
• $w_{max} \in [0,1]$, the optional maximal portfolio exposure
• $k$, the optional number of groups of assets
• $G \in \mathcal{M}(\mathbb{R}^{k \times n})$, the optional assets groups matrix defining $k$ group(s) of assets
• $u_g \in \mathbb{R}^{k}$, the optional maximum assets groups weights constraints

The maximum Sharpe ratio portfolio weights $w \in [0,1]^{n}$ satisfy: $$w = \operatorname{argmax} \frac{w {}^t \mu - r_f }{\sqrt{ w {}^t \Sigma w}} \newline \textrm{s.t. } \begin{cases} l \leqslant w \leqslant u \newline Gw \leqslant u_g \newline w_{min} \leqslant \sum_{i=1}^{n} w_i \leqslant w_{max} \end{cases}$$

Notes:

• The value of the risk free rate $r_f$ is usually either taken as the interest rate on a riskless asset like cash or as the interest rate on borrowings
• The maximum Sharpe ratio portfolio is mean-variance efficient

Let be:

• $n$, the number of assets
• $C \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets correlation matrix
• $\sigma_1,...,\sigma_n$, the assets volatilities

The minimum correlation portfolio is a portfolio where the assets are weighted proportionally to their average correlation with each other.

In more details:

• The correlation matrix of the assets $C$ is converted to an adjusted correlation matrix $C'$ that does not have negative values, penalizing high correlation and rewarding low correlation
• The assets that act as portfolio diversifiers are then initially weighted more heavily than the others, using the adjusted correlation matrix $C'$
• The initial weights are then normalized by the assets inverse volatilities $1/\sigma_i, i=1..n$, to ensure that each asset contributes to the same level of portfolio risk

Let be:

• $n$, the number of assets
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints
• $w_{min} \in [0,1]$, the optional minimum portfolio exposure
• $w_{max} \in [0,1]$, the optional maximal portfolio exposure
• $k$, the optional number of groups of assets
• $G \in \mathcal{M}(\mathbb{R}^{k \times n})$, the optional assets groups matrix defining $k$ group(s) of assets
• $u_g \in \mathbb{R}^{k}$, the optional maximum assets groups weights constraints

The most diversified portfolio weights $w \in [0,1]^{n}$ satisfy: $$w = \operatorname{argmax} \frac{w {}^t \sigma }{\sqrt{ w {}^t \Sigma w}} \newline \textrm{s.t. } \begin{cases} l \leqslant w \leqslant u \newline Gw \leqslant u_g \newline w_{min} \leqslant \sum_{i=1}^{n} w_i \leqslant w_{max} \end{cases}$$

Let be:

• $n$, the number of assets
• $\mu \in \mathbb{R}^{n}$, the vector of the assets arithmetic returns
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints
• $w_{min} \in [0,1]$, the optional minimum portfolio exposure
• $w_{max} \in [0,1]$, the optional maximal portfolio exposure
• $k$, the optional number of groups of assets
• $G \in \mathcal{M}(\mathbb{R}^{k \times n})$, the optional assets groups matrix defining $k$ group(s) of assets
• $u_g \in \mathbb{R}^{k}$, the optional maximum assets groups weights constraints

A mean-variance efficient portfolio is a portfolio whose weights $w \in [0,1]^{n}$ satisfy: $$\exists \lambda \in [0, +\infty[, w = \operatorname{argmin} \frac{1}{2} w {}^t \Sigma w - \lambda \mu {}^t w \newline \textrm{s.t. } \begin{cases} l \leqslant w \leqslant u \newline Gw \leqslant u_g \newline w_{min} \leqslant \sum_{i=1}^{n} w_i \leqslant w_{max} \end{cases}$$

The parameter $\lambda$ is usually called the risk tolerance parameter, and is determined by an additional constraint on the portfolio:

• A return constraint $r_c$, in which case $\lambda$, if it exists, is determined such that the portfolio has a return equal to $r_c$
• A volatility constraint $v_c \geq 0$, in which case $\lambda$, if it exists, is determined such that the portfolio has a volatility equal to $v_c$
• A risk tolerance constraint $\lambda_c \geq 0$, in which case $\lambda$ always exist and is equal to $\lambda_c$

Notes:

• The parameter $1/\lambda$ is usually called the risk aversion parameter
• When no group weights constraints are present, and if numerically possible, the algorithm used internally to solve the linearly constrained quadratic optimization problem above is the Critical Line Method from Harry_Markowitz

Let be:

• $n$, the number of assets
• $w_t \in [0,1]^{n}$, the desired portfolio weights, with $\sum_{i=1}^{n} w_{t,i} = 1$
• $TV$, the desired portfolio monetary value
• $P_1,...,P_n$, the prices of the assets $1,...,n$
• $nl_1,...,nl_n$, the number of shares by which to purchase the assets $1,...,n$
• $ml_1,...,ml_n$, the minimum number of shares to purchase for the assets $1,...,n$
• $mv_1,...,mv_n$, the minimum monetary amount to purchase for the assets $1,...,n$

The investable portfolio weights $w \in [0,1]^{n}$ closest to the desired portfolio weights $w_t$ satisfy: $$w = \operatorname{argmin} \frac{1}{2} \lVert w - w_t \rVert_2^2 \newline \textrm{s.t. } \begin{cases} \sum_{i=1}^{n} w_i \leq 1 \newline w_i = \frac{k_i nl_i P_i}{TV}, k_i \in \mathbb{N}, i=1,...,n \newline k_i \neq 0 \implies k_i nl_i \geq ml_i, i=1,...,n \newline k_i \neq 0 \implies k_i nl_i P_i \geq mv_i, i=1,...,n \end{cases}$$

Unfortunately, the above optimization problem is computationally intractable due to the integer constraints, so that it is only possible to compute an approximate solution.

Notes:

• In case the desired portfolio weights $w_t$ do not satisfy $\sum_{i=1}^{n} w_{t,i} = 1$, the optimization problem above is reformulated to try to best accommodate the situation
• In case at least one group of assets is present, the investable portfolio weights $w \in [0,1]^{n}$ satisfy a more complex optimization problem than above, additionally involving:
• An assets groups matrix that identifies the membership of each asset within each assets group
• The desired portfolio groups weights
• The desired portfolio maximum groups weights
• In case at least one group of assets is present and the desired assets weights, assets groups weights and maximum assets groups weights are incompatible, the optimization problem above is reformulated to try to best accommodate the situation

Let be:

• $T$, the number of time periods
• $r_b = (r_{b,1},...,r_{b,T}) \in \mathbb{R}^{T}$, the returns of the benchmark
• $n_p$, the number of portfolios
• $r_p = (r_{p,1},...,r_{p,T}) \in \mathbb{R}^{T}$, the returns of the portfolio $p$, $p=1..n_p$

The tracking error of the $p$-th portfolio, $p=1..n_p$, is defined as the volatility of the difference of the returns of the portfolio and of the returns of the benchmark over the $T$ time periods: $$\sqrt{\frac{\sum_{t=1}^{T} (r_{b,t} - r_{p,t})^2 }{T}}$$

Notes:

• The tracking error is sometimes defined differently, for example as the absolute difference in returns between a portfolio and a benchmark.

The definition above corresponds to the most commonly used definition.

Let be:

• $m$, the number of factors
• $T$, the number of time periods
• $X \in \mathcal{R}^{m \times T}$, the matrix of the factors returns

The returns $R_{res, i} \in \mathcal{R}^{T}$ of the residualized factor $i \in {1..m}$ are defined as: $$R_{res, i} {}^t = X_i - \alpha - \beta {}^t X_{-i}$$ where:

• $X_i$ represents the row $i$ of the matrix $X$
• $X_{-i}$ represents the matrix $X$ after removing the row $i$
• $(\alpha, \beta)$ is the unique solution of minimum euclidean norm of the linear least squares problem $$\operatorname{argmin_{(\alpha \in \mathcal{R}, \beta \in \mathcal{R}^{m})}} \lVert X_i - \alpha - \beta {}^t X_{-i} \rVert_2^2$$

Let be:

• $m$, the number of factors
• $T$, the number of time periods
• $X \in \mathcal{R}^{m \times T}$, the matrix of the factors returns
• $n_p$, the number of portfolios
• $r_p = (r_{p,1},...,r_{p,T}) \in \mathbb{R}^{T}$, the returns of the portfolio $p$, $p=1..n_p$

The exposures $\beta_p \in \mathcal{R}^{m}$ of the $p$-th portfolio to the $m$ factors, $p=1..n_p$, are defined as the unique solution of minimum euclidean norm of the linear least squares problem: $$\operatorname{argmin_{(\alpha_p \in \mathcal{R}, \beta_p \in \mathcal{R}^{m})}} \lVert r_p {}^t - \alpha_p - \beta_p {}^t X \rVert_2^2$$

Notes:

• $\alpha_p$ represents the portion of the portfolio $p$ returns that cannot be attributed to the portfolio exposure to the $m$ factors
• $\beta_{p}$ represents the magnitude of the portfolio $p$ exposure to the $m$ factors

Let be:

• $T$, the number of time periods
• $r_b = (r_{b,1},...,r_{b,T}) \in \mathbb{R}^{T}$, the returns of the benchmark
• $r_f = (r_{f,1},...,r_{f,T})\in \mathbb{R}^{T}$, the risk free returns
• $n_p$, the number of portfolios
• $r_p = (r_{p,1},...,r_{p,T}) \in \mathbb{R}^{T}$, the returns of the portfolio $p$, $p=1..n_p$

The Jensen's alpha $\alpha_p \in \mathbb{R}$ of the $p$-th portfolio, $p=1..n_p$, is defined as the intercept of the regression equation in the Capital Asset Pricing Model: $$r_{p,t} - r_{f,t} = \alpha_p + \beta_p (r_{b,t} - r_{f,t}) + \epsilon_t$$, with $t=1..T$

Notes:

• The Jensen's alpha $\alpha_p$ of the $p$-th portfolio corresponds to the excess return of the $p$-th portfolio adjusted for its systematic risk.

Let be:

• $T$, the number of time periods
• $r_b = (r_{b,1},...,r_{b,T}) \in \mathbb{R}^{T}$, the returns of the benchmark
• $r_f = (r_{f,1},...,r_{f,T})\in \mathbb{R}^{T}$, the risk free returns
• $n_p$, the number of portfolios
• $r_p = (r_{p,1},...,r_{p,T}) \in \mathbb{R}^{T}$, the returns of the portfolio $p$, $p=1..n_p$

The beta $\beta_p \in \mathbb{R}$ of the $p$-th portfolio, $p=1..n_p$, is defined as the slope of the regression equation in the Capital Asset Pricing Model: $$r_{p,t} - r_{f,t} = \alpha_p + \beta_p (r_{b,t} - r_{f,t}) + \epsilon_t$$, with $t=1..T$

Notes:

• The beta $\beta_p$ of the $p$-th portfolio corresponds to the systematic risk of the $p$-th portfolio.

Let be:

• $n$, the number of assets
• $C \in \mathcal{M}(\mathbb{R}^{n \times n})$ the correlation matrix of $n$ assets
• $T \in \mathcal{M}(\mathbb{R}^{n \times n})$ a target correlation matrix
• $\lambda \in [0,1]$ a real number

The (linear) shrinkage of the matrix $C$ toward the matrix $T$ is done through the computation of the convex linear combination: $$S = (1-\lambda) C + \lambda T$$

Notes:

• The resulting matrix $S$ is a correlation matrix.
• The parameter $\lambda$ is usually called the shrinkage factor, or the shrinkage intensity, or the shrinkage constant.
• This endpoint provides 3 predefined target correlation matrices:
• The equicorrelation matrix made of 1, representing the maximum correlation matrix $$\begin{bmatrix} 1 & 1 & ... & 1 \\ 1 & 1 & ... & 1 \\ ... & ... & ... & ... \\ 1 & 1 & ... & 1 \end{bmatrix}$$
• The equicorrelation matrix made of 0, representing the minimum non-negative correlation matrix $$\begin{bmatrix} 1 & 0 & ... & 0 \\ 0 & 1 & ... & 0 \\ ... & ... & ... & ... \\ 0 & 0 & ... & 1 \end{bmatrix}$$
• The equicorrelation matrix made of $-\frac{1}{n-1}$, representing the minimum negative correlation matrix $$\begin{bmatrix} 1 & -\frac{1}{n-1} & ... & -\frac{1}{n-1} \\ -\frac{1}{n-1} & 1 & ... & -\frac{1}{n-1} \\ ... & ... & ... & ... \\ -\frac{1}{n-1} & -\frac{1}{n-1} & ... & 1 \end{bmatrix}$$

Let be:

• $n$, the number of assets
• $\Sigma \in \mathcal{M}(\mathbb{R}^{n \times n})$, the assets covariance matrix
• $l \in [0,1]^{n}$, the optional minimum assets weights constraints
• $u \in [0,1]^{n}$, the optional maximum assets weights constraints
• $w_{min} \in [0,1]$, the optional minimum portfolio exposure
• $w_{max} \in [0,1]$, the optional maximal portfolio exposure

The hierarchical risk parity portfolio is a portfolio blending graph theory and machine learning techniques where similar assets are first grouped together thanks to a hierarchical clustering algorithm and assets weights are then computed through a recursive top-down bisection of the resulting hierarchical tree.

Notes:

Let be:

• $n$, the number of assets

A random correlation matrix is a matrix $C \in \mathcal{M}(\mathbb{R}^{n \times n})$ generated uniformly at random over the space of positive definite correlation matrices, which is defined as $$\mathcal{E}_n = \{ C \in \mathcal{M}(\mathbb{R}^{n \times n}) : C {}^t = C, C_{i,i} = 1, i=1..n, x {}^t C x > 0, \forall x \in\mathbb{R}^n \}$$

Notes:

• This endpoint uses a computationally more efficient algorithm than the one described in the reference.