The Heston Model

:
A Practical Approach
with
Matlab Code
Nimalin Moodley
2005
An Honours Project
submitted to the
Faculty of Science,
University of the Witwatersrand,
Johannesburg,
South Africa,
in partial fulfillment
of the requirements of the
Bachelor of Science Honours,
Programme in Advanced Mathematics of Finance
by
Nimalin Moodley
nimalin@yahoo.com
Acknowledgements
My gratitude and appreciation goes out to the following people: My Internal
Supervisor and ‘Chief’ of Maths of Finance, Prof. David Taylor, for running
the slickest department ever, his advice and motivation. Dr Graeme West (aka
Supa G), for his help, advice, selflessness, and inspiration. Grant Lotter, the
Don of L
A
T
E
X, for inspiring me to further my L
A
T
E
X skills. Ulrich N¨ ogel of
Fraunhofer-Institut f¨ ur Technound Wirtschaftsmathematik for his advice and
encouragement. The Class of 2005 for creating an environment that encour-
aged learning and challenged my thinking thus enabling me to achieve greater
things. My family and Adisha, for all their love and support. Oscar (PhD
Chaos Theory), for sitting by me while I researched. Marchand van Rooyen,
for suggesting the topic.
i
“If I have seen further it is by standing on the
shoulders of Giants.”
-Sir Isaac Newton
This project is dedicated to my Grandfather.
Thank you for being that intellectual Giant.
ii
ABSTRACT
This document covers various aspects the Heston model. The structure
and topics covered is as follows:
Chapter 1 introduces the model and provides theoretical and graphi-
cal motivation for its robustness and hence popularity. It also discusses
pricing using the Partial Differential Equation and Equivalent Martin-
gale Measure techniques
Chapter 2 discusses how the different components of the model can be
evaluated computationally and how this can be achieved with different
methods. These methods are then compared to each other.
Chapter 3 addresses the calibration problem. Different methods are
presented as well as practical implementation, results thereof, and com-
parisons.
All the MATLAB code required to implement the model is provided in
the appendix
iii
Contents
Introduction 1
I. A Brief Overview 2
1.
1
The Heston Model . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.
2
Motivation and Parameters . . . . . . . . . . . . . . . . . . . . . 2
1.
3
Pricing Options . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.
3
.
1
PDE approach . . . . . . . . . . . . . . . . . . . . . . . 8
1.
3
.
2
Risk Neutral approach . . . . . . . . . . . . . . . . . . . 8
II. Computational Evaluation 10
2.
1
The Closed-Form Solution . . . . . . . . . . . . . . . . . . . . . 10
2.
2
Fast Fourier Transform (FFT) . . . . . . . . . . . . . . . . . . . . 11
2.
3
Numerical Integration - Quadrature Rules . . . . . . . . . . . . . 14
2.
3
.
1
Adaptive Simpson’s Rule . . . . . . . . . . . . . . . . . . 14
2.
3
.
2
Adaptive Gaussian Quadrature Rules . . . . . . . . . . . 16
2.
3
.
3
Computation of the ‘Heston Integral’ . . . . . . . . . . . 17
2.
3
.
4
Comparison of Quadrature Rules . . . . . . . . . . . . . . 18
2.
4
Comparison of FFT and Numerical Integration . . . . . . . . . . 18
III Calibration 21
3.
1
The Calibration Problem . . . . . . . . . . . . . . . . . . . . . . 21
3.
2
Calibration methods . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.
2
.
1
Regularisation . . . . . . . . . . . . . . . . . . . . . . . 23
3.
2
.
2
Matlab’s lsqnonlin . . . . . . . . . . . . . . . . . . . 24
3.
2
.
3
Excel’s Solver . . . . . . . . . . . . . . . . . . . . . . . 25
3.
2
.
4
Simulated Annealing (SA) . . . . . . . . . . . . . . . . . 25
3.
2
.
5
Adaptive Simulated Annealing (ASA) . . . . . . . . . . . 27
3.
3
Calibration Results . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.
4
Comparisons, Considerations and Shortcomings . . . . . . . . . . 29
3.
5
Other Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Conclusion 33
iv
Contents
Appendix 34
A.
1
Simulation of Probability Densities . . . . . . . . . . . . . . . . . 34
A.
2
Generating Volatility Surfaces and Skews . . . . . . . . . . . . . 35
A.
3
Evaluation of the Closed-Form Solution . . . . . . . . . . . . . . 37
A.
3
.
1
European Call using FFT . . . . . . . . . . . . . . . . . . 37
A.
3
.
2
European Call using Numerical Integration . . . . . . . . 40
A.
4
Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
A.
4
.
1
Using Matlab’s lsqnonlin . . . . . . . . . . . . . . . 41
A.
4
.
2
Adaptive Simulated Annealing (ASA) in MATLAB . . . . 43
References 46
v
Introduction
The Heston Model is one of the most widely used stochastic volatility (SV)
models today. Its attractiveness lies in the powerful duality of its tractability and
robustness relative to other SV models.
This project initially begun as one that addressed the calibration problem of
this model. Attempting to solve such a problem was an impossible task due to the
lack of exposure to such ‘advanced’ models.
I, therefore, decided to take a slight digression into the world of Heston and
stochastic volatility. Enroute I realised that fundamental information that one
would require to gain an intuitive understanding of such a model was very dis-
joint and hence incomplete. This project, therefore, evolved into something that
could fill this gap.
A practical approach has been adopted since the focus of calibration is quite
practical itself. All the relevant tools are provided to facilitate this calibration
process, including MATLAB code. This code has been confined to the appendix to
keep the main body clutter free and ‘quick-to-read’.
All the functions and spreadsheets herein mentioned are included on the at-
tached CD so that the reader is not confined to this document and has some sort
of practical reference when approaching this subject.
1
CHAPTER I
A Brief Overview
The purpose of this section is to give the reader a succinct overview of the Heston
Model. A ‘broad-brush’, pragmatic approach is adopted to give the reader an
intuitive understanding of the model, rather than an overly technical one, so that
the sections that follow are easily absorbed. If further technical details are desired,
the reader is directed to the relevant references.
1.
1
The Heston Model
(Heston 1993) proposed the following the model:
dS
t
= µS
t
dt +
_
V
t
S
t
dW
1
t
(1.1)
dV
t
= κ(θ −V
t
)dt +σ
_
V
t
dW
2
t
(1.2)
dW
1
t
dW
2
t
= ρdt (1.3)
where {S
t
}
t≥0
and {V
t
}
t≥0
are the price and volatility processes, respectively, and
{W
1
t
}
t≥0
, {W
2
t
}
t≥0
are correlated Brownian motion processes (with correlation
parameter ρ). {V
t
}
t≥0
is a square root mean reverting process, first used by (Cox,
Ingersoll & Ross 1985), with long-run mean θ, and rate of reversion κ. σ is
referred to as the volatility of volatility. All the parameters, viz. µ, κ, θ, σ, ρ, are
time and state homogenous.
1.
2
Motivation and Parameters
There are many economic, empirical, and mathematical reasons for choosing a
model with such a form (see (Cont 2001) for a detailed statistical/ empirical analy-
sis).
Empirical studies have shown that an asset’s log-return distribution is non-
Gaussian. It is characterised by heavy tails and high peaks (leptokurtic). There
is also empirical evidence and economic arguments that suggest that equity re-
turns and implied volatility are negatively correlated (also termed ‘the leverage
effect’). This departure from normality plagues the Black-Scholes-Merton model
with many problems.
In contrast, Heston’s model can imply a number of different distributions. ρ,
which can be interpreted as the correlation between the log-returns and volatility
2
1.2 Motivation and Parameters 3
of the asset, affects the heaviness of the tails. Intuitively, if ρ > 0, then volatility
will increase as the asset price/return increases. This will spread the right tail
and squeeze the left tail of the distribution creating a fat right-tailed distribution.
Conversely, if ρ < 0, then volatility will increase when the asset price/return
decreases, thus spreading the left tail and squeezing the right tail of the distribution
creating a fat left-tailed distribution (emphasising the fact that equity returns and
its related volatility are negatively correlated). ρ, therefore, affects the skewness
of the distribution. Figure 1.1 shows this effect for different values ρ. Matlab
code for this simulation can be found in the appendix, § A.
1
.
9 9.5 10 10.5 11
0
0.01
0.02
0.03
0.04
0.05
0.06
ρ = 0.9
ρ = 0
ρ = −0.9
Figure 1.1: The effect of ρ on the skewness of the
density function
The effect of changing the skewness of the distribution also impacts on the
shape of the implied volatility surface. Hence, ρ also affects this. Figures 1.2,
1.3 and 1.4 show the effect of varying ρ. As can be seen, the model can im-
ply a variety of volatility surfaces and hence addresses another shortcoming of
the Black-Scholes-Merton model, viz., constant volatility across differing strike
levels. Matlab code for generation of the volatility surfaces can be found in §
A.
2
.
σ affects the kurtosis (peak) of the distribution. When σ is 0 the volatility is
deterministic and hence the log-returns will be normally distributed. Increasing σ
will then increase the kurtosis only, creating heavy tails on both sides. Figure 1.5
shows the effect of varying σ. Matlab code for this simulation can be found in
the appendix, § A.
1
.
1.2 Motivation and Parameters 4
0
1
2
3
0.8
0.9
1
1.1
1.2
0.185
0.19
0.195
0.2
0.205
0.21
Maturity(years)
ρ = 0.5
Strike
I
m
p
l
i
e
d

V
o
l
a
t
i
l
i
t
y
Figure 1.2: Implied volatility surface, ρ =
1
2
, κ = 2,
θ = 0.04, σ = 0.1, V
0
= 0.04, r = 1%, S
0
=1, strikes
: 0.8 −1.2, maturities : 0.5 −3 years
0
1
2
3
0.8
0.9
1
1.1
1.2
0.199
0.2
0.201
0.202
Maturity(years)
ρ = 0
Strike
I
m
p
l
i
e
d

V
o
l
a
t
i
l
i
t
y
Figure 1.3: Implied volatility surface, ρ = 0, κ = 2,
θ = 0.04, σ = 0.1, V
0
= 0.04, r = 1%, S
0
=1, strikes
: 0.8 −1.2, maturities : 0.5 −3 years
Again, the effect of changing the kurtosis of the distribution impacts on the
implied volatility. Figures 1.6, 1.7 and 1.8 show how σ affects the ‘significance’
of the smile/skew. Higher σ makes the skew/smile more prominent. This makes
sense relative to the leverage effect. Higher σ means that the volatility is more
volatile. This means that the market has a greater chance of extreme movements.
So, writers of puts must charge more and those of calls, less, for a given strike.
1.2 Motivation and Parameters 5
0
1
2
3
0.8
0.9
1
1.1
1.2
0.19
0.195
0.2
0.205
0.21
0.215
Maturity(years)
ρ = −0.5
Strike
I
m
p
l
i
e
d

V
o
l
a
t
i
l
i
t
y
Figure 1.4: Implied volatility surface, ρ = −
1
2
, κ =
2, θ = 0.04, σ = 0.1, V
0
= 0.04, r = 1%, S
0
=1,
strikes : 0.8 −1.2, maturities : 0.5 −3 years
0.092 0.094 0.096 0.098 0.1 0.102 0.104 0.106 0.108 0.11
0
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
σ = 0
σ = 0.1
σ = 0.25
Figure 1.5: The effect of σ on the kurtosis of the
density function
Matlab code for generation of the volatility smiles/skews can be found in § A.
2
.
κ, the mean reversion parameter, can be interpreted as representing the degree
of ‘volatility clustering’. This is something that has been observed in the market,
viz., large price variations are more likely to be followed by large price variations
1.2 Motivation and Parameters 6
0.8 0.85 0.9 0.95 1 1.05 1.1 1.15 1.2
0.17
0.18
0.19
0.2
0.21
0.22
0.23
I
m
p
l
i
e
d

V
o
l
a
t
i
l
i
t
y
Strike
ρ = 0.5
σ = 0.1
σ = 0.2
σ = 0.3
σ = 0.4
Figure 1.6: Implied volatility surface, ρ =
1
2
, κ = 2,
θ = 0.04, σ = 0.1, V
0
= 0.04, r = 1%, S
0
=1, strikes
: 0.8 −1.2, maturities : 0.5 −3 years
0.8 0.85 0.9 0.95 1 1.05 1.1 1.15 1.2
0.19
0.195
0.2
0.205
I
m
p
l
i
e
d

V
o
l
a
t
i
l
i
t
y
Strike
ρ = 0
σ = 0.1
σ = 0.2
σ = 0.3
σ = 0.4
Figure 1.7: Implied volatility surface, ρ = 0, κ = 2,
θ = 0.04, σ = 0.1, V
0
= 0.04, r = 1%, S
0
=1, strikes
: 0.8 −1.2, maturities : 0.5 −3 years
(Cont 2001).
A computationally convenient feature of the model is that it provides a closed-
1.3 Pricing Options 7
0.8 0.85 0.9 0.95 1 1.05 1.1 1.15 1.2
0.17
0.18
0.19
0.2
0.21
0.22
0.23
I
m
p
l
i
e
d

V
o
l
a
t
i
l
i
t
y
Strike
ρ = −0.5
σ = 0.1
σ = 0.2
σ = 0.3
σ = 0.4
Figure 1.8: Implied volatility surface, ρ = −
1
2
, κ =
2, θ = 0.04, σ = 0.1, V
0
= 0.04, r = 1%, S
0
=1,
strikes : 0.8 −1.2, maturities : 0.5 −3 years
form solution for European options, making it more tractable and easier to imple-
ment than other stochastic volatility models
1
.
The aforementioned features of this model enables it to produce a barrage of
distributions. This makes the model very robust and hence addresses the short-
comings of the Black-Scholes-Merton model. It provides a framework to price a
variety of options that is closer to reality.
1.
3
Pricing Options
In the Black-Scholes-Merton model, a contingent claim is dependent on one or
more tradable assets. The randomness in the option value is solely due to the
randomness of these assets. Since the assets are tradable, the option can be hedged
by continuously trading the underlyings. This makes the market complete, i.e.,
every contingent claim can be replicated.
In a stochastic volatility model, a contingent claim is dependent on the ran-
domness of the asset ({S
t
}
t≥0
) and the randomness associated with the volatil-
ity of the asset’s return ({V
t
}
t≥0
). Only one of these is tradable, viz., the asset.
Volatility is not a traded asset. This renders the market incomplete and has many
1
more specifically, it provides a closed-form solution for any value of ρ. Models like
Hull and White only provide such closed-form solutions for certain values of ρ.
1.3 Pricing Options 8
implications to the pricing of options.
1.
3
.
1
PDE approach
For purposes of brevity, the derivation of the PDE is not done here. The reader
is directed to (Black & Scholes 1973), (Gatheral 2004), (Majmin 2005) or (Xu
2003) for further details. Under the Heston model, the value of any option,
U(S
t
, V
t
, t, T), must satisfy the following partial differential equation,
1
2
V S
2

2
U
∂S
2
+ ρσV S

2
U
∂S∂V
+
1
2
σ
2
V

2
U
∂V
2
+ rS
∂U
∂S
+{κ[θ −V ] −Λ(S, V, t)σ

V }
∂U
∂V
−rU +
∂U
∂t
= 0 (1.4)
Λ(S, V, t) is called the market price of volatility risk. Heston assumes that the
market price of volatility risk is proportional to volatility, i.e.
Λ(S, V, t) = k

V for some constant k
⇒ Λ(S, V, t)σ

V = kσV
t
= λ(S, V, t), say
λ(S, V, t) therefore represents the market price of volatility risk. This parameter
does not appear in (1.1), (1.2) or (1.3) but does appear in the pricing formula, (2.1),
and hence needs to be approximated. This is no easy task as it well known that
the market price of volatility risk is nearly impossible to estimate. This problem is
overcome due to the parametric nature of the model and the existence of a closed-
form solution (see § 3.
1
and § 2.
1
).
1.
3
.
2
Risk Neutral approach
Risk neutral valuation is the pricing of a contingent claim in an equivalent martin-
gale measure (EMM). The price is evaluated as the expected discounted payoff of
the contingent claim
2
, under the EMMQ, say. So,
Option Value = E
Q
t
[e
r(T−t)
H(T)] (1.5)
where H(T) is the payoff of the option at time T and r is the risk free rate of
interest over [t, T] (we are assuming, of course, that interest rates are deterministic
and pre-visible, and that the numeraire is the money market instrument).
2
this is referred to as the ‘Law of the Unconscious Financial Mathematician’
1.3 Pricing Options 9
Moving from a real world measure to an EMM is achieved by Girsavov’s
Theorem. In particular, we have
d
˜
W
1
t
= dW
1
t

t
dt (1.6)
d
˜
W
2
t
= dW
2
t
+ Λ(S, V, t)dt (1.7)
dQ
dP
= exp
_

1
2
_
t
0

s
2
+ Λ(S, V, s)
2
)ds −
_
t
0
ϑ
s
dW
1
s

_
t
0
Λ(S, V, t)dW
2
s
_
(1.8)
ϑ
t
=
µ −r

V
t
(1.9)
where P is the real world measure and {
˜
W
1
t
}
t≥0
and {
˜
W
2
t
}
t≥0
are Q-Brownian
Motions. Under measure Q, (1.1), (1.2), and (1.3) become,
dS
t
= rS
t
dt +
_
V
t
S
t
d
˜
W
1
t
(1.10)
dV
t
= κ



−V
t
)dt + σ
_
V
t
d
˜
W
2
t
(1.11)
d
˜
W
1
t
d
˜
W
2
t
= ρdt (1.12)
where,
κ

= κ +λ
θ

=
κθ
κ + λ
This is an important result. Under the risk-neutral measure, λ has effectively been
‘eliminated’.
In a complete market, it can be shown that every asset/option has the same
market price of risk (i.e.,
µ
F
−r
σ
F
is constant for any asset F). Since volatility isn’t a
traded asset, the market is incomplete and Λ(S, V, t) isn’t constant. It is clear that
(1.6), (1.7), and (1.8) solely determine the EMM. This implies that the EMM is
not unique and is dependent on the value of Λ(S, V, t).
The implications are that the different EMM’s will produce different option
prices, depending on the value of Λ(S, V, t). This, initially, poses a problem.
Again, due to the parametric nature of the model and the existence of a closed-
form solution, we can work around this (see § 2.
1
and § 3.
1
).
CHAPTER II
Computational Evaluation
In order to practically implement such a model, one needs to be able to compute
the price of vanilla options implied by it. This is used in the calibration process to
obtain parameter values, which in turn will be used to price other exotic options.
This section, therefore, provides the tools required to perform such calculations.
2.
1
The Closed-Form Solution
The closed-formsolution of a European call option on a non-dividend paying asset
for the Heston model is:
C(S
t
, V
t
, t, T) = S
t
P
1
−Ke
−r(T−t)
P
2
(2.1)
where,
P
j
(x, V
t
, T, K) =
1
2
+
1
π
_

0
Re
_
e
−iφln (K)
f
j
(x, V
t
, T, φ)

_
dφ (2.2)
x = ln (S
t
)
f
j
(x, V
t
, T, φ) = exp {C(T −t, φ) + D(T −t, φ)V
t
+ iφx}
C(T −t, φ) = rφir +
a
σ
2
_
(b
j
−ρσφi + d)τ −2 ln
_
1 −ge
dr
1 −g
__
D(T −t, φ) =
b
j
−ρσφi + d
σ
2
_
1 −e
dr
1 −ge
dr
_
g =
b
j
−ρσφi + d
b
j
−ρσφi −d
d =
_
(ρσφi −b
j
)
2
−σ
2
(2u
j
φi −φ
2
)
for j = 1,2, where,
u
1
=
1
2
, u
2
= −
1
2
, a = κθ, b
1
= κ + λ −ρσ, b
2
= κ + λ
Such a formula looks intimidating, but in reality is quite ‘explicit’ and easy to
evaluate in Matlab. The only part that poses a slight problem is the limits of
the integral in (2.2). This integral cannot be evaluated exactly, but can be approx-
imated with reasonable accuracy by using some numerical integration technique,
e.g., Gauss Lagendre or Gauss Lobatto integration.
10
2.2 Fast Fourier Transform (FFT) 11
Under the EMMQ some parameter simplification takes place viz,
a = κ

θ

, b
1
= κ

−ρσ, b
2
= κ

