You are on page 1of 23

Option pricing by finite difference methods

Implicit methods

Alvaro M. Bossio Castro

Brno University of Tecnology


Department of Mathematics

07.01.2019
Table of Content

1 Basic concepts

2 Pricing of a Vanilla European Option by implicit methods


Mathematical formulation of the problem
Numerical setup
Matlab implementation
Results

3 Bibliography
Basic concepts

Option
It’s a contract which gives to its owner, called holder or buyer,
the right to buy or to sell at a fixed price, called strike or exercise
price, a specified underlying asset, like a stock, an index, or a
foreign currency, any time before or just on a specific date, called
expiry or maturity date. There are many different types:
CALL or PUT if they allow you to buy or to sell, respectively.
Exotic or vanilla if the final pay-off depends on the history of the
asset or not, respectively .
American or European if it is allowed to exercise the option before
the expiry date or not, respectively.
Basic concepts
Cont.

Options pricing – Black-Scholes equation


Suppose we have a portfolio Π formed by a short option position
and ∆ units of the asset itself:

Π = ∆S − f (S, t) (1)
We want to estimate the rate of change of the portfolio, so let’s
compute dΠ:

dΠ = ∆dS − df (2)
If the asset follows a lognormal or geometric brownian motion then
we know that dS = µSdt + σSdW , where µ is the drift of the
motion and σ is the volatility, so by Itô’s lemma we have:

1 2 2 ∂2f
   
∂f ∂f
dΠ = ∆ − dS − + σ S dt (3)
∂S ∂t 2 ∂S 2
Basic concepts
Cont.

In order to make this portfolio riskless, we may choose:

∂f
∆= (4)
∂S
This is called hedging. So we are left with:

1 2 2 ∂2f
 
∂f
dΠ = − + σ S dt (5)
∂t 2 ∂S 2
Now, since the portfolio is now riskless, this investment must be
equivalent to putting that money on a risk-less bank account
(no-arbitrage principle)

dΠ = Πrdt (6)
Where r is the risk-less interest rate.
Basic concepts
Cont.

Now we can substitute finally Eq. 1, Eq. 4 and Eq. 5 here and get
the famous Black-Scholes equation:

∂f ∂f 1 ∂2f
+ rS + σ 2 S 2 2 = rf (Black-Scholes equation)
∂t ∂S 2 ∂S
(7)
Basic concepts
Cont.

Finite difference method


The main idea is that we may approximate derivatives considering
a very small but finite differences, there are several approaches:
Forward difference
df fi+1 − fi
(xi ) ≈ , i : 0, 1, ..., N − 1. (8)
dx δx
Backward difference
df fi − fi−1
(xi ) ≈ , i : 1, ..., N. (9)
dx δx
Central difference
df fi+1 − fi−1
(xi ) ≈ , i : 1, ..., N − 1. (10)
dx 2δx
Basic concepts
Cont.

In a similar way we may approximate higher order derivatives using


approximation of lower order ones, for instance second order
derivative may be approximated by:

d 2f
 
1 fi+1 − fi fi − fi−1 fi+1 − 2fi + fi−1
2
(x0 = xi ) ≈ − =
dx δx δx δx δx 2
(11)
Pricing of a Vanilla European Option by implicit methods
Mathematical formulation of the problem

Mathematical formulation of the problem


Let f (S, t) be the price of the option, where S(t) is some
stochastic process representing the price of the underlying asset
(e.g. the price of some stock) and t is time. As seen the the
previous section, the price of the option follows the partial
differential equation known as Black-Scholes equation, which is:

∂f ∂f 1 ∂2f
+ rS + σ 2 S 2 2 = rf (Black-Scholes equation)
∂t ∂S 2 ∂S
(12)
Pricing of a Vanilla European Option by implicit methods
Mathematical formulation of the problem

Regarding boundary conditions:


Call option

