1 / 11

HW12

HW12. 100071021. Barrier Option (Conditioning). function [ c, p ] = BO_CD ( S0,K,r,T,sigma,Sb,ud,io,NRepl,NStep ) [ cw , pw] = blsprice (S0,K,r,T,sigma); dt = T / NStep ; Ncross = 0; C_Payoffs = zeros (NRepl,1); P_Payoffs = zeros (NRepl,1); Times = zeros (NRepl,1);

brac
Download Presentation

HW12

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. HW12 100071021

  2. Barrier Option (Conditioning) function [ c, p ] = BO_CD ( S0,K,r,T,sigma,Sb,ud,io,NRepl,NStep ) [cw, pw] = blsprice(S0,K,r,T,sigma); dt = T / NStep; Ncross = 0; C_Payoffs = zeros(NRepl,1); P_Payoffs = zeros(NRepl,1); Times = zeros(NRepl,1); StockVals = zeros(NRepl,1); for i = 1 : NRepl Path = AssetPaths( S0,r,sigma,T,NStep,1); if ud == 0 % up tcross = min(find(Path >= Sb)); else % down tcross = min(find(Path <= Sb)); end if not(isempty(tcross)) Ncross = Ncross + 1; Times(Ncross) = (tcross-1) * dt; StockVals(Ncross) = Path(tcross); end end

  3. if Ncross>0 [Caux, Paux] = blsprice(StockVals(1:Ncross),K,r,T-Times(1:Ncross),sigma); C_Payoffs(1:Ncross) = exp(-r*Times(1:Ncross)) .* Caux; P_Payoffs(1:Ncross) = exp(-r*Times(1:Ncross)) .* Paux; end if io == 0 % in c = mean(C_Payoffs); p = mean(P_Payoffs); else % out c = mean(cw - C_Payoffs); p = mean(pw - P_Payoffs); end end

  4. Demo code %demo for BO S0=50; K=52; r=0.1; T=2/12; sigma=0.4; Sb=60; NStep=60; NRepl=200; mccd_cui = zeros(NRepl,1); for i = 1 : NRepl mccd_cui(i) = BO_CD(S0,K,r,T,sigma,Sb,0,0,i*1000,60); end plot(1:NRepl,mccd_cui);

  5. SIGN without Puttable (Monte Carlo) function [ payoff, var, CI ] = SIGN_MC( S,K,r,sigma,T,NRepl ) Days = T * 250; Payoffs = zeros(NRepl,1); Paths = AssetPaths(S,r,sigma,T,Days,NRepl); for i = 1 : NRepl Pm = mean( Paths(i,Days-32:Days-2) ); if Pm >= K Payoffs(i) = 10 * (1+(Pm-K)/K); else Payoffs(i) = 10; end end [payoff, var, CI] = normfit(Payoffs); end

  6. SIGN as European (Binomial Tree) function [ payoff, lattice ] = SIGN_bit( S0, K, 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 P = S0 * u^(N-i) * d^(i); S(i+1) = 10; if P > K S(i+1) = 10 * (1+(P-K)/K); end end for i = N : -1 : 1 for j = 0 : i-1 S(j+1) = max(10, exp(-r*deltaT) * ( S(j+1)*p + S(j+2)*(1-p) ) ); end lattice(1:i,i) = S(1:i); end payoff = S(1); end

  7. Demo code %demo for SIGN S = 400; K = 336.69; r = 0.1; sigma = 0.2; T = 1; N = 5000; for i = 1:200 MC(i) = SIGN_MC(i+300,K,r,sigma,T,N); bit(i) = SIGN_bit(i+300,K,r,sigma,T,N); end plot(301:500,MC,301:500,bit)

  8. for i = 1:200 MC(i) = SIGN_MC(S,i+300,r,sigma,T,N); bit(i) = SIGN_bit(S,i+300,r,sigma,T,N); end plot(301:500,MC,301:500,bit)

More Related