Again, it can be seen that, effectively, the parameter λ has been eliminated.
A method to evaluate formulas in the form of (2.1) has been proposed by (Carr
& Madan 1999). This method is much quicker than using a numerical method for
the said integrals.
2.
2
Fast Fourier Transform (FFT)
This method has been proposed by (Carr & Madan 1999). We first begin with
some basic definitions.
Definition 2.1. The Fourier transform (F{·}) and inverse Fourier trans-
form (F

1{·}) of an integrable function, f(x), is
F{f(x)} =
_

−∞
e
iφx
f(x)dx = F(φ) (2.3)
F
−1
{F(φ)} =
1

_

−∞
e
−iφx
F(φ)dφ = f(x) (2.4)
In our framework, f(x) is the risk neutral density function of the log-return
of the underlying and F(φ) is called the characteristic function of f(x). It should
be noted that even if a random variable is not absolutely continuous
3
, its charac-
teristic function exists. For absolutely continuous random variables (say X), the
characteristic function can be expressed as an expectation, viz.,
E[e
iφX
]
FFT is an efficient algorithm used to calculate summations of the following
form:
w(k) =
N

j=1
e
−i

N
(j−1)(k−1)
x(j) (2.5)
It is a type of discrete approximation to a Fourier transform. Carr and Madan have
the following to say regarding their method:
‘...find that the use of the FFT is considerably faster than most avail-
able methods and furthermore, the traditional method described in
Heston , Bates , Bakshi and Madan , and Scott can be both slow and
inaccurate...’
3
A random variable is absolutely continuous if it has a density function.
2.2 Fast Fourier Transform (FFT) 12
Option pricing lends itself well to this sort of application due to the form of (1.5).
Let x
t
:= ln S
t
and k := ln K, where K is the strike price of the option. Then the
value of a European call, with maturity T, as a function of k is,
C
T
(k) = e
−rT
_

k
(e
x
T
−e
k
)f
T
(x
T
)dx
T
(2.6)
where f
T
(x) is the risk neutral density function of x, defined above. Carr and
Madan define a modified call price function
4
,
c
T
(k) = e
αk
C
T
(k), α > 0 (2.7)
We now expect c
T
(k) to be square integrable for a range of α values and ∀ k. α
is referred to as the dampening factor. The Fourier transform and inverse Fourier
transform of c
T
(k) is,
F
c
T
(φ) =
_

−∞
e
iφk
c
T
(k)dk (2.8)
c
T
(k) =
1

_

−∞
e
−iφk
F
c
T
(φ)dφ (2.9)
Substituting (2.9) into (2.7),
C
T
(k) = e
−αk
c
T
(k) (2.10)
= e
−αk
1

_

−∞
e
−iφk
F
c
T
(φ)dφ (2.11)
= e
−αk
1
π
_

0
e
−iφk
F
c
T
(φ)dφ (2.12)
Substituting (2.6) and (2.7) into (2.8),
F
c
T
(φ) =
_

−∞
e
iφk
e
αk
e
−rT
_

k
(e
x
T
−e
k
)f
T
(x
T
)dx
T
dk
=
_

−∞
e
−rT
f
T
(x
T
)
_
x
T
−∞
(e
x
T
+αk
−e
(α+1)k
)e
iφk
dkdx
T
=
e
−rT
α
2
+ α −φ
2
+i(2α + 1)φ
_

−∞
e
(α+1+iφ)x
T
f
T
(x
T
)dx
T
=
e
−rT
α
2
+ α −φ
2
+i(2α + 1)φ
_

−∞
e
(−αi−i+φ)ix
T
f
T
(x
T
)dx
T
=
e
−rT
F
C
T
(φ −(α + 1)i)
α
2
+ α −φ
2
+i(2α + 1)φ
4
because C
T
(k) is not square integrable
2.2 Fast Fourier Transform (FFT) 13
where F
C
T
(φ) is the characteristic function of x
T
, under Q, given by (Hong 2004):
F
C
T
(φ) = e
A(φ)+B(φ)+C(φ)
A(φ) = iφ(x
0
+ rT)
B(φ) =
2ζ(φ)(1 −e
−ψ(φ)T
)V
0
2ψ(φ) −(ψ(φ) −γ(φ))(1 −e
−ψ(φ)T
)
C(φ) = −
κθ
σ
2
_
2 log
_
2ψ(φ) −(ψ(φ) −γ(φ))(1 −e
−ψ(φ)T
)
2ψ(φ)
_
+
(ψ(φ) −γ(φ))T
_
ζ(φ) = −
1
2

2
+ iφ)
ψ(φ) =
_
γ(φ)
2
−2σ
2
ζ(φ)
γ(φ) = κ −ρσφi
(Carr & Madan 1999) show that,
C
T
(k
u
) ≈
e
−αk
u
π
N

j=1
e
−i

N
(j−1)(u−1)
e
ibv
j
F
c
T
(v
j
)
η
3
(3 + (−1)
j
−δ
j−1
)
. ¸¸ .

(2.13)
where
5
,
v
j
= η(j −1)
η =
c
N
c = 600
N = 4096
b =
π
η
k
u
= −b +
2b
N
(u −1), u = 1, 2, . . . , N + 1
This is now a direct application of (2.5) and hence FFT. Matlab can perform
FFT using the fft(X) function, where X is the vector created from . fft(X)
returns a (1 × N) vector whose j
th
column corresponds to a log-strike of −b +
2b
N
(j − 1). The appendix, § A.
3
.
1
, contains the code for pricing a European Call
using FFT.
5
these parameters have been specified by Carr and Madan so that a balance is struck
between computational time and accuracy.
2.3 Numerical Integration - Quadrature Rules 14
All that remains is to choose the value of α. (Carr & Madan 1999) suggest
that α be chosen such that
E[S
α+1
T
] < ∞ (2.14)
⇒ F
C
T
(−(α + 1)i) < ∞
Carr goes further to provide FFT for out-of the money options. He argues that
the above formula depends on the intrinsic value of the option. Since out-of-the-
money options have no intrinsic value, an FFT based on the time value of the
option has to be derived. The formula is presented here without derivation, for
completeness, as the author finds very little difference between the solutions of
the two methods. The Matlab code can also be found in § A.
3
.
1
.
C
T
(k
u
) ≈
1
π sinh(αk
u
)
N

j=1
e
−i

N
(j−1)(u−1)
e
ibv
j
γ
T
(v
j
)
η
3
(3 + (−1)
j
−δ
j−1
)
γ
T
(v) =
ϕ
T
(v −iα) −ϕ
T
(v + iα)
2
ϕ
T
(v) = e
−rT
_
1
1 + iv

e
rT
iv

F
C
T
(v −i)
v
2
−iv
_
2.
3
Numerical Integration - Quadrature Rules
Numerical integration can be used to evaluate the integral in (2.2). Two techniques
are briefly discussed together with their implementation.
2.
3
.
1
Adaptive Simpson’s Rule
The following is adapted from (Cheney & Kincaid 1999). The basic Simpson’s
Rule for numerical integration of a function, f(x), over two equal subintervals,
with partition points a, a + h, and a + 2h (we choose this form of partition for
ease of calculation and notation. A general formula will be given later), is
_
a+2h
a
f(x)dx ≈
h
3
[f(a) + 4f(a +h) + f(a + 2h)] (2.15)
The error of the above approximate can be established with a basic Taylor
6
6
no relation to the internal supervisor of this document.
2.3 Numerical Integration - Quadrature Rules 15
series. Consider,
f(a +h) = f(a) + hf

(a) +
1
2!
h
2
f

(a) +
1
3!
h
3
f

(a) +
1
4!
h
4
f
(4)
(a) + . . .
f(a + 2h) = f(a) + 2hf

(a) + 2h
2
f

(a) +
4
3
h
3
f

(a) +
2
4
4!
h
4
f
(4)
(a) + . . .
So,
RHS of (2.15) = 2hf + 2h
2
f

+
4
3
h
3
f

+
2
3
h
4
f

+
20
3.4!
h
5
f
(4)
(a) + . . .
(2.16)
Now, define
F(x) :=
_
x
a
f(t)dt
Again, using a Taylor series,
F(a+2h) = F(a)+2hF

(a)+2h
2
F

(a)+
4
3
h
3
F

(a)+
2
3
h
4
F
(4)
(a)+
2
5
5!
h
5
F
(5)
(a) . . .
Noting, by the Fundamental Theorem of Calculus, that F
(n+1)
(a) = f
(n)
(a) and
F(a) = 0 we have
_
a+2h
a
f(x)dx = F(a + 2h)
= 2hf(a) + 2h
2
f

(a) +
4
3
h
3
f

(a) +
2
3
h
4
f

(a) + . . .
(2.17)
Subtracting (2.16) from (2.17), we get,
Error in approximation = −
h
5
90
f
(4)
(ξ) = O(h
5
), ξ ∈ (a, a + 2h)
We now state a general result for the basic Simpson’s Rule,
_
b
a
f(x)dx ≈
b −a
6
_
f(a) + 4f
_
a + b
2
_
+ f(b)
_
Error = −
1
90
_
b −a
2
_
5
f
(4)
(ξ), ξ ∈ (a, b)
An Adaptive Simpson’s Rule divides the interval of integration into more than
2 subintervals. The number of subintervals is dependent on the required accuracy
2.3 Numerical Integration - Quadrature Rules 16
of the estimate. This is quantified by the error term given above. The function
will, in general, behave differently over different parts of the interval and hence
the intervals chosen will not be of uniform length.
The Matlab function quad(@fun,a,b) uses an Adaptive Simpson’s Rule
to numerically integrate @fun over [a,b]. It produces a result that has an error
less than 10
−6
or a user defined tolerance level which is prescribed by a fourth
argument.
2.
3
.
2
Adaptive Gaussian Quadrature Rules
Gaussian quadrature rules approximate the integral of a function, f(x), over [a, b]
by:
_
b
a
f(x)dx ≈
n

i=0
A
i
f(x
i
) (2.18)
where,
A
i
=
_
b
a

i
(x)dx

i
(x) =
n

j=0
j=i
_
x −x
j
x
i
−x
j
_
where {x
i
}
0≤i≤n
, termed nodes or abscissae, are the zeros of a Lagrange interpo-
lating polynomial.
ALagrange interpolating polynomial is a polynomial of order n−1 that passes
through n given points. Examples can be seen in figure 2.1.
The approximation in (2.18) is a weighted average of the function at dis-
crete nodes, {x
i
}
0≤i≤n
, with weights {A
i
}
0≤i≤n
. The interpolating polynomial,
p
n+1
(x), of degree n + 1 must satisfy:
_
b
a
x
k
p(x)dx = 0, (0 ≤ k ≤ n)
It is quite intuitive that the choice of the polynomials will determine the accuracy
of the estimate in (2.18). The most popular choice of these polynomials are the
Legendre polynomials. These are generated by setting the interval of integration
to [−1, 1] and standardising p
n
(x) such that p
n
(1) = 1. The roots of these polyno-
mials will then be used as nodes in the Gaussian quadrature over [−1, 1]. A simple
linear transformation can translate the original integral over [a, b] to [−1, 1].
2.3 Numerical Integration - Quadrature Rules 17
0 2 4 6
0
2
4
6
n=2
0 2 4 6
0
5
10
15
20
n=3
0 2 4 6
0
5
10
15
20
n=4
0 2 4 6
−100
0
100
200
300
400
500
n=5
Figure 2.1: Lagrange interpolating polynomials for
n = 2, 3, 4 and 5 points. These polynomials are of
order 1, 2, 3 and 4 respectively.
The Matlab function quadl(@fun,a,b) implements an adaptive Gauss Lo-
batto quadrature rule on the function @fun over the interval [a, b]. It’s defined as
the Gaussian quadrature presented above, with a specific form for the weights and
nodes. The integral is evaluated over [−1, 1] with nodes that are from the Legen-
dre polynomials. The nodes are symmetric about the origin and also include the
endpoints of the interval. The error in the estimate is given by,
Error = −
n(n −1)
3
2
2n−1
((n −2)!)
4
(2n −1)((2n −2)!)
3
f
(2n−2)
(ξ)
where n = number of nodes, and ξ ∈ (−1, 1). The rule is adaptive as it divides the
original integral into smaller subintervals and performs Gauss Lobatto integration
with varying node quantities. This is performed to achieve an estimate whose error
is less than 10
−6
or a user defined tolerance level prescribed by a fourth argument.
2.
3
.
3
Computation of the ‘Heston Integral’
In order to evaluate (2.1) we need to compute the integral in (2.2), viz.:
P
j
(x, V
t
, T, K) =
1
2
+
1
π
_

0
Re
_
e
−iφln (K)
f
j
(x, V
t
, T, φ)

_
dφ (2.19)
2.4 Comparison of FFT and Numerical Integration 18
for j = 1, 2. This can be done in Matlab with the 2 functions, quad(@fun
a,b) and quadl(@fun,a,b), discussed above. A problem arises as (2.19) is
an improper integral and the argument b cannot be specified as ‘infinity’ i.e.,
quad(@fun,a,b) evaluates only proper integrals. A quick plot of the integrand
will reveal that it converges very quickly to zero. Figure 2.2 shows the effect of
changing the parameters on the integrand. The parameters that were changed were
those that had the most significant effect on the integrand.
So, for sufficiently large b, the integral of (2.19) can be evaluated with the
required accuracy. I have chosen b = 100 to be prudent.
Matlab code to price a European call option using Heston’s model via Adap-
tive Gauss Lobatto integration/Simpson’s Rule can be found in the appendix, §
A.
3
.
2
.
2.
3
.
4
Comparison of Quadrature Rules
The purpose of this section is to gauge which quadrature rule to use. For a com-
plete discussion refer to (Gander & Gautschi 1998).
Matlab defines the functions, quad and quadl, as low order and high order
quadrature rules. One would therefore expect quadl to be superior.
(Gander & Gautschi 1998) say that for extremely small tolerance levels quadl
outperforms quad in:
• efficiency as measured by the number of recursive steps required to compute
an answer within a certain tolerance level.
• reliability as measured by the extent to which the required tolerance is
achieved.
For large tolerance levels, quad is more efficient (faster) than quadl, but less
reliable. Keeping in mind that we’re pricing options, we require an extremely low
tolerance level. Hence quadl would be better suited for our purposes.
2.
4
Comparison of FFT and Numerical Integration
It now remains to find which method is better suited for our purposes.
FFT is faster in a sense that it generates a matrix of prices with differing
strikes. Thousands of European call option prices are immediately available. The
quadrature rule evaluates the option price only for a given set of parameters, i.e.,
2.4 Comparison of FFT and Numerical Integration 19
0 20 40 60 80 100
−5
0
5
10
15
x 10
−3
φ
σ = 0.1, strike = 100, maturity = 1 month
0 20 40 60 80 100
−0.05
0
0.05
0.1
0.15
φ
σ = 0.1, strike = 100, maturity = 1 year
0 20 40 60 80 100
−0.2
0
0.2
0.4
0.6
0.8
φ
σ = 0.1, strike = 50, maturity = 1 month
0 20 40 60 80 100
−0.4
−0.3
−0.2
−0.1
0
0.1
φ
σ = 0.1, strike = 150, maturity = 1 month
0 20 40 60 80 100
−0.05
0
0.05
0.1
0.15
φ
σ = 0.9, strike = 100, maturity = 1 month
0 20 40 60 80 100
−5
0
5
10
15
x 10
−3
φ
σ = 0.1, strike = 100, maturity = 1 month
Figure 2.2: The Integrand of (2.19). Notice how
quickly this integrand converges to zero. Parame-
ters that were kept constant : κ = 2, θ = 0.04, ρ =
−0.5, V
0
= 0.05, S
0
= 100, r = 0.1
only for one strike price at a time. The time difference is extremely significant.
For a given set of parameters, FFT calculates prices for 4097 different strikes
in approximately 0.14 seconds. The quadrature rule takes approximately 281.89
seconds to perform the same calculation. FFT is faster by a factor of 2014.
FFT, in this application, suffers from one drawback, i.e., accuracy. The solu-
tions produced are depend on the choice of α (figure 2.3 shows the price produced
by FFT as a function of α). From (2.14) we can also see that α is depend on the set
of parameters. The relationship between α and these parameters is not as trivial
2.4 Comparison of FFT and Numerical Integration 20
to identify as is done in (Carr & Madan 1999) for the Variance-Gamma model.
We are therefore left with the quadrature rule as our primary tool for evalua-
tion. If an α can be found that satisfies (2.14), then FFT is far superior.
0 1 2 3 4 5
30
31
32
33
34
35
36
37
38
39
α
p
r
i
c
e
Figure 2.3: This illustrates how the price of an
option is depend on the choice of α
CHAPTER III
Calibration of the Model
3.
1
The Calibration Problem
The price to pay for more realistic models is the increased complexity of model
calibration. Often, the estimation method becomes as crucial as the model itself
(Cont 2005).
The Heston model has six parameters that need estimation, viz., κ, θ, σ, V
0
,
ρ, λ. Research has shown that the implied parameters (i.e. those parameters that
produce the correct vanilla option prices) and their time-series estimate counter-
parts are different (see (Bakshi, Cao & Chen 1997)). So one cannot just use
empirical estimates for the parameters.
This leads to a complication that plagues stochastic volatility models in gen-
eral
7
. A common solution is to find those parameters which produce the correct
market prices of vanilla options. This is called an inverse problem, as we solve
for the parameters indirectly through some implied structure
8
.
The most popular approach to solving this inverse problem is to minimise the
error or discrepancy between model prices and market prices. This usually turns
out to be a non-linear least-squares optimisation problem. More specifically, the
squared differences between vanilla option market prices and that of the model
are minimised over the parameter space, i.e., we evaluate
min

S(Ω) = min

N

i=1
w
i
_
C

i
(K
i
, T
i
) −C
M
i
(K
i
, T
i
)
¸
2
(3.1)
where Ω is a vector of parameter values, C

i
(K
i
, T
i
) and C
M
i
(K
i
, T
i
) are the i
th
option prices from the model and market, respectively, with strike K
i
and maturity
T
i
. N is the number of options used for calibration, and the w
i
’s are weights (the
choice of these weights will be discussed later).
The question now arises as to what market prices to use in this calibration
process, as for any given option there exists a bid and ask price. This may seem
as a problem but it actually allows flexibility in the calibration process.
7
On the positive side, we need not estimate the market price of volatility risk, which
is near impossible to do in practice.
8
eg. solving for a polynomial with given roots is an inverse problem.
21
3.2 Calibration methods 22
We will use the mid-price of the option but accept a parameter set, Ω
0
, given
that
N

i=1
w
i
_
C

0
i
(K
i
, T
i
) −C
M
i
(K
i
, T
i
)
¸
2

N

i=0
w
i
[bid
i
−ask
i
]
2
(3.2)
where bid
i
/ask
i
are the bid/ask prices of the i
th
option. This means that we do
not require the model to match the mid-prices exactly, but fall, on average, within
the bid-offer spread. This is not an unreasonable relaxation of the calibration
process. We should bare in mind that the modeling process should produce the
required estimates within a certain tolerance level. Accuracy beyond this could be
spurious and hence produce less accurate exotic prices.
The minimisation mentioned above is not as trivial as it would seem. In gen-
eral, S(Ω) is neither convex nor does it have any particular structure. This poses
some complications:
• Finding the minimum of S(Ω) is not as simple as finding those parameter
values that make the gradient of S(Ω) zero. This means that a gradient
based optimisation method will prove to be futile.
• Hence, finding a global minimum is difficult (and very dependent on the
optimisation method used).
• Unique solutions to (3.1) need not necessarily exist, in which case only local
minima can be found. This has some implications regarding the stationarity
of parameter values which are important in these types of models. This is
discussed later.
The last two points make this an ill-posed problem. This is therefore an in-
verse, ill-posed problem termed the calibration problem.
Figure 3.1 plots S(Ω) as a function of κ and σ. It is easy to see that gradient
based optimisers will struggle to find a global minimum. Notice, also, the number
of points that are non-differentiable. This poses a further problem for gradient
based optimisers. The graph presents a graphical idea of the nature of S(Ω) as
a function of two of its parameters, but it is important to remember that S(Ω) is
5-dimensional and as such could be even nastier in its ‘true’ form.
The aim is therefore to identify optimisation methods that can deal with the
peculiarities of the calibration problem.
3.
2
Calibration methods
Before discussing the calibration methods, we address some technical issues.
3.2 Calibration methods 23
0
5
10
15
0
5
10
0
1
2
3
4
x 10
4
σ
κ
W
e
i
g
h
t
e
d

S
q
u
a
r
e
d

E
r
r
o
r
s
Figure 3.1: The Heston error surface as a function
of κ and σ
The calibration problem has a slight simplification when we price options un-
der an EMM, i.e., we can evaluate (3.1) using the C

