Table of Contents

Class LognormalCmsSpreadPricer

Namespace
NanoQL.Experimental
Assembly
NanoQL.dll

The CMS spread coupon pricer of Brigo and Mercurio, 13.6.2, with the extensions for shifted lognormal and normal dynamics of http://ssrn.com/abstract=2686998: QuantLib's LognormalCmsSpreadPricer.

[Experimental("NQL0001")]
public sealed class LognormalCmsSpreadPricer : CmsSpreadCouponPricer
Inheritance
LognormalCmsSpreadPricer
Inherited Members

Remarks

The two swap rates' convexity adjustments are the CMS pricer's, on its swaption volatility, whose type and shifts the spread model inherits by default; or the type is given, and on a lognormal model the shifts, 0 when not given. An at-the-money surface takes only the inherited type; a cube is read on the model's type and shifts through its smile sections. The correlation is clamped to ±0.9999, so that the integrand never divides by 0; at the default 16 Gauss-Hermite points its value at 0.9999 is 1.5e-3 off the 256-point value, the points the caller's choice. References: Brigo and Mercurio, Interest Rate Models - Theory and Practice, 2nd edition, Springer, 2006, chapter 13.6.2.

With unequal shifts, the integrand branches on the displaced strike k + g₁s₁ + g₂s₂, and its negative branch shifts the second rate by its own shift, as QuantLib's master does after 1.44 (#2874); QuantLib 1.44 branches on the strike and shifts the second rate by the first's, which prices NaN caplets and floorlets at strikes 0.008 and 0.002 on #2874's set-up and breaks put-call parity by 2.03e-2 at others (Divergences/CmsSpreadUnequalShiftsTests.cs). Equal shifts take the same branch either way.

Without a coupon discount curve, each coupon is discounted on its own first swap index's curve, its discounting curve when exogenous and its forwarding curve otherwise; QuantLib's pricer keeps the first coupon's curve for every later coupon, so one pricer serving coupons on different indexes discounts them all on the first's (Divergences/CmsSpreadCouponDiscountCurveTests.cs). A pricer is stateless here, as every nanoql pricer: what QuantLib's initialize stores is computed per call, one state serving a capped coupon's three rates.

Constructors

LognormalCmsSpreadPricer(CmsCouponPricer, double?, YieldTermStructure?, int, VolatilityType?, double?, double?)

Initializes a new instance of the LognormalCmsSpreadPricer class.

public LognormalCmsSpreadPricer(CmsCouponPricer cmsPricer, double? correlation, YieldTermStructure? couponDiscountCurve = null, int integrationPoints = 16, VolatilityType? volatilityType = null, double? shift1 = null, double? shift2 = null)

Parameters

cmsPricer CmsCouponPricer

The pricer of the two CMS coupons, whose swaption volatility the model reads.

correlation double?

The correlation of the two swap rates, or null, QuantLib's empty handle, refused when a future fixing is priced.

couponDiscountCurve YieldTermStructure

The curve the coupons are discounted on, or null for each coupon's first swap index's.

integrationPoints int

The number of Gauss-Hermite points, at least 4.

volatilityType VolatilityType?

The spread model's volatility type, or null to inherit the swaption volatility's.

shift1 double?

The first rate's shift on a given lognormal type, 0 when null.

shift2 double?

The second rate's shift on a given lognormal type, 0 when null.

Exceptions

ArgumentNullException

cmsPricer is null.

NanoQLException

There are fewer than 4 points, shifts are given with an inherited type, or the type is inherited from a CMS pricer with no swaption volatility, with QuantLib's texts.

Methods

CapletPrice(FloatingRateCoupon, double, EvaluationContext)

The price of a caplet on the coupon's rate.

public override double CapletPrice(FloatingRateCoupon coupon, double effectiveCap, EvaluationContext context)

Parameters

coupon FloatingRateCoupon

The coupon.

effectiveCap double

The cap on the index fixing.

context EvaluationContext

The evaluation context.

Returns

double

The price.

Exceptions

ArgumentException

The coupon isn't a CMS spread coupon.

NanoQLException

As SwapletPrice(FloatingRateCoupon, EvaluationContext).

CapletRate(FloatingRateCoupon, double, EvaluationContext)

The rate of a caplet on the coupon's rate.

public override double CapletRate(FloatingRateCoupon coupon, double effectiveCap, EvaluationContext context)

Parameters

coupon FloatingRateCoupon

The coupon.

effectiveCap double

The cap on the index fixing.

context EvaluationContext

The evaluation context.

Returns

double

The rate.

Exceptions

ArgumentException

The coupon isn't a CMS spread coupon.

NanoQLException

As SwapletPrice(FloatingRateCoupon, EvaluationContext).

FloorletPrice(FloatingRateCoupon, double, EvaluationContext)

The price of a floorlet on the coupon's rate.

public override double FloorletPrice(FloatingRateCoupon coupon, double effectiveFloor, EvaluationContext context)

Parameters

coupon FloatingRateCoupon

The coupon.

effectiveFloor double

The floor on the index fixing.

context EvaluationContext

The evaluation context.

Returns

double

The price.

Exceptions

ArgumentException

The coupon isn't a CMS spread coupon.

NanoQLException

As SwapletPrice(FloatingRateCoupon, EvaluationContext).

FloorletRate(FloatingRateCoupon, double, EvaluationContext)

The rate of a floorlet on the coupon's rate.

public override double FloorletRate(FloatingRateCoupon coupon, double effectiveFloor, EvaluationContext context)

Parameters

coupon FloatingRateCoupon

The coupon.

effectiveFloor double

The floor on the index fixing.

context EvaluationContext

The evaluation context.

Returns

double

The rate.

Exceptions

ArgumentException

The coupon isn't a CMS spread coupon.

NanoQLException

As SwapletPrice(FloatingRateCoupon, EvaluationContext).

SwapletPrice(FloatingRateCoupon, EvaluationContext)

The swaplet's price: the coupon's amount, discounted.

public override double SwapletPrice(FloatingRateCoupon coupon, EvaluationContext context)

Parameters

coupon FloatingRateCoupon

The coupon.

context EvaluationContext

The evaluation context.

Returns

double

The price.

Exceptions

ArgumentException

The coupon isn't a CMS spread coupon.

NanoQLException

The gearings aren't of opposite signs, a curve, the volatility or the correlation is missing, or the volatility type isn't inherited on an at-the-money surface.

SwapletRate(FloatingRateCoupon, EvaluationContext)

The swaplet's rate: the coupon's rate.

public override double SwapletRate(FloatingRateCoupon coupon, EvaluationContext context)

Parameters

coupon FloatingRateCoupon

The coupon.

context EvaluationContext

The evaluation context.

Returns

double

The rate.

Exceptions

ArgumentException

The coupon isn't a CMS spread coupon.

NanoQLException

As SwapletPrice(FloatingRateCoupon, EvaluationContext).