Академический Документы
Профессиональный Документы
Культура Документы
Introduction
This is an introduction to the PDE method used for pricing European options. Everything comes from the book Numerical Methods in Finance and Economics by Paolo Brandimarte.
2.1
Black-Scholes PDE
Let f (S(t), t) denote the value at time t of an option written on an underlyin asset S(t). f 1 2f f + rS + 2 S 2 2 = rf. t S 2 S
2.2
Boundary Conditions
Terminal condition, f (S, T ) = max{S K, 0}, S [0, +], Left boundary, f (0, t) = 0, t [0, T ], Right boundary,
ST +
lim
Let S and Smax be the incremental interval and the maximum price price at time T , and t be the incremental interval for the time dimension. Numerically, we consider [0, T ] [0, Smax ]: t = 0, t, 2t, . . . , N t, S = 0, S, 2S, . . . , M S. Then, the above boundary conditions become fm,N = max{m S K, 0}, m = 1, . . . , M, f0,n = 0, n = 1, . . . , N, fM,n = M S Ker(T n)t . 2.2.2 Put Option
Terminal condition, f (S, T ) = max{K S, 0}, S [0, +], Left boundary, f (0, t) = Ker(T t) , t [0, T ], Right boundary,
ST +
lim
f (ST , t) = 0, t [0, T ].
Numerically, we consider [0 : t : T ] [0 : S : Smax ]. Then, the above boundary conditions become fm,N = max{K m S, 0}, m = 1, . . . , M, f0,n = Ker(T n)t , n = 1, . . . , N, fM,n = 0, n = 1, . . . , N.
2.3
2.3.1
f We approximate f by a backward nite dierence and S by a central nite t dierence. Then the Black-Scholes PDE can be approximated by
fm,n fm,n1 fm+1,n fm1,n 1 2 fm+1,n 2fm,n + fm1,n +r(mS) + (mS)2 = rfm,n . t 2S 2 (S)2 Since we know the terminal condition, we can solve for the option price f (S0 , 0) by backward recursion. From the above nite dierence approximation, we obtain an explicit scheme fm,n1 = am fm1,n + bm fm,n + cm fm+1,n , 2
Note that the explicit method is stable only if t < Mathlab Code
Essentially, we have dened a terminal condition for f (S, T ) = h(S). Through the above approximation, we aim to solve for f (S, 0). In the terminal price grid [0, Smax , the initial price S0 may not necessarily included. Therefore, we will need to interpolate from f (S, 0) for f (S0 , 0). function [call, put] = EuropeanOption_explicit_PDE(S0,K,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); matval_call = zeros(M+1,N+1); vetS = linspace(0,Smax,M+1); veti = 0:M; vetj = 0:N; % set up boundary conditions matval(:,N+1) = max(K-vetS,0); matval(1,:) = K*exp(-r*dt*(N-vetj)); matval(M+1,:) = 0; matval_call(:,N+1) = max(vetS - K, 0); matval_call(1,:) = 0; matval_call(M+1,:) = M*dS - K*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; % solve backward in time for j=N:-1:1 for i=2:M matval(i,j) = a(i)*matval(i-1,j+1) + b(i)*matval(i,j+1)+ ... c(i)*matval(i+1,j+1);
matval_call(i,j) = a(i)*matval_call(i-1,j+1) +... b(i)*matval_call(i,j+1)+ c(i)*matval_call(i+1,j+1); end end % return price, possibly by linear interpolation outside the grid put = interp1(vetS, matval(:,1), S0); call = interp1(vetS, matval_call(:,1), S0);
2.4
An Implicit Method
Alternatively, we can approximate the Black-Scholes PDE by fm+1,n fm1,n 1 2 fm+1,n 2fm,n + fm1,n fm,n+1 fm,n = rfm,n . +r(mS) + (mS)2 t 2S 2 (S)2 We obtain an implicit scheme am fm1,n + bm fm,n + cm fm+1,n = fm,n+1 , for m = 1, . . . , M 1 and n = 0, 1, . . . , N 1,where 1 am = t( 2 m2 rm) 2 bm = 1 + t( 2 m2 + r) 1 cm = t( 2 m2 + rm). 2 Here, three unknown values are linked to one known values. Note that for each time layer, there are M 1 equations in M 1 unknowns, the boundary conditions yield two missing values for each time layer, and the terminal conditions give the values in the last time layer. As in the explicit case, we go backward in time, solving a sequence of systems of linear equations for n = N 1, . . . , 0. The system for time layer n is f1,j b1 c 1 f1,j+1 a1 f0,j f2,j f2,j+1 a 2 b2 c 2 0 f3,j f3,j+1 a 3 b3 c3 0 . = . . .. .. . . . . . . . . fM 2,j fM 2,j+1 aM 1 bM 2 cM 2 0 aM 1 bM 1 fM 1,j fM 1,j+1 cM 1 fM,j We note that the matrix is tridiagonal and constant for each time layer n. We use the LU-factorization to solve the linear system. The implicit method is unconditionally stable for any t and S.
Matlab Code function [call, put] = EuropeanOption_implicit_PDE(S0,K,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); matval_call = zeros(M+1, N+1); vetS = linspace(0,Smax,M+1); veti = 0:M; vetj = 0:N; % set up boundary conditions matval(:,N+1) = max(K-vetS,0); matval(1,:) = K*exp(-r*dt*(N-vetj)); matval(M+1,:) = 0; matval_call(:,N+1) = max(vetS - K, 0); matval_call(1,:) = 0; matval_call(M+1,:) = M*dS - K*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)); coeff = diag(a(3:M),-1) + diag(b(2:M)) + diag(c(2:M-1),1); [L,U] = lu(coeff); % solve the sequence of linear systems aux = zeros(M-1,1); for j=N:-1:1 aux(1) = - a(2) * matval(1,j); % other term from BC is zero matval(2:M,j) = U \ (L \ (matval(2:M,j+1) + aux)); matval_call(2:M,j) = U \ (L \ (matval_call(2:M,j+1) + aux)); end % return price, possibly by linear interpolation outside the grid put = interp1(vetS, matval(:,1), S0); call = interp1(vetS, matval_call(:,1), S0);
2.5
Crank-Nicolson Method
The Crank-Nicolson method is a way to improve accuracy by combining the explicit and implicit methods. r(m S) fm+1,n fm1,n r(m S) fm+1,n1 fm1,n1 fm,n fm,n1 + + t 2 2S 2 2S 2 2 2 (m S) fm+1,n1 2fm,n1 + fm1,n1 (m S)2 fm+1,n 2fm,n + fm1,n + + 4 (S)2 4 (S)2 = rfm,n . These equations can be rewritten as m fm1,n1 +(1m )fm,n1 m fm+1,n1 = i fm1,n +(1+m )fm,n +m fm+1,n , where 1 t( 2 m2 rm) 4 1 i = t( 2 m2 + r) 2 1 i = t( 2 m2 + rm) 4 Consider a Down and Out barrier option. In this case, we need only to consider the domain S [Sb , Smax ], where Sb is the barrier level. The terminal condition is unchanged, and the left and right boundary conditions are i = f (Smax , t) = 0, f (Sb , t) = 0. Taking into account these boundary conditions, the above equation becomes M1 fj1 = M2 fj , where 1 1 2 M1 = 1 + 1 2 M2 = 1 1 2 3 2 1 3 .. . 3 .. . . M 2 ..
1 M 2 M 1
1 1 + 2 3
2 1 + 3 .. .
M 2 1 M 1
3 .. .
. M 2
..
1 + M 2 M 1
M 2 1 + M 1
and
Matlab Code function price = DOPutCK(S0,K,r,T,sigma,Sb,Smax,dS,dt) % set up grid and adjust increments if necessary M = round((Smax-Sb)/dS); dS = (Smax-Sb)/M; N = round(T/dt); dt = T/N; matval = zeros(M+1,N+1); vetS = linspace(Sb,Smax,M+1); veti = vetS / dS; vetj = 0:N; % set up boundary conditions matval(:,N+1) = max(K-vetS,0); matval(1,:) = 0; matval(M+1,:) = 0; % set up the coefficients matrix alpha = 0.25*dt*( sigma^2*(veti.^2) - r*veti ); beta = -dt*0.5*( sigma^2*(veti.^2) + r ); gamma = 0.25*dt*( sigma^2*(veti.^2) + r*veti ); M1 = -diag(alpha(3:M),-1) + diag(1-beta(2:M)) - diag(gamma(2:M-1),1); [L,U] = lu(M1); M2 = diag(alpha(3:M),-1) + diag(1+beta(2:M)) + diag(gamma(2:M-1),1); % solve the sequence of linear systems for j=N:-1:1 matval(2:M,j) = U \ (L \ (M2*matval(2:M,j+1))); end % return price, possibly by linear interpolation outside the grid price = interp1(vetS, matval(:,1), S0);