Hierarchical Risk Parity, benchmarked honestly
A from-scratch build of Lopez de Prado's HRP (2016), tested out of sample on real Polygon data against 1/N and inverse-variance. It gives the lowest volatility and never blows up, and it does not beat naive 1/N on after-cost Sharpe.
00Overview
Hierarchical Risk Parity allocates by the correlation tree instead of inverting a noisy covariance matrix. This is a from-scratch implementation of the Lopez de Prado (2016) algorithm, then the part most projects skip: an honest out-of-sample comparison against the baselines it is supposed to beat.
The result
01The algorithm
- Tree clustering of assets via a correlation distance metric.
- Quasi-diagonalisation: recover the dendrogram leaf order so similar assets sit together.
- Recursive bisection that splits risk top-down with inverse-variance cluster weights.
02The honest test
HRP delivers the lowest out-of-sample volatility (0.1199 vs 0.1330 for 1/N) and the smoothest path, but its Sharpe gap to 1/N is -0.224. The Jobson-Korkie-Memmel test gives p = 0.189, and a bootstrap 95% CI on the gap is [-0.592, 0.123], straddling zero. The verdict is no significant difference: HRP is a better risk story, not a better return story.
03Validation
HRP weights match PyPortfolioOpt to ~1e-7; the Ledoit-Wolf shrinkage matches scikit-learn to 1e-10; the simplex constraint holds to 1e-12. 236 tests at ~92% coverage, with a yfinance to Stooq to synthetic fallback so CI never depends on a live feed.