Table of Contents

Class AnalyticCapFloorEngine

Namespace
NanoQL.PricingEngines
Assembly
NanoQL.dll

The analytic cap/floor engine: each optionlet an option on a discount bond of an affine model.

public static class AnalyticCapFloorEngine
Inheritance
AnalyticCapFloorEngine
Inherited Members

Remarks

A static class: Calculate runs QuantLib's four steps (playbook §2.1) on the model, an argument where QuantLib's engine holds it. An optionlet whose payment is past (or on the reference date, unless the context includes that day's payments) is skipped; one fixed on or before the reference date pays its known amount, discounted on the model; any other is (1 + Kτ) times the model's option on the discount bond from its start to its payment, struck at 1/(1 + Kτ), a put for a caplet and a call for a floorlet.

The option's expiry: QuantLib's option expires at the optionlet's start (analyticcapfloorengine.cpp:94-112), where the instrument fixes its rate and QuantLib's Monte Carlo engine reads it at the fixing date, so an optionlet with a fixing lag is priced on the variance to its start. On a HullWhite model, an optionlet fixed before its start is the option expiring at its fixing on the bond from its start to its payment, QuantLib's own five-argument bond option, as its Jamshidian engine prices one; one fixed on its start is QuantLib's value, bit for bit. The other models keep QuantLib's expiry at the start, since QuantLib has no such option for them: its affine model's five-argument option ignores the bond's start. A divergence (Divergences/CapletFixingExpiryTests.cs).

An in-arrears caplet still to be fixed, fixed after its start, is refused, on every model, since no closed form values it: QuantLib prices it as the caplet in advance, on its start and its accrual period, reading neither its fixing nor its index's period (Divergences/CapletInArrearsTests.cs). The tree and Monte Carlo engines value it at its fixing.

The term structure is needed only when the model can't provide one: a model that is an ITermStructureConsistentModel reads its own curve's reference date and day counter, as QuantLib's engine does, whatever curve is given.

Methods

Calculate(CapFloor, EvaluationContext, IAffineModel, YieldTermStructure?)

Prices a cap, floor or collar on an affine model.

public static InstrumentResults Calculate(CapFloor capFloor, EvaluationContext context, IAffineModel model, YieldTermStructure? termStructure = null)

Parameters

capFloor CapFloor

The cap, floor or collar.

context EvaluationContext

The evaluation context.

model IAffineModel

The affine model.

termStructure YieldTermStructure

The curve that gives the reference date and day counter of the times, for a model that has no curve of its own; null, QuantLib's empty handle, by default.

Returns

InstrumentResults

The instrument's results: the expired results when it has expired.

Exceptions

ArgumentNullException

The cap, the context or the model is null.

NanoQLException

The cap's terms are inconsistent, a cash flow isn't a floating-rate coupon, a forward can't be computed, the model has no curve and none is given, or a caplet still to be fixed is fixed after its start (in arrears).