i
(K
i
, T
i
)’s under an EMM.
As mentioned in § 1.
3
.
2
, evaluation under an EMM effectively reduces the number
of estimated parameters to five. The following must therefore hold:
OptionValue
P
(κ, θ, σ, V
0
, ρ, λ) = OptionValue
Q


, θ

, σ, V
0
, ρ, 0)
We also address the choice of the weights in (3.1). We choose the w
i
’s to be
1
|bid
i
−ask
i
|
. This choice is quite intuitive. If the spread is great, we have a wider
range of prices that the model can imply. In other words the model is allowed to
imply a wider range of prices around the mid-price. This means that less weight
should be placed on such a price, and vice-versa. (Cont 2005) suggests using the
implied volatilities as weights.
We also need a constraint on the parameters to prevent the volatility reaching
zero. (Mikhailov & N¨ ogel 2003) suggest that this constraint be 2κθ > σ
2
.
3.
2
.
1
Regularisation
This method is discussed briefly for completeness. For a detailed discussion refer
to (Chiarella, Craddock & El-Hassan 2000).
Regularisation involves adding a penalty function, p(Ω), to (3.1) such that
N

i=1
w
i
_
C

i
(K
i
, T
i
) −C
M
i
(K
i
, T
i
)
¸
2
+ αp(Ω) (3.3)
3.2 Calibration methods 24
is convex. α, here, is called the regularisation parameter.
The philosophy behind this strategy is one of pragmatism. We cannot hope
to determine the exact solution to our problem because of its very nature. Conse-
quently, we attempt to find an approximation which is as close to the true solution
as possible. To achieve this we are moved to replace our problem with one which
is close to the original, but does not possess the ill conditioning which the makes
the original intractable. In other words: Don’t try and solve the given problem,
try and solve a different one whose solution is close to that of your problem. This
is the essence of all regularisation methods (Chiarella et al. 2000).
When applied to a given set of market prices, these methods yield a single
set of model parameters calibrated to the market but also require the extra step of
determining the regularisation parameter, α (Cont 2005).
(Mikhailov & N¨ ogel 2003) suggest using αp(Ω) = ||Ω−Ω
0
||
2
, where Ω
0
is
an initial estimate of the parameters. This method is therefore dependent on the
choice of the the initial parameters. It is, in a sense, a local minimum optimiser.
Equation (3.3) can be minimised in MATLAB using the function lsqnonlin().
3.
2
.
2
Matlab’s lsqnonlin
MATLAB’S least-squares, non-linear optimiser is the function lsqnonlin(fun,
x0,lb,ub). It minimises the vector-valued function, fun, using the vector of
initial parameter values, x0, where the lower and upper bounds of the parameters
are specified in vectors lb and ub, respectively.
lsqnonlin uses an interior-reflective Newton method for large scale prob-
lems. MATLAB defines a large scale problem as one containing bounded / un-
bounded parameters, where the system is not under-determined, i.e., where the
number of equations to solve is more than the required parameters. Given that the
underlying of the model is liquidly traded, there should exist a rich set of market
prices for calibration. So, hopefully, our system will never be under-determined
9
.
MATLAB suggests (Coleman & Li 1996) and (Coleman & Li 1994) for further
reference on these methods.
The result produced by lsqnonlin is dependent on the choice of x0, the initial
estimate. This is, therefore, not a global optimiser, but rather, a local one. We have
no way of knowing whether the solution is a global/local minimum, but if (3.2)
is satisfied, the solution is acceptable. If not, then the calibration process would
have to be rerun with a different x0.
9
in fact, all one needs is five or more market prices
3.2 Calibration methods 25
The appendix, § A.
4
.
1
, contains information and code on using lsqnonlin
for calibration. § 3.
3
contains a comparison of this method to the others presented
here.
3.
2
.
3
Excel’s Solver
The standard Solver supplied with Excel contains an optimiser that can be used
for calibration under specific circumstances. It uses a Generalized Reduced Gra-
dient (GRG) method and hence is a local optimiser (for more information go to
www.solver.com). The calibration results are therefore extremely sensitive to the
initial estimates of the parameters. This optimiser should only be used when one
is sure that the initial estimates are quite close to the optimal parameter set.
The author has used MATLAB’S Excel Link to link the function HestonCall-
Quad between Excel and MATLAB. The spreadsheets HestonCalibration1 and
HestonCalibration2 use this function to calculate the model prices. Solver can
then be run to calibrate the model.
The attractiveness of using Excel and Solver is that most people are comfort-
able with them and they are available on almost every computer in a workplace.
On the down side, Excel is useless at handling calculations with very small num-
bers. These sort of calculations do appear during the calibration process, e.g.,
calculating the bound 2κθ > σ
2
, and hence can make your result suspect!
Overall, Excel provides a quick and dirty solution to our problem, under cer-
tain conditions. These conditions must be met in order to motivate its use. An
advanced version of Solver can be purchased which contains a global optimiser. §
3.
3
contains a comparison of this method to the others presented here.
3.
2
.
4
Simulated Annealing (SA)
Simulated Annealing is a probability-based, non-linear, optimiser inspired by the
physical process of annealing. Its attractiveness lies in the fact that it can:
• process objective functions (eg. (3.1)) possessing quite arbitrary degrees of
nonlinearities, discontinuities, and stochasticity.
• process quite arbitrary boundary conditions and constraints imposed on
these objective functions.
• be implemented quite easily with the degree of coding quite minimal, rela-
tive to other nonlinear optimisation algorithms.
3.2 Calibration methods 26
• statistically guarantee finding an optimal solution.
Annealing is a formal term for the ancient art of heating and/or cooling mate-
rials to forge pottery, tools, weapons, and works of art (Frost & Heineman 1997).
In a typical annealing process melted metal is allowed to cool subject to differ-
ing temperatures and pressures. The different combinations of these temperatures
and pressures determine the structural properties of the cooled product. Simulated
Annealing was borne out of the need to model such processes thereby advancing
the types of said materials produced. Annealing has played a key role in human
history: entire nations have been won and lost on the abilities of craftsmen to
produce fit materials (Frost & Heineman 1997).
The algorithm was first developed by (Metropolis, Rosenbluth, Rosenbluth,
Teller & Teller 1953) as a means of finding the equilibrium configuration of a
collection of atoms at a given temperature for the actual annealing process. It
was (Kirkpatrick, Jr. & Vecchi 1983) who realised the algorithms application to
optimisation in general.
The algorithm works in the following way:
1. First the objective function is evaluated at the user-specified initial parame-
ter estimates.
2. Next a random set of parameters is generated based on point 1 above.
3. If the value of the objective function is less than that of point 1, then we
‘accept’ the parameter set from point 2, else, the parameter set is accepted
with probability exp {−
δf
T
k
}, where δf is the difference between the ob-
jective functions using the parameter sets in points 1 and 2, and T
k
is the
temperature
10
parameter at iteration k, specified by the algorithm.
4. This process is iterated, with the temperature parameter decreased at each
iteration, until a termination condition is met (usually a specified value of
the temperature parameter).
The above algorithm not only ‘accepts’ parameter sets that decrease the ob-
jective function, but also that which increases it (subject to the probability con-
straints). This ensures that the algorithm does not get stuck in a local minimum.
It helps to imagine the objective function, that we want to minimise, as a
geographical terrain. We want to find the deepest valley of this terrain. Simulated
Annealing approaches this problem in the same way that a bouncing ball can
10
termed this because of obvious historical reasons.
3.2 Calibration methods 27
bounce over mountains, from valley to valley. Initially, when the temperature is
high, the ball has a lot of energy and can bounce from any valley to any other
valley. As time progresses, and the temperature parameter decreases, the ball
loses energy and settles down in relatively smaller ranges of valleys.
The algorithm requires only the value of the objective function for a given set
of parameters. It does not require the form of this objective function. This, in
a sense, makes the function a ‘black-box’ to the optimiser. Constraints are en-
capsulated within the ‘black-box’. This means that the objective function should
be able to tell the optimiser whether a set of parameters lies within the required
parameter space (in our case, whether 2κθ > σ
2
), and hence limits the search to a
feasible space.
Parameters that are determined by the model (eg. the temperature parameter)
are collectively known as the annealing scheme. The annealing scheme broadly
determines the efficiency and accuracy of the algorithm. For example, it deter-
mines the degree of ‘uphill’ movement and the rate of decrease of temperature,
which in turn affects how long the algorithm runs for. It is therefore obvious that
the annealing scheme be optimally specified. Such a specification isn’t obvious
since parameters like temperature don’t have an explicit/implicit mathematical
relationship with the objective function. This sort of specification has therefore
become an art form.
To reduce the subjective nature of the aforementioned specification, adaptive
methods of Simulated Annealing have been developed. The most famous and
widely used of these is Adpative Simulated Annealing.
3.
2
.
5
Adaptive Simulated Annealing (ASA)
ASA was developed by the theoretical physicist Lester Ingber. ASA is similar to
SA except that it uses statistical measures of the algorithm’s current performance
to modify its control parameters i.e. the annealing scheme.
A proof is provided by that Ingber shows that ASA is a global optimiser. He
also provides arguments for ASA’s computational effeciency and accuracy.
The C++ code is open-source and available from www.ingber.com. It has
always been open-source and hence Ingber has had a lot of feedback from users
of ASA. Over the years it has, therefore, been modified to a point where it is now
perfect. ASA works quite well in it’s ‘standard’ form, but also allows the user to
tweak the annealing scheme for greater efficiency. For a detailed discussion on
ASA the reader is referred to (Ingber 1993) and (Ingber 1995).
3.3 Calibration Results 28
ASA can be implemented in MATLAB by downloading the function asamin,
written by Shinichi Sakata. asamin is a MATLAB gateway function to ASA. This
means that asamin uses the actual C++ code of Ingeber’s ASA through MAT-
LAB. Detailed instructions on how to install and use ASA on one’s computer and
asamin into MATLAB can be found in (Moins 2002). The MATLAB code for cal-
ibrating the model using ASA can be found in § A.
4
.
2
.
Given the thin requirements of the objective function, ASA lends itself well to
a variety of applications in different disciplines. Ingber has consulted on projects,
where he has successfully implemented ASA, in the following fields:
• Circuit design
• Mathematics/combinatorics
• Data analysis
• Imaging
• Neural networks
• Biology
• Physics
• Geophysics
• Finance
• Military
3.
3
Calibration Results
Having an artillery of calibration methods at our disposal we can proceed to cali-
brate the model and compare the results. Vanilla calls on Anglo American shares,
listed on the LSE, was used as market data. An example of this data can be found
at the end of § A.
4
.
1
.
lsqnonlin, Solver and ASA were run with the same initial estimates on 2
sets of data. The results are as follows:
3.4 Comparisons, Considerations and Shortcomings 29
Method κ θ σ ρ V
0
S(Ω) Time
11 October 2005
Initial Estimate 3 0.05 0.5 -0.5 0.15 386.10
lsqnonlin 4.0481 0.0487 0.6066 -0.8061 0.1450 87.50 62.63 sec
ASA 21.3108 0.1034 2.0099 -0.4998 0.1583 81.80 4.7 hrs
Solver 5.7369 0.0579 0.8141 -0.74783 0.1568 78.10 10 mins
20 October 2005
Initial Estimate 5 0.057 0.7 -0.75 0.16 148.32
lsqnonlin 15.096 0.1604 2.0859 -0.7416 0.1469 88.58 6 mins
ASA 10 0.1072 1.4189 -0.8236 0.1829 77.38 3.5 hours
Solver 7.3284 0.0745 1.0227 -0.7670 0.1938 89.88 20 mins
where Time is the running time of the calibration process
11
. As can be seen,
ASA gives the best result in minimising S(Ω), on average, but is far more com-
putationally demanding. At this point it should be noted that ASA statistically
guarantees to find an optimal solution. On the 11 October ASA doesn’t produce
the lowest S(Ω), but is very close. Although Solver produces the best parameter
set, the results will be quite different for a different set of initial estimates. ASA
will provide the best estimate if the annealing scheme is optimised.
The reason that ASA runs so long is because it searches the entire parameter
space for a global minimum, unlike lsqnonlin and Solver which settles down
quite quickly into a local minimum. Figures 3.2 and 3.3 illustrate this point. No-
tice that lsqnonlin drops down very quickly to a local minimum whereas ASA
keeps on searching for other minima and hence oscillates.
3.
4
Comparisons, Considerations and Shortcomings
Relative to ASA, lsqnonlin and Solver don’t perform that badly in minimising
S(Ω) . Given that they are far quicker than ASA, the difference in S(Ω) is accept-
able. This conclusion can only be made for the given set of initial parameters. One
should be careful and not generalise such a conclusion as the solutions presented
by lsqnonlin and Solver are very dependent on the initial parameters. If these
were chosen differently, then lsqnonlin and Solver’s solutions could have been
very far off from ASA’s. There have been trial runs where the differences between
lsqnonlin, Solver and ASA were quite significant (ASA producing the best es-
timate). As mentioned above, lsqnonlin and Solver should only be used when
one is confident that the solution to (3.1) isn’t very far from the initial estimates.
11
This was run on a Pentium M 1.6 Ghz, 512MB RAM.
3.4 Comparisons, Considerations and Shortcomings 30
0 100 200 300 400 500 600 700 800
0
200
400
600
800
1000
1200
1400
Iteration
O
b
j
e
c
t
i
v
e

F
u
n
c
t
i
o
n
Figure 3.2: This illustrates how the objective func-
tion is minimised when using lsqnonlin.
0 0.5 1 1.5 2 2.5
x 10
4
0
2
4
6
8
10
12
x 10
4
Iteration
O
b
j
e
c
t
i
v
e

