Table of Contents

Class SwapForwardMappings

Namespace
NanoQL.Models
Assembly
NanoQL.dll

The mappings between swap rates and forward rates: annuities, the swap rates' derivatives and Jacobians in the forwards, the Z matrices that switch a model's base from forwards to swap rates, and a swaption's implied volatility by frozen coefficients.

public static class SwapForwardMappings
Inheritance
SwapForwardMappings
Inherited Members

Remarks

Three departures from QuantLib: the coinitial Z matrix scales every entry of its rows, where QuantLib's scales from the diagonal rightward, as the coterminal one does, though a coinitial row is nonzero left of it (Divergences/CoinitialZedMatrixTests.cs); and the swaption's implied volatility refuses an evolution whose times don't hold the swaption's expiry, and unequal displacements, as QuantLib's frozen-coefficient adapters refuse them, since it sums whole steps up to the expiry and reads the first displacement alone (Divergences/SwaptionImpliedVolatilityGridTests.cs).

Methods

Annuity(CurveState, int, int, int)

The annuity of the swap from the start index to the end index, in units of a numeraire bond.

public static double Annuity(CurveState cs, int startIndex, int endIndex, int numeraireIndex)

Parameters

cs CurveState

The curve state.

startIndex int

The swap's first rate.

endIndex int

The swap's end, after its last rate, at most the number of rates.

numeraireIndex int

The numeraire bond.

Returns

double

The annuity.

Remarks

QuantLib reads the accrual periods past their vector at an end past the rates, refused.

Exceptions

ArgumentOutOfRangeException

An index is outside the rates.

CmSwapForwardJacobian(CurveState, int)

The Jacobian dsrᵢ/dfⱼ of the constant-maturity swap rates in the forwards.

public static Matrix CmSwapForwardJacobian(CurveState cs, int spanningForwards)

Parameters

cs CurveState

The curve state.

spanningForwards int

The forwards each swap spans.

Returns

Matrix

A new matrix, swap rates by forwards.

Exceptions

ArgumentOutOfRangeException

spanningForwards is negative.

CmSwapZedMatrix(CurveState, int, double)

The Z matrix switching a model's base from forwards to constant-maturity swap rates.

public static Matrix CmSwapZedMatrix(CurveState cs, int spanningForwards, double displacement)

Parameters

cs CurveState

The curve state.

spanningForwards int

The forwards each swap spans.

displacement double

The rates' displacement.

Returns

Matrix

A new matrix, swap rates by forwards.

Exceptions

ArgumentOutOfRangeException

spanningForwards is negative.

CoinitialSwapForwardJacobian(CurveState)

The Jacobian dsrᵢ/dfⱼ of the coinitial swap rates, from the first rate time to the (i + 1)-th, in the forwards.

public static Matrix CoinitialSwapForwardJacobian(CurveState cs)

Parameters

cs CurveState

The curve state, set from the first rate.

Returns

Matrix

A new matrix, swap rates by forwards.

CoinitialSwapZedMatrix(CurveState, double)

The Z matrix switching a model's base from forwards to coinitial swap rates.

public static Matrix CoinitialSwapZedMatrix(CurveState cs, double displacement)

Parameters

cs CurveState

The curve state, set from the first rate.

displacement double

The rates' displacement.

Returns

Matrix

A new matrix, swap rates by forwards.

Remarks

Each row is scaled whole: QuantLib's scales from the diagonal rightward, leaving the entries left of it, nonzero for a coinitial swap, raw derivatives blind to the displacement. Each row then equals QuantLib's own CmSwapZedMatrix(CurveState, int, double)'s first row at a spanning of the row's swap, bit for bit.

CoterminalSwapForwardJacobian(CurveState)

The Jacobian dsrᵢ/dfⱼ of the coterminal swap rates in the forwards.

public static Matrix CoterminalSwapForwardJacobian(CurveState cs)

Parameters

cs CurveState

The curve state, set from the first rate.

Returns

Matrix

A new matrix, swap rates by forwards.

CoterminalSwapZedMatrix(CurveState, double)

The Z matrix switching a model's base from forwards to coterminal swap rates.

public static Matrix CoterminalSwapZedMatrix(CurveState cs, double displacement)

Parameters

cs CurveState

The curve state, set from the first rate.

displacement double

The rates' displacement.

Returns

Matrix

A new matrix, swap rates by forwards.

SwapDerivative(CurveState, int, int, int)

The derivative of the swap rate from the start index to the end index in a forward rate.

public static double SwapDerivative(CurveState cs, int startIndex, int endIndex, int forwardIndex)

Parameters

cs CurveState

The curve state.

startIndex int

The swap's first rate.

endIndex int

The swap's end, after its last rate.

forwardIndex int

The forward.

Returns

double

The derivative, 0 for a forward outside the swap.

Exceptions

ArgumentOutOfRangeException

An index the derivative reads is outside the rates.

SwaptionImpliedVolatility(MarketModel, int, int)

The implied volatility of the swaption on the swap from the start index to the end index, by frozen coefficients: the model's variance of the swap rate summed over the steps to the swaption's expiry, the start index's rate time.

public static double SwaptionImpliedVolatility(MarketModel volStructure, int startIndex, int endIndex)

Parameters

volStructure MarketModel

The model.

startIndex int

The swap's first rate.

endIndex int

The swap's end, after its last rate, at most the number of rates.

Returns

double

The implied volatility.

Exceptions

ArgumentException

The start index isn't before the end, the model's displacements aren't equal, or its evolution times don't hold the swaption's expiry.

ArgumentOutOfRangeException

An index is outside the rates.