Hierarchical Risk Parity

A machine-learning-inspired portfolio allocation method that uses hierarchical clustering and recursive bisection to build diversified portfolios without requiring covariance matrix inversion.

Overview

Hierarchical Risk Parity (HRP), introduced by Marcos Lopez de Prado in 2016, represents a paradigm shift in portfolio construction. Unlike traditional methods (MVO, minimum variance) that require inverting the covariance matrix, HRP uses graph theory and machine learning techniques to allocate weights based on the hierarchical structure of asset correlations.

The key insight is that asset returns exhibit a natural hierarchical clustering structure: assets within the same sector or asset class tend to be more correlated with each other than with assets in different sectors. HRP exploits this structure to allocate risk in a top-down manner, with the aim of producing portfolios that are less sensitive to estimation error than MVO.

The algorithm proceeds in three well-defined steps: (1) hierarchical clustering of assets based on a correlation distance metric, (2) quasi-diagonalization of the covariance matrix to group correlated assets together, and (3) recursive bisection to allocate weights using an inverse-variance heuristic.

Step 1: Hierarchical Clustering

Correlation Distance

The first step converts the correlation matrix into a proper distance metric. The distance between assets and is defined as:

where is the Pearson correlation between the returns of assets and . This distance satisfies the properties of a proper metric: when (perfectly correlated), when (perfectly anti-correlated), and when (uncorrelated).

Agglomerative Clustering

Using the distance matrix, single-linkage agglomerative clustering is applied to build a hierarchical tree (dendrogram). The original paper uses single linkage, and so does this platform. At each step, the two closest clusters are merged until all assets belong to a single cluster. The result is a binary tree that captures the hierarchical correlation structure of the asset universe.

Step 2: Quasi-Diagonalization

The quasi-diagonalization step reorders the rows and columns of the covariance matrix according to the hierarchical clustering output. Assets that belong to the same cluster are placed adjacent to each other, producing a matrix where the largest values are concentrated along the diagonal:

where is a permutation matrix derived from the dendrogram ordering. This reordering is essential because it ensures that the recursive bisection in Step 3 splits the portfolio along meaningful cluster boundaries, grouping similar assets together and dissimilar assets apart.

Step 3: Recursive Bisection

Weight Allocation

The recursive bisection step allocates weights top-down. It walks the quasi-diagonal order from Step 2, not the dendrogram nodes: at each step a list of assets is cut in half into two sub-clusters and , and capital is allocated inversely proportional to cluster variance:

where and are the variances of the inverse-variance portfolio within each sub-cluster (Lopez de Prado, 2016).

Recursive Process

The bisection is applied recursively: each half is cut in half again, and the process continues until individual assets are reached. The final weight of each asset is the product of all the allocation fractions along the path from the root to that asset. This ensures that weights sum to one by construction, without requiring an explicit budget constraint.

On this platform the method uses PyPortfolioOpt's HRPOpt, with the Pearson correlation and the sample covariance of daily returns over the run window. When the run carries per-name bounds, each split is held inside the range of capital that both halves can feasibly receive. When no bound binds, the result matches the unconstrained allocation.

Sector and group rules: a second solve on top of the HRP weights

HRP itself does not take a group rule, such as a sector cap or a market-cap band. A sector cuts across the branches of the tree, so no split forms that sum. Per-name bounds and exclusions are different: they shape each split as the tree is walked, so HRP solves them directly.

  • Unchanged when the rules already hold. When the HRP weights with per-name bounds and exclusions already meet every group rule, they are used unchanged. No second solve runs.
  • Otherwise, a second solve. A second solve runs on top of those weights and finds the closest portfolio that meets every rule. “Closest” is a chi-square distance, which measures how far each split of the HRP tree moved. With the HRP weight of asset and the final weight, the second solve minimizes
    under every rule of the run. It is the closest portfolio in that distance only. It is not the portfolio with the smallest possible turnover, and no single portfolio is closest in every measure at once.
  • The result is no longer an HRP allocation. HRP's split ratios no longer hold, and the run records this. The results page and the backtest page state it.
  • What it costs. Measured on 169 binding cases on 2026-10-03:
    • The turnover was at the smallest possible in the median case.
    • The turnover was up to 13 percentage points above the smallest possible when an exclusion and a group cap act together.
    • The turnover was 1.8 to 3.3 points above the smallest possible under overlapping group rules.
    • The distance is about 7% above the smallest plain distance at the median.
    • Its largest single change is about 1.6 times the smallest possible at the median.
  • What it keeps. It sets no holding to zero that HRP held. Under one group rule with no binding per-name bound, every member of the group moves by one common factor.
  • What it refuses. A mandate it cannot meet is refused by name and never relaxed. HERC and HERC2 still refuse group rules.

These are statements about how the weights are built, not about performance.

Advantages & Limitations

Advantages

  • No matrix inversion: Does not require inverting the covariance matrix, avoiding the numerical instability that plagues MVO.
  • No return estimates: Like minimum variance, HRP does not require expected return forecasts.
  • Stability: Uses no expected-return estimate and no matrix inversion, which tends to give allocations that change less between rebalances than MVO-based methods.
  • Simulation evidence: In the Monte Carlo experiments of Lopez de Prado (2016), HRP had lower out-of-sample variance than the critical line algorithm's minimum variance portfolio and than inverse-variance weighting. That result is specific to his simulation design.
  • Works with singular matrices: Can handle cases where the covariance matrix is singular or near-singular.

Limitations

  • Heuristic method: Not derived from an explicit optimization problem, so there is no formal optimality guarantee.
  • Clustering sensitivity: Results depend on the choice of linkage method and distance metric.
  • Group sums need a second solve: HRP supports per-name weight bounds and asset exclusions directly: the bound shapes each split as the dendrogram is descended, so the limit is solved with the allocation rather than applied after it. A group sum limit, such as a sector cap, is not a quantity any branch of the tree forms. A second solve on top of the HRP weights meets it, so the result is no longer a pure HRP allocation and can have higher turnover (see Sector and group rules). Turnover bounds are not available on any method.
  • Ignores returns: Cannot incorporate views on expected returns into the allocation.

References

  • Lopez de Prado, M. (2016). "Building Diversified Portfolios that Outperform Out of Sample." The Journal of Portfolio Management, 42(4), 59-69.
  • Lopez de Prado, M. (2018). Advances in Financial Machine Learning. John Wiley & Sons.
  • Raffinot, T. (2017). "Hierarchical Clustering-Based Asset Allocation." The Journal of Portfolio Management, 44(2), 89-99.
  • Bailey, D. H., & Lopez de Prado, M. (2013). "An Open-Source Implementation of the Critical-Line Algorithm for Portfolio Optimization." Algorithms, 6(1), 169-196.

Not investment advice. Past performance is not indicative of future results.