# naginterfaces.library.specfun.opt_​heston_​term¶

naginterfaces.library.specfun.opt_heston_term(calput, x, fwd, disc, ts, t, alpha, lamda, corr, sigmat, var0)[source]

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

For full information please refer to the NAG Library document for s30nc

https://www.nag.com/numeric/nl/nagdoc_28.5/flhtml/s/s30ncf.html

Parameters
calputstr, length 1

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.

xfloat, array-like, shape

contains the th strike price, for .

fwdfloat

The forward price of the asset.

discfloat

The discount factor, where the current price of the underlying asset, , is given as .

tsfloat, array-like, shape

must contain the length of the time intervals for which the corresponding element of , , and apply. These should be ordered as they occur in time i.e., .

tfloat

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.

alphafloat, array-like, shape

must contain the value of , the value of the volatility of the scaled volatility, , over time subinterval .

lamdafloat, array-like, shape

must contain the value, , of the mean reversion parameter over the time subinterval .

corrfloat, array-like, shape

must contain the value, , of the correlation parameter over the time subinterval .

sigmatfloat, array-like, shape

must contain the value, , of the variance scale factor over the time subinterval .

var0float

, the initial scaled variance.

Returns
pfloat, ndarray, shape

contains the computed option price at the expiry time, , corresponding to strike for the specified term structure, for .

Raises
NagValueError
(errno )

On entry, .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

Quadrature has not converged to the specified accuracy. However, the result should be a reasonable approximation.

(errno )

Solution cannot be computed accurately. Check values of input arguments.

Notes

opt_heston_term 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 .

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