Commit 2043afd
feat(hierarchical): add HERCOpt and NCOpt portfolio allocation methods
Extends the hierarchical portfolio module with two additional methods:
HERCOpt - Hierarchical Equal Risk Contribution (Raffinot 2018)
Equal Risk Contribution (ERC) weights at every level of the hierarchy
instead of the inverse-variance weights used by HRP. ERC accounts for
within-cluster correlations, producing more balanced risk allocation
when intra-cluster correlations are high. Implemented via cyclical
coordinate descent (Roncalli 2013).
NCOpt - Nested Cluster Optimization (Lopez de Prado 2019)
Two-level nested procedure: within-cluster optimization followed by
meta-portfolio optimization across clusters. Supports three objectives
at each level - min_variance, erc, and equal-weight - giving 9
combinations. The meta-covariance is computed analytically from the
full covariance matrix, so no return history is required.
Both classes:
- Share the same API as HRPOpt (fit from returns or cov_matrix)
- Export portfolio_performance() with expected return and Sharpe ratio
- Are exported from pypfopt.__init__ and __all__
- Accept all scipy linkage methods
Also adds two private helpers:
- _erc_weights_ccd: ERC via multiplicative CCD (Roncalli 2013)
- _min_var_weights: long-only min-variance with analytic + SLSQP fallback
53 tests across 9 test classes; all existing HRP tests still pass.
References
----------
Raffinot, T. (2018). Hierarchical clustering-based asset allocation.
Journal of Portfolio Management, 44(2), 89-99.
Lopez de Prado, M. (2019). A Robust Estimator of the Efficient Frontier.
SSRN Working Paper. https://ssrn.com/abstract=3469961
Roncalli, T. (2013). Introduction to Risk Parity and Budgeting.
CRC Press.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent c524c6e commit 2043afd
3 files changed
Lines changed: 997 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
0 commit comments