Tải bản đầy đủ (.pdf) (416 trang)

IT training the heston model and its extensions in MATLAB and c rouah 2013 09 03

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (17.97 MB, 416 trang )

The Heston Model
and Its Extensions in
Matlab and C#


Founded in 1807, John Wiley & Sons is the oldest independent publishing company
in the United States. With offices in North America, Europe, Australia, and Asia,
Wiley is globally committed to developing and marketing print and electronic
products and services for our customers’ professional and personal knowledge and
understanding.
The Wiley Finance series contains books written specifically for finance and
investment professionals as well as sophisticated individual investors and their
financial advisors. Book topics range from portfolio management to e-commerce,
risk management, financial engineering, valuation, and financial instrument analysis,
as well as much more.
For a list of available titles, visit our website at www.WileyFinance.com


The Heston Model
and Its Extensions in
Matlab and C#

FABRICE DOUGLAS ROUAH


Cover illustration: Gilles Gheerbrant, ‘‘1 2 3 4 au hasard’’ (1976);
C Gilles Gheerbrant
Cover design: Gilles Gheerbrant
Copyright C 2013 by Fabrice Douglas Rouah. All rights reserved.
Published by John Wiley & Sons, Inc., Hoboken, New Jersey.
Published simultaneously in Canada.


No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form
or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as
permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior
written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to
the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax
(978) 646-8600, or on the Web at www.copyright.com. Requests to the Publisher for permission should
be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ
07030, (201) 748-6011, fax (201) 748-6008, or online at />Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in
preparing this book, they make no representations or warranties with respect to the accuracy or
completeness of the contents of this book and specifically disclaim any implied warranties of
merchantability or fitness for a particular purpose. No warranty may be created or extended by sales
representatives or written sales materials. The advice and strategies contained herein may not be suitable
for your situation. You should consult with a professional where appropriate. Neither the publisher nor
author shall be liable for any loss of profit or any other commercial damages, including but not limited
to special, incidental, consequential, or other damages.
For general information on our other products and services or for technical support, please contact our
Customer Care Department within the United States at (800) 762-2974, outside the United States at
(317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material
included with standard print versions of this book may not be included in e-books or in
print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version
you purchased, you may download this material at . For more information
about Wiley products, visit www.wiley.com.

Library of Congress Cataloging-in-Publication Data:
Rouah, Fabrice, 1964The Heston model and its extensions in Matlab and C# / Fabrice Douglas Rouah.
pages cm. – (Wiley finance series)
Includes bibliographical references and index.
ISBN 978-1-118-54825-7 (paper); ISBN 978-1-118-69518-0 (ebk); ISBN 978-1-118-69517-3 (ebk)
1. Options (Finance)–Mathematical models. 2. Options (Finance)–Prices. 3. Finance–Mathematical

models. 4. MATLAB. 5. C# (Computer program language) I. Title.
HG6024.A3R6777 2013
332.64 53028553–dc23
2013019475

Printed in the United States of America.
10

9

8

7

6

5

4

3

2

1


Contents
Foreword


ix

Preface

xi

Acknowledgments
CHAPTER 1
The Heston Model for European Options
Model Dynamics
The European Call Price
The Heston PDE
Obtaining the Heston Characteristic Functions
Solving the Heston Riccati Equation
Dividend Yield and the Put Price
Consolidating the Integrals
Black-Scholes as a Special Case
Summary of the Call Price
Conclusion

CHAPTER 2
Integration Issues, Parameter Effects, and Variance Modeling
Remarks on the Characteristic Functions
Problems With the Integrand
The Little Heston Trap
Effect of the Heston Parameters
Variance Modeling in the Heston Model
Moment Explosions
Bounds on Implied Volatility Slope
Conclusion


CHAPTER 3
Derivations Using the Fourier Transform
The Fourier Transform
Recovery of Probabilities With Gil-Pelaez Fourier Inversion
Derivation of Gatheral (2006)
Attari (2004) Representation
Carr and Madan (1999) Representation
Bounds on the Carr-Madan Damping Factor and Optimal Value
The Carr-Madan Representation for Puts
The Representation for OTM Options
Conclusion

xiii
1
1
4
5
10
12
17
18
19
22
23

25
25
29
31

34
43
56
57
61

63
63
65
67
69
73
76
82
84
89

v


vi

CONTENTS

CHAPTER 4
The Fundamental Transform for Pricing Options
The Payoff Transform
The Fundamental Transform and the Option Price
The Fundamental Transform for the Heston Model
Option Prices Using Parseval’s Identity

Volatility of Volatility Series Expansion
Conclusion

CHAPTER 5
Numerical Integration Schemes
The Integrand in Numerical Integration
Newton-Cotes Formulas
Gaussian Quadrature
¨
Integration Limits and Kahl and Jackel
Transformation
Illustration of Numerical Integration
Fast Fourier Transform
Fractional Fast Fourier Transform
Conclusion

CHAPTER 6
Parameter Estimation
Estimation Using Loss Functions
Speeding up the Estimation
Differential Evolution
Maximum Likelihood Estimation
Risk-Neutral Density and Arbitrage-Free Volatility Surface
Conclusion

CHAPTER 7
Simulation in the Heston Model
General Setup
Euler Scheme
Milstein Scheme

Milstein Scheme for the Heston Model
Implicit Milstein Scheme
Transformed Volatility Scheme
Balanced, Pathwise, and IJK Schemes
Quadratic-Exponential Scheme
Alfonsi Scheme for the Variance
Moment Matching Scheme
Conclusion

91
91
92
95
100
108
113

115
116
116
121
130
136
137
141
145

147
147
158

162
166
170
175

177
177
179
181
183
185
188
191
193
198
201
202


Contents

CHAPTER 8
American Options
Least-Squares Monte Carlo
The Explicit Method
Beliaeva-Nawalkha Bivariate Tree
Medvedev-Scaillet Expansion
Chiarella and Ziogas American Call
Conclusion


CHAPTER 9
Time-Dependent Heston Models
Generalization of the Riccati Equation
Bivariate Characteristic Function
Linking the Bivariate CF and the General Riccati Equation
¨
Mikhailov and Nogel
Model
Elices Model
Benhamou-Miri-Gobet Model
Black-Scholes Derivatives
Conclusion

CHAPTER 10
Methods for Finite Differences
The PDE in Terms of an Operator
Building Grids
Finite Difference Approximation of Derivatives
The Weighted Method
Boundary Conditions for the PDE
Explicit Scheme
ADI Schemes
Conclusion

CHAPTER 11
The Heston Greeks
Analytic Expressions for European Greeks
Finite Differences for the Greeks
Numerical Implementation of the Greeks
Greeks Under the Attari and Carr-Madan Formulations

Greeks Under the Lewis Formulations
Greeks Using the FFT and FRFT
American Greeks Using Simulation
American Greeks Using the Explicit Method
American Greeks from Medvedev and Scaillet
Conclusion

vii

205
205
213
217
228
253
261

263
263
264
269
271
278
285
299
300

301
301
302

303
306
315
316
321
325

327
327
332
333
339
343
345
346
349
352
354


viii

CONTENTS

CHAPTER 12
The Double Heston Model
Multi-Dimensional Feynman-KAC Theorem
Double Heston Call Price
Double Heston Greeks
Parameter Estimation

Simulation in the Double Heston Model
American Options in the Double Heston Model
Conclusion

357
357
358
363
368
373
380
382

Bibliography

383

About the Website

391

Index

397


Foreword
am pleased to introduce The Heston Model and Its Extensions in Matlab and C#
by Fabrice Rouah. Although I was already familiar with his previous book entitled
Option Pricing Models and Volatility Using Excel/VBA, I was pleasantly surprised

to discover he had written a book devoted exclusively to the model that I developed
in 1993 and to the many enhancements that have been brought to the original model
in the twenty years since its introduction. Obviously, this focus makes the book
more specialized than his previous work. Indeed, it contains detailed analyses and
extensive computer implementations that will appeal to careful, interested readers.
This book should interest a broad audience of practitioners and academics, including
graduate students, quants on trading desks and in risk management, and researchers
in option pricing and financial engineering.
There are existing computer programs for calculating option prices, such as
those in Rouah’s prior book or those available on Bloomberg systems. But this
book offers more. In particular, it contains detailed theoretical analyses in addition
to practical Matlab and C# code for implementing not only the original model,
but also the many extensions that academics and practitioners have developed
specifically for the model. The book analyzes numerical integration, the calculation
of Greeks, American options, many simulation-based methods for pricing, finite
difference numerical schemes, and recent developments such as the introduction of
time-dependent parameters and the double version of the model. The breadth of
methods covered in this book provides comprehensive support for implementation
by practitioners and empirical researchers who need fast and reliable computations.
The methods covered in this book are not limited to the specific application
of option pricing. The techniques apply to many option and financial engineering
models. The book also illustrates how implementation of seemingly straightforward
mathematical models can raise many questions. For example, one colleague noted
that a common question on the Wilmott forums was how to calculate a complex
logarithm while still guaranteeing that the option model produces real values.
Obviously, an imaginary option value will cause problems in practice! This book
resolves many similar difficulties and will reward the dedicated reader with clear
answers and practical solutions. I hope you enjoy reading it as much as I did.

I


Professor Steven L. Heston
Robert H. Smith School of Business
University of Maryland
January 3, 2013

ix


Preface
n the twenty years since its introduction in 1993, the Heston model has become
one of the most important models, if not the single most important model, in
a then-revolutionary approach to pricing options known as stochastic volatility
modeling. To understand why this model has become so important, we must revisit
an event that shook financial markets around the world: the stock market crash of
October 1987 and its subsequent impact on mathematical models to price options.
The exacerbation of smiles and skews in the implied volatility surface that
resulted from the crash brought into question the ability of the Black-Scholes model
to provide adequate prices in a new regime of volatility skews, and served to
highlight the restrictive assumptions underlying the model. The most tenuous of
these assumptions is that of continuously compounded stock returns being normally
distributed with constant volatility. An abundance of empirical studies since the
1987 crash have shown that this assumption does not hold in equities markets. It
is now a stylized fact in these markets that returns distributions are not normal.
Returns exhibit skewness, and kurtosis—fat tails—that normality cannot account
for. Volatility is not constant in time, but tends to be inversely related to price, with
high stock prices usually showing lower volatility than low stock prices. A number
of researchers have sought to eliminate this assumption in their models, by allowing
volatility to be time-varying.
One popular approach for allowing time-varying volatility is to specify that

volatility be driven by its own stochastic process. The models that use this approach,
including the Heston (1993) model, are known as stochastic volatility models. The
models of Hull and White (1987), Scott (1987), Wiggins (1987), Chensey and
Scott (1989), and Stein and Stein (1991) are among the most significant stochastic
volatility models that pre-date Steve Heston’s model. The Heston model was not the
first stochastic volatility model to be introduced to the problem of pricing options,
but it has emerged as the most important and now serves as a benchmark against
which many other stochastic volatility models are compared.
Allowing for non-normality can be done by introducing skewness and kurtosis
in the option price directly, as done, for example, by Jarrow and Rudd (1982),
Corrado and Su (1997), and Backus, Foresi, and Wu (2004). In these models,
skewness and kurtosis are specified in Edgeworth expansions or Gram-Charlier
expansions. In stochastic volatility models, skewness can be induced by allowing
correlation between the processes driving the stock price and the process driving its
volatility. Alternatively, skewness can arise by introducing jumps into the stochastic
process driving the underlying asset price.
The parameters of the Heston model are able to induce skewness and kurtosis,
and produce a smile or skew in implied volatilities extracted from option prices
generated by the model. The model easily allows for the inverse relationship between
price level and volatility in a manner that is intuitive and easy to understand.
Moreover, the call price in the Heston model is available in closed form, up to an

I

xi


xii

PREFACE


integral that must be evaluated numerically. For these reasons, the Heston model
has become the most popular stochastic volatility model for pricing equity options.
Another reason the Heston model is so important is that it is the first to exploit
characteristic functions in option pricing, by recognizing that the terminal price
density need not be known, only its characteristic function. This crucial line of
reasoning was the genesis for a new approach for pricing options, known as pricing
by characteristic functions. See Zhu (2010) for a discussion.
In this book, we present a treatment of the classical Heston model, but also of the
many extensions that researchers from the academic and practitioner communities
have contributed to this model since its inception. In Chapter 1, we derive the characteristic function and call price of Heston’s (1993) original derivation. Chapter 2 deals
with some of the issues around the model such as integrand discontinuities, and also
shows how to model implied and local volatility in the model. Chapter 3 presents
several Fourier transform methods for the model, and Chapter 4 deals exclusively
with Alan Lewis’ (2000, 2001) approach to stochastic volatility modeling, as it
applies to the Heston model. Chapter 5 presents a variety of numerical integration
schemes and explains how integration can be speeded up. Chapter 6 deals with
parameter estimation, and Chapter 7 presents classical simulation schemes applied
to the model and several simulation schemes designed specifically for the model.
Chapter 8 deals with pricing American options in the Heston model. Chapter 9
presents models in which the parameters of the original Heston model are allowed
to be piecewise constant. Chapter 10 presents methods for obtaining the call price
that rely on solving the Heston partial differential equation with finite differences.
Chapter 11 presents the Greeks in the Heston model. Finally, Chapter 12 presents
the double Heston model, which introduces an additional stochastic process for
variance and thus allows the model to provide a better fit to the volatility surface.
All of the models presented in this book have been coded in Matlab and C#.


Acknowledgments


would like to thank Steve Heston not only for having bestowed his model to
the financial engineering community, but also for contributing the Foreword to
this book and to Leif B.G. Andersen, Marco Avellaneda, Peter Christoffersen, Jim
Gatheral, Espen Gaarder Haug, Andrew Lesniewski, and Alan Lewis for their
generous endorsement. And to my team at Wiley—Bill Falloon, Meg Freeborn,
Steven Kyritz, and Tiffany Charbonier—thank you. I am also grateful to Gilles
Gheerbrant for his strikingly beautiful cover design.
Special thanks also to a group who offered moral support, advice, and technical
reviews of the material in this book: Amir Atiya, S´ebastien Bossu, Carl Chiarella,
Elton Daal, Redouane El-Kamhi, Judith Farer, Jacqueline Gheerbrant, Emmanuel
Gobet, Greg N. Gregoriou, Antoine Jacquier, Dominique Legros, Pierre Leignadier,
Alexey Medvedev, Sanjay K. Nawalkha, Razvan Pascalau, Jean Rouah, Olivier
Scaillet, Martin Schmelzle, and Giovanna Sestito. Lastly, a special mention to Kevin
Samborn at Sapient Global Markets for his help and support.

I

xiii


The Heston Model
and Its Extensions in
Matlab and C#


CHAPTER

1


The Heston Model
for European Options

Abstract
In this chapter, we present a complete derivation of the European call price under the
Heston model. We first present the model and obtain the various partial differential
equations (PDEs) that arise in the derivation. We show that the call price in the
Heston model can be expressed as the sum of two terms that each contains an in-themoney probability, but obtained under a separate measure, a result demonstrated
by Bakshi and Madan (2000). We show how to obtain the characteristic function
for the Heston model, and how to solve the Riccati equation from which the
characteristic function is derived. We then show how to incorporate a continuous
dividend yield and how to compute the price of a European put, and demonstrate
that the numerical integration can be speeded up by consolidating the two numerical
integrals into a single integral. Finally, we derive the Black-Scholes model as a special
case of the Heston model.

MODEL DYNAMICS
The Heston model assumes that the underlying stock price, St , follows a BlackScholes–type stochastic process, but with a stochastic variance vt that follows a
Cox, Ingersoll, and Ross (1985) process. Hence, the Heston model is represented by
the bivariate system of stochastic differential equations (SDEs)

dSt = μSt dt + vt St dW 1,t
(1.1)

dvt = κ(θ − vt )dt + σ vt dW 2,t
where EP [dW 1,t dW 2,t ] = ρdt.
We will sometimes drop the time index and write S = St , v = vt , W1 = W1,t and
W2 = W2,t for notational convenience. The parameters of the model are
κ
θ

σ
v0

μ the drift of the process for the stock;
> 0 the mean reversion speed for the variance;
> 0 the mean reversion level for the variance;
> 0 the volatility of the variance;
> 0 the initial (time zero) level of the variance;

The Heston Model and Its Extensions in Matlab and C#. Fabrice Douglas Rouah.
© 2013 Fabrice Douglas Rouah. Published 2013 by John Wiley & Sons, Inc.

1


2

THE HESTON MODEL AND ITS EXTENSIONS IN MATLAB AND C#

ρ ∈ [−1, 1] the correlation between the two Brownian motions W1 and W2 ; and
λ the volatility risk parameter. We define this parameter in the next
section and explain why we set this parameter to zero.
We will see in Chapter 2 that these parameters affect the distribution of the
terminal stock price in a manner that is intuitive. Some authors refer to v0 as an
unobserved initial state variable, rather than a parameter. Because volatility cannot
be observed, only estimated, and because v0 represents this state variable at time
zero, this characterization is sensible. For the purposes of estimation, however, many
authors treat v0 as a parameter like any other. Parameter estimation is covered in
Chapter 6.


It is important to note that the volatility vt is not modeled directly in the
Heston model, but rather through the variance vt . The process for the variance arises

from the Ornstein-Uhlenbeck process for the volatility ht = vt given by
dht = −βht dt + δdW2,t .

(1.2)

¯ lemma, vt = h2t follows the process
Applying Ito’s

dvt = (δ 2 − 2βvt )dt + 2δ vt dW 2,t .

(1.3)

Defining κ = 2β, θ = δ 2 /(2β), and σ = 2δ expresses dvt from Equation (1.1)
as (1.3).
The stock price and variance follow the processes in Equation (1.1) under
the historical measure P, also called the physical measure. For pricing purposes,
however, we need the processes for (St , vt ) under the risk-neutral measure Q. In the
Heston model, this is done by modifying each SDE in Equation (1.1) separately by
an application of Girsanov’s theorem. The risk-neutral process for the stock price is
dSt = rSt dt +


vt St dW1,t

(1.4)

where

μ−r
W1,t = W1,t + √ t .
vt
It is sometimes convenient to express the price process in terms of the log price
¯ lemma, the log price process is
instead of the price itself. By an application of Ito’s
d ln St = μ −

1

dt + vt dW 1,t .
2

The risk-neutral process for the log price is
d ln St = r −

1

dt + vt dW1,t .
2

(1.5)

If the stock pays a continuous dividend yield, q, then in Equations (1.4) and
(1.5) we replace r by r − q.


3

The Heston Model for European Options


The risk-neutral process for the variance is obtained by introducing a function
λ(St , vt , t) into the drift of dvt in Equation (1.1), as follows

dvt = [κ(θ − vt ) − λ(St , vt , t)]dt + σ vt dW2,t

(1.6)

where
W2,t = W2,t +

λ St , vt , t
t .

σ vt

(1.7)

The function λ(S, v, t) is called the volatility risk premium. As explained in
Heston (1993), Breeden’s (1979) consumption model yields a premium proportional
to the variance, so that λ(S, v, t) = λvt , where λ is a constant. Substituting for λvt in
Equation (1.6), the risk-neutral version of the variance process is

dvt = κ ∗ (θ ∗ − vt )dt + σ vt dW2,t

(1.8)

where κ ∗ = κ + λ and θ ∗ = κθ/(κ + λ) are the risk-neutral parameters of the variance
process.
To summarize, the risk-neutral process is


vt St dW1,t

dvt = κ ∗ (θ ∗ − vt )dt + σ vt dW2,t
dSt = rSt dt +

(1.9)

where EQ [dW1,t dW2,t ] = ρdt and with Q the risk-neutral measure.
Note that, when λ = 0, we have κ ∗ = κ and θ ∗ = θ so that these parameters under
the physical and risk-neutral measures are the same. Throughout this book, we set
λ = 0, but this is not always needed. Indeed, λ is embedded in the risk-neutral parameters κ ∗ and θ ∗ . Hence, when we estimate the risk-neutral parameters to price options
we do not need to estimate λ. Estimation of λ is the subject of its own research, such
as that by Bollerslev et al. (2011). For notational simplicity, throughout this book
we will drop the asterisk on the parameters and the tilde on the Brownian motion
when it is obvious that we are dealing with the risk-neutral measure.

Properties of the Variance Process
The properties of vt are described by Cox, Ingersoll, and Ross (1985) and Brigo
and Mercurio (2006), among others. It is well-known that conditional on a realized
value of vs , the random variable 2ct vt (for t > s) follows a non-central chi-square
distribution with d = 4κθ/σ 2 degrees of freedom and non-centrality parameter
2ct vs e−κ(t−s) , where

(1.10)
ct = 2
σ (1 − e−κ(t−s) )
and with t > s. The mean and variance of vt , conditional on the value vs are,
respectively
m = E[vt |vs ] = θ + (vs − θ )e−κ(t−s) ,

S2 = Var[vt |vs ] =

vs σ 2 e−κ(t−s)
θσ2
(1 − e−κ(t−s) ) +
(1 − e−κ(t−s) )2 .
κ


(1.11)


4

THE HESTON MODEL AND ITS EXTENSIONS IN MATLAB AND C#

The effect of the mean reversion speed κ on the moments is intuitive and
explained in Cox, Ingersoll, and Ross (1985). When κ → ∞ the mean m approaches
the mean reversion rate θ and the variance S2 approaches zero. As κ → 0 the mean
approaches the current level of variance, vs , and the variance approaches σ 2 vt (t − s).
If the condition 2κθ > σ 2 holds, then the drift is sufficiently large for the variance
process to be guaranteed positive and not reach zero. This condition is known as the
Feller condition.

THE EUROPEAN CALL PRICE
In this section, we show that the call price in the Heston model can be expressed in a
manner which resembles the call price in the Black-Scholes model, which we present
in Equation (1.76). Authors sometimes refer to this characterization of the call price
as ‘‘Black-Scholes–like’’ or ‘‘a` la Black-Scholes.’’ The time-t price of a European call
on a non-dividend paying stock with spot price St , when the strike is K and the time

to maturity is τ = T − t, is the discounted expected value of the payoff under the
risk-neutral measure Q
C(K) = e−rτ EQ [(ST − K)+ ]
= e−rτ EQ [(ST − K)1ST >K ]
= e−rτ EQ [ST 1ST >K ] − Ke−rτ EQ [1ST >K ]

(1.12)

= St P1 − Ke−rτ P2
where 1 is the indicator function. The last line of (1.12) is the ‘‘Black-Scholes–like’’
call price formula, with P1 replacing (d1 ), and P2 replacing (d2 ) in the BlackScholes call price (1.76). In this section, we explain how the last line of (1.12) can be
derived from the third line. The quantities P1 and P2 each represent the probability
of the call expiring in-the-money, conditional on the value St = ext of the stock and
on the value vt of the volatility at time t. Hence
Pj = Pr(ln ST > ln K)

(1.13)

for j = 1, 2. These probabilities are obtained under different probability measures. In
Equation (1.12), the expected value EQ [1ST >K ] is the probability of the call expiring
in-the-money under the measure Q that makes W1 and W2 in the risk-neutral version
of Equation (1.1) Brownian motion. We can therefore write
EQ [1ST >K ] = Q(ST > K) = Q(ln ST > ln K) = P2 .
Evaluating e−rτ EQ [ST 1ST >K ] in (1.12) requires changing the original measure Q
to another measure QS . Consider the Radon-Nikodym derivative
dQ
BT /Bt
EQ [exT ]
=
=

dQS
ST /St
exT
where
t

Bt = exp

rdu = ert .
0

(1.14)


5

The Heston Model for European Options

In (1.14), we have written St er(T−t) = EQ [exT ], since under Q assets grow at the
risk-free rate, r. The first expectation in the third line of (1.12) can therefore be
written as
e−r(T−t) EQ [ST 1ST >K ] = St EQ

ST /St
ST /St
dQ
S
1ST >K = St EQ
1ST >K
BT /Bt

BT /Bt
dQS

QS

(1.15)

= St E [1ST >K ] = St Q (ST > K) = St P1 .
S

This implies that the European call price of Equation (1.12) can be written in
terms of both measures as
C(K) = St QS (ST > K) − Ke−rτ Q(ST > K).

(1.16)

The measure Q uses the bond Bt as the numeraire, while the measure QS
uses the stock price St . Bakshi and Madan (2000) present a derivation of the call
price expressed as (1.16), but under a general setup. As shown in their paper,
the change of measure that leads to (1.16) is valid for a wide range of models,
including the Black-Scholes and Heston models. We will see later in this chapter
that when ST follows the lognormal distribution specified in the Black-Scholes
model, then QS (ST > K) = (d1 ) and Q(ST > K) = (d2 ). Hence, the characteristic
function approach to pricing options, pioneered by Heston (1993), applies to the
Black-Scholes model also.

THE HESTON PDE
In this section, we explain how to derive the PDE for the Heston model. This
derivation is a special case of a PDE for general stochastic volatility models,
described in books by Gatheral (2006), Lewis (2000), Musiela and Rutkowski

(2011), Joshi (2008), and others. The argument is similar to the hedging argument
that uses a single derivative to derive the Black-Scholes PDE. In the Black-Scholes
model, a portfolio is formed with the underlying stock, plus a single derivative which
is used to hedge the stock and render the portfolio riskless. In the Heston model,
however, an additional derivative is required in the portfolio, to hedge the volatility.
Hence, we form a portfolio consisting of one option V = V(S, v, t),
units of the
stock, and ϕ units of another option U(S, v, t) for the volatility hedge. The portfolio
has value
=V+

S + ϕU

where the t subscripts are omitted for convenience. Assuming the portfolio is
self-financing, the change in portfolio value is
d

= dV +

dS + ϕdU.

(1.17)

¯ lemma
The strategy is similar to that for the Black-Scholes case. We apply Ito’s
to obtain the processes for U and V, which allows us to find the process for . We
then find the values of
and ϕ that makes the portfolio riskless, and we use the
result to derive the Heston PDE.



6

THE HESTON MODEL AND ITS EXTENSIONS IN MATLAB AND C#

Setting Up the Hedging Portfolio
¯ lemma to the value of the first
To form the hedging portfolio, first apply Ito’s
derivative, V(S, v, t). We must differentiate V with respect to the variables t, S, and
v, and form a second-order Taylor series expansion. The result is that dV follows
the process
dV =

∂V
∂V
1
∂ 2V
∂V
dt +
dS +
dv + vS2 2 dt
∂t
∂S
∂v
2
∂S
∂ 2V
1 2 ∂ 2V
dt.
dt + σρvS

+ vσ
2
∂v2
∂S∂v

(1.18)

We have used the fact that (dS)2 = vS2 (dW 1 )2 = vS2 dt, that (dv)2 = σ 2 vdt, and
that dSdv = σ vSdW1 dW 2 = σρvSdt. We have also used (dt)2 = 0 and dW 1 dt =
¯ lemma to the second derivative, U(S, v, t), produces an
dW 2 dt = 0. Applying Ito’s
expression identical to (1.18), but in terms of U. Substituting these two expressions
into (1.17), the change in portfolio value can be written
d

= dV +
=

dS + ϕdU

1
1
∂ 2V
∂ 2V
∂ 2V
∂V
+ vS2 2 + ρσ vS
+ σ 2 v 2 dt
∂t
2

∂S
∂v∂S 2
∂v

+

∂U 1 2 ∂ 2 U
1
∂ 2U
∂ 2U
+ vS
+ σ 2 v 2 dt
+ ρσ vS
2
∂t
2
∂S
∂v∂S 2
∂v
∂V
∂U

+
∂S
∂S

dS +

(1.19)


∂V
∂U

dv.
∂v
∂v

In order for the portfolio to be hedged against movements in both the stock and
volatility, the last two terms in Equation (1.19) must be zero. This implies that the
hedge parameters must be
ϕ=−

∂V
∂v

∂U
,
∂v

Substitute these values of ϕ and
d

=

= −ϕ

∂U ∂V

.
∂S

∂S

(1.20)

into (1.19) to produce

1
1
∂ 2V
∂ 2V
∂ 2V
∂V
+ vS2 2 + ρσ vS
+ σ 2 v 2 dt
∂t
2
∂S
∂S∂v 2
∂v
∂U 1 2 ∂ 2 U
1
∂ 2U
∂ 2U

+ vS
+ σ 2 v 2 dt.
+ ρσ vS
2
∂t
2

∂S
∂S∂v 2
∂v

(1.21)

The condition that the portfolio earn the risk-free rate, r, implies that the change
in portfolio value is d = r dt. Equation (1.17) thus becomes
d

= r(V +

S + ϕU)dt.

Now equate Equation (1.22) with (1.21), substitute for ϕ and
term and re-arrange. This yields

(1.22)
, drop the dt


7

The Heston Model for European Options

∂V
∂V
1
1
∂ 2V

∂ 2V
∂ 2V
+ vS2 2 + ρσ vS
+ σ 2 v 2 − rV + rS
∂t
2
∂S
∂S∂v 2
∂v
∂S
∂V
∂v
2
∂U 1 2 ∂ U
∂ 2U
∂U
1 2 ∂ 2U
+
ρσ
vS
+ vS
+
σ v 2 − rU + rS
∂t
2
∂S2
∂S∂v 2
∂v
∂S
=

∂U
∂v

(1.23)

which we exploit in the next section.

The PDE for the Option Price
The left-hand side of Equation (1.23) is a function of V only, and the right-hand
side is a function of U only. This implies that both sides can be written as a function
f (S, v, t). Following Heston (1993), specify this function as
f (S, v, t) = −κ(θ − v) + λ(S, v, t)
where λ(S, v, t) is the price of volatility risk. An application of Breeden’s (1979)
consumption model yields a price of volatility risk that is a linear function of
volatility, so that λ(S, v, t) = λv, where λ is a constant. Substitute for f (S, v, t) in the
left-hand side of Equation (1.23)
− κ (θ − v) + λ(S, v, t)

=

∂U 1 2 ∂ 2 U
∂U
1 2 ∂ 2U
∂ 2U
+ vS
+
σ v 2 − rU + rS
+
ρσ
vS

2
∂t
2
∂S
∂S∂v 2
∂v
∂S
∂U
∂v

Rearrange to produce the Heston PDE expressed in terms of the price S
1
∂U 1 2 ∂ 2 U
∂ 2U
∂ 2U
+ vS
+ σ 2v 2
+ ρσ vS
2
∂t
2
∂S
∂v∂S 2
∂v
∂U
∂U
+ [κ(θ − v) − λ(S, v, t)]
= 0.
− rU + rS
∂S

∂v

(1.24)

This is Equation (6) of Heston (1993).
The following boundary conditions on the PDE in Equation (1.24) hold for a
European call option with maturity T and strike K. At maturity, the call is worth its
intrinsic value
U(S, v, T) = max(0, S − K).

(1.25)

When the stock price is zero, the call is worthless. As the stock price increases,
delta approaches one, and when the volatility increases, the call option becomes
equal to the stock price. This implies the following three boundary conditions
U(0, v, t) = 0,

∂U
(∞, v, t) = 1,
∂S

U(S, ∞, t) = S.

(1.26)


8

THE HESTON MODEL AND ITS EXTENSIONS IN MATLAB AND C#


Finally, note that the PDE (1.24) can be written
∂U
+ AU − rU = 0
∂t

(1.27)

where
A = rS


∂2
1
+ vS2 2
∂S 2
∂S

1

∂2
∂2
+ [κ(θ − v) − λ(S, v, t)] + σ 2 v 2 + ρσ vS
∂v 2
∂v
∂S∂v

(1.28)

is the generator of the Heston model. As explained by Lewis (2000), the first line in


Equation (1.28) is the generator of the Black-Scholes model, with v = σBS , where
σBS is the Black-Scholes volatility. The second line augments the PDE for stochastic
volatility.
We can define the log price x = ln S and express the PDE in terms of (x, v, t)
instead of (S, v, t). This leads to a simpler form of the PDE in which the spot price
S does not appear. This simplification requires the following derivatives. By the
chain rule
∂U 1
∂U
=
,
∂S
∂x S

∂ 2U

=
∂v∂S
∂v

1 ∂U
S ∂x

=

1 ∂ 2U
.
S ∂v∂x

Using the product rule,

∂ 2U

=
∂S2
∂S

1 ∂U
S ∂x

=−

1 ∂U
1 ∂ 2U
1 ∂U 1 ∂ 2 U
+
=− 2
+ 2
.
2
S ∂x
S ∂S∂x
S ∂x
S ∂x2

Substitute these expressions into the Heston PDE in (1.24). All the S terms
cancel, and we obtain the Heston PDE in terms of the log price x = ln S
∂U 1 ∂ 2 U
∂U
∂ 2U
1

+ v 2 + r− v
+ ρσ v
∂t
2 ∂x
2
∂x
∂v∂x
1
∂ 2U
∂U
=0
+ σ 2 v 2 − rU + [κ(θ − v) − λv]
2
∂v
∂v

(1.29)

where we have substituted λ(S, v, t) = λv. The modern approach to obtaining the
PDE in (1.29) is by an application of the Feynman-Kac theorem, which we will
encounter in Chapter 12 in the context of the double Heston model of Christoffersen
et al. (2009).

The PDE for P 1 and P 2
Recall Equation (1.16) for the European call price, written here using x = xt = ln St
C(K) = ex P1 − Ke−rτ P2 .

(1.30)

Equation (1.30) expresses C(K) in terms of the in-the-money probabilities

P1 = QS (ST > K) and P2 = Q(ST > K). Since the European call satisfies the PDE
(1.29), we can find the required derivatives of Equation (1.30), substitute them into


9

The Heston Model for European Options

the PDE, and express the PDE in terms of P1 and P2 . The derivative of C(K) with
respect to t is
∂P
∂C
∂P
= ex 1 − Ke−rτ rP2 + 2 .
∂t
∂t
∂t

(1.31)

∂C
∂P
∂P
= ex P1 + 1 − Ke−rτ 2 .
∂x
∂x
∂x

(1.32)


2
2
∂ 2C
x
x ∂P1
x ∂ P1
−rτ ∂ P2
+
e
=
e
P
+
2e

Ke
1
∂x2
∂x
∂x2
∂x2
2
2
∂ P2
∂P
∂ P1
− Ke−rτ
= ex P1 + 2 1 +
.
2

∂x
∂x
∂x2

(1.33)

With respect to x

With respect to x2

With respect to v, and v2
∂C
∂P
∂P
= ex 1 − Ke−rτ 2 ,
∂v
∂v
∂v

2
2
∂ 2C
x ∂ P1
−rτ ∂ P2
=
e

Ke
.
∂v2

∂v2
∂v2

(1.34)

With respect to v and x
∂P1
∂ 2C
∂ 2 P2
∂ 2 P1
− Ke−rτ
= ex
+
.
∂x∂v
∂v
∂x∂v
∂x∂v

(1.35)

As mentioned earlier, since the European call C(K) is a financial derivative, it
also satisfies the Heston PDE in (1.29), which we write here in terms of C(K)
∂C
∂ 2C
1
∂C 1 ∂ 2 C
+ v 2 + r− v
+ ρσ v
∂t

2 ∂x
2
∂x
∂v∂x
1
∂ 2C
∂C
= 0.
+ σ 2 v 2 − rC + [κ(θ − v) − λv]
2
∂v
∂v

(1.36)

To obtain the Heston PDE for P1 and P2 , Heston (1993) argues that the PDE in
(1.36) holds for any contractual features of C(K), in particular, for any strike price
K ≥ 0, for any value of S ≥ 0, and for any value r ≥ 0 of the risk-free rate. Setting
K = 0 and S = 1 in the call price in Equation (1.12) produces an option whose
price is simply P1 . This option will also follow the PDE in (1.36). Similarly, setting
S = 0, K = 1, and r = 0 in (1.12) produces an option whose price is −P2 . Since −P2
follows the PDE, so does P2 .
In Equations (1.31) through (1.35), regroup terms common to P1 , cancel ex , and
substitute the terms into the PDE in (1.36) to obtain
1
∂P1 1
∂P
∂ 2 P1
+ r− v
+ v P1 + 2 1 +

∂t
2
∂x
∂x2
2
+

P1 +

∂P1 ∂ 2 P1
∂P1
+ ρσ v
+
∂x
∂v ∂x∂v

1 2 ∂ 2 P1
∂P
σ v 2 − rP1 + [κ(θ − v) − λv] 1 = 0.
2
∂v
∂v

(1.37)


10

THE HESTON MODEL AND ITS EXTENSIONS IN MATLAB AND C#


Simplifying, (1.37) becomes
∂P1
1
∂P1
1 ∂ 2P
∂ 2 P1
+ r+ v
+ v 21 + ρσ v
∂t
2
∂x
2 ∂x
∂x∂v
∂P
∂ 2P
1
+ [ρσ v + κ(θ − v) − λv] 1 + σ 2 v 21 = 0.
∂v
2
∂v

(1.38)

Similarly, in Equations (1.31) through (1.35) regroup terms common to P2 ,
cancel −Ke−rτ, and substitute the terms into the PDE in Equation (1.36) to obtain
1
∂P2
1 ∂ 2P
∂P2
∂ 2 P2

+ v 22 + r − v
+ ρσ v
∂t
2 ∂x
2
∂x
∂v∂x

(1.39)

1
∂ 2P
∂P
+ σ 2 v 22 + [κ(θ − v) − λv] 2 = 0.
2
∂v
∂v

For notational convenience, combine Equations (1.38) and (1.39) into a single
expression
∂ 2 Pj
∂ 2 Pj
∂Pj
1 ∂ 2 Pj
1
+ ρσ v
+ v 2 + σ 2v 2
∂t
∂v∂x 2 ∂x
2

∂v
(1.40)
∂Pj
∂Pj
+ (a − bj v)
=0
+ (r + uj v)
∂x
∂v
for j = 1, 2 and where u1 = 12 , u2 = − 12 , a = κθ, b1 = κ + λ − ρσ , and b2 = κ + λ.
This is Equation (12) of Heston (1993).

OBTAINING THE HESTON CHARACTERISTIC FUNCTIONS
When the characteristic functions fj (φ; x, v) are known, each in-the-money probability Pj can be recovered from the characteristic function via the Gil-Pelaez (1951)
inversion theorem, as
Pj = Pr(ln ST > ln K) =

1
1
+
2 π



Re
0

e−iφ ln K fj (φ; x, v)



dφ.

(1.41)

Inversion theorems can be found in many textbooks, such as that by Stuart
(2010). The inversion theorem in (1.41) will be demonstrated in Chapter 3. A
discussion of how the theorem relates to option pricing in stochastic volatility
models appears in Jondeau et al. (2007).
At maturity, the probabilities are subject to the terminal condition
Pj = 1xT >ln K

(1.42)

where 1 is the indicator function. Equation (1.42) simply states that, when ST > K
at expiry, the probability of the call being in-the-money is unity. Heston (1993)
postulates that the characteristic functions for the logarithm of the terminal stock
price, xT = ln ST , are of the log linear form
fj (φ; xt , vt ) = exp(Cj (τ , φ) + Dj (τ , φ)vt + iφxt )

(1.43)


11

The Heston Model for European Options


where i = −1 is the imaginary, unit, Cj and Dj are coefficients and τ = T − t is the
time to maturity.
The characteristic functions fj will follow the PDE in Equation (1.40). This is

a consequence of the Feynman-Kac theorem, which stipulates that, if a function
f (xt , t) of the Heston bivariate system of SDEs xt = (xt , vt ) = (ln St , vt ) satisfies the
PDE ∂f /∂t − rf + Af = 0, where A is the Heston generator from (1.28), then the
solution to f (xt , t) is the conditional expectation
f (xt , t) = E[f (xT , T)|Ft ].
Using f (xt , t) = exp(iφ ln St ) produces the solution
f (xt , t) = E[eiφ ln ST |xt , vt ]
which is the characteristic function for xT = ln ST . Hence, the PDE for the characteristic function is, from Equation (1.40)


∂ 2 fj
1 ∂ 2 fj
1
v 2 + σ 2v 2
∂τ
∂v∂x 2 ∂x
2
∂v
∂fj
∂fj
+ (a − bj v)
= 0.
+ (r + uj v)
∂x
∂v

∂fj

+ ρσ v


∂ 2 fj

+

(1.44)

Note the transformation from t to τ , which explains the negative sign in front of
the first term in the PDE (1.44). The following derivatives are required to evaluate
(1.44)
∂fj

∂Cj

=

∂τ
∂ 2 fj

∂τ

+

= −φ 2 fj ,

∂x2

∂Dj
∂τ

v fj ,


∂ 2 fj

∂fj
∂x

= D2j fj ,

∂v2

= iφfj ,
∂ 2 fj
∂v∂x

∂fj
∂v

= Dj fj ,

= iφDj fj .

Substitute these derivatives into (1.44) and drop the fj terms to obtain


∂Cj
∂τ

+v

∂Dj

∂τ

+ ρσ viφDj −

1 2 1 2 2
vφ + vσ Dj
2
2

(1.45)

+ (r + uj v)iφ + (a − bj v)Dj = 0,
or equivalently
v −

∂Dj
∂τ

+ ρσ iφDj −

∂Cj
1 2 1 2 2
φ + σ Dj + uj iφ − bj Dj −
+ riφ + aDj = 0. (1.46)
2
2
∂τ

This produces two differential equations
∂Dj

∂τ
∂Cj
∂τ

= ρσ iφDj −
= riφ + aDj .

1 2 1 2 2
φ + σ Dj + uj iφ − bj Dj
2
2

(1.47)


12

THE HESTON MODEL AND ITS EXTENSIONS IN MATLAB AND C#

These are Equations (A7) in Heston (1993). The first equation in (1.47) is a
Riccati equation in Dj , while the second is an ordinary derivative for Cj that can
solved using straightforward integration once Dj is obtained. Solving these equations
requires two initial conditions. Recall from (1.43) that the characteristic function is
fj (φ; xt , vt ) = E[eiφxT ] = exp(Cj (τ , φ) + Dj (τ , φ)vt + iφxt ).

(1.48)

At maturity (τ = 0), the value of xT = ln ST is known, so the expectation in
(1.48) will disappear, and consequently the right-hand side will reduce to simply
exp(iφxT ). This implies that the initial conditions at maturity are Dj (0, φ) = 0 and

Cj (0, φ) = 0.
Finally, when we compute the characteristic function, we use xt as the log spot
price of the underlying asset, and vt as its unobserved initial variance. This last
quantity is the parameter v0 described earlier in this chapter, and must be estimated.
We sometimes write (x0 , v0 ) for (xt , vt ), or simply (x, v).

SOLVING THE HESTON RICCATI EQUATION
In this section, we explain how the expressions in Equation (1.47) can be solved
to yield the call price. First, we introduce the Riccati equation and explain how its
solution is obtained. The solution can be found in many textbooks on differential
equations, such as that by Zwillinger (1997).

The Riccati Equation in a General Setting
The Riccati equation for y(t) with coefficients P(t), Q(t), and R(t) is defined as
dy(t)
= P(t) + Q(t)y(t) + R(t)y(t)2 .
dt

(1.49)

The equation can be solved by considering the following second-order ordinary
differential equation (ODE) for w(t)
w −

P
+ Q w + PRw = 0
P

(1.50)


which can be written w + bw + cw = 0. The solution to Equation (1.49) is then
y(t) = −

w (t) 1
.
w(t) R(t)

The ODE in (1.50) can be solved via the auxiliary equation r2 + br + c = 0,
which has two solutions α and β given by


−b + b2 − 4c
−b − b2 − 4c
α=
, β=
.
2
2
The solution to the second-order ODE in (1.50) is
w(t) = Meαt + Neβt


×