How to find tangency portfolio (maximize sharpe ratio) using quadprog
Afficher commentaires plus anciens
Hi,
We are performing a mean-var portfolio optimazation including serveral constraints. Using Mean-Variance Stochastic goal programming we have found the sub -optimal frontier accountin g for desierable weights in a subset of sustainable assets. Using the code below we were able to find the sub-optimal frontier changing the desired return level (r) . However, we now want to obtain the tangency portfolio as our selected optimal portfolio strategy, but we can´t figure out how. Given a risk free rate of 0.000412 does anyone know how we can find the tangency portfolio (i.e maximizing the sharp ratio) ?
Best regards ,
Agnethe and Guro
C = readtable('V strong.xlsx')
Covariance = table2array(C)
M = readtable('m.xlsx')
Mean_return = table2array(M)
M1 = readtable('h.xlsx')
Mean_return_h = table2array(M1)
nAsset = numel(Mean_return); r = 0.03
e_0 = 0.027900578
%Optimization Problem
portprob = optimproblem;
x = optimvar('x',nAsset,'LowerBound',0,'UpperBound',1);
objective = x'*Covariance*x;
portprob.Objective = objective;
sumcons = sum(x) == 1;
portprob.Constraints.sumcons = sumcons;
averagereturn = dot(Mean_return, x) >= r;
portprob.Constraints.averagereturn = averagereturn;
averagereturn2 = dot(Mean_return_h, x) >= e_0;
portprob.Constraints.averagereturn2 = averagereturn2;
%Run Optimization Problem
options = optimoptions('quadprog','Display','iter','TolFun',1e-10);
tic
[x1,fval1] = solve(portprob,'Options',options);
toc
C2 = readtable('V1.xlsx')
Covariance2 = table2array(C2) %Covariance Matrix All Assets
ReturnStrong = value'*Mean_return
VarStrong = value'*Covariance2*value
RiskStrong = sqrt(VarStrong)
2 commentaires
John D'Errico
le 15 Mar 2019
Modifié(e) : John D'Errico
le 15 Mar 2019
Note that just as you have learned to assign a field in a structure, you can access it too using the dot, without using getfield.
value = x1.x
John D'Errico
le 15 Mar 2019
Modifié(e) : John D'Errico
le 15 Mar 2019
Of course, now you just removed that line completely from your code. But now I note that the code you show never even assigns value, but you use it afterwards. If you just change your code randomly, nobody will ever be able to help you.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Portfolio Optimization and Asset Allocation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

