You are on page 1of 27

Delft University of Technology

Review of the Carr-Madan Method

George K. Inkoom (4004817)


August 16, 2014

Contents
1 Review of the Carr-Madan method
1.1 Option Valuation with Carr-Madan method . . . . . . . . . . . . . . . . .

4
4

2 Carr-Madans result presented in Table 1

3 Carr-Madan result presented in Table 2

10

4 Carr-Madan result presented in Table 6

12

5 Carr-Madan result for H1-HW model

14

Introduction
In this paper, we discuss the Carr-Madan method, which is an option pricing method
for European options based on Fast-Fourier transform. In particular, we review the
theoretical aspects of the Carr-Madan method and also reproduce the Carr-Madan results obtained by the numerical experiment performed in [Fang and Oosterlee, 2008]
and [Grzelak and Oosterlee, 2009].
The paper is organized as follow: In Section 1, we review the theoretical aspects of
Carr-Madan method, reproduce the Carr-Madan results presented in Table 1, 2 and 6
of [Fang and Oosterlee, 2008] in section 2, 3 and 4 respectively. In section 5, we perform
a numerical experiment using the Carr-Madan method to price European option under
the H1-HW model.
Note that most of this report refers to [Fang and Oosterlee, 2008], [Carr and Madan,
1999], [Kienitz and Wetterau, 2012], [Ng, 2005] and [Grzelak and Oosterlee, 2009].

1 Review of the Carr-Madan method


In this section, we discuss the Fourier-inversion technique proposed by Carr & Madan in
1999 called the Carr-Madan method. The Carr-Madan method rely on a transformation
to the Fourier domain and on the availability of the (discounted) characteristic function
of the logarithm of the stock price. In fact, in many situations, the characteristic function
for a wide class of stock models are analytically obtainable even if the risk-neutral density
themselves are not always available explicitly.
The Carr-Madan method ensures that the Fourier transform of the European option
prices exist by the inclusion of an exponential damping factor. Furthermore, singularities
are removed by the damping factor and also European option prices are computed by
FFT algorithm.

1.1 Option Valuation with Carr-Madan method


Consider the problem of valuing a European call of maturity T under different assumptions of the underlying assets model.
Let ST denote the stock price at maturity T of an underlying asset of an European
call option with strike price K. Further, define k log(K) as the log of the strike price
K, sT log(ST ) as the log asset price at time T and fT (s) as the risk neutral density
of the log asset price, sT , under the Q-measure. Then, the characteristic function of the
risk neutral density of the log asset price is given as:

eius fT (s) ds

T (u) =

(1)

The initial European call price, C(K, T ), related to the risk neutral density, fT (s),
is then given by:
C(K, T ) = erT EQ [max{ST K, 0}]
= erT EQ [max{esT ek , 0}]
Z
max{esT ek , 0}fT (sT ) dsT
= erT
Z

(esT ek )fT (sT ) dsT


= erT

(2)

Note that the initial European call price, C(ek , T ), is not in L1 for a given maturity
T , since
lim C(K, T ) = lim C(ek , T ) = S0

K0

(3)

and thus does not tend to zero for k .


However, to assure integrability, we introduce a damping parameter, R. We
then consider the following modified call price:
c(k, T ) ek C(ek , T ),

for > 0.

(4)

Note that the choice for > 0 is to ensure the existence of the Fourier transform of
c(k, T ) which we will discuss later.
For > 0, we expect c(k, T ) L1 , the space of integrable functions and so therefore
we have that the Fourier transform of c(k, T ) is well-defined and given as:
Z
\
T,call (v) c(k, T ) =
eivk c(k, T ) dk
(5)

Inverting gives
1
c(k, T ) =
2

eivk T,call (v) dv

(6)

Then the initial European call price value is equivalent to


Z
e log(K) iv log(K)
C(K, T ) = e log(K) c(k, T ) =
e
T,call (v) dv
2

Z

e log(K)  iv log(K)
=
e
T,call (v) dv
<

(7)

The expression for T,call (v) which is the Fourier transform of c(k, T ) can be written
as follow:
Z
Z
ivk
T,call (v) =
e c(k, T ) dk =
eivk ek C(ek , T ) dk
Z
Z



(iv+)k
rT
(esT ek )fT (sT ) dsT dk
=
e
e
k

Z

Z s T
e(iv+)k (esT ek ) dk dsT
fT (sT )
= erT

Z sT
Z
Z sT



e(iv++1)k dk dsT
fT (sT ) esT
e(iv+)k dk
= erT

Z
 h 1
h
isT
i sT 

1
fT (sT ) esT
= erT

e(iv+)k
e(iv++1)k
dsT
iv +
iv + + 1

(8)
Since for > 0, we have that
lim |e(iv+)k | = lim |e(iv++1)k | = lim e(+1)k = 0

(9)

Equation (8) becomes


T,call (v) = erT
=

fT (sT )

h e(iv+)sT

iv +

rT
e
T (v ( + 1)i)
2
+ v 2 + i(2 + 1)v

e(iv++1)sT i
dsT
iv + + 1

