Professional Documents
Culture Documents
103071509
LatticeEurPut.m
function [price, lattice] = LatticeEurPut(S0,X,r,T,sigma,N)
deltaT = T/N;
u=exp(sigma * sqrt(deltaT));
d=1/u;
p=(exp(r*deltaT) - d)/(u-d);
lattice = zeros(N+1,N+1);
for j=0:N
lattice(N+1,j+1)=max(0 , S0*(u^j)*(d^(N-j)) - X);
end
for i=N-1:-1:0
for j=0:i
lattice(i+1,j+1) = exp(-r*deltaT) * ...
(p * lattice(i+2,j+2) + (1-p) * lattice(i+2,j+1));
end
end
price = lattice(1,1);
CompLatticeBLSPut.
m
% CompLatticeBLSPut.m
S0 = 60;
X = 60;
r = 0.05;
sigma = 0.4;
T = 0.5;
N=60;
BlsP = blsprice(S0,X,r,T,sigma);
LatticeP = zeros(1,N);
for i=(1:N)
LatticeP(i) = LatticeEurPut(S0,X,r,T,sigma,i);
end
plot(1:N, ones(1,N)*BlsP);
hold on;
plot(1:N, LatticeP)
LatticeEurPut vs.BLS
S0 = 50;
X = 50;
r = 0.1;
sigma = 0.4;
T = 5/12;
N=50;
BlsP = blsprice(S0,X,r,T,sigma);
LatticeP = zeros(1,N);
for i=(1:N)
LatticeP(i) = LatticeEurPut(S0,X,r,T,sigma,i);
end
plot(1:N, ones(1,N)*BlsP);
hold on;
plot(1:N, LatticeP);
title('LatticeEurPut v.s BLS')
LatticeAmCall
vs.BLS
S0 = 50;
X = 50;
r = 0.1;
sigma = 0.4;
T = 5/12;
N=50;
BlsC = blsprice(S0,X,r,T,sigma);
LatticeC = zeros(1,N);
for i=(1:N)
LatticeC(i) = LatticeAmCall(S0,X,r,T,sigma,i);
end
plot(1:N, ones(1,N)*BlsC);
hold on;
plot(1:N, LatticeC);
title('compare LatticeAmCall to bls')
Bull spread
S0=30:1:90;
for T=2:-0.25:0
[C1,P1]=blsprice(S0,50,0.05,T,0.
3);
[C2,P2]=blsprice(S0,60,0.05,T,0.
3);
plot(S0,C1-C2);
hold on;
End
%Bull_spread
S0=30:1:90;
for T=2:-0.25:0
[C1,P1]=blsprice(S0,40,0.05,T,0.5);
[C2,P2]=blsprice(S0,50,0.05,T,0.5);
plot(S0,P1-P2);
hold on;
end
Bear spread
%Bear_spread
S0=30:1:90;
for T=2:-0.25:0
[C1,P1]=blsprice(S0,40,0.05,T,0.
5);
[C2,P2]=blsprice(S0,50,0.05,T,0.
5);
plot(S0,C2-C1);
hold on;
end
%Bear_spread
S0=30:1:90;
for T=2:-0.25:0
[C1,P1]=blsprice(S0,40,0.05,T,0.5);
[C2,P2]=blsprice(S0,50,0.05,T,0.5);
plot(S0,P2-P1);
hold on;
end
Butterfly
spread
%Butterfly_spread
S0=30:1:90;
for T=2:-0.25:0
[C1,P1]=blsprice(S0,40,0.05,T,0
.5);
[C2,P2]=blsprice(S0,50,0.05,T,0
.5);
[C3,P3]=blsprice(S0,60,0.05,T,0
.5);
plot(S0,C1-2*C2+C3);
hold on;
end
%Butterfly_spread
S0=30:1:90;
for T=2:-0.25:0
[C1,P1]=blsprice(S0,40,0.0
5,T,0.5);
[C2,P2]=blsprice(S0,50,0.0
5,T,0.5);
[C3,P3]=blsprice(S0,60,0.0
5,T,0.5);
plot(S0,P1-2*P2+P3);
hold on;
end