S30NCF (PDF version)
S Chapter Contents
S Chapter Introduction
NAG Library Manual

NAG Library Routine Document

S30NCF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

S30NCF computes the European option price given by Heston's stochastic volatility model with term structure.

2  Specification

SUBROUTINE S30NCF ( CALPUT, M, NUMTS, X, FWD, DISC, TS, T, ALPHA, LAMBDA, CORR, SIGMAT, VAR0, P, IFAIL)
INTEGER  M, NUMTS, IFAIL
REAL (KIND=nag_wp)  X(M), FWD, DISC, TS(NUMTS), T, ALPHA(NUMTS), LAMBDA(NUMTS), CORR(NUMTS), SIGMAT(NUMTS), VAR0, P(M)
CHARACTER(1)  CALPUT

3  Description

S30NCF 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 1. This leads to
d St St = μt d t+σt νt d Wt1 , (1)
d νt = λt 1-νt d t+ αt νt d Wt2 , (2)
Cov d W t 1 , d W t 2 = ρt d t , (3)
where μt=rt-qt is the drift term representing the contribution of interest rates, rt, and dividends, qt, while σt is the scaling parameter, νt is the scaled variance, λt is the mean reversion rate and αt is the volatility of the scaled volatility, νt. Then, Wti, for i=1,2, are two standard Brownian motions with correlation parameter ρt. Without loss of generality, the drift term, μt, is eliminated by modelling the forward price, Ft, directly, instead of the spot price, St, with
Ft = S0 exp 0 t μs d s . (4)
If required, the spot can be expressed as, S0 = D Ft , where D is the discount factor.
The option price is computed by dividing the time to expiry, T, into ns subintervals t0,t1 , , ti-1,ti , , tns-1,T  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 τ=T-t, the characteristic function solution for the first time subinterval, starting at τ=0, 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, T, the form of the SDE system given by Heston (1993)
d St St = μt d t+ Vt d W t 1 , (5)
d Vt = κ η-Vt d t + σv Vt d W t 2 , (6)
can be recovered by setting V0 = η = σt2 , κ=λt , σv = σt αt .
Conversely, given the Heston form of the SDE pair, to get the term structure form set σ=η , αt = σv / η , λt = κ .

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  Parameters

1:     CALPUT – CHARACTER(1)Input
On entry: determines whether the option is a call or a put.
CALPUT='C'
A call; the holder has a right to buy.
CALPUT='P'
A put; the holder has a right to sell.
Constraint: CALPUT='C' or 'P'.
2:     M – INTEGERInput
On entry: m, the number of strike prices to be used.
Constraint: M1.
3:     NUMTS – INTEGERInput
On entry: ns, the number of subintervals into which the time to expiry, T, is divided.
Constraint: NUMTS1.
4:     XM – REAL (KIND=nag_wp) arrayInput
On entry: Xi contains the ith strike price, for i=1,2,,m.
Constraint: Xiz ​ and ​ Xi 1 / z , where z = X02AMF , the safe range parameter, for i=1,2,,M.
5:     FWD – REAL (KIND=nag_wp)Input
On entry: the forward price of the asset.
Constraint: FWDz and FWD1/z, where z=X02AMF, the safe range parameter.
6:     DISC – REAL (KIND=nag_wp)Input
On entry: the discount factor, where the current price of the underlying asset, S0, is given as S0=DISC×FWD.
Constraint: DISCz and DISC1/z, where z=X02AMF, the safe range parameter.
7:     TSNUMTS – REAL (KIND=nag_wp) arrayInput
On entry: TSi 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., Δ ti = ti - ti-1.
Constraint: TSiz ​ and ​ TSi 1 / z , where z = X02AMF , the safe range parameter, for i=1,2,,NUMTS.
8:     T – REAL (KIND=nag_wp)Input
On entry: T contains the time to expiry. If T > Δ ti  then the parameters associated with the last time interval are extended to the expiry time. If T < Δ ti  then the parameters specified are used up until the expiry time. The rest are ignored.
Constraint: Tz, where z = X02AMF , the safe range parameter.
9:     ALPHANUMTS – REAL (KIND=nag_wp) arrayInput
On entry: ALPHAi must contain the value of αt, the value of the volatility of the scaled volatility, ν, over time subinterval Δti.
Constraint: ALPHAiz ​ and ​ ALPHAi 1 / z , where z = X02AMF , the safe range parameter, for i=1,2,,NUMTS.
10:   LAMBDANUMTS – REAL (KIND=nag_wp) arrayInput
On entry: LAMBDAi must contain the value, λt, of the mean reversion parameter over the time subinterval Δ ti.
Constraint: LAMBDAiz ​ and ​ LAMBDAi 1 / z , where z = X02AMF , the safe range parameter, for i=1,2,,NUMTS.
11:   CORRNUMTS – REAL (KIND=nag_wp) arrayInput
On entry: CORRi must contain the value, ρt, of the correlation parameter over the time subinterval Δ ti.
Constraint: -1.0CORRi1.0, for i=1,2,,NUMTS.
12:   SIGMATNUMTS – REAL (KIND=nag_wp) arrayInput
On entry: SIGMATi must contain the value, σt, of the variance scale factor over the time subinterval Δti.
Constraint: SIGMATiz ​ and ​ SIGMATi 1 / z , where z = X02AMF , the safe range parameter, for i=1,2,,NUMTS.
13:   VAR0 – REAL (KIND=nag_wp)Input
On entry: ν0, the initial scaled variance.
Constraint: VAR00.0.
14:   PM – REAL (KIND=nag_wp) arrayOutput
On exit: Pi contains the computed option price at the expiry time, T, corresponding to strike Xi for the specified term structure, for i=1,2,,M.
15:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry, CALPUT=value was an illegal value.
IFAIL=2
On entry, M=value.
Constraint: M1.
IFAIL=3
On entry, NUMTS=value.
Constraint: NUMTS1.
IFAIL=4
On entry, Xvalue=value.
Constraint: valueXivalue.
IFAIL=5
On entry, FWD=value.
Constraint: valueFWDvalue.
IFAIL=6
On entry, DISC=value.
Constraint: valueDISCvalue.
IFAIL=7
On entry, TSvalue=value.
Constraint: valueTSivalue.
IFAIL=8
On entry, T=value.
Constraint: Tvalue.
IFAIL=9
On entry, ALPHAvalue=value.
Constraint: valueALPHAivalue.
IFAIL=10
On entry, LAMBDAvalue=value.
Constraint: valueLAMBDAivalue.
IFAIL=11
On entry, CORRvalue=value.
Constraint: CORRi1.0.
IFAIL=12
On entry, SIGMATvalue=value.
Constraint: valueSIGMATivalue.
IFAIL=13
On entry, VAR0=value.
Constraint: VAR0>0.0.
IFAIL=14
Quadrature has not converged to the specified accuracy. However, the result should be a reasonable approximation.
IFAIL=15
Solution cannot be computed accurately. Check values of input parameters.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

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 10 -8 . 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 10 -10  is used and solutions smaller than this are not accurately evaluated.

8  Parallelism and Performance

S30NCF 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 routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9  Further Comments

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 (s30ncfe.f90)

10.2  Program Data

Program Data (s30ncfe.d)

10.3  Program Results

Program Results (s30ncfe.r)


S30NCF (PDF version)
S Chapter Contents
S Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015