>> sigmas=[0.9509 1.4259 1.5227 1.1062 1.0877]/100;
>> correlations=[1.0000 0.4403 0.4735 0.4334 0.6855
0.4403 1.0000 0.7597 0.7809 0.4343
0.4735 0.7597 1.0000 0.6978 0.4926
0.4334 0.7809 0.6978 1.0000 0.4289
0.6855 0.4343 0.4926 0.4289 1.0000];
>> expcov=corr2cov(sigmas,correlations)
expcov =
1.0e-003 *
0.0904 0.0597 0.0686 0.0456 0.0709
0.0597 0.2033 0.1649 0.1232 0.0674
0.0686 0.1649 0.2319 0.1175 0.0816
0.0456 0.1232 0.1175 0.1224 0.0516
0.0709 0.0674 0.0816 0.0516 0.1183
>> sp=100;no=504;ns=2;dt=1;na=5;
>> randn('state',0);
>> retexact=portsim(expreturn,expcov,no,dt,ns,'Exact');
>> w=ones(na,1)/na;
>> pretexact=zeros(no,ns);
>> for i=1:ns
pretexact(:,i)=retexact(:,:,i)*w;
end
>> portexact=ret2tick(pretexact,repmat(sp,1,ns));
>> plot(portexact,'-r')
>> ylabel('portfolio prices');title('exact method')


雷达卡



京公网安备 11010802022788号