F
u
n
c
t
i
o
n
Figure 3.3: This illustrates how the objective func-
tion is minimised when using ASA.
It should also be noted that ASA is being used in its raw form. There has been
no tweaking of the annealing schedule which can result in a significant decrease
in run-time. Also, for a random guess of the initial parameters (e.g. this would be
done when the model is calibrated for the very first time), ASA is the best option
3.4 Comparisons, Considerations and Shortcomings 31
The obvious question is, which method do we use? There isn’t a straight
answer to this. The choice of method should be dependent on the amount of in-
formation available related to parameter values and the state of the market. If a
global minimum was obtained yesterday (by using ASA), and the market condi-
tions are quite normal (i.e. no crashes or dramatic movements since yesterday)
then lsqnonlin and Solver can quite safely be used. We expect that today’s para-
meters are in a small neighborhood around yesterday’s. If there has been a crash
or dramatic market movement then such an expectation is unreal. In this case ASA
would have to be used. So, there should be a marriage of the different methods to
create efficiency and not sacrifice accuracy.
Another issue to consider is the stationarity of parameters. Due to time con-
straints placed on such an honours project, such a task wasn’t able to perform. But,
(Mikhailov & N¨ ogel 2003) say that the parameters aren’t stationary, and hence the
comment above about calibrating the model each day. The stationarity that most
practitioners on this topic refer to is that of the parameters that solve (3.1). But, a
parameter set that we use need not be this set. An acceptable set is one that satis-
fies (3.2). An initial problem with ASA, lsqnonlin and Solver is that they don’t
tell us anything about the multiplicity of solutions of the calibration problem. But
we can employ a clever trick and adapt ASA and lsqnonlin to do this.
First, calculate the RHS of (3.2). Call this value SumBidOffer. Remem-
ber that the objective function is the LHS of (3.2) that is evaluated at each itera-
tion. By adding the following logical test in functions HestonDifference and
HestonCostFunc we can store those parameter sets that satisfy (3.2):
if (sum(PriceDifference.^2) < SumBidOffer
PossibleSolutions{j} = input;
j = j+1
end
where j is the appropriate index of the cell matrix
12
PossibleSolutions. The
model should now be calibrated every day/month until enough PossibleSo-
lutions matices are available. Comparing the PossibleSolutions matrices
over the different days/months it could be possible to extract a set of parameters
that are more or less an element of each PossibleSolutions. This creates a
stationary set of parameters that satisfy (3.2).
Extracting the common set of parameters is not as trivial as it may seem. We
seek a 5-dimensional set of stationary parameters and hence the usual arguments
12
a cell matrix in Matlab is a matrix of matrices
3.5 Other Methods 32
that are used in such stationarity tests, in the 1-dimensional case, are not that
helpful.
3.
5
Other Methods
For completeness a few of the other calibration methods will be presented.
(Shu & Zhang 2004) propose a 2-step Indirect Inference method of cal-
ibrating the model. First, the recently developed simulation-based “indirect in-
ference method” (time-series relative) is used to estimate the parameters for the
dynamics of the asset. A non-linear least squares method is then used to calibrate
the remaining parameters, similar to what is presented above.
As mentioned before, the parameters have no relation to their time-series
counterparts, so it seems counter-intuitive to estimate some of the parameters us-
ing some time-series method. But it is exactly for this reason that we can estimate
a few of the parameters by some other method and then use a non-linear least
squares method to fit the model. This effectively reduces the dimension over
which (3.1) has to be minimised.
This seems like an extension to the method presented here and could be an
interesting extension to this project.
(Johnson & Lee 2004) proposes calibrating the model using an Ensemble
method. This method does not involve fitting the parameters to market data as
most methods do. Rather, it uses an ensemble of parameter sets. Each set of
the ensemble is assigned a weight which is attained by just one matrix inversion.
The calibrated ensemble will then reproduce exact market prices. (Johnson & Lee
2004) state that the attractiveness in the model lies in it’s simplicity and robustness
in being able to calibrate to any type of instrument, e.g., barrier options, forward
starting options, etc. Also, hedge ratios are easily calculated.
Lastly, while reading through the Wilmott forums, it seems that the calculation
of (3.1) can be carried out using genetic algorithms. MATLAB contains some
genetic algorithms in the Direct Search Toolbox which is an extension of the Op-
timisation Toolbox. However, (Ingber 1993) notes that these algorithms are much
slower that ASA, though.
Conclusion
As Mathematicians (or students thereof) we can get caught up in the magic of
Mathematics. It is important to remember that the Heston model is, essentially, a
model. It is a mathematical tool that models something that is infinitely complex.
It therefore cannot wholly capture the complicated and diverse dynamics that exist
in reality, of volatility.
Calibration of the model is an important task. Energy should not be wasted,
though, on over-fitting the model. Such efforts can lead to spurious results. After
all, one is trying to perfectly fit a model that doesn’t perfectly explain the real
world.
This doesn’t make stochastic models, in general, useless. If the underlying
assumptions are carefully understood and its application carefully applied then
stochastic models are powerful tools. They are the best that we have in an unpre-
dictable world without which we would be far worse off!
33
Appendix
A.
1
Simulation of Probability Densities
Monte Carlo simulation was performed by discretising the stochastic processes
using the Euler-Maruyama method. This resulted in,
S
t
= S
t−1
+ rS
t−1
dt +
_
V
t−1
S
t−1

dtZ
1
t
V
t
= V
t−1
+ κ(θ −V
t−1
)dt + σ
_
V
t−1

dtZ
2
t
where {Z
1
t
}
t≥0
and {Z
2
t
}
t≥0
are standard normal random variables with correla-
tion ρ. The above can be made computationally easier by expressing {Z
1
t
}
t≥0
and
{Z
2
t
}
t≥0
, as a function of independent standard normal random variables, using
the Cholesky decomposition,
Z
1
t
= φ
1
t
Z
2
t
= ρφ
1
t
+
_
1 −ρ
2
φ
2
t
where {φ
1
t
}
t≥0
and {φ
2
t
}
t≥0
are independent standard normal random variables.
Matlab code for the simulation of figure 1.1 is as follows:
S0 = 10; V0 = .01; r = 0; k = 2;
theta =.01; sigma= .1; delT = .02; rho =-0.9;
numberOfSimulations = 1000000;
i = 1:numberOfSimulations;
NormRand1 = randn(1,numberOfSimulations);
NormRand2 = randn(1,numberOfSimulations);
S = zeros(1,numberOfSimulations);
V = zeros(1,numberOfSimulations);
V(i) = V0 + k*(theta - V0)*delT + sigma*sqrt(V0)* ...
(rho*NormRand1 + sqrt(1- rho^2)*NormRand2)*sqrt(delT);
V = abs(V); %prevents negative volatilities
S(i) = S0 + r*S0*delT + S0*V.^(0.5).*NormRand1*sqrt(delT);
The code is broadly similar for the simulation of figure 1.5.
34
A.2 Generating Volatility Surfaces and Skews 35
A.
2
Generating Volatility Surfaces and Skews
Prices of the European call options are calculated, using the Heston closed-form
solution (§ 2.
1
), at different maturities and strikes. These prices are then equated
to the Black-Scholes-Merton (BSM) solution and the volatility that satisfies this
equation is evaluated. The function blsimpv returns the BSM implied volatility
for a given set of parameters. The following script file, VolSmile.m generates the
volatility surfaces of § 1.
2
(figures 1.3, 1.2, 1.4).
strikes = linspace(.8,1.2,11);
mats = linspace(.3,3,11); %maturities
for i = 1:11
for j = 1:11
price = HestonCallQuad(2,.04,.1,0.5,.04,.01,mats(i),1...
,strikes(j));
prices(i,j) = price;
Volatility(i,j) = blsimpv(1, strikes(j), 0.01 , ...
mats(i), price);
end
end
[strike mat] = meshgrid(strikes,mats);
surf(mat,strike,Volatility),xlabel(’Maturity(years)’), ...
ylabel(’Strike’),Title(’\rho = 0.5’),zlabel(’Implied ...
Volatility’);
figure;
for i = 1:11
for j = 1:11
price = HestonCallQuad(2,.04,.1,0,.04,.01,mats(i),1...
,strikes(j));
prices(i,j) = price;
Volatility(i,j) = blsimpv(1, strikes(j), 0.01 , ...
mats(i), price);
end
end
surf(mat,strike,Volatility),xlabel(’Maturity(years)’),
ylabel(’Strike’),Title(’\rho = 0’),zlabel(’Implied ...
Volatility’);
figure;
for i = 1:11
for j = 1:11
price = HestonCallQuad(2,.04,.1,-0.5,.04,.01,mats(i),...
1,strikes(j));
A.2 Generating Volatility Surfaces and Skews 36
prices(i,j) = price;
Volatility(i,j) = blsimpv(1, strikes(j), 0.01 ,...
mats(i), price);
end
end
surf(mat,strike,Volatility),xlabel(’Maturity(years)’),
ylabel(’Strike’),Title(’\rho = -0.5’),zlabel(’Implied...
Volatility’);
The following script, HestonVolSmileVolVol.m, generates figures 1.6, 1.7
and 1.8 of § 1.
2
.
strikes = linspace(.8,1.2,11);
volvols = [.1:.1:.4];
styleV = {[’-’][’--’] [’-.’] [’:’]};
colourV = {[’k’] [’b’] [’r’] [’m’]};
for i = 1:4
for j = 1:11
price = HestonCallQuad(2,.04,volvols(i),0.5,.04, ...
.01,1,1,strikes(j));
prices(i,j) = price;
Volatility(i,j) = blsimpv(1, strikes(j), 0.01 , ...
1, price);
end
plot(strikes,Volatility(i,:),[char(colourV(i)), ...
char(styleV(i))]),ylabel(’Implied Volatility’), ...
xlabel(’Strike’),Title(’\rho = 0.5’);
hold on;
end
legend(’\sigma = 0.1’,’\sigma = 0.2’,’\sigma = 0.3’, ...
’\sigma = 0.4’) figure;
for i = 1:4
for j = 1:11
price = HestonCallQuad(2,.04,volvols(i),0,.04, ...
.01,1,1,strikes(j));
prices(i,j) = price;
Volatility(i,j) = blsimpv(1, strikes(j), 0.01 , ...
1, price);
end
plot(strikes,Volatility(i,:),[char(colourV(i)), ...
char(styleV(i))]),ylabel(’Implied Volatility’), ...
xlabel(’Strike’),Title(’\rho = 0’);
A.3 Evaluation of the Closed-Form Solution 37
hold on;
end
legend(’\sigma = 0.1’,’\sigma = 0.2’,’\sigma = 0.3’, ...
’\sigma = 0.4’) figure;
for i = 1:4
for j = 1:11
price = HestonCallQuad(2,.04,volvols(i),-0.5,.04,...
.01,1,1,strikes(j));
prices(i,j) = price;
Volatility(i,j) = blsimpv(1, strikes(j), 0.01 , ...
1, price);
end
plot(strikes,Volatility(i,:),[char(colourV(i)), ...
char(styleV(i))]),ylabel(’Implied Volatility’), ...
xlabel(’Strike’),Title(’\rho = -0.5’);
hold on;
end
legend(’\sigma = 0.1’,’\sigma = 0.2’,’\sigma = 0.3’, ...
’\sigma = 0.4’)
A.
3
Evaluation of the Closed-Form Solution
Presented here are the two methods discussed in § 2.
2
and § 2.
3
for computation-
ally evaluating the closed-form solution for a European call.
A.
3
.
1
European Call using FFT
The following function calculates at-the-money and in-the-money European call
prices using FFT.
function CallValue = HestonCallFft(kappa,theta,sigma,rho,r ...
,v0,s0,strike,T)
%kappa = rate of reversion
%theta = long run variance
%sigma = Volatility of volatility
%v0 = initial Variance
%rho = correlation
%T = Time till maturity
A.3 Evaluation of the Closed-Form Solution 38
%r = interest rate
%s0 = initial asset price
x0 = log(s0);
alpha = 1.25;
N= 4096;
c = 600;
eta = c/N;
b =pi/eta;
u = [0:N-1]*eta;
lambda = 2*b/N;
position = (log(strike) + b)/lambda + 1; %position of call
%value in FFT
%matrix
v = u - (alpha+1)*i;
zeta = -.5*(v.^2 +i*v);
gamma = kappa - rho*sigma*v*i;
PHI = sqrt(gamma.^2 - 2*sigma^2*zeta);
A = i*v*(x0 + r*T);
B = v0*((2*zeta.*(1-exp(-PHI.*T)))./(2*PHI - ...
(PHI-gamma).*(1-exp(-PHI*T))));
C = -kappa*theta/sigma^2*(2*log((2*PHI - ...
(PHI-gamma).*(1-exp(-PHI*T)))./ ...
(2*PHI)) + (PHI-gamma)*T);
charFunc = exp(A + B + C);
ModifiedCharFunc = charFunc*exp(-r*T)./(alpha^2 ...
+ alpha - u.^2 + i*(2*alpha +1)*u);
SimpsonW = 1/3*(3 + (-i).^[1:N] - [1, zeros(1,N-1)]);
FftFunc = exp(i*b*u).*ModifiedCharFunc*eta.*SimpsonW;
payoff = real(fft(FftFunc));
CallValueM = exp(-log(strike)*alpha)*payoff/pi;
format short;
CallValue = CallValueM(round(position));
The following function calculates out-of-the-money European call prices us-
ing FFT.
function CallValue = HestonCallFftTimeValue(kappa,theta,...
sigma,rho,r,v0,s0,strike,T)
%kappa = rate of reversion
%theta = long run variance
%sigma = Volatility of volatility
%v0 = initial Variance
A.3 Evaluation of the Closed-Form Solution 39
%rho = correlation
%T = Time till maturity
%r = interest rate
%s0 = initial asset price
x0 = log(s0);
alpha = 1.25;
N= 4096;
c = 600;
eta = c/N;
b =pi/eta;
u = [0:N-1]*eta;
lambda = 2*b/N;
position = (log(strike) + b)/lambda + 1; %position of call
%value in FFT matrix
w1 = u-i*alpha;
w2 = u+i*alpha;
v1 = u-i*alpha -i;
v2 = u+i*alpha -i;
zeta1 = -.5*(v1.^2 +i*v1);
gamma1 = kappa - rho*sigma*v1*i;
PHI1 = sqrt(gamma1.^2 - 2*sigma^2*zeta1);
A1 = i*v1*(x0 + r*T);
B1 = v0*((2*zeta1.*(1-exp(-PHI1.*T)))./(2*PHI1 - ...
(PHI1-gamma1).*(1-exp(-PHI1*T))));
C1 = -kappa*theta/sigma^2*(2*log((2*PHI1 - ...
(PHI1-gamma1).*(1-exp(-PHI1*T)))./(2*PHI1)) ...
+ (PHI1-gamma1)*T);
charFunc1 = exp(A1 + B1 + C1);
ModifiedCharFunc1 = exp(-r*T)*(1./(1+i*w1) - ...
exp(r*T)./(i*w1) - charFunc1./(w1.^2 - i*w1));
zeta2 = -.5*(v2.^2 +i*v2);
gamma2 = kappa - rho*sigma*v2*i;
PHI2 = sqrt(gamma2.^2 - 2*sigma^2*zeta2);
A2 = i*v2*(x0 + r*T);
B2 = v0*((2*zeta2.*(1-exp(-PHI2.*T)))./(2*PHI2 - ...
(PHI2-gamma2).*(1-exp(-PHI2*T))));
C2 = -kappa*theta/sigma^2*(2*log((2*PHI2 - ...
(PHI2-gamma2).*(1-exp(-PHI2*T)))./(2*PHI2)) ...
+ (PHI2-gamma2)*T);
charFunc2 = exp(A2 + B2 + C2);
ModifiedCharFunc2 = exp(-r*T)*(1./(1+i*w2) - ...
exp(r*T)./(i*w2) - charFunc2./(w2.^2 - i*w2));
ModifiedCharFuncCombo = (ModifiedCharFunc1 - ...
ModifiedCharFunc2)/2 ;
A.3 Evaluation of the Closed-Form Solution 40
SimpsonW = 1/3*(3 + (-1).^[1:N] - [1, zeros(1,N-1)]);
FftFunc = exp(i*b*u).*ModifiedCharFuncCombo*eta.*...
SimpsonW;
payoff = real(fft(FftFunc));
CallValueM = payoff/pi/sinh(alpha*log(strike));
format short;
CallValue = CallValueM(round(position));
A.
3
.
2
European Call using Numerical Integration
The function HestonCallQuad(kappa,theta,sigma,rho,v0,r,T,s0,K) cal-
culates the value of a European call. It calls HestonP(kappa,theta,sigma,
rho,v0,r,T,s0,K,type), where type = 1,2, which evaluates (2.19), either us-
ing an adaptive Gauss Lobatto rule or adaptive Simpson’s Rule. This, in turn, calls
HestonPIntegrand(phi,kappa,theta,sigma,rho,v0,r,T,s0,K,type), wh-
ich evaluates the integrand of (2.19). This, in turn calls Hestf(phi,kappa,theta,
sigma,rho,v0,r,T,s0,type), which evaluates the ‘f’ function in the integrand
of (2.19). All variable names are the same as used in (Heston 1993).
function call = HestonCallQuad(kappa,theta,sigma,rho,v0,r,T,...
s0,K)
warning off;
call = s0*HestonP(kappa,theta,sigma,rho,v0,r,T,s0,K,1) - ...
K*exp(-r*T)*HestonP(kappa,theta,sigma,rho,v0,r,T,s0,K,2);
function ret = HestonP(kappa,theta,sigma,rho,v0,r,T,s0,K,type)
ret = 0.5 + 1/pi*quadl(@HestonPIntegrand,0,100,[],[],kappa, ...
theta,sigma,rho,v0,r,T,s0,K,type);
function ret = HestonPIntegrand(phi,kappa,theta,sigma,rho, ...
v0,r,T,s0,K,type)
ret = real(exp(-i*phi*log(K)).*Hestf(phi,kappa,theta,sigma, ...
rho,v0,r,T,s0,type)./(i*phi));
function f = Hestf(phi,kappa,theta,sigma,rho,v0,r,T,s0,type);
if type == 1
u = 0.5;
b = kappa - rho*sigma;
else
u = -0.5;
b = kappa;
A.4 Calibration 41
end
a = kappa*theta; x = log(s0);
d = sqrt((rho*sigma*phi.*i-b).^2-sigma^2*(2*u*phi.*i-phi.^2));
g = (b-rho*sigma*phi*i + d)./(b-rho*sigma*phi*i - d);
C = r*phi.*i*T + a/sigma^2.*((b- rho*sigma*phi*i + d)*T - ...
2*log((1-g.*exp(d*T))./(1-g)));
D = (b-rho*sigma*phi*i + d)./sigma^2.*((1-exp(d*T))./ ...
(1-g.*exp(d*T)));
f = exp(C + D*v0 + i*phi*x);
A.
4
Calibration
The following contains the MATLAB code for calibrating the Heston model.
A.
4
.
1
Using Matlab’s lsqnonlin
The script file HestonLsCalibration.m initiates the calibration process. It cre-
ates a handle on the function HestonDifferences that calculates the differences
between the model and market prices within lsqnonlin. The ‘load OptionD-
ata.txt’ line imports the strikes, maturities, market prices, bid and offers, etc.,
of the options and underlying from the file OptionData.txt
13
. The first parame-
ter of input that MATLAB sends into HestonDifference is 2κθ −σ
2
. It is done
here in this way because it is easier to encapsulate the constraint 2κθ − σ
2
> 0.
Reasonable bounds on the parameters were chosen relative to this.
clear;
global OptionData;
global NoOfOptions;
global NoOfIterations;
global PriceDifference;
NoOfIterations = 0;
load OptionData.m ;
%OptionData = [r,T,S0,K,Option Value,bid,offer]
Size = size(OptionData);
NoOfOptions = Size(1);
13
an example of the composition of OptionData.m is presented at the end of this sub-
section
A.4 Calibration 42
%input sequence in initial vectors [2*kappa*theta - sigma^2,...
% theta,sigma,rho,v0]
x0 = [6.5482 0.0731 2.3012 -0.4176 0.1838];
lb = [0 0 0 -1 0];
ub = [20 1 5 0 1];
options = optimset(’MaxFunEvals’,20000);
%sets the max no. of iteration to 20000 so that termination
%doesn’t take place early.
tic;
Calibration = lsqnonlin(@HestonDifferences,x0,lb,ub);
toc;
Solution = [(Calibration(1)+Calibration(3)^2)/ ...
(2*Calibration(2)), Calibration(2:5)];
function ret = HestonDifferences(input)
global NoOfOptions;
global OptionData;
global NoOfIterations;
global PriceDifference;
NoOfIterations = NoOfIterations + 1;
%counts the no of iterations run to calibrate model
for i = 1:NoOfOptions
PriceDifference(i) = (OptionData(i,5)-HestonCallQuad( ...
(input(1)+input(3)^2)/(2*input(2)),input(2), ...
input(3),input(4),input(5), ...
OptionData(i,1),OptionData(i,2),OptionData(i,3), ...
OptionData(i,4)))/sqrt((abs(OptionData(i,6)- ...
OptionData(i,7))));
%input matrix = [kappa theta sigma rho v0]
end
ret = PriceDifference’;
As mentioned before, the file OptionData.m is a text file containing the mar-
ket data for calibration. Vanilla calls written on Anglo American shares that trade
on the LSE have been used. For illustrative purposes, OptionData contains the
following information:
A.4 Calibration 43
r-q Term Spot Strike Mid Price Bid Offer
2.2685% 0.126027 1544.50 1000.00 559.00 553.00 565.00
2.2685% 0.126027 1544.50 1050.00 509.50 503.50 515.50
2.2685% 0.126027 1544.50 1100.00 460.00 454.00 466.00
2.2685% 0.126027 1544.50 1150.00 411.00 405.00 417.00
2.2685% 0.126027 1544.50 1200.00 362.50 356.50 368.50
2.2342% 0.375342 1544.50 1200.00 386.00 378.50 393.50
2.2685% 0.126027 1544.50 1250.00 315.00 309.00 321.00
2.2342% 0.375342 1544.50 1250.00 345.50 338.00 353.00
2.2685% 0.126027 1544.50 1300.00 269.50 263.50 275.50
2.2342% 0.375342 1544.50 1300.00 300.50 293.00 308.00
2.2685% 0.126027 1544.50 1350.00 223.00 217.00 229.00
2.2342% 0.375342 1544.50 1350.00 259.00 251.50 266.50
2.1947% 0.627397 1544.50 1350.00 281.00 272.00 290.00
2.2685% 0.126027 1544.50 1400.00 179.00 176.00 182.00
2.2342% 0.375342 1544.50 1400.00 221.00 213.50 228.50
2.1947% 0.627397 1544.50 1400.00 244.00 235.00 253.00
2.2685% 0.126027 1544.50 1450.00 140.00 136.00 144.00
2.2342% 0.375342 1544.50 1450.00 180.00 174.00 186.00
2.1947% 0.627397 1544.50 1450.00 207.50 198.50 216.50
2.2685% 0.126027 1544.50 1500.00 105.00 102.00 108.00
2.2342% 0.375342 1544.50 1500.00 149.50 145.00 154.00
2.1947% 0.627397 1544.50 1500.00 173.00 166.00 180.00
2.2685% 0.126027 1544.50 1600.00 56.50 51.50 61.50
2.2342% 0.375342 1544.50 1600.00 96.00 92.00 100.00
2.1947% 0.627397 1544.50 1600.00 121.00 114.00 128.00
2.2685% 0.126027 1544.50 1700.00 23.50 20.50 26.50
2.2342% 0.375342 1544.50 1700.00 57.25 51.00 63.50
2.1947% 0.627397 1544.50 1700.00 81.50 77.00 86.00
2.2685% 0.126027 1544.50 1800.00 10.00 7.00 13.00
2.2342% 0.375342 1544.50 1800.00 32.50 28.00 37.00
2.1947% 0.627397 1544.50 1800.00 50.50 44.50 56.50
2.2685% 0.126027 1544.50 1900.00 4.50 2.00 7.00
2.2342% 0.375342 1544.50 1900.00 18.25 14.50 22.00
2.1947% 0.627397 1544.50 1900.00 35.50 29.50 41.50
A.
4
.
2
Adaptive Simulated Annealing (ASA) in MATLAB
The scheme that controls the ‘acceptance’ of new solutions is so simple that the
cost of implementing ASA is purely dependent on the computational efficiency of
A.4 Calibration 44
evaluating the objective function. In our case, calculation of the objective function
for a given set of parameters entails the evaluation of a large number of options.
This makes ASA very computationally demanding and time consuming. The fol-
lowing script, HestonASACalibration, calibrates the model using ASA. It uses
the function HestonCostFunc
clear;
global OptionData;
global NoOfOptions;
global NoOfIterations;
global PriceDifference;
global ObjectiveFunc;
NoOfIterations = 0;
load OptionData.m ;
%OptionData = [r,T,S0,K,Option Value,bid,offer]
Size = size(OptionData);
NoOfOptions = Size(1);
%input sequence in initial vectors [kappa,theta,sigma,rho,v0]
x0 = [0.030854841 0.999999922 0.248415019 -1 0.08977599];
lb = [0 0 0 -1 0];
ub = [10 1 5 0 1];
asamin(’set’,’test_in_cost_func’,0)
tic;
[fstar, xstar, grad, hessian, state] = asamin(’minimize’,...
’HestonCostFunc’,x0’,lb’,ub’,-1*ones(5,1));
toc;
function [cost , flag] = HestonCostFunc(input)
global NoOfOptions;
global OptionData;
global NoOfIterations;
global PriceDifference;
global ObjectiveFunc;
%input matrix = [kappa theta sigma rho v0]
NoOfIterations = NoOfIterations + 1;
if (2*input(1)*input(2)<=input(3)^2) %test for constraint
flag = 0; %flag = 0 if contraint is violated, else = 1
A.4 Calibration 45
cost = 0
else
for i = 1:NoOfOptions
PriceDifference(i) = (OptionData(i,5)-HestonCallQuad(...
input(1),input(2),input(3),input(4),input(5), ...
OptionData(i,1),OptionData(i,2),OptionData(i,3),...
OptionData(i,4)))/sqrt((abs(OptionData(i,6)- ...
OptionData(i,7))));
end
cost = sum(PriceDifference.^2)
ObjectiveFunc(NoOfIterations) = cost; %stores the path of
flag = 1; %the optimiser
end
References
Bakshi, G., Cao, C. & Chen, Z. (1997), ‘Empirical performance of alternative
option pricing models’, Journal of Finance 52, 20032049.
Black, F. & Scholes, M. (1973), ‘Valuation of options and corporate liabilities’,
Journal of Political Economy 81, 637–654.
Carr, P. & Madan, D. B. (1999), ‘Option evaluation the using fast fourier trans-
form’, Journal of Computational Finance 2(4), 61–73.
Cheney, W. & Kincaid, D. (1999), Numerical Mathematics and Computing, 4 edn,
Brooks/Cole Publishing Company.
Chiarella, C., Craddock, M. & El-Hassan, N. (2000), The calibration of stock
option pricing models using inverse problem methodology, Research Paper
Series 39, Quantitative Finance Research Centre, University of Technology,
Sydney. http://ideas.repec.org/p/uts/rpaper/39.html.
Coleman, T. F. & Li, Y. (1994), ‘On the convergence of reflective newton meth-
ods for large-scale nonlinear minimization subject to bounds’, Mathematical
Programming.
Coleman, T. F. & Li, Y. (1996), ‘An interior, trust region approach for nonlinear
minimization subject to bounds’, SIAMJournal on Optimization 6, 418–445.
Cont, R. (2001), ‘Empirical properties of asset returns: stylized facts and statisti-
cal issues’, Quantitative Finance 1, 223–236.
Cont, R. (2005), ‘Recovering volatilty from option prices by evolutionary optimi-
sation’, Research Paper Series.
Cox, J. C., Ingersoll, J. E. & Ross, S. A. (1985), ‘A theory of the term structure of
interest rates’, Econometrica 53, 385–407.
Frost, R. & Heineman, P. (1997), Simulated annealing: A heuristic for parallel
stochastic optimization., in ‘PDPTA’, pp. 1595–.
Gander, W. & Gautschi, W. (1998), Adaptve quadrature - revisited, Technical
report, Departement Informatik, ETH Z¨ urich.
46
References 47
Gatheral, J. (2004), ‘Lecture 1: Stochastic volatility and local volatility’, Case
Studies in Financial Modelling Notes, Courant Institute of Mathematical
Sciences.
Heston, S. L. (1993), ‘A closed-form solution for options with stochastic volatility
with applications to bonds and currency options’, The Review of Financial
Studies 6(2), 327–343.
Hong, G. (2004), ‘Forward smile and derivative pricing’.
Ingber, A. L. (1993), ‘Simulated annealing: Practice versus theory’, Journal of
Mathematical Computational Modelling 18(11), 29–57.
Ingber, A. L. (1995), ‘Adaptive simulated annealing (asa): Lessons learned’, Con-
trol and Cybernetics.
Johnson, S. & Lee, H. (2004), ‘Capturing the smile’, Risk Magazine March, 89–
93.
Kirkpatrick, S., Jr., C. D. G. & Vecchi, M. P. (1983), ‘Optimization by simulated
annealing’, Science 220(4598), 671–680.
Majmin, L. (2005), Local and stochastic volatility models: An investigation into
the pricing of exotic equity options, Master’s thesis, University of the Wit-
watersrand, South Africa.
Metropolis, N., Rosenbluth, A., Rosenbluth, M., Teller, A. & Teller, E. (1953),
‘Equation of state calculations by fast computing machines’, Journal of
Chemisry and Physics 21(6), 1087–1092.
Mikhailov, S. & N¨ ogel, U. (2003), ‘Hestons stochastic volatility model implemen-
tation, calibration and some extensions’, Wilmott.
Moins, S. (2002), Implementation of a simulated annealing algorithm for MAT-
LAB, Technical report, Link¨ oping Institute of Technology.
Shu, J. & Zhang, J. E. (2004), ‘Pricing s&p 500 index options under stochastic
volatility with the indirect inference method’, Journal of Derivatives Ac-
counting 1(2), 1–16.
Xu, J. (2003), Pricing and hedging under stochastic volatility, Master’s thesis,
Peking University, China.

An Honours Project
submitted to the

Faculty of Science, University of the Witwatersrand, Johannesburg, South Africa,
in partial fulfillment of the requirements of the

Bachelor of Science Honours, Programme in Advanced Mathematics of Finance
by

Nimalin Moodley
nimalin@yahoo.com

Acknowledgements My gratitude and appreciation goes out to the following people: My Internal Supervisor and ‘Chief’ of Maths of Finance, Prof. David Taylor, for running the slickest department ever, his advice and motivation. Dr Graeme West (aka Supa G), for his help, advice, selflessness, and inspiration. Grant Lotter, the A A Don of LTEX, for inspiring me to further my LTEX skills. Ulrich N¨ gel of o Fraunhofer-Institut f¨ r Technound Wirtschaftsmathematik for his advice and u encouragement. The Class of 2005 for creating an environment that encouraged learning and challenged my thinking thus enabling me to achieve greater things. My family and Adisha, for all their love and support. Oscar (PhD Chaos Theory), for sitting by me while I researched. Marchand van Rooyen, for suggesting the topic.

i

“If I have seen further it is by standing on the shoulders of Giants.” -Sir Isaac Newton This project is dedicated to my Grandfather. Thank you for being that intellectual Giant.

ii

A BSTRACT
This document covers various aspects the Heston model. The structure and topics covered is as follows: Chapter 1 introduces the model and provides theoretical and graphical motivation for its robustness and hence popularity. It also discusses pricing using the Partial Differential Equation and Equivalent Martingale Measure techniques Chapter 2 discusses how the different components of the model can be evaluated computationally and how this can be achieved with different methods. These methods are then compared to each other. Chapter 3 addresses the calibration problem. Different methods are presented as well as practical implementation, results thereof, and comparisons. All the M ATLAB code required to implement the model is provided in the appendix

iii

Contents
Introduction I. A Brief Overview 1.1 The Heston Model . . . . . . 1.2 Motivation and Parameters . . 1.3 Pricing Options . . . . . . . . 1.3 .1 PDE approach . . . . 1.3 .2 Risk Neutral approach 1 2 2 2 7 8 8 10 10 11 14 14 16 17 18 18 21 21 22 23 24 25 25 27 28 29 32 33 iv

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

II. Computational Evaluation 2.1 The Closed-Form Solution . . . . . . . . . . . 2.2 Fast Fourier Transform (FFT) . . . . . . . . . . 2.3 Numerical Integration - Quadrature Rules . . . 2.3 .1 Adaptive Simpson’s Rule . . . . . . . . 2.3 .2 Adaptive Gaussian Quadrature Rules . 2.3 .3 Computation of the ‘Heston Integral’ . 2.3 .4 Comparison of Quadrature Rules . . . . 2.4 Comparison of FFT and Numerical Integration III Calibration 3.1 The Calibration Problem . . . . . . . . . . . . 3.2 Calibration methods . . . . . . . . . . . . . . . 3.2 .1 Regularisation . . . . . . . . . . . . . 3.2 .2 Matlab’s lsqnonlin . . . . . . . . . 3.2 .3 Excel’s Solver . . . . . . . . . . . . . 3.2 .4 Simulated Annealing (SA) . . . . . . . 3.2 .5 Adaptive Simulated Annealing (ASA) . 3.3 Calibration Results . . . . . . . . . . . . . . . 3.4 Comparisons, Considerations and Shortcomings 3.5 Other Methods . . . . . . . . . . . . . . . . . Conclusion

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . A. .1 Using Matlab’s lsqnonlin . . . . . . .3 . .4 Calibration . . . . . . . . . . . . . . A. . . . . . . . . A. .1 Simulation of Probability Densities . . . . . . .2 European Call using Numerical Integration . . . . .1 European Call using FFT . . . A. .2 Adaptive Simulated Annealing (ASA) in M ATLAB References . . . . . . . . . . . . . . . . .3 . . . . . 34 34 35 37 37 40 41 41 43 46 v . . . .Contents Appendix A. . . . A. . . . . . . . . A. A.4 . . . . . . . . . . . . . . . . . . .2 Generating Volatility Surfaces and Skews . . .4 . . . . .3 Evaluation of the Closed-Form Solution . . . . . . .

I. A practical approach has been adopted since the focus of calibration is quite practical itself. This project initially begun as one that addressed the calibration problem of this model. This code has been confined to the appendix to keep the main body clutter free and ‘quick-to-read’. 1 . All the functions and spreadsheets herein mentioned are included on the attached CD so that the reader is not confined to this document and has some sort of practical reference when approaching this subject. Its attractiveness lies in the powerful duality of its tractability and robustness relative to other SV models. evolved into something that could fill this gap. therefore. All the relevant tools are provided to facilitate this calibration process. decided to take a slight digression into the world of Heston and stochastic volatility. Enroute I realised that fundamental information that one would require to gain an intuitive understanding of such a model was very disjoint and hence incomplete.Introduction The Heston Model is one of the most widely used stochastic volatility (SV) models today. including M ATLAB code. This project. Attempting to solve such a problem was an impossible task due to the lack of exposure to such ‘advanced’ models. therefore.

There is also empirical evidence and economic arguments that suggest that equity returns and implied volatility are negatively correlated (also termed ‘the leverage effect’).3) dVt = κ(θ − Vt )dt + σ 1 dWt dWt2 = ρdt where {St }t≥0 and {Vt }t≥0 are the price and volatility processes. which can be interpreted as the correlation between the log-returns and volatility 2 . µ. empirical. This departure from normality plagues the Black-Scholes-Merton model with many problems. κ. It is characterised by heavy tails and high peaks (leptokurtic). A ‘broad-brush’. with long-run mean θ. ρ. Empirical studies have shown that an asset’s log-return distribution is nonGaussian. ρ.CHAPTER I A Brief Overview The purpose of this section is to give the reader a succinct overview of the Heston Model. and mathematical reasons for choosing a model with such a form (see (Cont 2001) for a detailed statistical/ empirical analysis). and rate of reversion κ. 1. 1. If further technical details are desired. All the parameters. σ is referred to as the volatility of volatility. {Wt2 }t≥0 are correlated Brownian motion processes (with correlation parameter ρ).2) (1.2 Motivation and Parameters There are many economic. rather than an overly technical one. In contrast. the reader is directed to the relevant references. and {Wt1 }t≥0 .1 The Heston Model (Heston 1993) proposed the following the model: dSt = µSt dt + Vt St dWt1 Vt dWt2 (1. first used by (Cox. respectively. σ. Ingersoll & Ross 1985). are time and state homogenous. {Vt }t≥0 is a square root mean reverting process. so that the sections that follow are easily absorbed.1) (1. viz. pragmatic approach is adopted to give the reader an intuitive understanding of the model. Heston’s model can imply a number of different distributions. θ.

σ affects the kurtosis (peak) of the distribution.1 shows this effect for different values ρ.1 .3 and 1.05 0. Increasing σ will then increase the kurtosis only.06 ρ = 0. Hence. therefore.01 0 9 9.5 shows the effect of varying σ. § A. Matlab code for this simulation can be found in the appendix.04 0. 0. viz. creating heavy tails on both sides. affects the skewness of the distribution. constant volatility across differing strike levels. . Figure 1.2 Motivation and Parameters 3 of the asset. When σ is 0 the volatility is deterministic and hence the log-returns will be normally distributed. then volatility will increase as the asset price/return increases.03 0. Intuitively.1. This will spread the right tail and squeeze the left tail of the distribution creating a fat right-tailed distribution.2. Conversely.. § A.5 11 Figure 1. if ρ < 0.1: The effect of ρ on the skewness of the density function The effect of changing the skewness of the distribution also impacts on the shape of the implied volatility surface. affects the heaviness of the tails. if ρ > 0. Figures 1.4 show the effect of varying ρ. then volatility will increase when the asset price/return decreases.2 . ρ. 1. thus spreading the left tail and squeezing the right tail of the distribution creating a fat left-tailed distribution (emphasising the fact that equity returns and its related volatility are negatively correlated).02 0.9 0.1 . As can be seen. Matlab code for generation of the volatility surfaces can be found in § A. Figure 1. the model can imply a variety of volatility surfaces and hence addresses another shortcoming of the Black-Scholes-Merton model. Matlab code for this simulation can be found in the appendix.9 ρ=0 ρ = −0.5 10 10. ρ also affects this.

8 − 1.201 0. for a given strike. .8 show how σ affects the ‘significance’ of the smile/skew.5 4 0.8 0. S0 =1.2 0 1 Maturity(years) 2 3 Figure 1.19 0.1.9 1 1.1 Strike 1. V0 = 0. maturities : 0. S0 =1. This makes sense relative to the leverage effect. maturities : 0.7 and 1. strikes : 0. the effect of changing the kurtosis of the distribution impacts on the implied volatility.8 0.2. Higher σ means that the volatility is more volatile.195 0.185 0.202 Implied Volatility 0. σ = 0. Figures 1. κ = 2.2: Implied volatility surface.2 0.8 − 1.04.2 Motivation and Parameters ρ = 0. strikes : 0.2 0. σ = 0.04. less. θ = 0.5 − 3 years Again.2.6. writers of puts must charge more and those of calls.1.199 0. ρ = 1 .205 Implied Volatility 0. Higher σ makes the skew/smile more prominent. κ = 2. ρ = 0.9 1 1. This means that the market has a greater chance of extreme movements.21 0. 2 θ = 0.1.5 − 3 years ρ=0 0. r = 1%. So. 1.04.04.3: Implied volatility surface. r = 1%.1 Strike 1.2 0 1 Maturity(years) 2 3 Figure 1. V0 = 0.

5 − 3 years 0.098 0. κ.8 − 1.094 0. strikes : 0.1.11 Figure 1.106 0.215 0. θ = 0. the mean reversion parameter. This is something that has been observed in the market. viz. ρ = − 1 .21 Implied Volatility 0.2 Motivation and Parameters ρ = −0.092 σ=0 σ = 0.2 0 1 Maturity(years) 2 3 Figure 1.06 0.01 0 0.07 0.5: The effect of σ on the kurtosis of the density function Matlab code for generation of the volatility smiles/skews can be found in § A.2 .04.25 0.108 0. S0 =1. large price variations are more likely to be followed by large price variations .102 0.4: Implied volatility surface.04 0. maturities : 0.1 σ = 0.04.1 0. κ = 2 2.8 0.5 5 0.2 0.05 0.03 0.19 0..1.08 0. r = 1%.9 1 1.2.096 0. σ = 0.104 0. can be interpreted as representing the degree of ‘volatility clustering’.195 0.1 Strike 1.205 0. V0 = 0.02 0.

9 0.2 Figure 1.2 Figure 1.85 0. S0 =1.1 1. σ = 0.3 σ = 0.15 1.1 1.23 σ = 0.04.19 0.1.2 Implied Volatility 0.195 0.9 0.2 σ = 0.95 1 Strike 1.04.8 − 1.19 0.2. maturities : 0.04. κ = 2. σ = 0.1 σ = 0.5 − 3 years ρ=0 0.22 0. ρ = 0.2.5 − 3 years (Cont 2001).7: Implied volatility surface.15 1.4 0. V0 = 0.2 σ = 0.05 1.18 0. r = 1%.8 0.05 1. V0 = 0. θ = 0. κ = 2.1. strikes : 0. maturities : 0.4 6 0.5 0. 2 θ = 0. A computationally convenient feature of the model is that it provides a closed- .8 0.85 0.205 σ = 0.1 σ = 0. r = 1%.04.1. S0 =1.21 Implied Volatility 0. ρ = 1 .2 0.17 0.3 σ = 0.2 Motivation and Parameters ρ = 0.95 1 Strike 1.6: Implied volatility surface.8 − 1. strikes : 0.

95 1 Strike 1..21 Implied Volatility 0. The aforementioned features of this model enables it to produce a barrage of distributions. Models like Hull and White only provide such closed-form solutions for certain values of ρ.04. making it more tractable and easier to implement than other stochastic volatility models1 .85 0.1.e. 1.8: Implied volatility surface.19 0.3 Pricing Options In the Black-Scholes-Merton model. It provides a framework to price a variety of options that is closer to reality. This makes the market complete.2. V0 = 0. i. Volatility is not a traded asset.15 1. a contingent claim is dependent on the randomness of the asset ({St }t≥0 ) and the randomness associated with the volatility of the asset’s return ({Vt }t≥0 )..22 0. This makes the model very robust and hence addresses the shortcomings of the Black-Scholes-Merton model. it provides a closed-form solution for any value of ρ.17 0.5 0.3 σ = 0. This renders the market incomplete and has many more specifically. viz.9 0.1. r = 1%.18 0. S0 =1. maturities : 0. θ = 0. Since the assets are tradable. every contingent claim can be replicated.1 1. In a stochastic volatility model. a contingent claim is dependent on one or more tradable assets.1 σ = 0. the option can be hedged by continuously trading the underlyings.5 − 3 years form solution for European options. κ = 2 2. 1 .2 σ = 0.2 0.2 Figure 1. σ = 0. The randomness in the option value is solely due to the randomness of these assets.05 1. the asset.8 0.4 7 0. ρ = − 1 .8 − 1.3 Pricing Options ρ = −0. Only one of these is tradable.23 σ = 0.04. strikes : 0.

must satisfy the following partial differential equation. V. T ] (we are assuming. of course. V. say. V. (Majmin 2005) or (Xu 2003) for further details. T ). U (St .1 PDE approach For purposes of brevity.2 Risk Neutral approach Risk neutral valuation is the pricing of a contingent claim in an equivalent martingale measure (EMM). 2 1 ∂ 2U 1 2 ∂ 2U ∂U 2∂ U VS + ρσV S + σ V + rS 2 ∂S 2 ∂S∂V 2 ∂V 2 ∂S √ ∂U ∂U +{κ[θ − V ] − Λ(S.1 ). say λ(S. V. This parameter does not appear in (1.5) where H(T ) is the payoff of the option at time T and r is the risk free rate of interest over [t. and that the numeraire is the money market instrument). 1. t). (Gatheral 2004). t)σ V } − rU + =0 ∂V ∂t (1. (1. 2 this is referred to as the ‘Law of the Unconscious Financial Mathematician’ . Under the Heston model.3 . the value of any option. t. (2.1).1). This is no easy task as it well known that the market price of volatility risk is nearly impossible to estimate.4) Λ(S. t)σ V = kσVt = λ(S. t) is called the market price of volatility risk. Vt . that interest rates are deterministic and pre-visible.e. The price is evaluated as the expected discounted payoff of the contingent claim2 . 1.3 . This problem is overcome due to the parametric nature of the model and the existence of a closedform solution (see § 3. under the EMM Q.3 Pricing Options 8 implications to the pricing of options. t) = k V for some constant k √ ⇒ Λ(S. V. The reader is directed to (Black & Scholes 1973).1. i. the derivation of the PDE is not done here.2) or (1. and hence needs to be approximated. Heston assumes that the market price of volatility risk is proportional to volatility. t) therefore represents the market price of volatility risk. V. √ Λ(S. Option Value = EQ [er(T −t) H(T )] t (1.3) but does appear in the pricing formula.1 and § 2. So.

7). depending on the value of Λ(S. we have ˜ dWt1 = dWt1 + ϑt dt ˜ dWt2 = dWt2 + Λ(S.8) (1.e. The implications are that the different EMM’s will produce different option prices.8) solely determine the EMM. Under measure Q. t)dt dQ 1 t 2 = exp − (ϑs + Λ(S.3) become. poses a problem. we can work around this (see § 2. This implies that the EMM is not unique and is dependent on the value of Λ(S. s)2 )ds − dP 2 0 t 0 (1.12) dVt = κ (θ − Vt )dt + σ ˜ 1 dW 2 = ρdt dWt ˜t where. and (1.3 Pricing Options 9 Moving from a real world measure to an EMM is achieved by Girsavov’s Theorem. V.7) ϑs dWs1 − t 0 Λ(S. dSt = rSt dt + ∗ ∗ ˜ Vt St dWt1 ˜ Vt dWt2 (1. . In a complete market. V. κ∗ = κ + λ κθ θ∗ = κ+λ This is an important result. it can be shown that every asset/option has the same −r market price of risk (i.11) (1.6). Under the risk-neutral measure. t)dWs2 (1. V. due to the parametric nature of the model and the existence of a closedform solution. V. λ has effectively been ‘eliminated’. Again. t). V. In particular.2).10) (1. (1. Since volatility isn’t a σ traded asset. t) isn’t constant. (1.1 ). This. and (1. t). µF F is constant for any asset F ).6) (1. initially. V. It is clear that (1.1).. the market is incomplete and Λ(S.1 and § 3.9) ϑt = µ−r √ Vt ˜ ˜ where P is the real world measure and {Wt1 }t≥0 and {Wt2 }t≥0 are Q-Brownian Motions. (1.1.

2). T. This integral cannot be evaluated exactly. b2 = κ + λ e−iφ ln (K) fj (x. φ) = C(T − t. but in reality is quite ‘explicit’ and easy to evaluate in Matlab. K) = x = fj (x.2) (2. Vt . Vt . This section.. 2. This is used in the calibration process to obtain parameter values. Vt . 1 u1 = . b1 = κ + λ − ρσ. e. 2 1 u2 = − . 10 . φ)Vt + iφx} 1 − gedr a rφir + 2 (bj − ρσφi + d)τ − 2 ln σ 1−g dr bj − ρσφi + d 1 − e σ2 1 − gedr bj − ρσφi + d bj − ρσφi − d (ρσφi − bj )2 − σ 2 (2uj φi − φ2 ) (2. The only part that poses a slight problem is the limits of the integral in (2. T. provides the tools required to perform such calculations.g.1 The Closed-Form Solution The closed-form solution of a European call option on a non-dividend paying asset for the Heston model is: C(St . which in turn will be used to price other exotic options. but can be approximated with reasonable accuracy by using some numerical integration technique. 2 a = κθ. T ) = St P1 − Ke−r(T −t) P2 where. T. Vt . φ) = D(T − t.CHAPTER II Computational Evaluation In order to practically implement such a model. one needs to be able to compute the price of vanilla options implied by it. t. φ) = g = d = for j = 1. therefore. Pj (x. Gauss Lagendre or Gauss Lobatto integration.1) Such a formula looks intimidating.2. φ) + D(T − t. φ) 1 1 ∞ Re + dφ 2 π 0 iφ ln (St ) exp {C(T − t. where.

a = κ∗ θ∗ ..1. This method is much quicker than using a numerical method for the said integrals. Bates . A method to evaluate formulas in the form of (2.’ 3 A random variable is absolutely continuous if it has a density function.. E[eiφX ] FFT is an efficient algorithm used to calculate summations of the following form: N w(k) = j=1 e−i N (j−1)(k−1) x(j) 2π (2.2. it can be seen that. is ∞ F{f (x)} = −∞ eiφx f (x)dx = F (φ) ∞ −∞ (2. effectively. . its characteristic function exists.2 Fast Fourier Transform (FFT) This method has been proposed by (Carr & Madan 1999). For absolutely continuous random variables (say X). the characteristic function can be expressed as an expectation. We first begin with some basic definitions.. the traditional method described in Heston . 2. Carr and Madan have the following to say regarding their method: ‘. f (x) is the risk neutral density function of the log-return of the underlying and F (φ) is called the characteristic function of f (x). b2 = κ∗ Again. f (x).5) It is a type of discrete approximation to a Fourier transform..2 Fast Fourier Transform (FFT) 11 Under the EMM Q some parameter simplification takes place viz. The Fourier transform (F{·}) and inverse Fourier transform (F − 1{·}) of an integrable function.4) F −1 {F (φ)} = 1 2π e−iφx F (φ)dφ = f (x) In our framework..1) has been proposed by (Carr & Madan 1999). b1 = κ∗ − ρσ.find that the use of the FFT is considerably faster than most available methods and furthermore.3) (2. and Scott can be both slow and inaccurate. It should be noted that even if a random variable is not absolutely continuous3 . Bakshi and Madan . the parameter λ has been eliminated. viz. Definition 2.

8).6) and (2.7).5). ∞ ∞ k (2.2. where K is the strike price of the option. α>0 (2. with maturity T . Carr and Madan define a modified call price function4 . defined above. Then the value of a European call.9) −∞ 1 2π e−iφk FcT (φ)dφ CT (k) = e−αk cT (k) ∞ 1 e−iφk FcT (φ)dφ = e−αk 2π −∞ 1 ∞ −iφk = e−αk e FcT (φ)dφ π 0 Substituting (2. eiφk cT (k)dk ∞ −∞ (2. as a function of k is.7) into (2.10) (2.12) FcT (φ) = = eiφk eαk e−rT e−rT fT (xT ) (exT − ek )fT (xT )dxT dk (exT +αk − e(α+1)k )eiφk dkdxT ∞ −∞ ∞ −∞ −∞ ∞ −∞ xT −∞ e−rT = 2 α + α − φ2 + i(2α + 1)φ e−rT = 2 α + α − φ2 + i(2α + 1)φ e−rT FCT (φ − (α + 1)i) = 2 α + α − φ2 + i(2α + 1)φ 4 e(α+1+iφ)xT fT (xT )dxT e(−αi−i+φ)ixT fT (xT )dxT because CT (k) is not square integrable . cT (k) = eαk CT (k).2 Fast Fourier Transform (FFT) 12 Option pricing lends itself well to this sort of application due to the form of (1.8) (2.6) where fT (x) is the risk neutral density function of x. Let xt := ln St and k := ln K. CT (k) = e−rT k ∞ (exT − ek )fT (xT )dxT (2.7) We now expect cT (k) to be square integrable for a range of α values and ∀ k.11) (2.9) into (2. The Fourier transform and inverse Fourier transform of cT (k) is. ∞ FcT (φ) = cT (k) = Substituting (2. α is referred to as the dampening factor.

. under Q. fft(X) returns a (1 × N ) vector whose j th column corresponds to a log-strike of −b + 2b (j − 1).5) and hence FFT. The appendix. e−αku CT (ku ) ≈ π where5 .2. N + 1 This is now a direct application of (2. 2. .2 Fast Fourier Transform (FFT) 13 where FCT (φ) is the characteristic function of xT . Matlab can perform FFT using the fft(X) function. . 5 . given by (Hong 2004): FCT (φ) = eA(φ)+B(φ)+C(φ) A(φ) = iφ(x0 + rT ) 2ζ(φ)(1 − e−ψ(φ)T )V0 B(φ) = 2ψ(φ) − (ψ(φ) − γ(φ))(1 − e−ψ(φ)T ) κθ 2ψ(φ) − (ψ(φ) − γ(φ))(1 − e−ψ(φ)T ) C(φ) = − 2 2 log σ 2ψ(φ) (ψ(φ) − γ(φ))T 1 ζ(φ) = − (φ2 + iφ) 2 ψ(φ) = γ(φ)2 − 2σ 2 ζ(φ) γ(φ) = κ − ρσφi (Carr & Madan 1999) show that. contains the code for pricing a European Call N using FFT. .1 .13) 3 j=1 + N u = 1.3 . these parameters have been specified by Carr and Madan so that a balance is struck between computational time and accuracy. where X is the vector created from . § A. N 2π η e−i N (j−1)(u−1) eibvj FcT (vj ) (3 + (−1)j − δj−1 ) (2. vj = η(j − 1) c η = N c = 600 N = 4096 π b = η 2b ku = −b + (u − 1).

The formula is presented here without derivation. The Matlab code can also be found in § A. an FFT based on the time value of the option has to be derived. and a + 2h (we choose this form of partition for ease of calculation and notation. Since out-of-themoney options have no intrinsic value. as the author finds very little difference between the solutions of the two methods. Two techniques are briefly discussed together with their implementation.2. (Carr & Madan 1999) suggest that α be chosen such that α+1 E[ST ] < ∞ ⇒ FCT (−(α + 1)i) < ∞ (2.15) The error of the above approximate can be established with a basic Taylor6 6 no relation to the internal supervisor of this document.Quadrature Rules 14 All that remains is to choose the value of α.3 Numerical Integration .3 .2). a + h. for completeness. with partition points a.14) Carr goes further to provide FFT for out-of the money options. over two equal subintervals.3 .1 . A general formula will be given later). He argues that the above formula depends on the intrinsic value of the option. is a+2h f (x)dx ≈ a h [f (a) + 4f (a + h) + f (a + 2h)] 3 (2.3 Numerical Integration . .Quadrature Rules Numerical integration can be used to evaluate the integral in (2. 1 CT (ku ) ≈ π sinh(αku ) γT (v) = 2π η e−i N (j−1)(u−1) eibvj γT (vj ) (3 + (−1)j − δj−1 ) 3 j=1 N ϕT (v − iα) − ϕT (v + iα) 2 1 erT FC (v − i) − − T ϕT (v) = e−rT 1 + iv iv v 2 − iv 2.1 Adaptive Simpson’s Rule The following is adapted from (Cheney & Kincaid 1999). The basic Simpson’s Rule for numerical integration of a function. f (x). 2.

An Adaptive Simpson’s Rule divides the interval of integration into more than 2 subintervals. 2! 3! 4! 4 3 24 4 (4) f (a + 2h) = f (a) + 2hf (a) + 2h2 f (a) + h f (a) + h f (a) + . we get. 3 3 5! Noting. Consider. b) 1 Error = − 90 f (4) (ξ). using a Taylor series. .17) Subtracting (2.Quadrature Rules 15 series. 1 2 1 1 h f (a) + h3 f (a) + h4 f (4) (a) + . The number of subintervals is dependent on the required accuracy . . 3 3 3. 4 2 25 F (a+2h) = F (a)+2hF (a)+2h2 F (a)+ h3 F (a)+ h4 F (4) (a)+ h5 F (5) (a) . . 3 4! f (a + h) = f (a) + hf (a) + So. Error in approximation = − h5 (4) f (ξ) = O(h5 ). define F (x) := a x f (t)dt Again. .15) = 2hf + 2h2 f + h3 f + h4 f + h f (a) + .4! (2.16) from (2. b f (x)dx ≈ a b−a f (a) + 4f 6 b−a 2 5 a+b 2 + f (b) ξ ∈ (a. .16) Now.3 Numerical Integration . 4 2 20 5 (4) RHS of (2. . . . that F (n+1) (a) = f (n) (a) and F (a) = 0 we have a+2h f (x)dx = F (a + 2h) a 4 2 = 2hf (a) + 2h2 f (a) + h3 f (a) + h4 f (a) + .2. . 3 3 (2. . 90 ξ ∈ (a.17). a + 2h) We now state a general result for the basic Simpson’s Rule. by the Fundamental Theorem of Calculus.

b) uses an Adaptive Simpson’s Rule to numerically integrate @fun over [a. 1].3 . .b]. It produces a result that has an error less than 10−6 or a user defined tolerance level which is prescribed by a fourth argument.18) where. A Lagrange interpolating polynomial is a polynomial of order n−1 that passes through n given points. The roots of these polynomials will then be used as nodes in the Gaussian quadrature over [−1. The function will. The approximation in (2. pn+1 (x). b] by: b n f (x)dx ≈ a i=0 Ai f (xi ) (2.2 Adaptive Gaussian Quadrature Rules Gaussian quadrature rules approximate the integral of a function.1. 1] and standardising pn (x) such that pn (1) = 1. These are generated by setting the interval of integration to [−1. in general. behave differently over different parts of the interval and hence the intervals chosen will not be of uniform length. A simple linear transformation can translate the original integral over [a. Examples can be seen in figure 2. 2. f (x). termed nodes or abscissae. with weights {Ai }0≤i≤n . are the zeros of a Lagrange interpolating polynomial.2. {xi }0≤i≤n .a. The most popular choice of these polynomials are the Legendre polynomials. over [a. b] to [−1.Quadrature Rules 16 of the estimate.18). 1]. of degree n + 1 must satisfy: b a xk p(x)dx = 0.18) is a weighted average of the function at discrete nodes. (0 ≤ k ≤ n) It is quite intuitive that the choice of the polynomials will determine the accuracy of the estimate in (2. The Matlab function quad(@fun. This is quantified by the error term given above.3 Numerical Integration . The interpolating polynomial. b Ai = a n i (x) i (x)dx = j=0 j=i x − xj xi − xj where {xi }0≤i≤n .

φ) dφ iφ (2.3 Numerical Integration .b) implements an adaptive Gauss Lobatto quadrature rule on the function @fun over the interval [a. b].: ∞ Pj (x. The integral is evaluated over [−1. 3.1: Lagrange interpolating polynomials for n = 2. 4 and 5 points. Vt . It’s defined as the Gaussian quadrature presented above.2.19) . 1] with nodes that are from the Legendre polynomials.Quadrature Rules n=2 6 20 15 4 10 2 5 0 0 n=3 17 0 2 n=4 4 6 0 2 n=5 4 6 20 15 500 400 300 10 5 200 100 0 0 0 2 4 6 −100 0 2 4 6 Figure 2. The rule is adaptive as it divides the original integral into smaller subintervals and performs Gauss Lobatto integration with varying node quantities. The nodes are symmetric about the origin and also include the endpoints of the interval. K) = 1 1 + 2 π Re 0 e−iφ ln (K) fj (x. 2. and ξ ∈ (−1. 1). T.3 .a.3 Computation of the ‘Heston Integral’ In order to evaluate (2.1) we need to compute the integral in (2. 2. The error in the estimate is given by. This is performed to achieve an estimate whose error is less than 10−6 or a user defined tolerance level prescribed by a fourth argument. n(n − 1)3 22n−1 ((n − 2)!)4 (2n−2) Error = − f (ξ) (2n − 1)((2n − 2)!)3 where n = number of nodes. These polynomials are of order 1. The Matlab function quadl(@fun. with a specific form for the weights and nodes. T.2). viz. 3 and 4 respectively. Vt .

The parameters that were changed were those that had the most significant effect on the integrand. we require an extremely low tolerance level. Hence quadl would be better suited for our purposes.e.e. A problem arises as (2. for sufficiently large b. .2. Matlab code to price a European call option using Heston’s model via Adaptive Gauss Lobatto integration/Simpson’s Rule can be found in the appendix. Matlab defines the functions.2 . 2. For a complete discussion refer to (Gander & Gautschi 1998). • reliability as measured by the extent to which the required tolerance is achieved. The quadrature rule evaluates the option price only for a given set of parameters. This can be done in Matlab with the 2 functions. quad is more efficient (faster) than quadl. quad and quadl. § A.. So. (Gander & Gautschi 1998) say that for extremely small tolerance levels quadl outperforms quad in: • efficiency as measured by the number of recursive steps required to compute an answer within a certain tolerance level.4 Comparison of Quadrature Rules The purpose of this section is to gauge which quadrature rule to use. Thousands of European call option prices are immediately available. One would therefore expect quadl to be superior. but less reliable.4 Comparison of FFT and Numerical Integration 18 for j = 1. Keeping in mind that we’re pricing options. 2. A quick plot of the integrand will reveal that it converges very quickly to zero..2 shows the effect of changing the parameters on the integrand.4 Comparison of FFT and Numerical Integration It now remains to find which method is better suited for our purposes. the integral of (2. I have chosen b = 100 to be prudent.a.b).19) can be evaluated with the required accuracy. FFT is faster in a sense that it generates a matrix of prices with differing strikes.3 . quad(@fun a. quad(@fun.19) is an improper integral and the argument b cannot be specified as ‘infinity’ i.a. 2. Figure 2.b) evaluates only proper integrals.3 . For large tolerance levels. as low order and high order quadrature rules. discussed above.b) and quadl(@fun. i.

Notice how quickly this integrand converges to zero.14) we can also see that α is depend on the set of parameters.6 0. The time difference is extremely significant.9.1 only for one strike price at a time.19).1.15 15 x 10 −3 σ = 0.05 0 20 40 φ 60 80 100 −5 0 20 40 φ 60 80 100 Figure 2. maturity = 1 year σ = 0. maturity = 1 month 0. strike = 100. FFT. The quadrature rule takes approximately 281.1. ρ = −0. accuracy.1. r = 0. i.2: The Integrand of (2.8 0.89 seconds to perform the same calculation. strike = 50. Parameters that were kept constant : κ = 2.4 x 10 15 Comparison of FFT and Numerical Integration −3 19 σ = 0.04.2 −0.2. strike = 100.05 5 0 0 −0.5.05. maturity = 1 month 0.e. V0 = 0.. strike = 150.1 10 0. For a given set of parameters.14 seconds.1 0 −0. θ = 0.1.05 0 0 −5 0 20 40 φ σ = 0.4 0. maturity = 1 month 0.1 −0. The relationship between α and these parameters is not as trivial .3 −0.2 60 80 100 −0. suffers from one drawback. S0 = 100. strike = 100.1.05 0 20 40 φ 60 80 100 σ = 0.3 shows the price produced by FFT as a function of α). maturity = 1 month 0. The solutions produced are depend on the choice of α (figure 2. From (2. FFT is faster by a factor of 2014.15 10 0.1 5 0. strike = 100. maturity = 1 month 0. FFT calculates prices for 4097 different strikes in approximately 0.2 0 −0. in this application.4 0 20 40 φ 60 80 100 0 20 40 φ 60 80 100 σ = 0.

We are therefore left with the quadrature rule as our primary tool for evaluation. then FFT is far superior.3: This illustrates how the price of an option is depend on the choice of α .2.14). 39 38 37 36 35 34 33 32 31 30 price 0 1 2 α 3 4 5 Figure 2. If an α can be found that satisfies (2.4 Comparison of FFT and Numerical Integration 20 to identify as is done in (Carr & Madan 1999) for the Variance-Gamma model.

Ti ) are the ith option prices from the model and market. More specifically. those parameters that produce the correct vanilla option prices) and their time-series estimate counterparts are different (see (Bakshi.. This is called an inverse problem. κ. On the positive side. σ. This usually turns out to be a non-linear least-squares optimisation problem. The Heston model has six parameters that need estimation. viz. ρ. Ti ) 2 (3. which is near impossible to do in practice. and the wi ’s are weights (the choice of these weights will be discussed later). solving for a polynomial with given roots is an inverse problem. This leads to a complication that plagues stochastic volatility models in general7 . 8 eg. Ti ) − CiM (Ki . 7 21 . the squared differences between vanilla option market prices and that of the model are minimised over the parameter space. respectively. N is the number of options used for calibration. Often.1 The Calibration Problem The price to pay for more realistic models is the increased complexity of model calibration. This may seem as a problem but it actually allows flexibility in the calibration process. Ti ) and CiM (Ki . λ. Research has shown that the implied parameters (i. The most popular approach to solving this inverse problem is to minimise the error or discrepancy between model prices and market prices. CiΩ (Ki .CHAPTER III Calibration of the Model 3. the estimation method becomes as crucial as the model itself (Cont 2005).e. So one cannot just use empirical estimates for the parameters. The question now arises as to what market prices to use in this calibration process. A common solution is to find those parameters which produce the correct market prices of vanilla options.e. as we solve for the parameters indirectly through some implied structure 8 . we evaluate N min S(Ω) = min Ω Ω i=1 wi CiΩ (Ki . with strike Ki and maturity Ti .1) where Ω is a vector of parameter values. Cao & Chen 1997)). as for any given option there exists a bid and ask price. θ. we need not estimate the market price of volatility risk.. V0 . i.

but it is important to remember that S(Ω) is 5-dimensional and as such could be even nastier in its ‘true’ form. The minimisation mentioned above is not as trivial as it would seem. • Unique solutions to (3. 3. but fall. on average. the number of points that are non-differentiable. This means that a gradient based optimisation method will prove to be futile. also. ill-posed problem termed the calibration problem. This poses a further problem for gradient based optimisers. Accuracy beyond this could be spurious and hence produce less accurate exotic prices.2 th Calibration methods Before discussing the calibration methods. Ω0 . S(Ω) is neither convex nor does it have any particular structure.3. given that N wi CiΩ0 (Ki . It is easy to see that gradient based optimisers will struggle to find a global minimum. Figure 3. This is discussed later. This is therefore an inverse. in which case only local minima can be found.2) where bidi /aski are the bid/ask prices of the i option. • Hence. we address some technical issues. This is not an unreasonable relaxation of the calibration process. This has some implications regarding the stationarity of parameter values which are important in these types of models.2 Calibration methods 22 We will use the mid-price of the option but accept a parameter set. The last two points make this an ill-posed problem. In general. Ti ) i=1 2 N ≤ i=0 wi [bidi − aski ]2 (3. . within the bid-offer spread. Ti ) − CiM (Ki . Notice. This means that we do not require the model to match the mid-prices exactly. The graph presents a graphical idea of the nature of S(Ω) as a function of two of its parameters. finding a global minimum is difficult (and very dependent on the optimisation method used). This poses some complications: • Finding the minimum of S(Ω) is not as simple as finding those parameter values that make the gradient of S(Ω) zero. The aim is therefore to identify optimisation methods that can deal with the peculiarities of the calibration problem.1 plots S(Ω) as a function of κ and σ.1) need not necessarily exist. We should bare in mind that the modeling process should produce the required estimates within a certain tolerance level.

This means that less weight should be placed on such a price. We also need a constraint on the parameters to prevent the volatility reaching zero. (Cont 2005) suggests using the implied volatilities as weights. σ. ρ.. we can evaluate (3. Craddock & El-Hassan 2000). As mentioned in § 1.3.1 Regularisation This method is discussed briefly for completeness. σ. For a detailed discussion refer to (Chiarella. p(Ω). Ti ) i=1 2 + αp(Ω) (3. V0 . evaluation under an EMM effectively reduces the number of estimated parameters to five. Ti ) − CiM (Ki .1) using the CiΩ (Ki .1: The Heston error surface as a function of κ and σ The calibration problem has a slight simplification when we price options under an EMM.2 Calibration methods 23 x 10 4 Weighted Squared Errors 4 3 2 10 1 5 5 0 0 10 κ 15 0 σ Figure 3. 0) We also address the choice of the weights in (3. to (3. i. o 3. V0 .3) . Regularisation involves adding a penalty function.3 . (Mikhailov & N¨ gel 2003) suggest that this constraint be 2κθ > σ 2 . We choose the wi ’s to be 1 .1) such that N wi CiΩ (Ki . This choice is quite intuitive. λ) = OptionValueQ (κ∗ . we have a wider |bidi −aski | range of prices that the model can imply. ρ.e. θ∗ . Ti )’s under an EMM.1).2 . The following must therefore hold: OptionValueP (κ. θ. If the spread is great.2 . and vice-versa. In other words the model is allowed to imply a wider range of prices around the mid-price.

Equation (3. but does not possess the ill conditioning which the makes the original intractable. where Ω0 is o an initial estimate of the parameters. our system will never be under-determined9 . a local minimum optimiser. we attempt to find an approximation which is as close to the true solution as possible. then the calibration process would have to be rerun with a different x0. the initial estimate. To achieve this we are moved to replace our problem with one which is close to the original. Consequently. M ATLAB suggests (Coleman & Li 1996) and (Coleman & Li 1994) for further reference on these methods. but if (3. there should exist a rich set of market prices for calibration. (Mikhailov & N¨ gel 2003) suggest using αp(Ω) = ||Ω − Ω0 ||2 . a local one.lb. α. So.3. x0. i. In other words: Don’t try and solve the given problem. The result produced by lsqnonlin is dependent on the choice of x0. fun. If not. the solution is acceptable.3) can be minimised in M ATLAB using the function lsqnonlin(). We have no way of knowing whether the solution is a global/local minimum. try and solve a different one whose solution is close to that of your problem. these methods yield a single set of model parameters calibrated to the market but also require the extra step of determining the regularisation parameter. but rather. lsqnonlin uses an interior-reflective Newton method for large scale problems. where the lower and upper bounds of the parameters are specified in vectors lb and ub. here. The philosophy behind this strategy is one of pragmatism. all one needs is five or more market prices . It minimises the vector-valued function. M ATLAB defines a large scale problem as one containing bounded / unbounded parameters.2 Matlab’s lsqnonlin M ATLAB ’ S least-squares.2) is satisfied.2 . This is. Given that the underlying of the model is liquidly traded. respectively. where the number of equations to solve is more than the required parameters. This method is therefore dependent on the choice of the the initial parameters.ub). therefore. 9 in fact..e. non-linear optimiser is the function lsqnonlin(fun. It is. hopefully. This is the essence of all regularisation methods (Chiarella et al. not a global optimiser. We cannot hope to determine the exact solution to our problem because of its very nature. in a sense. is called the regularisation parameter.2 Calibration methods 24 is convex. 2000). x0. α (Cont 2005). where the system is not under-determined. 3. using the vector of initial parameter values. When applied to a given set of market prices.

solver. An advanced version of Solver can be purchased which contains a global optimiser. and stochasticity. .2 . These sort of calculations do appear during the calibration process. 3. e. The attractiveness of using Excel and Solver is that most people are comfortable with them and they are available on almost every computer in a workplace. relative to other nonlinear optimisation algorithms.g. § 3. contains information and code on using lsqnonlin for calibration. The author has used M ATLAB ’ S Excel Link to link the function HestonCallQuad between Excel and M ATLAB.. non-linear. • be implemented quite easily with the degree of coding quite minimal.2 . and hence can make your result suspect! Overall.4 Simulated Annealing (SA) Simulated Annealing is a probability-based. § 3.4 .2 Calibration methods 25 The appendix. optimiser inspired by the physical process of annealing. It uses a Generalized Reduced Gradient (GRG) method and hence is a local optimiser (for more information go to www. On the down side. • process quite arbitrary boundary conditions and constraints imposed on these objective functions.3 contains a comparison of this method to the others presented here. The spreadsheets HestonCalibration1 and HestonCalibration2 use this function to calculate the model prices. Excel provides a quick and dirty solution to our problem. The calibration results are therefore extremely sensitive to the initial estimates of the parameters. 3.com). (3. Its attractiveness lies in the fact that it can: • process objective functions (eg.3 contains a comparison of this method to the others presented here.3. These conditions must be met in order to motivate its use. Solver can then be run to calibrate the model.1)) possessing quite arbitrary degrees of nonlinearities. under certain conditions. § A. This optimiser should only be used when one is sure that the initial estimates are quite close to the optimal parameter set. calculating the bound 2κθ > σ 2 .3 Excel’s Solver The standard Solver supplied with Excel contains an optimiser that can be used for calibration under specific circumstances. Excel is useless at handling calculations with very small numbers.1 . discontinuities.

2. Annealing is a formal term for the ancient art of heating and/or cooling materials to forge pottery. until a termination condition is met (usually a specified value of the temperature parameter). 3. Rosenbluth. It helps to imagine the objective function. with the temperature parameter decreased at each iteration. and works of art (Frost & Heineman 1997). specified by the algorithm. It was (Kirkpatrick. then we ‘accept’ the parameter set from point 2. weapons. & Vecchi 1983) who realised the algorithms application to optimisation in general. and Tk is the temperature10 parameter at iteration k. The above algorithm not only ‘accepts’ parameter sets that decrease the objective function. the parameter set is accepted δf with probability exp {− Tk }. Annealing has played a key role in human history: entire nations have been won and lost on the abilities of craftsmen to produce fit materials (Frost & Heineman 1997). We want to find the deepest valley of this terrain. In a typical annealing process melted metal is allowed to cool subject to differing temperatures and pressures. but also that which increases it (subject to the probability constraints). The algorithm was first developed by (Metropolis. This ensures that the algorithm does not get stuck in a local minimum.2 Calibration methods 26 • statistically guarantee finding an optimal solution. Jr. Teller & Teller 1953) as a means of finding the equilibrium configuration of a collection of atoms at a given temperature for the actual annealing process. If the value of the objective function is less than that of point 1. The different combinations of these temperatures and pressures determine the structural properties of the cooled product. Rosenbluth. This process is iterated. as a geographical terrain. 4. where δf is the difference between the objective functions using the parameter sets in points 1 and 2. tools. that we want to minimise. Simulated Annealing approaches this problem in the same way that a bouncing ball can 10 termed this because of obvious historical reasons. else.3. The algorithm works in the following way: 1. Simulated Annealing was borne out of the need to model such processes thereby advancing the types of said materials produced. First the objective function is evaluated at the user-specified initial parameter estimates. . Next a random set of parameters is generated based on point 1 above.

makes the function a ‘black-box’ to the optimiser. This sort of specification has therefore become an art form. This means that the objective function should be able to tell the optimiser whether a set of parameters lies within the required parameter space (in our case. Parameters that are determined by the model (eg. but also allows the user to tweak the annealing scheme for greater efficiency. He also provides arguments for ASA’s computational effeciency and accuracy. The C++ code is open-source and available from www. The most famous and widely used of these is Adpative Simulated Annealing.3. been modified to a point where it is now perfect. adaptive methods of Simulated Annealing have been developed. Over the years it has.2 . whether 2κθ > σ 2 ). and the temperature parameter decreases. To reduce the subjective nature of the aforementioned specification. This. it determines the degree of ‘uphill’ movement and the rate of decrease of temperature. The annealing scheme broadly determines the efficiency and accuracy of the algorithm.com. As time progresses. It is therefore obvious that the annealing scheme be optimally specified. 3. It does not require the form of this objective function. the annealing scheme.5 Adaptive Simulated Annealing (ASA) ASA was developed by the theoretical physicist Lester Ingber. which in turn affects how long the algorithm runs for.2 Calibration methods 27 bounce over mountains. ASA is similar to SA except that it uses statistical measures of the algorithm’s current performance to modify its control parameters i. when the temperature is high. from valley to valley. It has always been open-source and hence Ingber has had a lot of feedback from users of ASA. the temperature parameter) are collectively known as the annealing scheme. .e. therefore. A proof is provided by that Ingber shows that ASA is a global optimiser. the ball has a lot of energy and can bounce from any valley to any other valley. Initially. in a sense.ingber. The algorithm requires only the value of the objective function for a given set of parameters. ASA works quite well in it’s ‘standard’ form. Such a specification isn’t obvious since parameters like temperature don’t have an explicit/implicit mathematical relationship with the objective function. and hence limits the search to a feasible space. For a detailed discussion on ASA the reader is referred to (Ingber 1993) and (Ingber 1995). Constraints are encapsulated within the ‘black-box’. For example. the ball loses energy and settles down in relatively smaller ranges of valleys.

This means that asamin uses the actual C++ code of Ingeber’s ASA through M ATLAB . listed on the LSE.3 Calibration Results Having an artillery of calibration methods at our disposal we can proceed to calibrate the model and compare the results.4 . The results are as follows: . An example of this data can be found at the end of § A. Given the thin requirements of the objective function. Solver and ASA were run with the same initial estimates on 2 sets of data.1 . was used as market data.4 .3. ASA lends itself well to a variety of applications in different disciplines. in the following fields: • Circuit design • Mathematics/combinatorics • Data analysis • Imaging • Neural networks • Biology • Physics • Geophysics • Finance • Military 3. asamin is a M ATLAB gateway function to ASA.3 Calibration Results 28 ASA can be implemented in M ATLAB by downloading the function asamin. Ingber has consulted on projects. written by Shinichi Sakata. where he has successfully implemented ASA. The M ATLAB code for calibrating the model using ASA can be found in § A.2 . lsqnonlin. Detailed instructions on how to install and use ASA on one’s computer and asamin into M ATLAB can be found in (Moins 2002). Vanilla calls on Anglo American shares.

1938 89.1034 2.6 Ghz.7 hrs 78. 11 This was run on a Pentium M 1.096 10 7.1450 ASA 21. but is far more computationally demanding. As can be seen.4 Comparisons.0481 0. 512MB RAM. 3.7416 0.7369 0.0745 1.38 3.2 and 3. As mentioned above.32 0. unlike lsqnonlin and Solver which settles down quite quickly into a local minimum.4 Comparisons.15 lsqnonlin 4.88 20 mins where Time is the running time of the calibration process11 . lsqnonlin and Solver don’t perform that badly in minimising S(Ω) . There have been trial runs where the differences between lsqnonlin. Although Solver produces the best parameter set.74783 0.0487 0.1469 88.4189 -0.16 148. Considerations and Shortcomings 29 V0 S(Ω) Time Method κ θ σ ρ 11 October 2005 Initial Estimate 3 0.0099 -0. the results will be quite different for a different set of initial estimates.8141 -0.5 0. on average. ASA will provide the best estimate if the annealing scheme is optimised.0859 -0.8236 0.10 10 mins 5 15.057 0.1) isn’t very far from the initial estimates.1829 77. the difference in S(Ω) is acceptable. .50 62.10 87. lsqnonlin and Solver should only be used when one is confident that the solution to (3. This conclusion can only be made for the given set of initial parameters.05 0.0579 0.7670 0. If these were chosen differently.1568 20 October 2005 Initial Estimate lsqnonlin ASA Solver 386. Solver and ASA were quite significant (ASA producing the best estimate).1583 Solver 5.1604 2.7 -0. One should be careful and not generalise such a conclusion as the solutions presented by lsqnonlin and Solver are very dependent on the initial parameters. The reason that ASA runs so long is because it searches the entire parameter space for a global minimum.1072 1.6066 -0. but is very close.58 6 mins 0.63 sec 81.3108 0. Figures 3. At this point it should be noted that ASA statistically guarantees to find an optimal solution. then lsqnonlin and Solver’s solutions could have been very far off from ASA’s.5 hours 0. Notice that lsqnonlin drops down very quickly to a local minimum whereas ASA keeps on searching for other minima and hence oscillates. Considerations and Shortcomings Relative to ASA.5 -0.3284 0.0227 -0. Given that they are far quicker than ASA.3. On the 11 October ASA doesn’t produce the lowest S(Ω). ASA gives the best result in minimising S(Ω).3 illustrate this point.8061 0.80 4.75 0.4998 0.

for a random guess of the initial parameters (e.3: This illustrates how the objective function is minimised when using ASA. x 10 4 12 10 Objective Function 8 6 4 2 0 0 0. There has been no tweaking of the annealing schedule which can result in a significant decrease in run-time. Also.3.2: This illustrates how the objective function is minimised when using lsqnonlin.4 Comparisons. ASA is the best option .5 1 Iteration 1. Considerations and Shortcomings 1400 30 1200 1000 Objective Function 800 600 400 200 0 0 100 200 300 400 Iteration 500 600 700 800 Figure 3.5 2 2. It should also be noted that ASA is being used in its raw form.5 x 10 4 Figure 3.g. this would be done when the model is calibrated for the very first time).

1).2). Comparing the PossibleSolutions matrices over the different days/months it could be possible to extract a set of parameters that are more or less an element of each PossibleSolutions. Another issue to consider is the stationarity of parameters. calculate the RHS of (3. An initial problem with ASA. Call this value SumBidOffer.3.2).^2) < SumBidOffer PossibleSolutions{j} = input. An acceptable set is one that satisfies (3. We expect that today’s parameters are in a small neighborhood around yesterday’s. In this case ASA would have to be used.4 Comparisons.2) that is evaluated at each iteration. lsqnonlin and Solver is that they don’t tell us anything about the multiplicity of solutions of the calibration problem. This creates a stationary set of parameters that satisfy (3. If there has been a crash or dramatic market movement then such an expectation is unreal. But. First. So. a parameter set that we use need not be this set. The stationarity that most practitioners on this topic refer to is that of the parameters that solve (3. Extracting the common set of parameters is not as trivial as it may seem. and the market conditions are quite normal (i. and hence the o comment above about calibrating the model each day. The model should now be calibrated every day/month until enough PossibleSolutions matices are available. But we can employ a clever trick and adapt ASA and lsqnonlin to do this. which method do we use? There isn’t a straight answer to this. j = j+1 end where j is the appropriate index of the cell matrix12 PossibleSolutions. Remember that the objective function is the LHS of (3. By adding the following logical test in functions HestonDifference and HestonCostFunc we can store those parameter sets that satisfy (3. Considerations and Shortcomings 31 The obvious question is. The choice of method should be dependent on the amount of information available related to parameter values and the state of the market. But. (Mikhailov & N¨ gel 2003) say that the parameters aren’t stationary. there should be a marriage of the different methods to create efficiency and not sacrifice accuracy. no crashes or dramatic movements since yesterday) then lsqnonlin and Solver can quite safely be used. If a global minimum was obtained yesterday (by using ASA). such a task wasn’t able to perform. Due to time constraints placed on such an honours project.2).2): if (sum(PriceDifference. We seek a 5-dimensional set of stationary parameters and hence the usual arguments 12 a cell matrix in Matlab is a matrix of matrices .e.

it seems that the calculation of (3. (Shu & Zhang 2004) propose a 2-step Indirect Inference method of calibrating the model. Also. The calibrated ensemble will then reproduce exact market prices. (Ingber 1993) notes that these algorithms are much slower that ASA. However.3. Rather. so it seems counter-intuitive to estimate some of the parameters using some time-series method. the recently developed simulation-based “indirect inference method” (time-series relative) is used to estimate the parameters for the dynamics of the asset. As mentioned before. Lastly. (Johnson & Lee 2004) proposes calibrating the model using an Ensemble method. Each set of the ensemble is assigned a weight which is attained by just one matrix inversion. in the 1-dimensional case. are not that helpful. similar to what is presented above. the parameters have no relation to their time-series counterparts. A non-linear least squares method is then used to calibrate the remaining parameters. while reading through the Wilmott forums.1) has to be minimised. . e.5 Other Methods For completeness a few of the other calibration methods will be presented. This seems like an extension to the method presented here and could be an interesting extension to this project. This method does not involve fitting the parameters to market data as most methods do. etc. though. it uses an ensemble of parameter sets. But it is exactly for this reason that we can estimate a few of the parameters by some other method and then use a non-linear least squares method to fit the model. 3. (Johnson & Lee 2004) state that the attractiveness in the model lies in it’s simplicity and robustness in being able to calibrate to any type of instrument. forward starting options.1) can be carried out using genetic algorithms. barrier options. First.g. This effectively reduces the dimension over which (3. M ATLAB contains some genetic algorithms in the Direct Search Toolbox which is an extension of the Optimisation Toolbox.5 Other Methods 32 that are used in such stationarity tests. hedge ratios are easily calculated..

It is important to remember that the Heston model is. If the underlying assumptions are carefully understood and its application carefully applied then stochastic models are powerful tools. essentially. one is trying to perfectly fit a model that doesn’t perfectly explain the real world. a model. After all. It is a mathematical tool that models something that is infinitely complex.Conclusion As Mathematicians (or students thereof) we can get caught up in the magic of Mathematics. It therefore cannot wholly capture the complicated and diverse dynamics that exist in reality. on over-fitting the model. useless. Energy should not be wasted. They are the best that we have in an unpredictable world without which we would be far worse off! 33 . This doesn’t make stochastic models. though. of volatility. in general. Such efforts can lead to spurious results. Calibration of the model is an important task.

r = 0. 34 . Zt1 = φ1 t Zt2 = ρφ1 + t 1 − ρ2 φ2 t where {φ1 }t≥0 and {φ2 }t≥0 are independent standard normal random variables. S = zeros(1. delT = .01.5. V = zeros(1.^(0. V(i) = V0 + k*(theta .5).02.1 Simulation of Probability Densities Monte Carlo simulation was performed by discretising the stochastic processes using the Euler-Maruyama method.numberOfSimulations).01. rho =-0.rho^2)*NormRand2)*sqrt(delT). t t Matlab code for the simulation of figure 1. sigma= . %prevents negative volatilities S(i) = S0 + r*S0*delT + S0*V.Appendix A. V0 = .1 is as follows: S0 = 10. theta =.9.. NormRand2 = randn(1. k = 2. The above can be made computationally easier by expressing {Zt1 }t≥0 and {Zt2 }t≥0 . numberOfSimulations = 1000000. i = 1:numberOfSimulations. using the Cholesky decomposition. The code is broadly similar for the simulation of figure 1..1. (rho*NormRand1 + sqrt(1. √ Vt−1 St−1 dtZt1 √ = Vt−1 + κ(θ − Vt−1 )dt + σ Vt−1 dtZt2 St = St−1 + rSt−1 dt + Vt where {Zt1 }t≥0 and {Zt2 }t≥0 are standard normal random variables with correlation ρ.numberOfSimulations).V0)*delT + sigma*sqrt(V0)* . V = abs(V). as a function of independent standard normal random variables.*NormRand1*sqrt(delT). This resulted in.numberOfSimulations). NormRand1 = randn(1.numberOfSimulations).

mats(i).1. .. Volatility’). mats(i).strikes(j)).Volatility).strike. 1.2 (figures 1. mats(i).j) = price.01.01.1..2.04.strikes(j)). . mats = linspace(.01 . . .1. price)..8.. figure..5. Volatility(i.04. figure.m generates the volatility surfaces of § 1. ylabel(’Strike’).04. surf(mat.04..j) = price. price). for i = 1:11 for j = 1:11 price = HestonCallQuad(2. prices(i. VolSmile. 1. 0.1.mats(i)...4).zlabel(’Implied ...strike. The function blsimpv returns the BSM implied volatility for a given set of parameters...5.1. for i = 1:11 for j = 1:11 price = HestonCallQuad(2.Volatility).1 )... .j) = blsimpv(1.0. Volatility’). .zlabel(’Implied . 1..strikes(j)).3. end end [strike mat] = meshgrid(strikes.xlabel(’Maturity(years)’)..2 Generating Volatility Surfaces and Skews Prices of the European call options are calculated.mats).j) = blsimpv(1..11).3. using the Heston closed-form solution (§ 2.01.Title(’\rho = 0. ylabel(’Strike’). strikes(j). prices(i.01 ..... at different maturities and strikes... %maturities for i = 1:11 for j = 1:11 price = HestonCallQuad(2...Title(’\rho = 0’).mats(i).3. strikes(j).04.-0. strikes = linspace(.. The following script file..0.. end end surf(mat.2.11).1.xlabel(’Maturity(years)’).04.5’). These prices are then equated to the Black-Scholes-Merton (BSM) solution and the volatility that satisfies this equation is evaluated. Volatility(i.A..2 Generating Volatility Surfaces and Skews 35 A. 0.

end plot(strikes.ylabel(’Implied Volatility’).0. price)...:).1.strike.j) = price.volvols(i). for i = 1:4 for j = 1:11 price = HestonCallQuad(2. 0. .j) = price.5’)..j) = blsimpv(1. 1. styleV = {[’-’][’--’] [’-. Volatility’).6. .’] [’:’]}.04.j) = blsimpv(1..1:. .1. prices(i.. end 36 end surf(mat. end plot(strikes.0.. Volatility(i.4].5.04. 0. .2 .4’) figure. .j) = price. ’\sigma = 0..8 of § 1.Volatility).volvols(i).8.04.Title(’\rho = -0.. .1. Volatility(i. colourV = {[’k’] [’b’] [’r’] [’m’]}. .. strikes(j).2 Generating Volatility Surfaces and Skews prices(i.01.zlabel(’Implied.01 .[char(colourV(i)). generates figures 1. mats(i). end legend(’\sigma = 0.1. strikes = linspace(. for i = 1:4 for j = 1:11 price = HestonCallQuad(2. ..Volatility(i. ylabel(’Strike’).. . hold on.01 ..1’. 0. 1.1. ..’\sigma = 0.. prices(i.’\sigma = 0.j) = blsimpv(1. price).A..[char(colourV(i)).. The following script. . xlabel(’Strike’)..2.2’..ylabel(’Implied Volatility’).01 .11).Title(’\rho = 0.1:..Volatility(i. .strikes(j)).. HestonVolSmileVolVol..5’). char(styleV(i))])..... price).:).m. Volatility(i.. strikes(j).01. xlabel(’Strike’). strikes(j). 1.strikes(j)).xlabel(’Maturity(years)’).3’.. char(styleV(i))]).7 and 1. volvols = [.04.Title(’\rho = 0’).

.. ...theta.5..4’) 37 A. ’\sigma = 0.01 .1... . price).3 for computationally evaluating the closed-form solution for a European call. 0.A. .2’.sigma. .5’).-0.. ’\sigma = 0.04.4’) figure. ...r .2’. .1 European Call using FFT The following function calculates at-the-money and in-the-money European call prices using FFT.:).’\sigma = 0..3 Evaluation of the Closed-Form Solution Presented here are the two methods discussed in § 2. hold on. A.01. Volatility(i.T) %kappa %theta %sigma %v0 %rho %T = = = = = = rate of reversion long run variance Volatility of volatility initial Variance correlation Time till maturity .s0.1’.04.3 ..’\sigma = 0.. function CallValue = HestonCallFft(kappa... strikes(j).v0. end legend(’\sigma = 0.3 Evaluation of the Closed-Form Solution hold on.1’.rho.j) = price.’\sigma = 0.Title(’\rho = -0.j) = blsimpv(1.ylabel(’Implied Volatility’).strikes(j))..3’.volvols(i).strike. end plot(strikes.1. prices(i. 1. char(styleV(i))]).[char(colourV(i)).2 and § 2. for i = 1:4 for j = 1:11 price = HestonCallQuad(2. end legend(’\sigma = 0. ..’\sigma = 0.3’.Volatility(i. xlabel(’Strike’).

(alpha+1)*i. FftFunc = exp(i*b*u).25..^2 . C = -kappa*theta/sigma^2*(2*log((2*PHI .*(1-exp(-PHI.2*sigma^2*zeta).A./(alpha^2 . (PHI-gamma). N= 4096.. CallValueM = exp(-log(strike)*alpha)*payoff/pi. B = v0*((2*zeta./(2*PHI .u. gamma = kappa .3 %r %s0 Evaluation of the Closed-Form Solution = interest rate = initial asset price 38 x0 = log(s0).theta.^2 +i*v). (2*PHI)) + (PHI-gamma)*T).. u = [0:N-1]*eta.../ . b =pi/eta.*(1-exp(-PHI*T)))).*(1-exp(-PHI*T))).*ModifiedCharFunc*eta.^2 + i*(2*alpha +1)*u).^[1:N] . position = (log(strike) + b)/lambda + 1..strike. lambda = 2*b/N. function CallValue = HestonCallFftTimeValue(kappa. CallValue = CallValueM(round(position)). + alpha . c = 600. SimpsonW = 1/3*(3 + (-i). charFunc = exp(A + B + C). zeta = -.r.rho.s0. (PHI-gamma).*T))).. The following function calculates out-of-the-money European call prices using FFT. A = i*v*(x0 + r*T).. payoff = real(fft(FftFunc)). alpha = 1. zeros(1. PHI = sqrt(gamma.*SimpsonW.. format short.rho*sigma*v*i..T) %kappa %theta %sigma %v0 = = = = rate of reversion long run variance Volatility of volatility initial Variance ..5*(v.N-1)]). %position of call %value in FFT %matrix v = u . sigma.[1.. eta = c/N.v0.. ModifiedCharFunc = charFunc*exp(-r*T).

2*sigma^2*zeta2). gamma2 = kappa .rho*sigma*v1*i./(2*PHI2)) . c = 600. ModifiedCharFunc1 = exp(-r*T)*(1. (PHI2-gamma2). %position of call %value in FFT matrix w1 w2 v1 v2 = = = = u-i*alpha. exp(r*T)./(w1.^2 ..*(1-exp(-PHI2*T))). (PHI2-gamma2).^2 +i*v1).. PHI1 = sqrt(gamma1. gamma1 = kappa ...... .5*(v1. C1 = -kappa*theta/sigma^2*(2*log((2*PHI1 ..*(1-exp(-PHI1*T)))). charFunc2 = exp(A2 + B2 + C2). lambda = 2*b/N. PHI2 = sqrt(gamma2. ModifiedCharFunc2 = exp(-r*T)*(1. exp(r*T). u = [0:N-1]*eta.*(1-exp(-PHI1*T)))./(w2.A. u-i*alpha -i..2*sigma^2*zeta1).rho*sigma*v2*i../(i*w1) . alpha = 1./(2*PHI2 . u+i*alpha -i.i*w2)). (PHI1-gamma1). u+i*alpha.*(1-exp(-PHI1..i*w1))./(1+i*w1) . eta = c/N. ModifiedCharFuncCombo = (ModifiedCharFunc1 ./(2*PHI1)) ./(2*PHI1 .. b =pi/eta...charFunc1. + (PHI2-gamma2)*T)./(1+i*w2) ../(i*w2) . zeta1 = -. A1 = i*v1*(x0 + r*T). position = (log(strike) + b)/lambda + 1..charFunc2..^2 ..^2 ...*T))). C2 = -kappa*theta/sigma^2*(2*log((2*PHI2 .3 %rho %T %r %s0 Evaluation of the Closed-Form Solution = = = = correlation Time till maturity interest rate initial asset price 39 x0 = log(s0). (PHI1-gamma1).. ModifiedCharFunc2)/2 .*(1-exp(-PHI2*T))))... A2 = i*v2*(x0 + r*T).25...*T))). B2 = v0*((2*zeta2. + (PHI1-gamma1)*T).^2 . N= 4096. zeta2 = -. charFunc1 = exp(A1 + B1 + C1).5*(v2.^2 +i*v2). B1 = v0*((2*zeta1.*(1-exp(-PHI2.

.r.theta.s0.K) calculates the value of a European call.v0.s0.kappa. where type = 1.kappa.T...[].r..0.[1.5.s0.. CallValue = CallValueM(round(position)).theta.s0. which evaluates the ‘f ’ function in the integrand of (2.rho.T.r.T.sigma. either using an adaptive Gauss Lobatto rule or adaptive Simpson’s Rule.rho.19).s0.rho.*Hestf(phi. .theta.type).sigma.3 Evaluation of the Closed-Form Solution SimpsonW = 1/3*(3 + (-1)./(i*phi)).kappa.v0.K.type) ret = real(exp(-i*phi*log(K)).sigma.r.K) warning off.T.sigma. v0. CallValueM = payoff/pi/sinh(alpha*log(strike)).type).s0. rho.v0.2).s0.^[1:N] .kappa..v0.sigma. .. == 1 0. .rho*sigma.v0. kappa. kappa . .rho.v0..s0.K.r.5. theta.N-1)]). All variable names are the same as used in (Heston 1993).rho.19).r.*ModifiedCharFuncCombo*eta.type).A.theta.2 European Call using Numerical Integration The function HestonCallQuad(kappa.r.v0. which evaluates (2.rho. in turn.T. This.19).v0.T. rho. function call = HestonCallQuad(kappa. function ret = HestonP(kappa.sigma.5 + 1/pi*quadl(@HestonPIntegrand. K*exp(-r*T)*HestonP(kappa. 40 A.type). zeros(1.2.r.sigma.rho.. -0. SimpsonW.100.T.sigma.theta.kappa.K. which evaluates the integrand of (2.theta.type).theta.K. call = s0*HestonP(kappa..1) .K.rho. s0.rho. calls HestonPIntegrand(phi.sigma. in turn calls Hestf(phi.type) ret = 0.r.sigma.theta.type)..s0.kappa.v0..[].K.r.T. function ret = HestonPIntegrand(phi.3 .T.K. format short.v0. It calls HestonP(kappa.s0. payoff = real(fft(FftFunc)). This..s0.r.T.T. function f if type u = b = else u = b = = Hestf(phi.r.*. sigma.theta.theta. FftFunc = exp(i*b*u).rho.theta.v0..T.sigma.

4 Calibration The following contains the M ATLAB code for calibrating the Heston model. NoOfOptions = Size(1).txt13 ./sigma^2.. clear. bid and offers. of the options and underlying from the file OptionData.. maturities./(b-rho*sigma*phi*i .*((b. C = r*phi.. It creates a handle on the function HestonDifferences that calculates the differences between the model and market prices within lsqnonlin.txt’ line imports the strikes.m .m initiates the calibration process./ . g = (b-rho*sigma*phi*i + d). market prices.T. A.d).bid. A. an example of the composition of OptionData. %OptionData = [r./(1-g))). etc..*i-phi. f = exp(C + D*v0 + i*phi*x).4 Calibration 41 end a = kappa*theta.*i*T + a/sigma^2.^2)). PriceDifference.*exp(d*T)).1 Using Matlab’s lsqnonlin The script file HestonLsCalibration. d = sqrt((rho*sigma*phi. (1-g.S0.. NoOfIterations.4 . x = log(s0). 2*log((1-g..*exp(d*T))).offer] Size = size(OptionData). Reasonable bounds on the parameters were chosen relative to this. The ‘load OptionData. load OptionData. The first parameter of input that M ATLAB sends into HestonDifference is 2κθ − σ 2 .*((1-exp(d*T)). global global global global OptionData. D = (b-rho*sigma*phi*i + d).K. NoOfIterations = 0.A.*i-b).^2-sigma^2*(2*u*phi. It is done here in this way because it is easier to encapsulate the constraint 2κθ − σ 2 > 0. NoOfOptions.Option Value.rho*sigma*phi*i + d)*T .m is presented at the end of this subsection 13 .

input(2).. Vanilla calls written on Anglo American shares that trade on the LSE have been used.1838]..5)-HestonCallQuad( .. (2*Calibration(2)).x0.4176 0. of iteration to 20000 so that termination %doesn’t take place early.input(5)... options = optimset(’MaxFunEvals’. %sets the max no. tic. . Solution = [(Calibration(1)+Calibration(3)^2)/ ....sigma. OptionData contains the following information: . PriceDifference.lb.OptionData(i..sigma^2.2). NoOfIterations = NoOfIterations + 1.20000)..OptionData(i.v0] x0 = [6...input(4). ub = [20 1 5 0 1].6).ub). function ret = HestonDifferences(input) global global global global NoOfOptions.A. lb = [0 0 0 -1 0]. Calibration = lsqnonlin(@HestonDifferences. %input matrix = [kappa theta sigma rho v0] end ret = PriceDifference’. OptionData(i. .. toc. %counts the no of iterations run to calibrate model for i = 1:NoOfOptions PriceDifference(i) = (OptionData(i. OptionData.1).m is a text file containing the market data for calibration.7)))). OptionData(i.. % theta. the file OptionData.4 Calibration 42 %input sequence in initial vectors [2*kappa*theta . For illustrative purposes.0731 2.3012 -0.4)))/sqrt((abs(OptionData(i.. input(3). . Calibration(2:5)]. (input(1)+input(3)^2)/(2*input(2)).5482 0.. NoOfIterations.3). As mentioned before. OptionData(i.rho.

50 1100.50 1900.00 368.00 121.00 1700.50 r-q 2.50 1800.00 114.50 86.00 35.50 1500.25 1700.375342 0.00 266.00 281.50 29.2685% 2.1947% 2.50 1544.627397 0.126027 0.00 154.375342 0.50 1544.00 217.2685% 2.2685% 2.00 41.50 1200.50 1800.50 1544.00 198.00 50.00 1400.126027 0.00 44.00 263.126027 0.50 1544.00 315.126027 0.126027 0.50 1350.375342 0.00 1450.00 1150.00 23.50 1544.50 466.50 1544.50 1300.126027 0.00 1200.00 1050.00 362.2685% 2.50 7.00 77.50 235.2685% 2.1947% 2.00 251.00 417.00 57.00 1400.00 244.1947% 2.00 221.00 1350.50 1544.50 1544.126027 0.00 128.126027 0.50 63.627397 0.2685% 2.2685% 2.50 272.50 378.00 1250.50 1544.2342% 2.00 1600.2342% 2.50 Offer 565.25 1900.50 308.00 460.00 81.50 321.00 28.50 454.00 7.126027 0.00 51.4 .50 1544.1947% A.50 102.00 275.00 213.1947% 2.375342 0.375342 0.50 108.50 1544.00 1400.00 223.50 1544.50 1544.00 1800.50 1544.2685% 2.2685% 2.1947% 2.126027 0.2342% 2.00 10.00 1250.50 1544.00 503.50 1300.50 51.00 18.2685% 2.00 20.00 105.126027 0.50 1544.00 515.2342% 2.00 345.00 1450.1947% 2.50 309.2685% 2.00 145.00 144.50 1700.00 176.50 1544.2685% 2.00 300.00 182.2342% 2.00 386.00 13.50 253.50 100.2342% 2.50 Bid 553.2342% 2.00 1350.00 229.50 1544.00 356.00 22.00 179.2342% 2.126027 0.50 1544.50 1544.627397 0.2685% 2.375342 0.00 140.50 1544.00 173.2 Adaptive Simulated Annealing (ASA) in M ATLAB The scheme that controls the ‘acceptance’ of new solutions is so simple that the cost of implementing ASA is purely dependent on the computational efficiency of .00 56.00 166.00 26.2685% 2.375342 0.50 1544.00 216.00 1450.375342 0.50 1544.50 Strike Mid Price 1000.00 509.00 136.375342 0.50 1600.00 269.00 180.00 174.00 56.50 1544.00 37.00 14.00 4.00 259.00 1500.00 1600.00 228.50 293.375342 0.2342% 2.50 1544.627397 0.50 1544.00 180.00 411.126027 0.126027 0.126027 0.00 405.50 1544.00 559.00 353.00 338.50 1544.A.00 207.2685% 2.50 1544.00 186.375342 0.50 92.00 96.50 1544.50 2.50 1544.1947% 2.50 393.627397 0.00 32.2342% 2.50 1500.50 290.627397 Spot 1544.4 Calibration 43 Term 0.50 1544.2342% 2.50 1900.627397 0.00 61.50 1544.627397 0.00 149.

bid. global OptionData. The following script. ’HestonCostFunc’.m . grad. %input matrix = [kappa theta sigma rho v0] NoOfIterations = NoOfIterations + 1.. calculation of the objective function for a given set of parameters entails the evaluation of a large number of options. global global global global global OptionData. hessian.lb’.sigma. NoOfIterations.S0. %flag = 0 if contraint is violated.rho.08977599]. toc. ub = [10 1 5 0 1].x0’. In our case.-1*ones(5.’test_in_cost_func’.offer] Size = size(OptionData). global ObjectiveFunc.Option Value. xstar. state] = asamin(’minimize’. else = 1 . calibrates the model using ASA. This makes ASA very computationally demanding and time consuming. %input sequence in initial vectors [kappa. global PriceDifference.theta. asamin(’set’.248415019 -1 0.1)). NoOfOptions. It uses the function HestonCostFunc clear. NoOfOptions = Size(1).4 Calibration 44 evaluating the objective function. PriceDifference. flag] = HestonCostFunc(input) global NoOfOptions. HestonASACalibration.. lb = [0 0 0 -1 0]. %OptionData = [r.K. [fstar. NoOfIterations = 0. load OptionData. global NoOfIterations. ObjectiveFunc.A.T.v0] x0 = [0..999999922 0. function [cost .0) tic.ub’.030854841 0. if (2*input(1)*input(2)<=input(3)^2) %test for constraint flag = 0.

..2).6).7)))).. OptionData(i. .OptionData(i.. OptionData(i. %the optimiser end .^2) ObjectiveFunc(NoOfIterations) = cost. input(1)..A.3)..4 Calibration 45 cost = 0 else for i = 1:NoOfOptions PriceDifference(i) = (OptionData(i. OptionData(i.5)-HestonCallQuad(..4)))/sqrt((abs(OptionData(i.input(4)..input(5). %stores the path of flag = 1.input(3)..input(2). end cost = sum(PriceDifference.1).OptionData(i..

(1999). (1994). D. Journal of Finance 52. ‘An interior. S. ‘Option evaluation the using fast fourier transform’. Quantitative Finance 1. Journal of Computational Finance 2(4). A. Cont. ‘Recovering volatilty from option prices by evolutionary optimisation’. F. R. F. (1999). Cheney.. D.. W. (1985). ‘Empirical performance of alternative option pricing models’. trust region approach for nonlinear minimization subject to bounds’. C. & Gautschi. 223–236. G. & Li. ‘Empirical properties of asset returns: stylized facts and statistical issues’. Ingersoll. & Scholes. Quantitative Finance Research Centre. 385–407. Gander. P.. 61–73. Coleman. Y. SIAM Journal on Optimization 6. M. B. P. Cont. C. Numerical Mathematics and Computing. & Kincaid. Adaptve quadrature .References Bakshi. pp. J. Departement Informatik. ‘A theory of the term structure of interest rates’. & Ross. W. 20032049. & Heineman. (1996). ‘On the convergence of reflective newton methods for large-scale nonlinear minimization subject to bounds’.html. Research Paper Series. E. Chiarella. C. Sydney. N. T. in ‘PDPTA’. Coleman.revisited. The calibration of stock option pricing models using inverse problem methodology. Brooks/Cole Publishing Company. u 46 . T. 418–445. & Madan. University of Technology. 4 edn. Black. Z. Econometrica 53. (1997). R. Cao. Carr. Y. & El-Hassan. Craddock. (1997). Research Paper Series 39. ETH Z¨ rich. J. Technical report. Cox. (2000). F. Frost. 637–654. & Li. http://ideas.org/p/uts/rpaper/39. Simulated annealing: A heuristic for parallel stochastic optimization. Journal of Political Economy 81. W. M.. & Chen. (1973). ‘Valuation of options and corporate liabilities’. (2005). Mathematical Programming. R. (1998).repec. 1595–. (2001).

(2003). J. E. (2004). Risk Magazine March. Pricing and hedging under stochastic volatility. P. S. calibration and some extensions’. (2002). (2004). C. (2004). 327–343. L. ‘Hestons stochastic volatility model implemeno tation.References 47 Gatheral.. University of the Witwatersrand. 89– 93. Technical report. Jr. J. Xu. L. (1993). Peking University. Wilmott. H. S. & Teller. o Shu. A. Metropolis. ‘A closed-form solution for options with stochastic volatility with applications to bonds and currency options’. Master’s thesis. Moins. J. & Zhang. L. Ingber. Master’s thesis. & Lee. Journal of Mathematical Computational Modelling 18(11). ‘Adaptive simulated annealing (asa): Lessons learned’. The Review of Financial Studies 6(2). ‘Equation of state calculations by fast computing machines’. ‘Capturing the smile’. (1993). (1995). ‘Simulated annealing: Practice versus theory’. Heston. Majmin. ‘Pricing s&p 500 index options under stochastic volatility with the indirect inference method’. S. E.. M. Control and Cybernetics. Kirkpatrick. Journal of Derivatives Accounting 1(2). China. Case Studies in Financial Modelling Notes. S. G. A. Johnson. ‘Optimization by simulated annealing’. Science 220(4598). Rosenbluth. M. Mikhailov. South Africa. 29–57. . (2003). Local and stochastic volatility models: An investigation into the pricing of exotic equity options. (2004). L. ‘Forward smile and derivative pricing’. 1–16.. Hong. A. S.. Implementation of a simulated annealing algorithm for M ATLAB . & N¨ gel. Ingber.. U. A. Courant Institute of Mathematical Sciences. (1953). (1983). 1087–1092. J. G. Journal of Chemisry and Physics 21(6). & Vecchi. Teller. N. ‘Lecture 1: Stochastic volatility and local volatility’. Link¨ ping Institute of Technology. Rosenbluth. 671–680. D. (2005).

Sign up to vote on this title
UsefulNot useful