Formulating a Maximum-Sharpe Fixed-Income Portfolio Optimization
Summary
The document presents a fixed-income portfolio optimization problem implemented with a convex optimization package. The setup uses expected returns, a covariance matrix, a benchmark or reference rate, and constraints related to nonnegative positions and duration or DV01 limits. It minimizes portfolio variance while imposing a unit excess-return constraint, then normalizes the resulting holdings into portfolio weights. The author reports that the resulting portfolios underperform the index and seem to behave in reverse, while manually reversing relative weights appears to produce the expected direction.
The replies suggest checking whether the objective and constraints match the intended maximization, since minimizing a quantity with the wrong sign can reverse the result. Another response points to the Charnes–Cooper transformation for handling a ratio objective, describing a scaling variable and corresponding weight normalization. The exchange offers brief diagnoses rather than a verified correction: it does not fully specify the constraints, data, or benchmark construction, so the code and reported behavior cannot be conclusively assessed from the document alone.
Key ideas
- The formulation minimizes variance subject to a unit excess-return constraint and portfolio limits.
- The resulting solution is normalized into portfolio weights after solving.
- A sign or objective-direction error can produce a portfolio opposite to the intended optimization.
- Ratio objectives may require a transformation such as Charnes–Cooper.
- The limited problem details prevent confirming which proposed diagnosis explains the reported underperformance.
Tags
Full text
# Fixed Income Portfolio Optimization
# Fixed Income Portfolio Optimization
I'm trying to solve for a maximum sharpe ratio portfolio in the fixed income space. To do so, i use CVXPY in python. I use this Paper as reference.
This is my "setup":
```
## SET UP PROBLEM
C = np.asmatrix(new_cov)
mu = np.asmatrix(s['E(r) after FXh']/100)
mu0 = np.asmatrix(cleared_swaps.iloc[z]['CHF1']/100)
## INITIATE WEIGHT VARIABLE
y = cp.Variable(len(framework))
# DEFINE CONSTRAINTS AND MODIFY FOR QUADRATIC PROBLEM
A_mod = A - b.T
## CREATE CONSTRAINTS
constraints = [(mu-mu0)@y==1,
0 <= y,
A_mod@y.T >= 0]
## FORM OBJECTIVE
obj = cp.Minimize(cp.quad_form(y,C))
## FORM AND SOLVE PROBLEM
prob = cp.Problem(obj, constraints)
try:
prob.solve()
w = y.value/sum(y.value)
w[w<=0] = 0
w = w/sum(w)*1
except:
print('Exception. Using Market weights')
w = np.repeat(df_mkt_val_pct.iloc[z][live_currencies.index.tolist()].values,2)/2
w = w/sum(w)*1
```
Where A basically holds the Subportfolio Duration (for example different EUR Durations):
and b holds the DV01 Limits:
Now when I run this script the portfolios I get are "inversely optimized" meaning that I'm constantly underperforming the index. If I then kind of reverse the optimal weight (for example I add the underweight in one currency to the BM weight so that I end up with an overweight) then the returns are as expected.
But this behavior is weird in my opinion. Is there a way how to "flip" the optimization so that I guet the optimized values which I can then use without having to "inverse" them?
## Answer by JeanGuillaume (score 1)
https://quant.stackexchange.com/a/46148
Do you have correctly formulated the problem for the solver ? If you want to maximise a function (the sharpe ratio) $f$, it is equivalent to minimise $-f$. This kind of confusion (minimising instead of maximising) would basically lead to a similar outcome as yours.
## Answer by Dany (score 0)
https://quant.stackexchange.com/a/50585
Your problem formulation is wrong, you must use the Charnes and Cooper transformation.
This means that your constraint `(mu-mu0)@y==1` must be `(mu-mu0)@y==k` and `w=y/k`, which implies that `k==cp.sum(y)`.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.