Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #398
Plain HRP can put a large weight on one low-volatility asset, as the example in #398 shows. This adds
weight_boundstoHRPOpt, in the same form asEfficientFrontier(a single(lower, upper)pair or one pair per asset):How it works. The bounds are applied inside the recursive bisection, following the constrained HRP in the paper linked in the issue (Pfitzinger and Katzke, 2019). At each split, the share
alphagiven to the first sub-cluster is clipped so that each sub-cluster's weight stays between the sum of its assets' lower bounds and the sum of their upper bounds. When the bisection reaches single assets, every weight is within its own bounds and the weights still sum to 1. The result is still HRP, not a projection of the HRP weights after the fact.(0, 1)gives exactly the same weights as before.0 <= lower <= upper, the lower bounds must add up to at most 1, and the upper bounds to at least 1 (otherwiseValueError).returnsandcov_matrixinputs.Example with the bundled
stock_prices.csvandweight_bounds=(0.02, 0.10): XOM, T and WMT go from about 11% each to 10%, and JPM, AMZN and BAC go from 1.4-1.8% to 2%. The weights still sum to 1.Tests: 5 new tests in
tests/test_hrp.pycover bounds respected, default unchanged, per-asset bounds,cov_matrixinput, and error cases. Docs: short section inOtherOptimizers.rstwith the reference.Note: on SciPy 1.18,
HRPOpt.optimizecurrently fails on main because of_LINKAGE_METHODS(#754, fixed in #755). I ran the full suite on SciPy 1.17 (308 passed). ruff check and format are clean.