Mean -Variance Portfolio Optimization using Quadratic Programing

조회 수: 1 (최근 30일)
civs
civs 2014년 7월 7일
편집: James Tursa 2014년 7월 7일
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.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Portfolio Optimization and Asset Allocation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by