∂f ∂f 1 2 2 ∂ 2 f
+rS + σ S = rf (Black-Scholes equation)
∂t ∂S 2 ∂S 2
f (S, T ) = (S−K )+ = max(S−K , 0) (Terminal condition)
−r (T −t)
f (0, t) = 0, f (Smax , t) = Smax −Ke (Boundary conditions)
Put option

∂f ∂f 1 2 2 ∂ 2 f
+rS + σ S = rf (Black-Scholes equation)
∂t ∂S 2 ∂S 2
f (S, T ) = (K −S)+ = max(K −S, 0) (Terminal condition)
f (0, t) = Ke −r (T −t) , f (Smax , t) = 0 (Boundary conditions)
Pricing of a Vanilla European Option by implicit methods
Numerical setup

Numerical setup
First of all, we need to discretize the domain, so we construct a
grid whose nodes are coordinates formed by the Cartesian product
of the sequences:

S = (0, δS, 2δS, ..., MδS = Smax )


and

t = (0, δt, 2δt, ..., Nδt = T )


We will denote Si = iδS and tj = jδt, and following this notation,
we call fi,j = f (Si , tj ).
Pricing of a Vanilla European Option by implicit methods
Numerical setup

Now we need to approximate the differential equation by finite


difference, here we have an important decision to make about the
type of approximation. In this case we choose a forward
difference approach for the time derivative, and central
difference for the asset price derivative:

fi,j+1 − fi,j fi+1,j − fi−1,j 1 2 2 2 fi+1,j − 2fi,j + fi−1,j


+riδS + σ i δS = rfi,j
δt 2δS 2 δS 2
(13)
Rearranging the terms we may write this equation as follows:
   
1 1 1 1
riδt − σ 2 i 2 δt +fi,j 1 + σ 2 i 2 δt + r δt +fi+1,j − riδt − σ 2 i 2 δt = fi,j+1

fi−1,j
2 2 | {z } 2 2
| {z } bi | {z }
ai ci
(14)
Pricing of a Vanilla European Option by implicit methods
Numerical setup

So setting, this equation for each asset price at some time tj we


get the following system:

b1 c1 f1,j f1,j+1 a1 f0,j


      
 a2 b2 c2  f2,j   f2,j+1   0 
.. .. .. .. .. ..
      
      

 . . . 
 .  
  .  
  . 

 ai bi ci  f i, j = f i, j + 1 −  0 
      
 .. .. ..  ..  .
..
  .
..


 . . . 
 . 
 
 
 


 aM−2 bM−2 cM−2   fM−2,j   fM−2,j+1   0 
aM−1 bM−1 fM−1,j fM−1,j+1 cM−1 fM,j
| {z } | {z } | {z } | {z }
A F(j) F(j+1) b(j)
(15)

And finally we can solve for F (j) as:

F (j) = A−1 (F (j + 1) − b(j)) (16)


Pricing of a Vanilla European Option by implicit methods
Matlab implementation

MATLAB implementation
Following the previously described strategy. We implement this
method to replicated the example shown by Wilcott in his section
28.12: The Code#1: European option on [2]. In his example
Wilcott tries to compute the price of an option with the following
features for different times.

Type of option Call


Interest rate (r) 5%
Volatibity (σ) 20%
Maturity time (T) 1 year
Strike price (K) 100 USD
Pricing of a Vanilla European Option by implicit methods
Matlab implementation

The code used is shown below:

1 %%%%%% F i n i t e d i f f e r e n c e method − I m p l i c i t %%%%%%%%


2 %%%%%%%%%%%%% E u r o p ea n O p t i o n s %%%%%%%%%%%%%%%%%%%%
3 t y p= ’C ’ ;
4 %%%% Choose t h e t y p e o f o p t i o n ”C” f o r C a l l and ”P” f o r
Put .
5
6 %I n i t i a l parameters
7 r =.05;
8 sigma =.2;
9 Smax=200;
10 T=1;
11 K=100;
12
13 %D i s c r e t i z a t i o n o f t h e domain
14 N=9;
15 M=99;
16 d t=T/N ;
17 dS=Smax/M;
Pricing of a Vanilla European Option by implicit methods
Matlab implementation

