HW 11
HW 11
HW 11
103071509
SIGN
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
%CompSIGN
S = 400;
K = 336.69;
r = 0.1;
sigma = 0.2;
T = 1;
N = 5000;
for i = 1:200
bit(i) = SIGN_bit(i+300,K,r,sigma,T,N);
end
plot(301:500,bit)
for i = 1:200
bit(i) = SIGN_bit(S,i+300,r,sigma,T,N);
end
plot(301:500,bit)
European Call (Explicit)
% EuCallExpl1.m
function price =
EuCallExpl1(S0,X,r,T,sigma,Smax,dS,dt)
% set up grid and adjust increments if
necessary
M = round(Smax/dS);
dS = Smax/M;
N = round(T/dt);
dt = T/N;
matval = zeros(M+1,N+1);
vetS = linspace(0,Smax,M+1)';
vetj = 0:N;
veti = 0:M;
% set up boundary conditions
matval(:,N+1) = max(vetS-X,0);
matval(1,:) =0;
matval(M+1,:) = Smax-X*exp(-r*dt*(N-vetj));
% set up coefficients
a = 0.5*dt*(sigma^2*veti - r).*veti;
b = 1- dt*(sigma^2*veti.^2 + r);
c = 0.5*dt*(sigma^2*veti + r).*veti;
S0=50;
X=50;
r=0.1;
T=5/12;
sigma1=0.4;
sigma2=0.3;
Smax=100;
dS1=2;
dS2=1.5;
dS3=1;
dT=5/1200;
[c01,p04]=blsprice(S0,X,r,T,sigma1);
Exps01=EuCallExpl1(S0,X,r,T,sigma1,Smax,dS1,dT);
[c02,p03]=blsprice(S0,X,r,T,sigma2);
Exps02dS2=EuCallExpl1(S0,X,r,T,sigma2,Smax,dS1,dT);
ExpdS15=EuCallExpl1(S0,X,r,T,sigma2,Smax,dS2,dT);
ExpdS1=EuCallExpl1(S0,X,r,T,sigma2,Smax,dS3,dT);
c01
Exps01
c02
Exps02dS2
ExpdS15
ExpdS1
c01 =
6.1165
Exps01 =
-3.5813e+04
c02 =
4.8851
Exps02dS2 =
4.8697
ExpdS15 =
252.2526
European Call (Implicit)
% EuCallImpl.m
function price =
EuCallImpl(S0,X,r,T,sigma,Smax,dS,dt)
% set up grid and adjust increments if necessary
M = round(Smax/dS);
dS = Smax/M;
N = round(T/dt);
dt = T/N;
matval = zeros(M+1,N+1);
vetS = linspace(0,Smax,M+1)';
vetj = 0:N;
veti = 0:M;
% set up boundary conditions
matval(:,N+1) = max(vetS-X,0);
matval(1,:) = 0;
matval(M+1,:) =Smax-X*exp(-r*dt*(N-vetj));
% set up the tridiagonal coefficients matrix
a = 0.5*(r*dt*veti-sigma^2*dt*(veti.^2));
b = 1+sigma^2*dt*(veti.^2)+r*dt;
c = -0.5*(r*dt*veti+sigma^2*dt*(veti.^2));
S0=50;
X=50;
r=0.1;
T=5/12;
sigma=0.4;
Smax=100;
dS=2;
dT=5/2400;
[c,p]=blsprice(S0,X,r,T,sigma);
Impl=EuCallImpl(S0,X,r,T,sigma,Smax,dS,dT);
S0=50;
X=50;
r=0.1;
T=5/12;
sigma=0.4;
Smax=100;
dS=0.5;
dT=5/2400;
[c,p]=blsprice(S0,X,r,T,sigma);
Impl=EuCallImpl(S0,X,r,T,sigma,Smax,dS,dT);
c
Impl
c
Impl
c=
c=
6.1165
Impl =
6.1165
Impl =
5.6977
5.7185