Expected Behavior
the implementation references/tries to implement:
quant.stackexchange.com/.../18521/...
The StackExchange answer describes the Charnes-Cooper substitution which only works when no inequality bounds on individual weights are present. Charnes-Cooper substitution requires: substitute y = w/κ, constrain mu'y = 1 (not mu'w = k), then minimize y'sum(y). The budget constraint becomes 1'y = κ and the bounds become 0 ≤ y_i ≤ κ appears in the bounds. our python optimizer ignores this.
image.png
as a result the optimizer will always default to min variance optimizer based on the equal weight expected return (it's forcing the portfolio return to match k), which is exactly what ends up happening if we run it
Actual Behavior
The portfolio should not be forced to match K, it should return the highest risk adjusted return correctly maximizing sharpe ratio.
Potential Solution
I provided the fixed sharpe ratio optimizer for both languages:
Python: Sharpe maximization via SLSQP
- Objective:
-μ'w / √(w'Σw)
- Constraints:
Σw = 1
- Bounds: (lower, upper) per weight
C#: Charnes-Cooper QP
- Objective:
min y'Σy
- Constraints:
μ'y = 1, y_i ≥ 0
- Recovery:
w = y / Σy
Reproducing the Problem
If we plot the weights for us to vizualize. Left plot is our built is the built in one (sharpe ratio 0.133) vs right is the fixed version provided (0.164 sharpe ratio).
Python version (flat weights on built in optimzer):


C# Version
Left is the built in MaximumSharpeRatioPortfolioOptimizer.cs optimzer (0.038 sharpe ratio), right is the fixed implementation version (0.154 sharpe ratio).

Note: the slight difference in backtest performance is due the different optimizers used matching the original implementation (since SLSQP is not built into C#.)
System Information
Cloud Master Branch
Checklist
- [ X ] I have completely filled out this template
- [ X ] I have confirmed that this issue exists on the current
master branch
- [ X ] I have confirmed that this is not a duplicate issue by searching issues
- [ X ] I have provided detailed steps to reproduce the issue
Expected Behavior
the implementation references/tries to implement:
quant.stackexchange.com/.../18521/...
The StackExchange answer describes the Charnes-Cooper substitution which only works when no inequality bounds on individual weights are present. Charnes-Cooper substitution requires: substitute y = w/κ, constrain mu'y = 1 (not mu'w = k), then minimize y'sum(y). The budget constraint becomes 1'y = κ and the bounds become 0 ≤ y_i ≤ κ appears in the bounds. our python optimizer ignores this.
image.png
as a result the optimizer will always default to min variance optimizer based on the equal weight expected return (it's forcing the portfolio return to match k), which is exactly what ends up happening if we run it
Actual Behavior
The portfolio should not be forced to match K, it should return the highest risk adjusted return correctly maximizing sharpe ratio.
Potential Solution
I provided the fixed sharpe ratio optimizer for both languages:
Python: Sharpe maximization via SLSQP
-μ'w / √(w'Σw)Σw = 1C#: Charnes-Cooper QP
min y'Σyμ'y = 1, y_i ≥ 0w = y / ΣyReproducing the Problem
If we plot the weights for us to vizualize. Left plot is our built is the built in one (sharpe ratio 0.133) vs right is the fixed version provided (0.164 sharpe ratio).


Python version (flat weights on built in optimzer):
C# Version

Left is the built in MaximumSharpeRatioPortfolioOptimizer.cs optimzer (0.038 sharpe ratio), right is the fixed implementation version (0.154 sharpe ratio).
Note: the slight difference in backtest performance is due the different optimizers used matching the original implementation (since SLSQP is not built into C#.)
System Information
Cloud Master Branch
Checklist
masterbranch