Table of Contents

Class AnalyticTwoAssetBarrierEngine

Namespace
NanoQL.PricingEngines
Assembly
NanoQL.dll

The analytic engine for a barrier option on two assets: the first asset's payoff, knocked in or out by the second asset at the barrier (Haug, "The Complete Guide to Option Pricing Formulas", 2nd ed.).

public static class AnalyticTwoAssetBarrierEngine
Inheritance
AnalyticTwoAssetBarrierEngine
Inherited Members

Remarks

The value alone, as QuantLib's. The bivariate normal is QuantLib's default, BivariateCumulativeNormalDistributionWe04DP, where QuantLib's engine reads Drezner's 1978 algorithm, to six decimal places; on QuantLib's cases the values move by at most 6.7e-6, within QuantLib's tolerance.

Five documented divergences. Each asset's carry reads its own process's curves and the payoff is discounted on the first process's risk-free curve, where QuantLib takes the second asset's carry from the first process's rate (Divergences/TwoAssetBarrierTwoCurvesTests.cs). The knock-in's vanilla carries the first asset's dividends, S₁e^((b₁−r)T)N(d₁), where QuantLib's drops them, so in-out parity holds (Divergences/TwoAssetBarrierDividendTests.cs). The second asset's volatility is read at the barrier, its own price level, where QuantLib reads it at the first asset's strike (Divergences/TwoAssetBarrierSmileTests.cs). And every rate and volatility is read over the time to expiry on the clock across both processes (NanoQL.Methods.FdmBlackScholesOp.ClockAcross(System.Collections.Generic.IReadOnlyList{NanoQL.Processes.GeneralizedBlackScholesProcess})), each structure at the instants that time denotes, accruing nothing before its date, where QuantLib reads everything at the first process's time; a structure sharing the clock's times is read as QuantLib reads it (Divergences/BarrierClosedFormMismatchedTimesTests.cs). And a non-European exercise is refused, as the family's European engines refuse it, where QuantLib prices it to its last date (Divergences/TwoAssetBarrierExerciseTests.cs).

The formula is a first-passage closed form in equivalent-constant rates and volatilities, the variance and discounts to expiry: no exact closed form exists for a first passage under general deterministic term structures, and its single correlation term, ρσ₁σ₂, can't carry a first volatility that moves over the option's life. On shaped markets (1.5 years; forward rates 1%, 3%, 6%, dividends 0%, 1%, 3% and volatilities 15%, 25%, 35%, rising or falling; ρ 0.5) it misses an independent Monte Carlo by −24% to +21%, and by 3% to 7% with the first volatility flat, where on a flat market it agrees. A Monte Carlo on the two processes is the term-structure-exact route.

Methods

Calculate(TwoAssetBarrierOption, EvaluationContext, GeneralizedBlackScholesProcess, GeneralizedBlackScholesProcess, double)

Prices a barrier option on two assets.

public static InstrumentResults Calculate(TwoAssetBarrierOption option, EvaluationContext context, GeneralizedBlackScholesProcess process1, GeneralizedBlackScholesProcess process2, double rho)

Parameters

option TwoAssetBarrierOption

The option.

context EvaluationContext

The evaluation context.

process1 GeneralizedBlackScholesProcess

The first asset's process, whose payoff the strike reads.

process2 GeneralizedBlackScholesProcess

The second asset's process, which the barrier monitors.

rho double

The correlation of the two assets.

Returns

InstrumentResults

The option's results: the value.

Exceptions

ArgumentNullException

An argument is null.

NanoQLException

The exercise isn't European, the payoff isn't plain vanilla or its strike isn't positive, the second spot isn't positive, or it lies beyond the barrier ("barrier touched").