So finally the initial European call price value is:


Z

ek  ivk
C(k, T ) =
<
e T,call (v) dv

0
where
T,call (v) =

erT T (v ( + 1)i)
.
2 + v 2 + i(2 + 1)v

(10)

(11)

(12)

In particular, a sufficient condition for the modified call value to be in L1 is provided


by T,call (0) being finite. However, form equation (4), we observe that T,call (0) is finite
provided that T (( + 1)i) is finite. From the definition of the characteristic function,
this requires that:
E[ST+1 ] < .
We show the proof below as Lemma.
Lemma: Let > 0. Then the Fourier transform of c(k, T ) exists (i.e. c(k, T ) L1 ),
if E[ST+1 ] < .

Proof. First note that E[ST+1 ] < implies


T,call (0) < ,
since
|T,call (0)| =

erT E[ST+1 ]
erT |T (( + 1)i)|
=
2 +
2 +

(13)

(14)

where the last equality of equation (14) follows from


|T (( + 1)i)| = |E[e(+1)i log(ST ) ]| = |E[e(+1)i log(ST ) ]| = E[ST+1 ]

(15)

However, we also have the equality:


Z

T,call (0) =

c(k, T ) dk.

(16)

which follows from equation (5). Combining equation (16) with equation (13) completes the proof.
We numerically evaluate the initial European call price value, C(K,T), by approximating the integral in terms of a sum by applying the trapezoidal integration rule. Now,
define g(v) eivk T,call (v), the trapezoidal rule over domain [0, D] then yields
Z

N 1

g(v) dv
0

i
X
h
g(v1 ) + 2
g(vn ) + g(vN )
2
n=2

N
hX
n=1

(17)

i
1
g(vn ) (g(v1 ) + g(vN ))
2

where D is the effective upper limit for the integration which is defined as:
D = N .
Let
vn = (n 1); and ku = b + (u 1).
where n = 1, 2, . . . , N is the grid in the v-domain and u = 1, 2, . . . , N to be the grid
in the k-domain.
Also, we choose the constant b as b = N2 , such that the grid is laid around atthe-money strikes since we are mainly interested in at-the-money option values; which
correspond to k log(K) near 0. Substituting the expression for vn and ku in equation
(17) (recall that g(v) eivk T,call (v)) yields

g(v) dv
0

N
hX
n=1

N
hX
n=1
N
hX
n=1
N
hX
n=1
N
hX

i
1
ei[b+(u1)][(n1)] T,call (vn ) (g(v1 ) + g(vN ))
2
i
1
eib(n1)i(n1)(u1) T,call (vn ) (g(v1 ) + g(vN ))
2
i
1
ei(n1)(u1) eib(n1) T,call (vn ) (g(v1 ) + g(vN ))
2

(18)

i
2
1
ei N (n1)(u1) eibvn T,call (vn ) (g(v1 ) + g(vN ))
2
(n1)(u1)

n=1

i
1
[eibvn T,call (vn )] (g(v1 ) + g(vN ))
2

where the last two equalities of equation (18) hold, since we respectively set
=

2
;
N

and

N = ei N .

Note that equation (18) is written in the form of Fast-Fourier transform (FFT). So,
therefore FFT can be utilized to evaluate the sum given in equation (18), provided that
g(v1 ) = g(vN ) exists. Also, note that the FFT is an efficient algorithm for computing
the sum of the form:
w(k) =

N
X

ei N (j1)(l1) xj ,

for l = 1, 2, . . . , N

(19)

j=1

where N representing the number of grid points is typically a power of 2. This


algorithm only requires O(N log2 (N )) arithmetic operations.
So, the approximation of C(k,T) for the Carr-Madan inversion is:
C(ku , T )

N
io
eku n hX (n1)(u1) ibvn
1
<
N
[e T,call (vn )] (g(v1 ) + g(vN ))

(20)

n=1

where we have imposed the Nyquist relation to the grid size in the v- and k-domains,
=

2
.
N

Note that to increase the accuracy of the approximation, one can apply the Simpsons
integration rule instead of the trapezoidal integration rule. In similar manner as above,

one can easily show that in the case of Simpsons integration rule we have
C(ku , T )

N
o
eku nX (n1)(u1) ibvn

