Lattice Oil Bond function price lattice Lattice Oil

• Slides: 13

Lattice. Oil. Bond function [price, lattice] = Lattice. Oil. Bond(S 0, r, T, sigma, N) delta. T = T/N; u=exp(sigma * sqrt(delta. T)); d=1/u; p=(exp(r*delta. T) - d)/(u-d); lattice = zeros(N+1, N+1); ST = zeros(N+1, N+1); for j=0: N ST(N+1, j+1)= S 0*(u^j)*(d^(N-j)); if(ST(N+1, j+1)<=25) lattice(N+1, j+1)=1000; elseif(25<ST(N+1, j+1)<40) lattice(N+1, j+1)=1000+(ST(N+1, j+1)-25)*170; else lattice(N+1, j+1)=1000+(40 -25)*170; end for i=N-1: 0 for j=0: i lattice(i+1, j+1) = exp(-r*delta. T) * (p * lattice(i+2, j+2) + (1 -p) * lattice(i+2, j+1)); end price = lattice(1, 1);

Lattice. Index. Currency. Option. Notes function [price, lattice] = Lattice. Index. Currency. Option. Notes(R 0, r, T, sigma, N) delta. T = T/N; u=exp(sigma * sqrt(delta. T)); d=1/u; p=(exp(r*delta. T) - d)/(u-d); lattice = zeros(N+1, N+1); RT = zeros(N+1, N+1); for j=0: N RT(N+1, j+1)= R 0*(u^j)*(d^(N-j)); if(RT(N+1, j+1)<=84. 5) lattice(N+1, j+1)=0; elseif(84. 5<RT(N+1, j+1)<169) lattice(N+1, j+1)=1000 -(1000*(169/RT(N+1, j+1)-1)); else lattice(N+1, j+1)=1000; end for i=N-1: 0 for j=0: i lattice(i+1, j+1) = exp(-r*delta. T) * (p * lattice(i+2, j+2) + (1 -p) * lattice(i+2, j+1)); end price = lattice(1, 1);

Comp. Bls. MCAVEur. Put S 0=50; X=52; r=0. 1; T=5/12; sigma=0. 4; NRepl 1=100000; NRepl 2=200000; [call, put]=blsprice(S 0, X, r, T, sigma); randn('seed', 0); [MC 200000, CI 1] = Bls. MCEur. Put(S 0, X, r, T, sigma, NRepl 2); randn('seed', 0); [MCAV 100000, CI 2] = Bls. MCAVEur. Put(S 0, X, r, T, sigma, NRepl 1); put MC 200000 CI 1 MCAV 100000 CI 2

Bls. MCAVEur. Put % Bls. MCAV. m function [Price, CI] = Bls. MCAVEur. Put(S 0, X, r, T, sigma, NRepl) nu. T = (r - 0. 5*sigma^2)*T; si. T = sigma * sqrt(T); Veps = randn(NRepl, 1); Payoff 1 = max( 0 , X-S 0*exp(nu. T+si. T*Veps)); Payoff 2 = max( 0 , X-S 0*exp(nu. T+si. T*(-Veps))); Disc. Payoff = exp(-r*T) * 0. 5 * (Payoff 1+Payoff 2); [Price, Var. Price, CI] = normfit(Disc. Payoff);

Bls. MCEur. Put % Bls. MCEur. Put. m function [Price, CI] = Bls. MCEur. Put(S 0, X, r, T, sigma, NRepl) nu. T = (r - 0. 5*sigma^2)*T; si. T = sigma * sqrt(T); Disc. Payoff = exp(-r*T) * max( 0 , X-S 0*exp(nu. T+si. T*randn(NRepl, 1))); [Price, Var. Price, CI] = normfit(Disc. Payoff);

MCIntegration: k=2 % MCIntegration: k=2 rand('seed', 0); N=1000; meanexp=zeros(1, N); for i=(1: N) meanexp(i)=mean(2*(exp(2*(rand(1, i))))); end exp=exp(2)-1 exp 10=meanexp(10) exp 100=meanexp(100) exp 1000=meanexp(1000) plot(1: N, meanexp); hold on; plot(1: N, exp, 'r');

Calculate PI rand('seed', 0); N=10000; n=0; X=rand(1, N); Y=rand(1, N); for i=1: N if (X(1, i)^2+Y(1, i)^2<=1) n=n+1; end PI=4*(n/N); PI