Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
dat;
load C:\Users\anamika.balodi\Documents\MATLAB\HW2\Factors_July26_July11.dat;
T=1021;
N=10;
tau = 3;
bill=Factors_July26_July11(1:T,5) / 100;
R_10=Indu10_July26_July11(1:T,2:11) / 100;
R_10_ex=R_10 - bill*ones(1,N);
excess of the T-bill
mu=mean(R_10_ex);
mu=mu';
V=cov(R_10_ex);
T-bill return
% the 10 industry returns
% industry returns in
%%%
Portfolio constraints %%%
a=zeros(N,1);
% letting a_i=0 for all i, i.e., no short sells
b=0.3*ones(N,1);
%
b_i=0.5, no more than 50% of money invested into one
asset
% a=-0.1*ones(N,1);
%%%%%%%%%% Computing the optimal weight on the N risky aasets based on Arnold
Neumaier's quadratic proramming routine: MINQ
%
%
min
fct = gam + c^T x + 0.5 x^T G x
%
%
s.t.
x in [xu,xo]
% xu<=xo is assumed
% where G is a symmetric n x n matrix, not necessarily
definite
% Note!!!:
if you have Matlab' Optimization Toolbox, you can use its
%
quadprog instead, with
[x,fval,exitflag]=QUADPROG(G,c,[],[],[],[],xu,xo,xx);
gam=0;
c=-mu;
G=tau*V;
xu=a;
xo=b;
xx=ones(N,1)/N;
the equal-weighted
prt=0;
[x,fct,ier,nsub]=quadprog(gam,c,G,xu,xo,prt,xx);
% calling the
minimization program to get the minimized value and the associated x
w_1=x;
constraints
w0=(1/tau)*V^(-1)*mu;
(174)
% Compute the Sharpe ratio of the constrained port, etc, with hindsight
and ignore transaction costs
Port_1=zeros(T,1);
portfolio
PortS=zeros(T,1);
Port_1(1)=bill(1)+w_1'*ReEX(1,:)';
period
ReEX(1,:)
is
% return at t
% accumulativ return at
Port0(1)=bill(1)+w0'*ReEX(1,:)';
PortS0(1)=1+Port0(1);
for t=2:T,
Port0(t)=bill(t) + w0'*ReEX(t,:)';
PortS0(t)=PortS0(t-1)*(1+Port0(t));
at t
end;
Port0EX=Port0 - bill;
muP0=mean(Port0EX);
sig2P0=var(Port0EX);
SharpeP0=muP0 / sqrt(sig2P0);
% return at t
% accumulativ return
Rm_01=RmEX_1 + bill;
adding back the riskfree rate
CC_RM_01=zeros(T,1);
CC_RM_01(1)=1+Rm_01(1);
first month
for t=2:T,
CC_RM_01(t)=CC_RM_01(t-1)*(1+Rm_01(t));
t
end;
fprintf('******
tau
fprintf('****** weights on the risky assets: constrained and unconstrained
ones ********** \n');
[w_1,w0]
********** \n');
B1=[max(Rm_01) min(Rm_01)]';
B2=[max(Port_1) min(Port_1)]';
B3=[max(Port0) min(Port0)]';
[B1 B2 B3]
fprintf('****** Accu return of the mkt, constrained and un-c* the ports
********** \n');
CC_RM_01(T)
PortS(T)
PortS0(T)
fprintf('******
********** \n');