How can I improve optimization result of fmincon (Sharpe ratio maximization)?
Show older comments
Hi,
I am a user of Matlab 2011a. I want to maximize Sharpe ratio and the only option I found was to use fmincon. My problem is to maximize: (x'*r-r0)/sqrt(x'*C*x), under constraints: lb=zeros(200,1), ub=0.03*ones(200,1), Aeq=ones(1,200), beq=1 Where: x- vector of shares r - vector of expected returns r0 - risk free C - covariance matrix
The problem is that no matter which algorithm I use the solution is for sure not global. With such a constrints the algorithm should choose between 34-40 assets most with the share of 0.03. But in practice algorithm puts above 0 share for nearly every asset, a lot with a very small share of like 1,111e-22 (why not 0?), and about 60 with higher share (about 20 assets with a share of 0.03).
I tried to decrease function tolerance, x tolerance but it didn't help.
How to get better result? How to e.g. fix that asset 1,2,3,4 should have a share of 0.03? Maybe other solver is possible and is better?
Answers (1)
My problem is to maximize: (x'*r-r0)/sqrt(x'*C*x)
which means that you're minimizing sqrt(x'*C*x)/(x'*r-r0) ? Your function is not differentiable at x=0 and null(C). Even if you know the solution doesn't lie there, if any of the iterations land (near) there, they will compute very bad derivates and will have a hard time finding a good new point. Use
x'*C*x/(x'*r-r0)^2
if the sign of x'*r-r0 doesn't matter.
a lot with a very small share of like 1,111e-22 (why not 0?)
Partly because of finite precision computer arithmetic. Partly because it's an iterative algorithm and only reaches the solution asymptotically. It should be fine to as assume that 111e-22 was really supposed to be zero.
How to e.g. fix that asset 1,2,3,4 should have a share of 0.03
If the values of assets 1,2,3,4 are known, you should remove them from the list of unknowns and rewrite your objective function with these values replaced by known constants.
Some algorithms will also let you set lb=ub=.03, but that's less efficient.
3 Comments
I don't know what you mean by rewiting my objective function. Can you explain in more details how to do that?
As a simpler example suppose C is 2x2 and therefore
x'*C*x = x1^2*C(1,1) +2*x1*x2*C(1,2) + x2^2*C(2,2)
If x2 is now a known constant, say x2=1, then this reduces to
x'*C*x = x1^2*C(1,1) +2*x1*C(1,2) + C(2,2)
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!