1 / 16

HW8

HW8. 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 oilp (i+1) = 25;

Download Presentation

HW8

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. HW8

  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. Monte Carlo Put Option function [ cp, pp, CIc, CIp] = blsMC( S, K, r, T, sigma, NRepl ) nuT = (r - 0.5*sigma^2) * T; siT = sigma * sqrt(T); c_payoffs = exp(-r*T) * max(0, S*exp(nuT + siT*randn(NRepl,1)) -K ); p_payoffs = exp(-r*T) * max(0, K - S*exp(nuT + siT*randn(NRepl,1)) ); [cp, varc, CIc] = normfit(c_payoffs); [pp, varp, CIp] = normfit(p_payoffs); end

  9. Demo S = 50; K = 50; r = 0.1; T = 1; sigma = 0.2; lamda= 1.2; [blsout_c, blsout_p] = blsprice(S,K,r,T,sigma); bls = ones(100) * blsout_p; for i = 1:100 [bitc(i), bitp(i)] = bitprice(S,K,r,T,sigma,i,0); [tric(i), trip(i)] = triprice(S,K,r,T,sigma,lamda,i,0); [MCc(i), MCp(i), temp1,temp2] = blsMC(S,K,r,T,sigma,i*100); CId(i) = temp2(2)-temp2(1); end

  10. Cash or Nothing function [ cp, pp ] = blsMC2( S, K, C, r, T, sigma, NRepl) nuT = (r - 0.5*sigma^2) * T; siT = sigma * sqrt(T); pvC = exp(-r*T) * C; Stock = S*exp(nuT + siT*randn(NRepl,1)); for i = 1:NRepl c_payoffs(i) = 0; p_payoffs(i) = 0; if Stock(i) > K c_payoffs(i) = pvC; elseif Stock(i) < K p_payoffs(i) = pvC; end end [cp, varc, CIc] = normfit(c_payoffs); [pp, varp, CIp] = normfit(p_payoffs); end

  11. Demo S = 50; K = 50; C = 10; r = 0.1; T = 1; sigma = 0.2; NRpel= 10000; for TS = 1:100 [MC1c(TS), MC1p(TS)] = blsMC2(TS,K,C,r,T,sigma,NRpel); End figure; plot(MC1c); hold on; plot(MC1p,'color',[1 0 0.5]); title('Cash or Nothing');

More Related