Repository navigation
Apply fully-invested risk lower bound only to fully-invested portfolios - #770
kadyrbekovhamit-cyber wants to merge 2 commits into
Conversation
Signed-off-by: kadyrbekovhamit-cyber <288885044+kadyrbekovhamit-cyber@users.noreply.github.com>
|
I checked out this branch (Python 3.12, cvxpy 1.9.3) and ran the two-asset case from the description with Two things I'd add tests for, since the precheck was the only thing that stopped some bad inputs early:
The |
Signed-off-by: kadyrbekovhamit-cyber <288885044+kadyrbekovhamit-cyber@users.noreply.github.com>
|
Added both requested compatibility cases in abdcd8c. Tight symmetric bounds produce weights [0.02, -0.02] with risk strictly below the target, pinning the risk inequality. Positive-only bounds retain the existing RuntimeWarning and automatic shorting-bound amendment; the test checks the resulting weights. All 8 tests in test_market_neutral_risk_regression.py pass locally against the package. No production-code behavior was added in this follow-up. AI assisted the tests and this note. |
|
Read abdcd8c: both cases are the ones I asked for, and pinning risk strictly below the target for For the positive-only bounds case, the existing code amends the bounds with a warning. Does the test also assert that the final weights sum to zero within tolerance, or only that the amended weights are what the old code produced? Market neutrality is the property the user cares about, so it is worth asserting directly. |
efficient_risk(..., market_neutral=True)currently applies the sum(weights)=1 global-minimum-volatility lower bound before solving the sum(weights)=0 problem. That rejects feasible low-risk neutral portfolios.For returns
[.1,0], covariance.04*I, bounds(-1,1)and target volatility.05, weights[.05/sqrt(.08),-.05/sqrt(.08)]are feasible and analytically optimal. The current precheck rejects them because the fully-invested lower bound is sqrt(.02).Apply that precheck only when
market_neutral=False; the solver still evaluates all user constraints. Tests cover three low-risk targets, updating the target parameter, preservation of the fully-invested rejection and a genuinely infeasible neutral constraint.Validation: original regressions 5 failed / 1 passed; patched efficient-frontier module plus regressions 77 passed / 4 skipped. Main a6638d2; Python 3.12, cvxpy 1.9.3. Related #569 discusses minimum-volatility rejections but does not supply this market-neutral counterexample; #362 concerns sector constraints, which this patch does not change.
AI-assisted investigation and patch; numerical work was sequential and single-threaded. This is a feasibility-check correction, not a claim about production portfolios.