1 t =0: d t : T ;
2 S=0: dS : Smax ;
3
4 %T e r m i n a l c o n d i t i o n and b o u n d a r y c o n d i t i o n s
5 F=z e r o s (M+1 ,N+1) ;
6 i f t y p==’C ’
7 f o r i =1: l e n g t h ( S )
8 F ( i , N+1)=max ( [ S ( i )−K , 0 ] ) ;
9 end
10 f o r j =1: l e n g t h ( t )
11 F ( 1 , j ) =0;
12 F (M+1 , j )=Smax−K∗ exp (− r ∗ (T−t ( j ) ) ) ;
13 end
14 e l s e i f t y p==’P ’
15 f o r i =1: l e n g t h ( S )
16 F ( i , N+1)=max ( [ K−S ( i ) , 0 ] ) ;
17 end
18
Pricing of a Vanilla European Option by implicit methods
Matlab implementation

1 f o r j =1: l e n g t h ( t )
2 F ( 1 , j )=K∗ exp (− r ∗ (T−t ( j ) ) ) ;
3 F (M+1 , j ) =0;
4 end
5 else
6 s p r i n t f ( ’ P l e a s e choose a v a l i d type between C f o r
c a l l s and P f o r p u t s ’ )
7 return
8 end
9
10 %C o n s t r u c t i o n o f m a t r i x A
11 a =0.5∗ r ∗ d t /dS∗S ( 2 :M) −.5∗( s i g m a ˆ 2 ) ∗ d t / ( dS ˆ 2 ) ∗ ( S ( 2 :M) . ˆ 2 )
;
12 b=1+r ∗ d t +( s i g m a ˆ 2 ) ∗ d t / ( dS ˆ 2 ) ∗ ( S ( 2 :M) . ˆ 2 ) ;
13 c =−.5∗ r ∗ d t /dS∗S ( 2 :M) −.5∗( s i g m a ˆ 2 ) ∗ d t / ( dS ˆ 2 ) ∗ ( S ( 2 :M) . ˆ 2 )
;
14 A=d i a g ( b )+d i a g ( a ( 2 :M−1) , −1)+d i a g ( c ( 1 :M−2) , 1 ) ;
15
16 %S o l u t i o n o f t h e s y s t e m
Pricing of a Vanilla European Option by implicit methods
Matlab implementation

1 %S o l u t i o n o f t h e s y s t e m
2 f o r j=N: −1:1
3 b=[ a ( 1 ) ∗F ( 1 , j ) ; z e r o s (M−3 ,1) ; c (M−1)∗F (M+1 , j ) ] ;
4 F ( ( 2 :M) , j )=A\ ( F ( ( 2 :M) , j +1)−b ) ;
5 end
6
Pricing of a Vanilla European Option by implicit methods
Results

Using the previous code we found the value of the option given the
price of the underlying asset at different times. Below the
distribution of the option value for different asset price and
different times is shown:

Figure: Option value for different asset prices and times


Pricing of a Vanilla European Option by implicit methods
Results

Option value vs asset price for different times


Now we show some cuts of the previous graph, where we can see
how the option value varies with asset price for different fixed
times:
Bibliography

DUPAČOVÁ, Jitka; HURT, Jan; ŠTĚPÁN, Josef. Stochastic


Modeling in Economics and Finance. Kluwer Academic
Publishers, 2002.
WILCOTT, Paul. Paul Wilcott introduces quantitative finance
(2nd edition). John Wiley & Sons, 2007.
BRANDIMARTE, Paolo. Numerical Methods in Finance and
Economics: A MATLAB-Based Introduction. John Wiley &
Sons; Hoboken, NJ, 2006.
Thanks for your attention.

You might also like