image thumbnail
from Monte Carlo Simulation for Portfolio Assets by Wilson Amoretty Palmeiro
Simulate sample path allow us to see the pattern that assets price will face. Crucial to hedge risk.

PortfolioMontecarlo.m
Stock1=[BAC]; %Matrix of prices (2012)
Stock2=[GE]; %Matrix of prices (2012)
RetStock1=ret2price(Stock1);
RetStock2=ret2price(Stock2);
Returnone=[Mean(RetStock1); Mean(RetStock2)];%We need aggregate the data
SigmaStock1=std(RetStock2);
SigmaStock2=std(RetStock2);
Sigmas=[SigmaStock1; SigmaStock2];% Aggregate the data
Correlation=corrcoef(RetStock1, RetStock2);
Covariance=corr2cov(Sigmas, Correlation);
startprice=[20.65; 11.59];
numobs=249; % 1 calendar year
numsim=1000;% Num Simulation
numassets=2; %Only Two asset
retintervals=1; %One day Trading on Exchange Market
RetExact=portsim(ExpReturn, ExpCovariance, Numobs, Retintervals, Numsim, 'Exact'); 
ReturnExact=RetExact(:,:,1)/100;%Convert Chart into Numeric (we need convert) and divide return by 100%
Weights=ones(Numassets,1)/Numassets;
PortReturn=ReturnExact*Weights; %Portret=Sum(Xi*Weights)
plot(PortPrices, '-b');



Contact us