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.
  2 件のコメント
civs
civs 2014 年 7 月 7 日
civs
civs 2014 年 7 月 7 日

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangePortfolio 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