Fix MaximumSharpeRatioPortfolioOptimizer to maximize the Sharpe ratio#9560
Open
Ruuudy1 wants to merge 1 commit into
Open
Fix MaximumSharpeRatioPortfolioOptimizer to maximize the Sharpe ratio#9560Ruuudy1 wants to merge 1 commit into
Ruuudy1 wants to merge 1 commit into
Conversation
The optimizer fixed the portfolio return to the equal-weight return ((µ − r_f)ᵀw = k) and minimized variance, which collapsed it to a minimum-variance optimizer instead of maximizing the Sharpe ratio. Python now maximizes (µ − r_f)ᵀw / √(wᵀΣw) directly with SLSQP, keeping the budget constraint Σw = 1 and the per-weight bounds. C# applies the Charnes-Cooper substitution y = κw, minimizing yᵀΣy subject to (µ − r_f)ᵀy = 1 and recovering w = y / (1ᵀy); the per-weight bounds are written as linear constraints in y (yᵢ − up·(1ᵀy) ≤ 0, yᵢ − lw·(1ᵀy) ≥ 0) so the problem stays a convex QP and the [lower, upper] range is honored. Both languages reach the same optimum, and the unit-test expectations are updated to the corrected weights. Addresses QuantConnect#9322
9b5cb20 to
d5af87f
Compare
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.
Description
Fix
MaximumSharpeRatioPortfolioOptimizerso it maximizes the Sharpe ratio. Python optimizes(mu - rf)'w / sqrt(w'Sw)directly with SLSQP. C# uses a bounds-aware Charnes-Cooper QP (y = kw, minimizey'Sys.t.(mu - rf)'y = 1, recoverw = y / (1'y)), with the per-weight bounds written as linear constraints inyso it stays a convex QP. Both honor the[lower, upper]range and reach the same optimum. Unit test expectations updated to the corrected weights.Related Issue
#9322
Motivation and Context
The optimizer constrained the portfolio return to the equal-weight return (
(mu - rf)'w = k) and minimized variance, so it behaved like a minimum-variance model and returned near-flat weights regardless of the inputs instead of the maximum Sharpe ratio portfolio.Requires Documentation Change
N/A
How Has This Been Tested?
Updated
MaximumSharpeRatioPortfolioOptimizerTestswith the corrected weights (regenerated from the solver output) and confirmed every case passes, including the bounds and fallback cases. No regression algorithm consumes this optimizer (the BlackLitterman models and tests passUnconstrainedMeanVariancePortfolioOptimizerexplicitly), so the impact is limited to this optimizer and its unit tests.Types of changes
Checklist: