1 / 15

HW9

HW9. 100071021 楊佑濬. Convertible Bonds. function [ price, lattice] = CBprice ( S, I, Q, r, T, sigma, N) deltaT = T/N; u = exp ( sigma * sqrt ( deltaT ) ); d = 1/u; p = ( exp( r * deltaT ) - d ) / ( u - d ); for i = 0 : N

fritz-wells
Download Presentation

HW9

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HW9 100071021 楊佑濬

  2. Convertible Bonds function [ price, lattice] = CBprice( S, I, Q, r, T, sigma, N) deltaT = T/N; u = exp( sigma * sqrt(deltaT) ); d = 1/u; p = ( exp( r * deltaT ) - d ) / ( u - d ); for i = 0 : N CB(i+1) = max( I/Q, S * u^(N-i) * d^(i) ); end for i = N : -1 : 1 for j = 0 : i-1 CB(j+1) = exp(-r*deltaT) * ( CB(j+1)*p + CB(j+2)*(1-p) ); S_p = S * u^(i-1-j) * d^(j) ; CB(j+1) = max( CB(j+1) , S_p ); end lattice(1:i,i) = CB(1:i); end price = CB(1); end

  3. S = 35; I = 100000; Q = 2500; r = 0.02; T = 5; sigma = 0.3; N = 100; >> CBprice(S,I,Q,r,T,sigma,N) ans = 44.959 >>

  4. Demo Code S = 35; I = 100000; Q = 2500; r = 0.02; T = 5; sigma = 0.3; N = 100; for ST = 1 : 100 P(ST) = CBprice(ST,I,Q,r,T,sigma,N); end B = I/Q * exp(-r*T); figure; plot(ones(100)*B); hold on; plot(P); title('S0 to CB price'); for i = 1 : 100 P(i) = CBprice(S,I,Q,r,T,i*0.002,N); end figure; plot(ones(100)*B); hold on; plot(P); title('Sigma to CB price');

  5. Monte Carlo of Normal CDF function [ p ] = MCnormcdf( X, N ) if(nargin<2) N = 10000000; end for i = 1:length(X) p(i) = 1/sqrt(2*pi) * mean( exp(-1* ((rand(1,N)*X(i)).^2) / 2 ) ) * X(i) + 0.5; end end

  6. Demo Code x = linspace(-40,40,1000); tic; plot(x,MCnormcdf(x),x,normcdf(x)); toc;

  7. Outcome • i7-4770 3.40GHz 8 cores / 8G memory >> MCdemo Elapsed time is 128.180229 seconds. >> • i5-2520M 2.50GHz 4 cores / 8G memory >> MCdemo Elapsed time is 302.060766 seconds. >>

  8. Demo Code x = linspace(-3,3,1000); tic; plot(x,MCnormcdf(x),x,normcdf(x)); toc; for i = 1:10000 MC(i) = MCnormcdf(1.96,i); end plot(1:10000,MC,1:10000,normcdf(1.96));

More Related