# Optimisation

This page is a technical deep dive into our optimisation implementation of our various blocks, layers and paths. We recommend reading our introduction and our model pages to fully understand where this deep dive fits in the PathLit ecosystem. These are quick reads and well spent time!

## Allocation strategies#

### l3ewp - Equally-Weighted Portfolios#

takes the covariances between the assets and computes the equally-weighted portfolio weights.

What is the math PathLit uses?

#### Objective Function:#

Let $w_i$ be the weight of the $i$th asset of $N$ total assets in a portfolio, the allocation is:

$w_i = \frac{1}{N}, \quad i=\{1,...,N\}$

### l3ivp - Inverse-Volatility Portfolios#

takes the covariances between the assets and computes the inverse-volatility weighted portfolio weights.

What is the math PathLit uses?

Objective Function: Let $w_i$ be the weight of the $i$th asset of $N$ total assets in a portfolio and $\Sigma$ be the estimated covariance matrix, the allocation is:

$\mathbf{w} = \frac{\sigma^{-1}}{\mathbf{1}^T \sigma^{-1}}, \quad \hbox{where,} \quad \sigma^2=diag(\Sigma)$

### l3rpp - Risk-Parity Portfolios#

takes the covariances between the assets and computes the risk-parity weighted portfolio weights.

What is the math PathLit uses?

Objective Function: Let $w_i$ be the weight of the $i$th asset of $N$ total assets in a portfolio and $\Sigma$ be the estimated covariance matrix, the allocation is:

\begin{aligned} \min_{\mathbf{w}} \quad & \sum_{i,j=1}^N (w_i(\Sigma \mathbf{w})_i - w_j(\Sigma \mathbf{w})_j)^2\\ \textrm{s.t.} \quad & \mathbf{1}^T\mathbf{w}=1, \\ &\mathbf{w}\geq0 \\ \end{aligned}

### l3mdp - Maximum Diversification Portfolios#

takes the covariances between the assets and computes the maximum diversification weighted portfolio weights.

What is the math PathLit uses?

Objective Function:

Let $w_i$ be the weight of the $i$th asset of $N$ total assets in a portfolio and $\Sigma$ be the estimated covariance matrix, the allocation is:

\begin{aligned} \min_{\mathbf{w}} \quad & \frac{\mathbf{w}^T \sigma}{\sqrt{\mathbf{w}^T \Sigma \mathbf{w}}} \quad \hbox{where,} \quad \sigma^2 = diag(\Sigma)\\ \textrm{s.t.} \quad & \mathbf{1}^T\mathbf{w}=1 \\ \end{aligned}

### l3mdcp - Maximum Decorrelation Portfolios#

takes the covariances between the assets and computes the maximum decorrelation weighted portfolio weights.

What is the math PathLit uses?

Let $w_i$ be the weight of the $i$th asset of $N$ total assets in a portfolio and $\Sigma$ be the estimated covariance matrix, the allocation is:

Objective Function:

\begin{aligned} \min_{\mathbf{w}} \quad & \mathbf{w}^T \mathbf{C} \mathbf{w} \quad \hbox{where,} \quad \mathbf{C} = diag(\Sigma)^{-\frac{1}{2}} \ \Sigma \ diag(\Sigma)^{-\frac{1}{2}}\\ \textrm{s.t.} \quad & \mathbf{1}^T\mathbf{w}=1 \\ \end{aligned}

### l3gmvp - Global Minimum Variance Portfolios#

takes the covariances between the assets and computes the global minimum-variance weighted portfolio weights.

What is the math PathLit uses?

Let $w_i$ be the weight of the $i$th asset of $N$ total assets in a portfolio and $\Sigma$ be the estimated covariance matrix, the allocation is:

Objective Function:

\begin{aligned} \min_{\mathbf{w}} \quad & \mathbf{w}^T \Sigma \mathbf{w} \\ \textrm{s.t.} \quad & \mathbf{1}^T\mathbf{w}=1 \\ \end{aligned}

### l3hrp - Hierarchical Risk-Parity Portfolios#

takes the covariances between the assets and computes the hierarchical risk-parity weighted portfolio weights.

As per Prado's seminal work that introduced HRP:

HRP applies modern mathematics (graph theory and machine learning techniques) to build a diversified portfolio based on the information contained in the covariance matrix. However, unlike quadratic optimizers, HRP does not require the invertibility of the covariance matrix. In fact, HRP can compute a portfolio on an ill-degenerated or even a singular covariance matrix, an impossible feat for quadratic optimizers. Monte Carlo experiments show that HRP delivers lower out-of-sample variance than CLA, even though minimum-variance is CLA’s optimization objective. HRP also produces less risky portfolios out-of-sample compared to traditional risk parity methods.

The algorithm can be broken down into 3 major steps:

1. Hierarchical Tree Clustering
2. Matrix Seriation
3. Recursive Bisection

Refer to Prado's paper for in depth analysis of the algorithm:

Source: Lopez de Prado, Marcos. (2016). Hierarchical Portfolio Construction: Dispelling Markowitz's Curse. SSRN Electronic Journal. 10.2139/ssrn.2708678.