Table of Contents

Class CoterminalSwapCurveState

Namespace
NanoQL.Models
Assembly
NanoQL.dll

The curve state of coterminal swap market models: set on coterminal swap rates, from a first valid index on.

[WorkingType]
public sealed class CoterminalSwapCurveState : CurveState
Inheritance
CoterminalSwapCurveState
Inherited Members

Remarks

A working type. The forwards and the constant-maturity swap rates are computed at each read into the state's own buffers, as QuantLib's are. A rate read at the number of rates, which QuantLib's index check admits and reads past its vectors, is refused with QuantLib's text.

Constructors

CoterminalSwapCurveState(ReadOnlySpan<double>)

Initializes a new instance of the CoterminalSwapCurveState class, not yet set.

public CoterminalSwapCurveState(ReadOnlySpan<double> rateTimes)

Parameters

rateTimes ReadOnlySpan<double>

The rate times: at least two, strictly increasing, the first greater than zero.

Exceptions

ArgumentException

The rate times aren't two or more strictly increasing positive times.

Methods

Clone()

A deep copy: the state, its buffers and its lazy reads.

public override CurveState Clone()

Returns

CurveState

The copy, of the receiver's type.

CmSwapAnnuity(int, int, int)

The annuity of the i-th constant-maturity swap, spanning spanningForwards forwards, in units of a numeraire bond.

public override double CmSwapAnnuity(int numeraire, int i, int spanningForwards)

Parameters

numeraire int

The numeraire bond's index, in [the first valid index, the number of rates].

i int

The swap's index, in [the first valid index, the number of rates).

spanningForwards int

The forwards each swap spans.

Returns

double

The annuity.

Exceptions

NanoQLException

The state isn't set yet.

ArgumentOutOfRangeException

The numeraire, i or the forwards is outside its range.

CmSwapRate(int, int)

The i-th constant-maturity swap rate, spanning spanningForwards forwards.

public override double CmSwapRate(int i, int spanningForwards)

Parameters

i int

The index, in [the first valid index, the number of rates).

spanningForwards int

The forwards each swap spans.

Returns

double

The swap rate.

Exceptions

NanoQLException

The state isn't set yet.

ArgumentOutOfRangeException

i or the forwards is outside its range.

CmSwapRates(int)

The constant-maturity swap rates spanning spanningForwards forwards: a view of the state's buffer, valid until the state is next set or the read is made with another number of forwards.

public override ReadOnlySpan<double> CmSwapRates(int spanningForwards)

Parameters

spanningForwards int

The forwards each swap spans.

Returns

ReadOnlySpan<double>

The swap rates.

Exceptions

NanoQLException

The state isn't set yet.

ArgumentOutOfRangeException

spanningForwards is negative.

CoterminalSwapAnnuity(int, int)

The annuity of the i-th coterminal swap in units of a numeraire bond.

public override double CoterminalSwapAnnuity(int numeraire, int i)

Parameters

numeraire int

The numeraire bond's index, in [the first valid index, the number of rates].

i int

The swap's index, in [the first valid index, the number of rates).

Returns

double

The annuity.

Exceptions

NanoQLException

The state isn't set yet.

ArgumentOutOfRangeException

The numeraire or i is outside its range.

CoterminalSwapRate(int)

The i-th coterminal swap rate, of the swap from tᵢ to tₙ.

public override double CoterminalSwapRate(int i)

Parameters

i int

The index, in [the first valid index, the number of rates).

Returns

double

The swap rate.

Exceptions

NanoQLException

The state isn't set yet.

ArgumentOutOfRangeException

i is outside the valid rates.

CoterminalSwapRates()

The coterminal swap rates: a view of the state's buffer, valid until the state is next set.

public override ReadOnlySpan<double> CoterminalSwapRates()

Returns

ReadOnlySpan<double>

The coterminal swap rates.

Exceptions

NanoQLException

The state isn't set yet.

DiscountRatio(int, int)

The ratio of the i-th discount bond to the j-th.

public override double DiscountRatio(int i, int j)

Parameters

i int

The numerator's index, in [the first valid index, the number of rates].

j int

The denominator's index, in the same range.

Returns

double

dᵢ/dⱼ.

Exceptions

NanoQLException

The state isn't set yet.

ArgumentOutOfRangeException

An index is outside [the first valid index, the number of rates].

ForwardRate(int)

The i-th forward rate.

public override double ForwardRate(int i)

Parameters

i int

The index, in [the first valid index, the number of rates).

Returns

double

The forward rate.

Exceptions

NanoQLException

The state isn't set yet.

ArgumentOutOfRangeException

i is outside the valid rates.

ForwardRates()

The forward rates: a view of the state's buffer, valid until the state is next set.

public override ReadOnlySpan<double> ForwardRates()

Returns

ReadOnlySpan<double>

The forward rates, those below the first valid index as the buffer holds them.

Exceptions

NanoQLException

The state isn't set yet.

SetOnCoterminalSwapRates(ReadOnlySpan<double>, int)

Sets the state on coterminal swap rates, those from the first valid index on.

public void SetOnCoterminalSwapRates(ReadOnlySpan<double> swapRates, int firstValidIndex = 0)

Parameters

swapRates ReadOnlySpan<double>

The coterminal swap rates, one per rate; those below the first valid index aren't read.

firstValidIndex int

The first valid index, below the number of rates.

Exceptions

ArgumentException

The number of swap rates isn't the number of rates.

ArgumentOutOfRangeException

firstValidIndex is outside the rates.