Table of Contents

Class AnalyticDoubleBarrierBinaryEngine

Namespace
NanoQL.PricingEngines
Assembly
NanoQL.dll

The analytic engine for double barrier binary options: cash-or-nothing knock-outs and knock-ins paid at expiry by Hui's eigenfunction series ("One-touch double barrier binary option values", Applied Financial Economics 6/1996), and KIKO and KOKI options paid at the hit, by the same series' sums.

public static class AnalyticDoubleBarrierBinaryEngine
Inheritance
AnalyticDoubleBarrierBinaryEngine
Inherited Members

Remarks

The knock-out and knock-in take a European exercise; KIKO and KOKI an American one paying at the hit, its window open from the start. Each rate is read on the volatility's clock and each time is the volatility's, as AnalyticBarrierEngine reads them, where QuantLib reads every structure at the risk-free curve's times.

Documented divergences. The knock-out integrates the killed density over the payoff's region, [max(K, L), U] for a call and [L, min(K, U)] for a put, where QuantLib's series integrates over the whole corridor whatever the payoff's strike and type, so a put struck at 0 pays (Divergences/DoubleBinaryStrikeTests.cs); the knock-in is the European cash-or-nothing less the knock-out, and one already knocked in is that European, where QuantLib pays the cash undiscounted (Divergences/DoubleBinaryKnockedInTests.cs). QuantLib's value stands for a call at K ≤ L, its own cases. Hui's series is taken where a bound on its dropped tail free of its sines, the terms' envelope, is within 1e-11 of its sum, where QuantLib checks its last term, which carries a sine and passes unconverged at x/Z = j/99 (Divergences/DoubleBinaryHuiCheckTests.cs); elsewhere, where QuantLib refuses ("serie did not converge sufficiently fast") among them, the knock-out is the cash-or-nothing part of QuantLib's double-barrier image series, AnalyticDoubleBarrierEngine's callKO and putKO, which converges fastest there, its terms in logs (Divergences/DoubleBinarySmallVarianceTests.cs). The rebate is priced as the double barrier engine prices it, a knock-out's at the first touch of either barrier, now where one is already touched, a knock-in's at expiry where neither is touched, where QuantLib's engine reads none; a KIKO's or KOKI's, for which no convention fixes the payment, is refused (Divergences/DoubleBinaryRebateTests.cs). KIKO and KOKI are QuantLib's 999-term sums where Abel's bound on their dropped tail is within 1e-11 of the sum, QuantLib's value and bits there; elsewhere, where QuantLib's 999 terms run unconverged or it refuses, the absorption flux of QuantLib's own image-series killed density at the barrier, integrated in log time between the roots that bound its mass (Divergences/DoubleBinaryKikoTests.cs). Below machine-epsilon variance the underlying follows its forward.

The degenerate branches, where a barrier is already touched, set the value, delta, gamma, vega and rho as QuantLib does, and no theta or dividend rho; one already knocked in takes those of the European cash-or-nothing it is.

The series are first-passage closed forms in equivalent-constant rates and a volatility, the variance and discounts to expiry: no exact closed form exists for a first passage under general deterministic term structures, and on shaped markets an independent Monte Carlo finds a knock-out +0.66% and +1.78% off, within two of its standard errors; the term-structure-exact route is a Monte Carlo on the process.

Methods

Calculate(DoubleBarrierOption, EvaluationContext, GeneralizedBlackScholesProcess)

Prices a double barrier binary option.

public static OneAssetOptionResults Calculate(DoubleBarrierOption option, EvaluationContext context, GeneralizedBlackScholesProcess process)

Parameters

option DoubleBarrierOption

The option, with a cash-or-nothing payoff.

context EvaluationContext

The evaluation context.

process GeneralizedBlackScholesProcess

The Black-Scholes process.

Returns

OneAssetOptionResults

The option's results: the value, and the Greeks QuantLib sets where a barrier is already touched; the expired results when the option has expired.

Exceptions

ArgumentNullException

An argument is null.

NanoQLException

A KIKO or KOKI option's exercise isn't American or opens after the volatility's reference date; another's isn't European; the payoff isn't cash-or-nothing; the spot or a barrier isn't positive; the lower barrier isn't below the upper one.