Optimization
/HRP Optimization
HRP Optimization
A modern portfolio optimization method that groups assets by similarity and distributes risk across clusters — without requiring a precise covariance matrix inversion.
Hierarchical Risk Parity (HRP) is a portfolio optimization method that incorporates elements of graph theory and machine learning. Unlike traditional Mean-Variance Optimization, HRP does not depend on precise estimates of expected returns. Instead, it groups similar assets together based on their return relationships, then allocates risk evenly across those groups.
The result is a more robust and diversified portfolio that is less sensitive to the estimation errors that often undermine classical optimization approaches.
Diversification
Risk is spread across asset groups, not concentrated in a few high-performing assets.
Resilience to market conditions
Because risk is more evenly distributed, HRP portfolios tend to hold up better across different market environments, including downturns.
Reduced volatility
The focus on risk allocation rather than return-chasing typically leads to lower overall portfolio volatility.
No covariance matrix inversion
HRP avoids inverting the covariance matrix, which is numerically unstable with many assets or short data histories. This makes it more reliable when inputs are noisy.
Optimization Settings
Risk Measure
Defines how risk is quantified when building the portfolio. HRP uses this measure to determine how much weight each asset and cluster should receive.
Volatility-Based:
Standard Deviation
The most common risk measure. Measures how much returns deviate from the average. A higher standard deviation means greater variability. Good default for most portfolios.
Mean Absolute Deviation (Pro)
The average distance of returns from the mean, calculated without squaring. Less sensitive to extreme outliers than standard deviation.
Downside Risk:
Semi Standard Deviation (Pro)
Like standard deviation, but only counts negative deviations — downside moves. Focuses on protecting against losses rather than reducing overall variability.
Sortino Ratio (Pro)
Measures risk-adjusted return relative to downside risk only. Assets are weighted to maximize the ratio of return to downside volatility.
Omega Ratio (Pro)
Considers both the upside and downside of the full return distribution. Compares the probability-weighted gains above a threshold to probability-weighted losses below it.
Drawdown-Based:
Maximum Drawdown
The largest peak-to-trough decline in each asset's history. Allocates less weight to assets that have experienced deep losses. Good for investors focused on wealth preservation.
Conditional Drawdown at Risk (CDaR) (Pro)
The average drawdown in the worst scenarios beyond a given probability threshold. More nuanced than Maximum Drawdown — accounts for the frequency, not just the magnitude, of severe declines.
Ulcer Index (Pro)
Measures both the depth and duration of drawdowns. An asset that stays underwater for a long time scores higher on the Ulcer Index than one that recovers quickly, even if the maximum depth is similar.
Tail Risk:
Value at Risk (VaR) (Pro)
The maximum expected loss at a given confidence level (e.g., 95%). Does not describe what happens beyond that threshold, but provides a clear worst-case boundary for normal conditions.
Conditional Value at Risk (CVaR) (Pro)
Also known as Expected Shortfall. The average loss in the worst scenarios beyond the VaR threshold. More conservative and comprehensive than VaR for capturing extreme event risk.
Risk Free Rate
The minimum return expected without taking any risk. Used when calculating risk-adjusted metrics for the results comparison. The default is pre-filled with a commonly used reference rate.
Reoptimize Frequency
Once
Optimizes using all available data up to the Optimization Date (or all data if no date is set). The weights are fixed after this single pass.
Quarterly (Pro)
Re-optimizes at the end of each quarter using only data available up to that point. Simulates running the strategy in real-time without look-ahead bias.
Yearly (Pro)
Re-optimizes once per year. Lower turnover than quarterly — appropriate for long-term strategies.
Optimization Date
Splits history into a training period (before the date) and an out-of-sample test period (after the date). The optimizer is calibrated on the training period; performance after the date is unseen and reflects real predictive accuracy.
Preset options: 1Y, 2Y, 3Y, 5Y ago, or a custom date.
Training Window
How much historical data is used to estimate the asset relationships used in clustering and allocation.
- 1 Year — reactive, captures recent dynamics, less statistically stable
- 3 Years — balanced default, suitable for most investors
- 5+ Years — more stable, may not reflect recent structural shifts
Correlated Assets
When set to Drop, assets with correlation above 0.95 are automatically removed before optimization. The optimizer keeps the asset with the lowest average correlation to others from each highly correlated pair. This prevents near-duplicate positions from distorting the clustering.
Constraints
Min. Position Weight
Minimum allocation any single asset can receive. Default is 0% — assets can be excluded by the optimizer.
Max. Position Weight
Maximum allocation any single asset can receive. Default is 100%.
Individual Asset Limits
Per-symbol overrides. Expand to set custom min/max boundaries for specific tickers.
Freeze
Lock a specific asset's allocation at its current weight. The optimizer leaves that position unchanged while adjusting everything else.
Benchmark
An optional market index (e.g., SPY) shown alongside the optimized portfolio in performance charts. Useful for evaluating whether HRP outperforms passive indexing.
Results
Asset Clusters
HRP uses hierarchical clustering to group assets by the similarity of their return patterns. The Optimal Asset Allocation section shows:
- The recommended weight for each asset
- The Asset Clusters — which assets were grouped together by the algorithm
Assets in the same cluster move similarly. HRP allocates risk within each cluster before distributing across clusters, ensuring no single group of correlated assets dominates the portfolio.
Key Improvements
Side-by-side comparison of the original and optimized portfolio across: Return (1Y), Volatility (1Y), Sharpe Ratio (1Y), Sortino Ratio (1Y), Calmar Ratio, Max Drawdown, and Worst Day. Improvements are highlighted in green.
Performance and Risk Charts
Full historical charts for the optimized portfolio:
- Portfolio Performance — cumulative return
- Allocation Over Time — how weights evolve over the analysis period
- Sharpe Ratio — rolling risk-adjusted return
- Drawdowns — depth and duration of losses
- Volatility — rolling volatility
- Correlation Matrix — pairwise correlations of the portfolio assets
When to Use HRP
You have many assets with complex relationships
HRP scales well with large numbers of assets and doesn't require estimating expected returns — which are notoriously hard to forecast accurately.
You want stability without return estimation
MVO is sensitive to small errors in expected return inputs. HRP sidesteps this problem by relying only on the covariance structure.
You want true diversification across risk
Unlike equal-weight or cap-weight portfolios, HRP accounts for how assets actually co-move and spreads risk accordingly.
You want to compare with HERC
HRP and HERC both use hierarchical clustering. HERC equalizes risk contribution across clusters; HRP weights inversely to cluster risk. Try both to see which fits your goals better.
Suggested Next Steps
Compare HRP with Mean-Variance Optimization
Run the same portfolio through both tools. MVO tends to concentrate weights in a few assets; HRP produces more balanced allocations.
Try different risk measures
Switch between Standard Deviation, Maximum Drawdown, and CVaR to see how the allocation changes. Each risk measure leads to a different view of "optimal".
Use the Optimization Date to backtest
Set a date in the past and evaluate how the clustering-based strategy performed out-of-sample during periods not used for training.