Table of Contents

Class COSHestonEngine

Namespace
NanoQL.PricingEngines
Assembly
NanoQL.dll

The COS-method Heston engine, on efficient Fourier-cosine series expansions.

public sealed class COSHestonEngine
Inheritance
COSHestonEngine
Inherited Members

Remarks

An immutable object over its HestonModel, the truncation range's width and the series' length; the static Calculate(VanillaOption, EvaluationContext, HestonModel, double, int) builds one and prices through it. The model's time runs from the earliest curve date and the forward and discount are read by date (AnalyticHestonEngine's reads); at the model's time 0 the price is QuantLib's bound, the forward's discounted intrinsic value, before any cumulant.

The cumulants are QuantLib's expressions, evaluated where κt calls for it in another arithmetic: QuantLib's double, and so its bits, from each cumulant's cut to its upper cut; double-double below the cut, quad-double below double-double's floor and, below quad-double's, each cumulant's cubic in κ through four quad-double values; past the upper cut, where e^{nκt} overflows, an extended-range double, each cut measured at the run against QuantLib's expressions in 50 to 250 digits. At a term of 0 the cumulants, the skew and the kurtosis are their limits, 0. Below σ = NanoQL.PricingEngines.COSHestonEngine.SigmaCut, where the classic form's division by σ² cancels, the characteristic function is ChF(Complex, double)'s, the same function in Andersen and Lake's form.

The series' length has to grow with the vol of variance and the term: at QuantLib's defaults, a range of 16 and 200 terms, a vol of variance of 1 prices a five-year call at twice the forward at −7.8 times its value and a twenty-year one 39% low, where 2,000 terms bring them within 0.6% and 0.02%; QuantLib's own large-σ case takes a range of 25 and 600 terms.

References: F. Fang, C.W. Oosterlee, A Novel Pricing Method for European Options based on Fourier-Cosine Series Expansions; F. Le Floc'h, Fourier Integration and Stochastic Volatility Calibration.

Constructors

COSHestonEngine(HestonModel, double, int)

Initializes a new instance of the COSHestonEngine class.

public COSHestonEngine(HestonModel model, double l = 16, int n = 200)

Parameters

model HestonModel

The Heston model.

l double

The truncation range's half-width in standard deviations.

n int

The number of terms of the cosine series.

Exceptions

ArgumentNullException

model is null.

Methods

C1(double)

The first cumulant of the log-forward's return at a time.

public double C1(double t)

Parameters

t double

The time.

Returns

double

The cumulant; 0 at a time of 0.

C2(double)

The second cumulant at a time.

public double C2(double t)

Parameters

t double

The time.

Returns

double

The cumulant; 0 at a time of 0.

C3(double)

The third cumulant at a time.

public double C3(double t)

Parameters

t double

The time.

Returns

double

The cumulant; 0 at a time of 0.

C4(double)

The fourth cumulant at a time.

public double C4(double t)

Parameters

t double

The time.

Returns

double

The cumulant; 0 at a time of 0.

Calculate(VanillaOption, EvaluationContext)

Prices a European plain-vanilla option.

public OneAssetOptionResults Calculate(VanillaOption option, EvaluationContext context)

Parameters

option VanillaOption

The option.

context EvaluationContext

The evaluation context.

Returns

OneAssetOptionResults

The option's results.

Exceptions

ArgumentNullException

An argument is null.

NanoQLException

The exercise isn't European, the payoff isn't plain vanilla or the underlying isn't positive.

Calculate(VanillaOption, EvaluationContext, HestonModel, double, int)

Prices a European plain-vanilla option.

public static OneAssetOptionResults Calculate(VanillaOption option, EvaluationContext context, HestonModel model, double l = 16, int n = 200)

Parameters

option VanillaOption

The option.

context EvaluationContext

The evaluation context.

model HestonModel

The Heston model.

l double

The truncation range's half-width in standard deviations.

n int

The number of terms of the cosine series.

Returns

OneAssetOptionResults

The option's results.

Exceptions

ArgumentNullException

An argument is null.

NanoQLException

The exercise isn't European, the payoff isn't plain vanilla or the underlying isn't positive.

ChF(double, double)

The normalized characteristic function of the log-forward's return at u.

public Complex ChF(double u, double t)

Parameters

u double

The argument.

t double

The time.

Returns

Complex

The value.

Kurtosis(double)

The excess kurtosis at a time.

public double Kurtosis(double t)

Parameters

t double

The time.

Returns

double

The kurtosis; its limit 0 at a time of 0.

Mu(double)

The mean of the log-forward's return at a time, its first cumulant.

public double Mu(double t)

Parameters

t double

The time.

Returns

double

The mean.

Skew(double)

The skewness at a time.

public double Skew(double t)

Parameters

t double

The time.

Returns

double

The skewness; its limit 0 at a time of 0.

Var(double)

The variance at a time, the second cumulant.

public double Var(double t)

Parameters

t double

The time.

Returns

double

The variance.