12.07.2015 Views

Computer Assignment 2 - Stockholms universitet

Computer Assignment 2 - Stockholms universitet

Computer Assignment 2 - Stockholms universitet

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

If you do not have access to the statistics toolbox you can use the function erf(x),which gives the error functionerf(x) = √ 2 ∫ xe −t2 dt πA comparison with F (x) suggests that the calculations above with x = 1.5, µ = 2 andσ = 0.7 can be made as>> (erf((1.5-2)/(0.7*sqrt(2)))+1)/2ans =0.2375Again, if you need to carry out similar calculations several times, you can create the filenormcdf.m in your working directory with the contentfunction y=normcdf(x,m,s)for i=1:length(x)y(i)=(erf((x(i)-m)/(s*sqrt(2)))+1)/2;end02 Exercises2.1 Cox-Ross-Rubinstein FormulaeIn the first exercise you are going to use historical data from the file histprices.txt on thecourse’s homepage again to price options on stock using Cox-Ross-Rubinstein Formulae.Import the file to Matlab in the same way as in the previous assignment and calculate thelogarithmic returns as>> k=log(data(2:251,:)./data(1:250,:));and choose one of the stock, for example by assigning an integer between 1 and 25 to thevariable stock.To be able to determine the price of an option on this stock we have to first define abinomial tree model for the price of one share of the stock. One way to determine u andd is to use the representation (3.7) in Section 3.3.2 in the textbook [2] and first estimatethe drift m and volatility σ as>> m=250*mean(k(:,stock));>> s=sqrt(250*var(k(:,stock)));4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!