Mean -Variance Portfolio Optimization using Quadratic Programing
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am working on a portfolio optimization problem. The code I have for the portfolio optimization is the below:
function [W]= mean_var_portopt1(MinRetvec, Rets)
[~, N]=size(Rets);
LM=length(MinRetvec);
themean=mean(Rets);
Varcov=cov(Rets);
Aeq=ones(1,N);
A=-themean;
LB=zeros(N, 1);
beq=1;
f=zeros(N, 1);
W=zeros(N,LM);
OPTIONS = optimset('LargeScale', 'off', 'Simplex', 'on','Display','off');
for loop=1:length(MinRetvec)%repeat for all values in MinRetvec
MinRet=MinRetvec(loop);
b=-MinRet;
[w]=quadprog(Varcov,f,A,b,Aeq,beq,LB,[],[],OPTIONS);
W(:,loop)=max(w(1:N),0);
end
end
In order to call the function from a M-script I have written down the below:
[filename,pathname]=uigetfile('*.xlsx');
[data,textdata,raw] = xlsread(filename,'Portfolio');
Rets=data(:,[1,2,3,4,5]);
[~,n]= size(MinRetvec);
W = zeros(1,n);
[W]= mean_var_portopt1(MinRetvec, Rets)
I want to compute the optimal weight for different numbers of mu_p , and I want to pass them all at once in a vector called 'MinRetvec'. This should be useful for plotting the efficient frontier. I am not sure if what I wrote above is correct, ultimately I want to pass MinRetvec (which is a vector) as an input to the function. Unfortunately I cannot get it to work.
Appreciate your comments/suggestions.
Respuestas (0)
Ver también
Categorías
Más información sobre Portfolio Optimization and Asset Allocation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!