How to calculte Efficient Frontier for Markowitz Portfolio
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I'm trying to construct an optimized portfolio with 3 risk free assets. I have found the minimum vriance portfolio's weights, but I have a problem constructing thw effiient frontier. I would like some help if anyone knows..
My data (Excel File) comprises monthly closing prices of three Dow Jon Composite stocks from June 2010 until May 2020.
Thanks!
--Edit: Attached is the code that I'm using
Data=Untitled;
prices=Data(2:end,2:4);
% Calculation of returns
returns=tick2ret(prices);
% Convert table to homogeneous array
returns=table2array(returns);
%Summary Statistics
Std=std(returns);
Mean=mean(returns);
Cov=cov(returns);
% Use of Quadprog Solver for quadratic objective functions with linear constraints. Quadprog finds a minimum for a problem specified
f=zeros(numel(Mean),1);
Aeq=ones(1,numel(Mean));
beq=1;
[min_weights min_var]=quadprog(Cov,f,[],[],Aeq,beq)
% Smallest and Bigger Return of these 3 assets portfolios
Smallest_Mean=min_weights'.*Mean;
Largest_Mean= max(Mean);
% We define how many portfolios will be include in the Effeicient Frontier
Expected_Ret=Smallest_Mean:(Largest_Mean-Smallest_Mean)/1000:Largest_Mean;
% Use of Quadprog Solver for quadratic objective functions with linear constraints. Here is used to find the Efficient Frontier
a=numel(Mean);Mean'
Aeq1=[ones(1,a)]
for i=1:length(Expected_Ret);
beq1=[1;Expected_Ret(i)];
[x y]=quadprog(Cov,f,[],[],Aeq1,beq1);
pMean=Mean'.*x;
pVar=sqrt(y);
Port_Return(i,1)=pMean;
Port_Std(i,1)=pVar;
weight(1,i)=x(1,1);
weight(2,i)=x(2,1);
weight(3,i)=x(3,1);
pmean=o;
pvar=o;
end
From MatLab i get:
Error using quadprog (line 304)
The number of rows in Aeq must be the same as the number of elements of beq.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Portfolio Optimization and Asset Allocation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!