NAG C Library Function Document
nag_heston_term (s30ncc)
1
Purpose
nag_heston_term (s30ncc) computes the European option price given by Heston's stochastic volatility model with term structure.
2
Specification
#include <nag.h> |
#include <nags.h> |
void |
nag_heston_term (Nag_CallPut option,
Integer m,
Integer numts,
const double x[],
double fwd,
double disc,
const double ts[],
double t,
const double alpha[],
const double lambda[],
const double corr[],
const double sigmat[],
double var0,
double p[],
NagError *fail) |
|
3
Description
nag_heston_term (s30ncc) computes the price of a European option for Heston's stochastic volatility model with time-dependent parameters which are piecewise constant. Starting from the stochastic volatility model given by the Stochastic Differential Equation (SDE) system defined by
Heston (1993), a scaling of the variance process is introduced, together with a normalization, setting the long run variance,
, equal to
. This leads to
where
is the drift term representing the contribution of interest rates,
, and dividends,
, while
is the scaling parameter,
is the scaled variance,
is the mean reversion rate and
is the volatility of the scaled volatility,
. Then,
, for
, are two standard Brownian motions with correlation parameter
. Without loss of generality, the drift term,
, is eliminated by modelling the forward price,
, directly, instead of the spot price,
, with
If required, the spot can be expressed as,
, where
is the discount factor.
The option price is computed by dividing the time to expiry,
, into
subintervals
and applying the method of characteristic functions to each subinterval, with appropriate initial conditions. Thus, a pair of ordinary differential equations (one of which is a Riccati equation) is solved on each subinterval as outlined in
Elices (2008) and
Mikhailov and Nögel (2003). Reversing time by taking
, the characteristic function solution for the first time subinterval, starting at
, is given by
Heston (1993), while the solution on each following subinterval uses the solution of the preceding subinterval as initial condition to compute the value of the characteristic function.
In the case of a ‘flat’ term structure, i.e., the parameters are constant over the time of the option,
, the form of the SDE system given by
Heston (1993) can be recovered by setting
,
,
and
.
Conversely, given the Heston form of the SDE pair, to get the term structure form set , , and .
4
References
Bain A (2011) Private communication
Elices A (2008) Models with time-dependent parameters using transform methods: application to Heston’s model arXiv:0708.2020v2
Heston S (1993) A closed-form solution for options with stochastic volatility with applications to bond and currency options Review of Financial Studies 6 327–343
Mikhailov S and Nögel U (2003) Heston’s Stochastic Volatility Model Implementation, Calibration and Some Extensions Wilmott Magazine July/August 74–79
5
Arguments
- 1:
– Nag_CallPutInput
-
On entry: determines whether the option is a call or a put.
- A call; the holder has a right to buy.
- A put; the holder has a right to sell.
Constraint:
or .
- 2:
– IntegerInput
-
On entry: , the number of strike prices to be used.
Constraint:
.
- 3:
– IntegerInput
-
On entry: , the number of subintervals into which the time to expiry, , is divided.
Constraint:
.
- 4:
– const doubleInput
-
On entry: contains the
th strike price, for .
Constraint:
, where , the safe range parameter, for .
- 5:
– doubleInput
-
On entry: the forward price of the asset.
Constraint:
and , where , the safe range parameter.
- 6:
– doubleInput
-
On entry: the discount factor, where the current price of the underlying asset, , is given as .
Constraint:
and , where , the safe range parameter.
- 7:
– const doubleInput
-
On entry:
must contain the length of the time intervals for which the corresponding element of
alpha,
lambda,
corr and
sigmat apply. These should be ordered as they occur in time i.e.,
.
Constraint:
, where , the safe range parameter, for .
- 8:
– doubleInput
-
On entry:
t contains the time to expiry. If
then the parameters associated with the last time interval are extended to the expiry time. If
then the parameters specified are used up until the expiry time. The rest are ignored.
Constraint:
, where , the safe range parameter.
- 9:
– const doubleInput
-
On entry: must contain the value of , the value of the volatility of the scaled volatility, , over time subinterval .
Constraint:
, where , the safe range parameter, for .
- 10:
– const doubleInput
-
On entry: must contain the value, , of the mean reversion parameter over the time subinterval .
Constraint:
, where , the safe range parameter, for .
- 11:
– const doubleInput
-
On entry: must contain the value, , of the correlation parameter over the time subinterval .
Constraint:
, for .
- 12:
– const doubleInput
-
On entry: must contain the value, , of the variance scale factor over the time subinterval .
Constraint:
, where , the safe range parameter, for .
- 13:
– doubleInput
-
On entry: , the initial scaled variance.
Constraint:
.
- 14:
– doubleOutput
-
On exit: contains the computed option price at the expiry time, , corresponding to strike for the specified term structure, for .
- 15:
– NagError *Input/Output
-
The NAG error argument (see
Section 3.7 in How to Use the NAG Library and its Documentation).
6
Error Indicators and Warnings
- NE_ACCURACY
-
Solution cannot be computed accurately. Check values of input arguments.
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_CONVERGENCE
-
Quadrature has not converged to the specified accuracy. However, the result should be a reasonable approximation.
- NE_INT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INTERNAL_ERROR
-
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
See
Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
- NE_REAL
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_REAL_ARRAY
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
7
Accuracy
The solution is obtained by integrating the pair of ordinary differential equations over each subinterval in time. The accuracy is controlled by a relative tolerance over each time subinterval, which is set to . Over a number of subintervals in time the error may accumulate and so the overall error in the computation may be greater than this. A threshold of is used and solutions smaller than this are not accurately evaluated.
8
Parallelism and Performance
nag_heston_term (s30ncc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the
x06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
None.
10
Example
This example computes the price of a European call using Heston's stochastic volatility model with a term structure of interest rates.
10.1
Program Text
Program Text (s30ncce.c)
10.2
Program Data
Program Data (s30ncce.d)
10.3
Program Results
Program Results (s30ncce.r)