Class YoYInflationLeg
A helper class building a sequence of year-on-year inflation coupons: QuantLib's yoyInflationLeg.
public sealed record YoYInflationLeg : IEquatable<YoYInflationLeg>
- Inheritance
-
YoYInflationLeg
- Implements
- Inherited Members
Remarks
An immutable builder: each method returns a modified copy. ToLeg() builds the leg, in place of QuantLib's conversion operator, and attaches QuantLib's default YoYInflationCouponPricer, as QuantLib does when there are no caps or floors; a leg with caps or floors needs a pricer set on it, as QuantLib's comment says. A period with a zero gearing is a fixed-rate coupon paying its spread, capped and floored; a period with a cap or a floor a CappedFlooredYoYInflationCoupon. A builder has no value equality.
Constructors
YoYInflationLeg(Schedule, Calendar?, YoYInflationIndex, Period, CPIInterpolationType)
Initializes a new instance of the YoYInflationLeg class.
public YoYInflationLeg(Schedule schedule, Calendar? paymentCalendar, YoYInflationIndex index, Period observationLag, CPIInterpolationType interpolation)
Parameters
scheduleScheduleThe schedule of accrual dates.
paymentCalendarCalendarThe payment calendar, or null, QuantLib's empty calendar.
indexYoYInflationIndexThe year-on-year inflation index.
observationLagPeriodThe observation lag.
interpolationCPIInterpolationTypeHow the index is observed.
Exceptions
- ArgumentNullException
scheduleorindexis null.- ArgumentOutOfRangeException
interpolationisn't a member of its type.
Methods
Equals(YoYInflationLeg?)
public bool Equals(YoYInflationLeg? other)
Parameters
otherYoYInflationLeg
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
ToLeg()
Builds the leg, with QuantLib's default pricer attached to each year-on-year coupon when there are no caps or floors.
public ImmutableArray<CashFlow> ToLeg()
Returns
- ImmutableArray<CashFlow>
The leg, one coupon per schedule period.
Exceptions
- NanoQLException
No payment day counter or notional was given; the schedule is empty; more notionals, gearings, spreads, caps or floors were given than there are periods; or a date is computed on QuantLib's empty calendar where it can't give one.
- ArgumentException
A period's cap is below its floor, with the coupon's text.
ToString()
public override string ToString()
Returns
WithCaps(IEnumerable<double?>)
Sets the coupons' caps; the last one repeats for any further coupons.
public YoYInflationLeg WithCaps(IEnumerable<double?> caps)
Parameters
capsIEnumerable<double?>The caps, each null for none.
Returns
- YoYInflationLeg
The modified builder.
Exceptions
- ArgumentNullException
capsis null.
WithCaps(double?)
Sets one cap for every coupon.
public YoYInflationLeg WithCaps(double? cap)
Parameters
Returns
- YoYInflationLeg
The modified builder.
WithFixingDays(IEnumerable<int>)
Sets the coupons' fixing days; the last one repeats for any further coupons.
public YoYInflationLeg WithFixingDays(IEnumerable<int> fixingDays)
Parameters
fixingDaysIEnumerable<int>The fixing days.
Returns
- YoYInflationLeg
The modified builder.
Exceptions
- ArgumentNullException
fixingDaysis null.- ArgumentOutOfRangeException
A count is negative.
WithFixingDays(int)
Sets one number of fixing days for every coupon.
public YoYInflationLeg WithFixingDays(int fixingDays)
Parameters
fixingDaysintThe fixing days.
Returns
- YoYInflationLeg
The modified builder.
Exceptions
- ArgumentOutOfRangeException
fixingDaysis negative.
WithFloors(IEnumerable<double?>)
Sets the coupons' floors; the last one repeats for any further coupons.
public YoYInflationLeg WithFloors(IEnumerable<double?> floors)
Parameters
floorsIEnumerable<double?>The floors, each null for none.
Returns
- YoYInflationLeg
The modified builder.
Exceptions
- ArgumentNullException
floorsis null.
WithFloors(double?)
Sets one floor for every coupon.
public YoYInflationLeg WithFloors(double? floor)
Parameters
Returns
- YoYInflationLeg
The modified builder.
WithGearings(IEnumerable<double>)
Sets the coupons' gearings; the last one repeats for any further coupons.
public YoYInflationLeg WithGearings(IEnumerable<double> gearings)
Parameters
gearingsIEnumerable<double>The gearings.
Returns
- YoYInflationLeg
The modified builder.
Exceptions
- ArgumentNullException
gearingsis null.
WithGearings(double)
Sets one gearing for every coupon.
public YoYInflationLeg WithGearings(double gearing)
Parameters
gearingdoubleThe gearing.
Returns
- YoYInflationLeg
The modified builder.
WithNotionals(IEnumerable<double>)
Sets the coupons' notionals, the last repeated for the coupons after it.
public YoYInflationLeg WithNotionals(IEnumerable<double> notionals)
Parameters
notionalsIEnumerable<double>The notionals.
Returns
- YoYInflationLeg
The modified builder.
Exceptions
- ArgumentNullException
notionalsis null.
WithNotionals(double)
Sets one notional for every coupon.
public YoYInflationLeg WithNotionals(double notional)
Parameters
notionaldoubleThe notional.
Returns
- YoYInflationLeg
The modified builder.
WithPaymentAdjustment(BusinessDayConvention)
Sets the convention adjusting the payment dates.
public YoYInflationLeg WithPaymentAdjustment(BusinessDayConvention convention)
Parameters
conventionBusinessDayConventionThe convention.
Returns
- YoYInflationLeg
The modified builder.
Exceptions
- ArgumentOutOfRangeException
conventionisn't a member of its type.
WithPaymentDayCounter(DayCounter?)
Sets the coupons' day counter.
public YoYInflationLeg WithPaymentDayCounter(DayCounter? dayCounter)
Parameters
dayCounterDayCounterThe day counter, or null, QuantLib's empty one, which the leg refuses.
Returns
- YoYInflationLeg
The modified builder.
WithSpreads(IEnumerable<double>)
Sets the coupons' spreads; the last one repeats for any further coupons.
public YoYInflationLeg WithSpreads(IEnumerable<double> spreads)
Parameters
spreadsIEnumerable<double>The spreads.
Returns
- YoYInflationLeg
The modified builder.
Exceptions
- ArgumentNullException
spreadsis null.
WithSpreads(double)
Sets one spread for every coupon.
public YoYInflationLeg WithSpreads(double spread)
Parameters
spreaddoubleThe spread.
Returns
- YoYInflationLeg
The modified builder.
Operators
operator ==(YoYInflationLeg?, YoYInflationLeg?)
public static bool operator ==(YoYInflationLeg? left, YoYInflationLeg? right)
Parameters
leftYoYInflationLegrightYoYInflationLeg
Returns
operator !=(YoYInflationLeg?, YoYInflationLeg?)
public static bool operator !=(YoYInflationLeg? left, YoYInflationLeg? right)
Parameters
leftYoYInflationLegrightYoYInflationLeg