1 / 13

HW7

HW7. 100071021 楊佑濬. Oil Bond. Oil Bond - code. S = 30; r = 0.02; sigma = 0.06; T = 1; N = 10; deltaT = T/N; u = exp ( sigma * sqrt ( deltaT ) ); d = 1/u; p = ( exp( r * deltaT ) - d ) / ( u - d );. for i = 0 : N oilp(i+1) = S * u^(N-i) * d^(i); if oilp (i+1)<25

Download Presentation

HW7

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. HW7 100071021 楊佑濬

  2. Oil Bond

  3. Oil Bond - code S = 30; r = 0.02; sigma = 0.06; T = 1; N = 10; deltaT = T/N; u = exp( sigma * sqrt(deltaT) ); d = 1/u; p = ( exp( r * deltaT ) - d ) / ( u - d ); for i = 0 : N oilp(i+1) = S * u^(N-i) * d^(i); if oilp(i+1)<25 oilp(i+1) = 25; elseifoilp(i+1)>40 oilp(i+1) = 40; end oilp(i+1) = 1000+( oilp(i+1) -25)*170; end

  4. Oil Bond – code (conti.) for i = N : -1 : 1 for j = 0 : i-1 oilp(j+1) = exp(-r*deltaT) * ( oilp(j+1)*p + oilp(j+2)*(1-p) ); end oillattice(1:i,i) = oilp(1:i); end format short g oilp(1,1) oillattice

  5. Index Currency Option Notes

  6. Index Currency Option Notes - Code S = 102; r = 0.02; sigma = 0.102; T = 1; N = 10; deltaT = T/N; u = exp( sigma * sqrt(deltaT) ); d = 1/u; p = ( exp( r * deltaT ) - d ) / ( u - d ); for i = 0 : N currp(i+1) = S * u^(N-i) * d^(i); if currp(i+1)>169 currp(i+1) = 1000; elseifcurrp(i+1)<84.5 currp(i+1) = 0; else currp(i+1) = 1000-(1000*(169/currp(i+1)-1)) ; end end

  7. Index Currency Option Notes - Code (Conti.) for i = N : -1 : 1 for j = 0 : i-1 currp(j+1) = exp(-r*deltaT) * ( currp(j+1)*p + currp(j+2)*(1-p) ); end currlattice(1:i,i) = currp(1:i); end format short g currp(1,1) currlattice

  8. Trinomial Tree – Code function [ Cprice, Pprice, Clattice, Plattice] = triprice( S, K, r, T, sigma, lamda, N, mode ) % mode : 1=>American 0=>European deltaT = T/N; u = exp( lamda * sigma * sqrt(deltaT) ); d = 1/u; pu = 1/(2*lamda^2)+(r-(sigma^2/2))*sqrt(deltaT)/(2*lamda*sigma); pm = 1-1/(lamda^2); pd = 1-pu-pm; for i = 0 : 2*N Sl(i+1) = S * u^(N-i); C(i+1) = max( 0, S * u^(N-i) - K ); P(i+1) = max( 0, K - S * u^(N-i) ); end

  9. Trinomial Tree – Code (Conti.) for i = N-1:-1:0 for j = 1:2*i+1 C(j) = exp(-r*deltaT) * (pu*C(j) + pm*C(j+1) + pd*C(j+2)); P(j) = exp(-r*deltaT) * (pu*P(j) + pm*P(j+1) + pd*P(j+2)); if mode == 1 C(j) = max( C(j) , C(j+1) ); P(j) = max( P(j) , P(j+1) ); end end %C(1:2*i+1) Clattice(1:2*i+1,i+1) = C(1:2*i+1); Plattice(1:2*i+1,i+1) = P(1:2*i+1); end Cprice = C(1); Pprice = P(1);

  10. Trinomial Tree – Demo S = 50; K = 50; r = 0.02; T = 1; sigma = 0.2; lamda = 1.2; N = 100; [bc,bp] = blsprice(S,K,r,T,sigma); bls_c = ones(N) * bc; bls_p = ones(N) * bp; for i = 1:N [bit_c(i),bit_p(i)] = bitprice(S,K,r,T,sigma,i,0); [tri_c(i),tri_p(i)] = triprice(S,K,r,T,sigma,lamda,i,0); end

  11. Outcome

More Related