<
N
[e T,call (vn ) (3 + (1)n n1 ] ,

(21)

n=1

where n1 is the Kronecker delta function that equals one whenever n = 1 and zero
otherwise. The approximation given above for both numerical integration rule can be
computed efficiently using the FFT in Matlab.
Note that we have only discussed the pricing of European call options by the CarrMadan method above. However, one can also obtain the prices of European put options
by the Carr-Madan method by choosing a negative value for . In particular, for the
European put option price, P (K, T ), we consider the modified put option:
p(k, T ) ek P (ek , T ),

for > 0.

(22)

Then the Fourier transform for the modified put option is given as:
T,put (u) =

erT T,call (u ( + 1)i)


.
2 u2 + i(2 + 1)u

(23)

2 Carr-Madans result presented in Table 1


In this section, we reproduce the results presented in Table 1 of [Fang and Oosterlee,
2008] for the Carr-Madan method. In fact, we use the trapezoidal integration rule
combined with the FFT algorithm to solve the inverse Fourier integral. The inverse
Fourier integral is given as:
Z
Z

1
1  iwx
iwx
f (x) =
e
(w) dw = <
e
(w) dw ,
(1)
2

0
We consider the following function, which is the probability density function of the
standard normal distribution, given by
1 2
1
f (x) = e 2 x ,
2

(2)

and determine the accuracy for the different values of N .


The characteristic function of the standard normal distribution is given as:


1
(w) = exp iw 2 w2 .
2

(3)

We recover the density function given above by approximating the integral given in
equation (1) of this section in terms of a sum by applying the trapezoidal integration rule
combined with the FFT algorithm. Note that the effective upper limit for the integration
in this case is D = 20 and we measure the maximum error at x = {5, 4, . . . , 4, 5}.
We use a truncation rang of size [0, 20]
Table 2.1 presents the Carr-Madan results for recovering the density function given
above. Note the all cpu times presented, in (milli)seconds, are determined after averaging the computing times obtained from 100 experiments. The computer used for the
experiments has Intel(R) Core(TM) i5 CPU, M 520 2.40GHz and the code is written in
Matlab R2013b. See Appendix for the Matlab code used for this experiment.
N
Max. error
cpu time (in seconds)

4
0.80222
2.33676e-04

8
7.23068
2.35292e-04

16
0.77663
2.47339e-04

32
3.55850e-05
2.53788e-04

64
8.72502e-06
6.76044e-04

Table 2.1: Cpu time and maximum error when recovering f (x) from (w) by Carr-Madan
method.
Looking at the values presented in Table 2.1, it seems strange that the value for
N = 8 is so high. This may be due to the choice of the truncation range or some mistake
in the code but I havent found any mistake yet in the Matlab code. However, we see
that the maximum error decreases for larger values of N , while the cpu time increases
for larger values of N .

3 Carr-Madan result presented in Table 2


In this section we discuss the experiment performed in section 5.2 of [Fang and Oosterlee, 2008]. In fact, we use the Carr-Madans method to price European call options
under the Geometric Brownian Motion (GBM) process for three different strike prices.
Furthermore, the call option experiment is performed under the GBM process with a
short time to maturity and we check the convergence bahaviour at three different strike
prices, namely K = 80, 100 and 120.
We use the same parameters as given in [Fang and Oosterlee, 2008] for the experiment
and also assume for this experiment that the damping factor, , in the Carr-Madans
method to be = 0.75 as in [Fang and Oosterlee, 2008]. Note that the results for these
strikes are obtained in one single numerical experiment and also we use a truncation rang
of size [0, 100]. Moreover, the reference values are obtained using the built-in function
blsprice in Matlab.

10

The characteristic function of the log-asset price for the GBM is given by:


1
1
GBM (u) = exp iu log(S0 ) + iu(r 2 ) 2 u2 ,
2
2

(1)

where = T t0 = T 0 = T .
The parameters used for this test are:
S0 = 100, r = 0.1, q = 0, T = 0.1, = 0.25.
The reference value corresponding to the three different strike prices are given in
Table 3.1.
Strike Price
80
100
120

Reference Value
20.799226308673340
3.659968453325448
0.044577814073288

Table 3.1: The reference value corresponding to the three different strike prices.

Table 3.2 shows the Carr-Madans results for pricing European calls under GBM
process. Note the all cpu times presented, in (milli)seconds, are determined after averaging the computing times obtained from 100 experiments. The computer used for the
experiments has Intel(R) Core(TM) i5 CPU, M 520 2.40GHz and the code is written in
Matlab R2013b. See Appendix for the Matlab code used for this experiment.
N
max. abs. err.
cpu time (msec.)

16
2.45188e+07
0.287098

32
1.76294e+06
0.280165

64
1.61966e+03
0.292623

128
16.23027
0.330376

256
0.07946
0.892498

Table 3.2: Error convergence and cpu time using the Carr-Madans method for pricing
European calls under GBM for the three different strike prices, namely K =
80, 100 and 120.
As we can see in Table 3.2, the values for the maximum error are matches the result
presented in Table 1 of [Fang and Oosterlee, 2008]. In fact, we see that the maximum
error decreases for larger values of N , while the cpu time increases for larger values of N .
Note that we cannot compare the cpu times presented here in this paper with the ones
obtained in [Fang and Oosterlee, 2008], because different type of computers are used.

11

4 Carr-Madan result presented in Table 6


In this section we discuss the experiment performed in section 5.3 of [Fang and Oosterlee,
2008]. In particular, we use the Carr-Madans method to price European call options
under the Heston model for 21 consecutive strike prices. Furthermore, the call option
experiment is performed under the Heston model with maturity T = 1 and we check the
convergence bahaviour at 21 consecutive strike prices, namely K = 50, 55, 60, . . . , 150.
We use the same parameters as given in [Fang and Oosterlee, 2008] for the experiment
and also assume for this experiment that the damping factor, , in the Carr-Madans
method to be = 0.75 as in [Fang and Oosterlee, 2008]. Note that the results for these
strike prices are obtained in one single numerical experiment and also we use a truncation
rang of size [0, 1200]. Moreover, the reference values are obtained by the Carr-Madan
method using N = 217 points with truncated Fourier domain set to [0, 1200].

In the Heston model, the volatility, denoted by ut , is modeled by a stochastic


differential equation,

dxt = (u 21 ut ) dt + ut dW1t ,

(1)
dut = (
u ut ) dt + ut dW2t ,
where xt denotes the log-asset price variable and ut the variance of the asset price
process. Parameters 0, u
0 and 0 are called the speed of mean reversion
, the mean level of variance and the volatility of volatility, respectively. Furthermore,
the Brownian motions, W1t and W2t , are assumed to be correlated with correlation
coefficient .
The characteristic function of the log-asset price for the Heston model is given by:
 u h 1 eD i

0
(

iw

D)
2 1 GeD

h
 1 GeD i
u
exp 2 ( iw D) 2 log

1G

heston (w) = exp(iw[log(S0 ) + r ]) exp

where = T t0 = T 0 = T ,
p
D = ( iw)2 + (w2 + iw) 2 ,
G=

iw D
iw + D.

(2)

(3)
(4)

The parameters used for this test are:


S0 = 100, r = 0, q = 0, T = 1, = 1.5768, = 0.5751, u
= 0.0398, u0 = 0.0175, = 0.5711.
Note for the Heston parameters given above that the Feller condition, i.e., 2
u > 2 ,
is not satisfied.

12

The reference value corresponding to the 21 consecutive strike prices, namely K =


50, 55, 60, . . . , 150 with maturity T = 1 are given in Table 4.1.
Strike Price
50
55
60
65
70
75
80
85
90
95
100

Reference Value
50.070539139723508
45.124108541464899
40.208801172304959
35.338694824309748
30.533286991857107
25.819775170846526
21.236638756022217
16.839368487397689
12.709531760206342
8.967794306297670
5.785155450240623

Strike Price
105
110
115
120
125
130
135
140
145
150

Reference Value
3.359201922125749
1.787135060623922
0.921148309770783
0.482828092902555
0.262123561233131
0.147593635853726
0.085878404410413
0.051414849791787
0.031553214380537
0.019788382151668

Table 4.1: The reference value corresponding to the 21 consecutive strike prices, namely
K = 50, 55, 60, . . . , 150 with maturity T = 1. Note that the reference value
are obtained by the Carr-Madan method using N = 217 points with truncated
Fourier domain set to [0, 1200]

Table 4.2 shows the Carr-Madans results for pricing European calls under Heston
model. Note the all cpu times presented, in (milli)seconds, are determined after averaging the computing times obtained from 100 experiments. The computer used for the
experiments has Intel(R) Core(TM) i5 CPU, M 520 2.40GHz and the code is written in
Matlab R2013b. See Appendix for the Matlab code used for this experiment.
N
max. abs. err.
cpu time (msec.)

512
2.70962e+05
0.92095

1024
4.96950e+02
1.62337

2048
0.56432
4.03544

4096
0.01071
4.32354

8192
3.44565e-06
8.07884

Table 4.2: Error convergence and cpu time using the Carr-Madans method for pricing
European calls under Heston model for 21 consecutive strike prices, namely
K = 50, 55, 60, . . . , 150 with maturity T = 1.
As we can see in Table 4.2, the values for the maximum error are different from the
result presented in Table 1 of [Fang and Oosterlee, 2008]. This may be due to the way
the maximum error is computed. In this paper, the maximum error is computed by
subtracting the computed European call option value with Carr-Madan method for the
21 consecutive strike prices from their corresponding reference values shown in Table
4.1. Nonetheless, we see that the maximum error decreases for larger values of N , while
the cpu time increases for larger values of N . Note that we cannot compare the cpu
times presented here in this paper with the ones obtained in [Fang and Oosterlee, 2008],
because different type of computers are used.

13

5 Carr-Madan result for H1-HW model


In this section we discuss the pricing of European options under the H1-HW using
the Carr-Madan method and we will also try to compare the results obtained for the
European options under H1-HW model with the ones obtain for the European options
under Heston model. In particular, we use the Carr-Madans method to price European
options under the H1-HW model for 21 consecutive strike prices. Furthermore, the
European option experiment is performed under the H1-HW model with maturity T = 1
and we check the convergence bahaviour at 21 consecutive strike prices, namely K =
50, 55, 60, . . . , 150.
For a state vector Xt = [St , t , rt ]T and fixed probability space (, F, Q) with a
filtration F = {Ft : t 0}, which satisfies the usual conditions. Then the Heston
Hull-White model is given by:

S0 > 0;
dSt = rt St dt + t St dWtx ,

dt = (
t ) dt + t dWt , 0 > 0;
(1)

r
drt = (t rt ) dt + dWt ,
r0 > 0;
with

dWtx dWt = x, dt;


dWtx dWtr = x,r dt;

dWt dWtr = ,r dt;

(2)

where > 0 determines the speed of adjustment of the volatility towards its theoretical mean,
> 0, > 0 determines the speed of mean reversion for the interest rate
process, t is the interest rate term-structure, controls the volatility of the interest rate
and
> 0 and > 0 is the second-order volatility, i.e. the variance of the volatility.
Furthermore, the reformulated Heston Hull-White hybrid model
the system of SDEs given by:

dSt = rt St dt + t St dWtx + t St dWtr + t St dWt ,

dt = (
t ) dt + t dWt ,

drt = (t rt ) dt + dWtr ,
with

dWtx dWt = x, dt;


dWtx dWtr = 0;

dWt dWtr = 0;

(H1-HW) follows

S0 > 0;
0 > 0;
r0 > 0;

(3)

(4)

where t is a time-dependent function, a constant parameter and we still assume


independence between instantaneous short rate, rt and the volatility process t , i.e.
r, = 0.

14

The coefficients for the H1-HW model are given by:

t x,r E( t )
2 = 2x, + 2x,r ;
x,
= x, x, ;

(5)

where


2 (1 et )(
et
+ 20 )  12
E( t )
:= (t)
(1 et ) + 0 et
8
(
et
+ 0 )

(6)

Moreover, the value E( t ) can be approximated by a function of the following form:

E( t ) a + bect
where the values a, b and c are estimated by:

q
2

a=
8
,

b = 0 a,

c = log(b1 ((1) a)).

(7)

(8)

The characteristic function for the H1-HW model is given in Lemma 3.4 of the
paper, [Grzelak and Oosterlee, 2009].
We now use the Carr-Madan method to price European options under H1-HW model
for 21 consecutive strike prices, namely K = 50, 55, 60, . . . , 150 with maturity T = 1.
We assume for this experiment that the damping factor, , in the Carr-Madans method
to be = 0.75 as in [Fang and Oosterlee, 2008]. Note that the results for these strike
prices are obtained in one single numerical experiment and also we use a truncation rang
of size [0, 1200]. Moreover, the reference values are obtained by the Carr-Madan method
using N = 217 points with truncated Fourier domain set to [0, 1200].
The parameters used for this test are:
S0 = 100, r = 0, q = 0, T = 1, = 1.5768;
= 0.0398; = 0.3;
= 0.05; r0 = = 0; = 0.05; x,r = 0.6; x, = 0.7; 0 = 0.0175;
Note for the H1-HW parameters given above that the Feller condition, i.e., 2
> 2,
is satisfied.
Table 5.1 shows the Carr-Madans results for pricing European calls under H1-HW
model. Note the all cpu times presented, in (milli)seconds, are determined after averaging the computing times obtained from 100 experiments. The computer used for the

15

experiments has Intel(R) Core(TM) i5 CPU, M 520 2.40GHz and the code is written in
Matlab R2013b. See Appendix for the Matlab code used for this experiment.
N
max. abs. err.
cpu time (msec.)

512
2.57660e+05
1.66956

1024
4.66523e+02
2.57719

2048
0.56432
4.54578

4096
0.01071
6.08057

8192
3.44565e-06
11.44484

Table 5.1: Error convergence and cpu time using the Carr-Madans method for pricing
European calls under H1-HW model for 21 consecutive strike prices, namely
K = 50, 55, 60, . . . , 150 with maturity T = 1.
As we can see in Table 5.1, the values for the maximum error are relatively the same
as the result presented in Table 4.2 of this paper. We compute the maximum error in
the same way as in section 4. Furthermore, we see that the maximum error decreases
for larger values of N , while the cpu time increases for larger values of N . Moreover,
we see that the cpu times for the H1-HW model are larger than the cpu times for the
Heston model.

16

Appendix

Matlab Implementations.

% Function for applying FFT with trapezoidal rule


function [ku,density,integral,values] = FFT(phi,fft_nu,fft_N,x)
fft_lambda = (2*pi)/(fft_N*fft_nu);
fft_b = 0.5*fft_N*fft_lambda;
ku = -fft_b + fft_lambda*[0:1:fft_N-1];

% spacing for log strike

u = [0:1:fft_N-1]*fft_nu;

% grid point of CHF-domain

% log strike levels ranging from -b to +b.

% applying FFT with trapezoidal rule


fft_input = exp(1i*fft_b.*u).*phi;
fft_output = fft(fft_input);
gamma1 = exp(1i*ku*u(1))*phi(1);
gamma2 = exp(1i*ku*u(end))*phi(end);
value = -0.5*(gamma1 + gamma2);
density = (fft_nu*real(fft_output + value))/pi;
integral = fft_lambda*(sum(density)-0.5*(density(1)+density(end)));
values = interp1(ku,density,x,spline);
end

% function for the computation of the characteristic function


% of the standard normal distribution
function [phi] = phi_normal(mu,sigma,fft_N,fft_nu)
u = [0:1:fft_N-1]*fft_nu;
% grid point of CHF-domain
phi = exp(1i*mu*u - 0.5*(sigma*u).^2);
end

% function for the computation of the characteristic function


% of the GBM process
function [phi] = phi_gbm(fft_nu,fft_N,S,r,sigma,tau)

17

lnS = log(S);
alpha = 0.75;
v1 = [0:1:fft_N-1]*fft_nu;
v2 = (v1 - 1i*(alpha + 1));
v = v2;

% Damping factor
% grid point of psi-domain
% shifted grid point of psi-domain

phi = exp(1i*v.*lnS + 1i*v.*(r - 0.5*sigma^2)*tau - 0.5*v.^2*sigma^2*tau);


end

% function for the computation of the characteristic function


% of the Heston model
function [phi] = phi_heston(fft_nu,fft_N,S,r,lambda,nu,u_bar,rho,tau,u0)
lnS = log(S);
alpha = 0.75;
% Damping factor
v1 = [0:1:fft_N-1]*fft_nu;
v2 = (v1 - 1i*(alpha + 1));
v = v2;

% grid point of psi-domain


% shifted grid point of psi-domain

D = sqrt((lambda - 1i*rho*nu.*v).^2 + (v.^2 + 1i*v).*nu^2);


G = (lambda - 1i*rho*nu.*v - D)./(lambda - 1i*rho*nu.*v + D);
phi1 = exp(1i*v.*(lnS + r*tau));
phi2 = exp((u0/nu^2).*((1 - exp(-D*tau))./(1 - G.*exp(-D*tau)))
.*(lambda - 1i*rho*nu.*v - D));
phi3 = exp((lambda*u_bar/nu^2)*(tau*(lambda - 1i*rho*nu.*v - D)
- 2*log((1 - G.*exp(-D*tau))./(1 - G))));
phi = phi1.*phi2.*phi3;
% Discounted Characteristic Function
end

% function for the computation of the characteristic function


% of the H1-HW model
function [phi] = phi_h1hw(fft_nu,fft_N,kappa,gamma,theta,lambda,nu,sigma_bar
,rho_xr,rho_xs,tau,r0,sigma0,S)
x0 = log(S);
alpha = 0.75;

% log transformation of stock


% Damping factor

18

% Checking Feller condition.


if 2*kappa*sigma_bar > gamma^2
% Values for the approximation of Ohm := rho(x,r)*(a+b*exp(-c*t)).
a = sqrt(sigma_bar - (gamma^2/8*kappa));
b = sqrt(sigma0) - a;
Expected_volatility = sqrt(sigma_bar*(1-exp(-kappa*(1)))
+ sigma0*exp(-kappa*(1)) - (gamma^2/8*kappa)*(((1-exp(-kappa*(1)))
*(sigma_bar*exp(kappa*(1))-sigma_bar+2*sigma0)) /(sigma_bar*exp(kappa*(1))
-sigma_bar+sigma0)));
c = -log((1/b)*(Expected_volatility - a));
% Values from equation 2.14 in paper.
rho_xs_hat = rho_xs^2 + rho_xr^2;
delta = rho_xs - rho_xs_hat;

v1 = [0:1:fft_N-1]*fft_nu;
v2 = (v1 - 1i*(alpha + 1));
v = v2;

% grid point of psi-domain


% shifted grid point of psi-domain

f1 = kappa - 1i*v*gamma*rho_xs_hat - 1i*v*gamma*delta;


f2 = -0.5*1i*v*(1 + delta^2 + 2*rho_xs_hat*delta) - 0.5*v.^2
*(1 + delta^2 + 2*rho_xs_hat*delta);
d = sqrt(f1.^2 - 2*gamma^2.*f2);
g = (f1 - d)./(f1 + d);
Bx = 1i*v;
Br = (1/lambda)*(1i*v - 1)*(1 - exp(-lambda*tau));
Bs = (1/gamma^2)*((1 - exp(-d*tau))./(1 - g.*exp(-d*tau))).*(f1 - d);
I0 = (1/lambda)*(1i*v - 1)*(tau + (1/lambda)*(exp(-lambda*tau) - 1));
I1 = (rho_xr^2/2*c)*(b^2*(1 - exp(-2*c*tau)) + 4*a*b*(1 - exp(-2*c*tau))
+ 2*a^2*c*tau);
I2 = (1/2*lambda^3)*(1i + v).^2*(3 + exp(-2*lambda*tau) - 4*exp(-lambda*tau)
- 2*lambda*tau);
I3 = (rho_xr*(1i*v - 1)./c*lambda^2*(c + lambda))*exp(-(c + lambda)*tau)
*(b*lambda*(c - exp(lambda*tau)*(c+lambda-lambda*exp(c*tau)))
+a*c*exp(c*tau)*(c+lambda)*(1+exp(lambda*tau)*(lambda*tau - 1)));
I4 = (1/gamma^2)*tau.*(f1 - d) - (2/gamma^2)*log((1 - g.*exp(-d*tau))./(1 - g));
A = lambda*theta.*I0 - (0.5*1i*v + 0.5*v.^2).*I1 + 0.5*nu^2.*I2
+ 1i*v*nu.*I3 + kappa*sigma_bar.*I4;
phi = exp(A + Bx*x0 + Bs*sigma0 + Br*r0);
disp(Feller Condition is satisfied)

19

else
disp(Feller Condition is not satisfied. Try again with valid values)
end

% The real matlab code used for reproducing the Carr-Madan results
format long
clc;
clear all;
close all;
clf;

% FFT method for standard normal distribution


mu = 0; sigma = 1;
x = [-5:1:5];
% vector of the maximum error
max_error_normal = zeros(5,1);
% Exact values of the standard normal distribution in the given points.
fx_normal_exact = (1/sqrt(2*pi))*exp(-0.5*x.^2);
% effective upper limit for integration which is uplim = fft_N*fft_nu.
% Note that the truncation range in this case is of size [0,20].
uplim = 1200;
% predefined parameters for fft
fft_N = [2.^[10:-1:2]];
% must be a power of two
fft_nu = uplim./fft_N;
% spacing of psi integrand
for i = 1:5
% Average runtime measurement for the GBM model
runTime_normal = 0;
% variable to store runtime
N_timemeasure_normal = 100;
% average of 100 runs
for run = 1:N_timemeasure_normal
tic;

% start stopwatch

20

% Discounted Characteristic Function of the normal distribution.


[phi_fft] = phi_normal(mu,sigma,fft_N(i),fft_nu(i));
% Applying FFT with trapezoidal rule.
[ku,density_fft,integral_fft,values_fft] = FFT(phi_fft,fft_nu(i),fft_N(i),x);
error_normal = abs(values_fft - fx_normal_exact);
max_error_normal(i) = max(error_normal);
runTime_normal = runTime_normal + toc;

% increase runtime

end
integral_fft;
max_error_normal;
runTime_normal_s = runTime_normal/N_timemeasure_normal
runTime_normal_ms = 1000*runTime_normal_s;
end
max_error_normal

% Recovered density function for the standard normal distribution.


figure(1)
plot(ku,density_fft)
ylim([0 0.45])
xlim([-11 11])

% Carr-Madan method results for GBM model


S = 100; r = 0.1; q = 0; T = 0.1; sigma = 0.25;
tau = T; Strike = [80, 100, 120];
n = length(Strike);
% vector of the maximum error
max_error_gbm = zeros(5,1);
% effective upper limit for integration which is uplim = fft_N*fft_nu.
% Note that the truncation range in this case is of size [0,100].
uplim = 100;
% predefined parameters for fft

21

fft_N = [2.^[8:-1:4]];
fft_nu = uplim./fft_N;

% must be a power of two (2^12 = 4096)


% spacing of psi integrand

% Exact Call option price with Black-Scholes model.


[Call_gbm,Put_gbm] = blsprice(S,Strike,r,tau,sigma,q);
for i = 1:5
% Average runtime measurement for the GBM model
runTime_gbm = 0;
% variable to store runtime
N_timemeasure_gbm = 100;
% average of 100 runs
for run = 1:N_timemeasure_gbm
tic;

% start stopwatch

% Discounted Characteristic Function for the GBM model


[phi_gbm1] = phi_gbm(fft_nu(i),fft_N(i),S,r,sigma,tau);
% Call option price with Carr-Madan method for the GBM model
[call_price_fft_gbm] = CarrMadanFFT(phi_gbm1,fft_nu(i),fft_N(i),Strike,tau,r);
% Error Convergence under GBM model
error_gbm = abs(call_price_fft_gbm - Call_gbm);
max_error_gbm(i) = max(error_gbm);
runTime_gbm = runTime_gbm + toc;

% increase runtime

end
max_error_gbm;
runTime_gbm_s = runTime_gbm/N_timemeasure_gbm;
runTime_gbm_ms = 1000*runTime_gbm_s
end
max_error_gbm
figure(2)
plot(Strike,Call_gbm,r,Strike,call_price_fft_gbm,b*)
xlabel(Strike)
ylabel(Call option price)

22

% Results of Carr-Madan for GBM model in table.


% Results_gmb = zeros(length(Strike),4);
Results_gmb = zeros(n,4);
Results_gmb(:,1) = Strike;
Results_gmb(:,2) = Call_gbm;
Results_gmb(:,3) = call_price_fft_gbm;
Results_gmb(:,4) = error_gbm;
Results_gmb;

% Carr-Madan method results for Heston model


S = 100; r = 0; q = 0; lambda = 1.5768; nu = 0.5751;
u_bar = 0.0398; u0 = 0.0175; rho = -0.5711; T = 1;
tau = T;
% Strike = 100;
Strike = [50:5:150];
n = length(Strike);
% vector of the maximum error
max_error_heston = zeros(5,1);
% effective upper limit for integration which is uplim = fft_N*fft_nu.
% Note that the truncation range in this case is of size [0,1200].
uplim = 1200;
% predefined parameters for fft
fft_N = [2.^[13:-1:9]];
% must be a power of two (2^12 = 4096)
fft_nu = uplim./fft_N;
% spacing of psi integrand
% Reference Call option values with Carr-Madan method for the Heston model
N_ref = 2^17;
% number of grid for the reference value
nu_ref = uplim/N_ref;
% spacing of psi integrand for the reference value
% Discounted Characteristic Function for the Heston model
[phi_ref] = phi_heston(nu_ref,N_ref,S,r,lambda,nu,u_bar,rho,tau,u0);
% Call option price with Carr-Madan method for the Heston model
[call_price_fft_ref] = CarrMadanFFT(phi_ref,nu_ref,N_ref,Strike,tau,r);
for i = 1:5
% Average runtime measurement for the Heston model

23

runTime_heston = 0;
N_timemeasure_heston = 100;

% variable to store runtime


% average of 100 runs

for run = 1:N_timemeasure_heston


tic;

% start stopwatch

% Discounted Characteristic Function for the Heston model


[phi_heston1] = phi_heston(fft_nu(i),fft_N(i),S,r,lambda,nu,u_bar,rho,tau,u0);

% Call option price with Carr-Madan method for the Heston model
[call_price_fft_heston] = CarrMadanFFT(phi_heston1,fft_nu(i),fft_N(i),Strike,tau,
% Error Convergence under Heston model
error_heston = abs(call_price_fft_heston - 5.785155450240623);
error_heston = abs(call_price_fft_heston - call_price_fft_ref);
max_error_heston(i) = max(error_heston);

runTime_heston = runTime_heston + toc;

% increase runtime

end
max_error_heston;
runTime_heston_s = runTime_heston/N_timemeasure_heston;
runTime_heston_ms = 1000*runTime_heston_s
end
max_error_heston
figure(3)
plot(Strike,call_price_fft_ref,r,Strike,call_price_fft_heston,b*)
xlabel(Strike)
ylabel(Call option price)

% Results of Carr-Madan for Heston model in table


% Results_heston = zeros(length(Strike),4);
Results_heston = zeros(n,4);
Results_heston(:,1) = Strike;
Results_heston(:,2) = call_price_fft_ref;
Results_heston(:,3) = call_price_fft_heston;
Results_heston(:,4) = error_heston;

24

Results_heston;

% Carr-Madan method results for H1-HW model


S = 100; r = 0; q = 0; T = 1; tau = T;
kappa = 1.5768; sigma_bar = 0.0398; gamma = 0.3;
lambda = 0.05; theta = 0; nu = 0.05;
% rho_xr = 0.1; rho_xs = -0.5711; % gives relatively good results
rho_xr = 0.6; rho_xs = -0.7; % gives a better results
r0 = theta; sigma0 = 0.0175;
Strike = [50:5:150];
n = length(Strike);
% effective upper limit for integration which is uplim = fft_N*fft_nu.
% Note that the truncation range in this case is of size [0,1200].
uplim = 1200;
% predefined parameters for fft
fft_N = 2^13;
% must be a power of two (2^12 = 4096)
fft_nu = uplim/fft_N;
% spacing of psi integrand
% Average runtime measurement for the H1-HW model
runTime_h1hw = 0;
% variable to store runtime
N_timemeasure_h1hw = 100;
% average of 100 runs
for run = 1:N_timemeasure_h1hw
tic;

% start stopwatch

% Discounted Characteristic Function for the H1-HW model


[phi_h1hw1] = phi_h1hw(fft_nu,fft_N,kappa,gamma,theta,lambda,nu,sigma_bar,
rho_xr,rho_xs,tau,r0,sigma0,S);
% Call option price with Carr-Madan method for the H1-HW model
[call_price_fft_h1hw] = CarrMadanFFT(phi_h1hw1,fft_nu,fft_N,Strike,tau,r);
% Error Convergence under H1-HW model
error_h1hw = abs(call_price_fft_h1hw - call_price_fft_ref);
max_error_h1hw = max(error_h1hw);
runTime_h1hw = runTime_h1hw + toc;

25

% increase runtime

end
max_error_h1hw
% calculate average runtime in seconds
runTime_h1hw_s = runTime_h1hw/N_timemeasure_h1hw;
% calculate average runtime in milliseconds
runTime_h1hw_ms = 1000*runTime_h1hw_s

figure(4)
plot(Strike,call_price_fft_ref,r,Strike,call_price_fft_h1hw,b*)
xlabel(Strike)
ylabel(Call option price)

26

References
[Carr and Madan, 1999] Carr, P. and Madan, D. B. (1999). Option Valuation Using the
Fast Fourier Transform. J. Comp. Finance, 2:6173.
[Fang and Oosterlee, 2008] Fang, F. and Oosterlee, C. (2008). A Novel Pricing Method
For European Options Based on Fourier-Cosine Series Expansions.
[Grzelak and Oosterlee, 2009] Grzelak, L. A. and Oosterlee, C. W. (2009). On The
Heston Model with Stochastic Interest Rates.
[Kienitz and Wetterau, 2012] Kienitz, J. and Wetterau, D. (2012). Financial Modelling:
Theory, Implementation and Practice. Wiley Finance.
[Ng, 2005] Ng, M. (2005). Option Pricing via the FFT and its Application to Calibration.

27

You might also like