Class YoYInflationCapFloor
- Namespace
- NanoQL.Instruments
- Assembly
- NanoQL.dll
The base class of year-on-year inflation cap-like instruments: caps, floors and collars on a YoY leg.
public class YoYInflationCapFloor : Instrument
- Inheritance
-
YoYInflationCapFloor
- Derived
- Inherited Members
Remarks
The standard YoY inflation cap or floor differs from a nominal one: a nominal cap has no first optionlet, since it sets in advance, while a YoY one sets (effectively) in arrears, against a lag of a few months, so its first optionlet counts; the parity test needs no special definition of the instrument. The relationship between the values of caps, floors and collars is checked, and so are the put-call parity with swaps and a known good value.
Unsealed, as in QuantLib, where YoYInflationCap, YoYInflationFloor and
YoYInflationCollar derive from it and engines take it. It holds its leg and its rates; an engine
computes QuantLib's arguments from them with the context (NanoQL.Instruments.YoYInflationCapFloor.SetupArguments(NanoQL.EvaluationContext)) and returns the instrument's
results, QuantLib's plain Instrument::results with the engine's additional results. A cash flow of the leg
that isn't a year-on-year inflation coupon is refused when the instrument is priced, as QuantLib refuses it, not
when it is built. Equality is by reference.
Constructors
YoYInflationCapFloor(YoYInflationCapFloorType, ImmutableArray<CashFlow>, IEnumerable<double>)
Initializes a new instance of the YoYInflationCapFloor class with strikes: a cap or a floor.
public YoYInflationCapFloor(YoYInflationCapFloorType type, ImmutableArray<CashFlow> yoyLeg, IEnumerable<double> strikes)
Parameters
typeYoYInflationCapFloorTypeyoyLegImmutableArray<CashFlow>The year-on-year leg.
strikesIEnumerable<double>The strikes, extended to the leg's length with the last one: the cap rates of a cap, the floor rates of a floor.
Exceptions
- ArgumentException
The leg is
defaultor holds a null cash flow, or there are no strikes.- ArgumentNullException
strikesis null.- ArgumentOutOfRangeException
typeis Collar or isn't a member of its type.
YoYInflationCapFloor(YoYInflationCapFloorType, ImmutableArray<CashFlow>, IEnumerable<double>, IEnumerable<double>)
Initializes a new instance of the YoYInflationCapFloor class with cap and floor rates.
public YoYInflationCapFloor(YoYInflationCapFloorType type, ImmutableArray<CashFlow> yoyLeg, IEnumerable<double> capRates, IEnumerable<double> floorRates)
Parameters
typeYoYInflationCapFloorTypeThe type.
yoyLegImmutableArray<CashFlow>The year-on-year leg.
capRatesIEnumerable<double>The cap rates, extended to the leg's length with the last one; read for a cap or a collar, and kept as given for a floor.
floorRatesIEnumerable<double>The floor rates, extended to the leg's length with the last one; read for a floor or a collar, and kept as given for a cap.
Exceptions
- ArgumentOutOfRangeException
typeisn't a member of its type.- ArgumentException
The leg is
defaultor holds a null cash flow, or the rates the type reads are empty.- ArgumentNullException
A rate sequence is null.
Properties
CapRates
Gets the cap rates, extended to the leg's length for a cap or a collar.
public ImmutableArray<double> CapRates { get; }
Property Value
FloorRates
Gets the floor rates, extended to the leg's length for a floor or a collar.
public ImmutableArray<double> FloorRates { get; }
Property Value
Type
Gets the type.
public YoYInflationCapFloorType Type { get; }
Property Value
YoYLeg
Gets the year-on-year leg.
public ImmutableArray<CashFlow> YoYLeg { get; }
Property Value
Methods
AtmRate(YieldTermStructure, EvaluationContext)
The at-the-money rate on a discount curve: the leg's at-the-money rate (AtmRate(ImmutableArray<CashFlow>, YieldTermStructure, EvaluationContext, bool?, Date?, Date?, double?)) at the curve's reference date, without the cash flows paid on it.
public virtual double AtmRate(YieldTermStructure discountCurve, EvaluationContext context)
Parameters
discountCurveYieldTermStructureThe discount curve.
contextEvaluationContextThe evaluation context: the coupons' amounts read its fixings and forecasts.
Returns
- double
The rate; 0 for an empty leg.
Exceptions
- ArgumentNullException
An argument is null.
- NanoQLException
The leg's BPS is 0, or a coupon can't be priced.
ImpliedVolatility(double, YoYInflationTermStructure?, double, EvaluationContext, double, int, double, double)
The implied volatility: not implemented, as in QuantLib.
public virtual double ImpliedVolatility(double price, YoYInflationTermStructure? yoyCurve, double guess, EvaluationContext context, double accuracy = 0.0001, int maxEvaluations = 100, double minVol = 1E-07, double maxVol = 4)
Parameters
pricedoubleThe price.
yoyCurveYoYInflationTermStructureThe year-on-year inflation curve.
guessdoubleThe solver's initial guess.
contextEvaluationContextThe evaluation context.
accuracydoubleThe solver's accuracy.
maxEvaluationsintThe solver's maximum number of evaluations.
minVoldoubleThe lower end of the bracket.
maxVoldoubleThe upper end of the bracket.
Returns
- double
Never returns.
Exceptions
- NanoQLException
Always: "not implemented yet".
IsExpired(EvaluationContext)
Whether every cash flow of the leg has occurred, an empty leg among them.
public override bool IsExpired(EvaluationContext context)
Parameters
contextEvaluationContextThe evaluation context.
Returns
Exceptions
- ArgumentNullException
contextis null.
LastYoYInflationCoupon()
The leg's last cash flow as a year-on-year inflation coupon.
public YoYInflationCoupon? LastYoYInflationCoupon()
Returns
- YoYInflationCoupon
The coupon, or null when the last cash flow isn't a year-on-year inflation coupon.
Exceptions
- NanoQLException
The leg is empty, where QuantLib reads past its end, which is undefined: a documented divergence.
MaturityDate()
The latest accrual end date of the leg's coupons.
public Date MaturityDate()
Returns
- Date
The maturity date.
Exceptions
- ArgumentException
The leg is empty.
Optionlet(int)
The i-th optionlet, a new YoYInflationCapFloor of the same type on that cash
flow alone, with its cap and floor rates.
public YoYInflationCapFloor Optionlet(int i)
Parameters
iintThe optionlet's index, from 0.
Returns
- YoYInflationCapFloor
The optionlet.
Exceptions
- ArgumentOutOfRangeException
iis negative.- ArgumentException
The leg has no cash flow at
i.
StartDate()
The earliest accrual start date of the leg's coupons.
public Date StartDate()
Returns
- Date
The start date.
Exceptions
- ArgumentException
The leg is empty.