Class OvernightLeg
A helper class building a sequence of overnight-indexed coupons.
public sealed record OvernightLeg : IEquatable<OvernightLeg>
- Inheritance
-
OvernightLeg
- Implements
- Inherited Members
Remarks
An immutable builder: each method returns a modified copy, so a builder kept and reused never changes under its holder. ToLeg() builds the leg, in place of QuantLib's conversion operator; it reads no evaluation date, since the coupons' value dates are always the full daily list. A builder has no value equality: its vectors compare by reference.
A period whose gearing is zero is a FixedRateCoupon at the spread, capped and floored; a period with a cap or a floor is a CappedFlooredOvernightIndexedCoupon. A coupon pricer given with WithCouponPricer(OvernightIndexedCouponPricer?) is set on each coupon and capped coupon; otherwise the coupons keep their default pricers, and the capped coupons have none.
Constructors
OvernightLeg(Schedule, OvernightIndex)
Initializes a new instance of the OvernightLeg record.
public OvernightLeg(Schedule schedule, OvernightIndex overnightIndex)
Parameters
scheduleScheduleThe schedule; its calendar is the default payment calendar.
overnightIndexOvernightIndexThe overnight index.
Exceptions
- ArgumentNullException
An argument is null.
Methods
CompoundingSpreadDaily(bool)
Sets whether the spread compounds daily.
public OvernightLeg CompoundingSpreadDaily(bool compoundSpreadDaily = true)
Parameters
compoundSpreadDailyboolThe flag.
Returns
- OvernightLeg
The modified builder.
Equals(OvernightLeg?)
public bool Equals(OvernightLeg? other)
Parameters
otherOvernightLeg
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
InArrears(bool)
Sets whether the rates are computed over each coupon's own period (in arrears, the default) or over the period before (in advance).
public OvernightLeg InArrears(bool inArrears)
Parameters
inArrearsboolThe flag.
Returns
- OvernightLeg
The modified builder.
ToLeg()
The leg: QuantLib's conversion to Leg.
public ImmutableArray<CashFlow> ToLeg()
Returns
- ImmutableArray<CashFlow>
The leg; empty for a schedule of one date.
Exceptions
- NanoQLException
No nominal is given, the coupon pricer doesn't suit the averaging method, the schedule is empty, the explicit payment dates don't match the periods, or, after every refusal QuantLib raises while it builds the leg, a period of zero gearing has no payment day counter.
ToString()
public override string ToString()
Returns
WithAveragingMethod(RateAveragingType)
Sets the averaging method.
public OvernightLeg WithAveragingMethod(RateAveragingType averagingMethod)
Parameters
averagingMethodRateAveragingTypeThe method.
Returns
- OvernightLeg
The modified builder.
WithCaps(IEnumerable<double?>)
Sets the coupons' caps, null for none; the last one repeats past the end.
public OvernightLeg WithCaps(IEnumerable<double?> caps)
Parameters
capsIEnumerable<double?>The caps.
Returns
- OvernightLeg
The modified builder.
WithCaps(double?)
Sets one cap for every coupon.
public OvernightLeg WithCaps(double? cap)
Parameters
Returns
- OvernightLeg
The modified builder.
WithCouponPricer(OvernightIndexedCouponPricer?)
Sets the pricer of every coupon and capped coupon: a compounding pricer for compounded coupons, an averaging pricer for averaged ones; null keeps the coupons' default pricers.
public OvernightLeg WithCouponPricer(OvernightIndexedCouponPricer? couponPricer)
Parameters
couponPricerOvernightIndexedCouponPricerThe pricer.
Returns
- OvernightLeg
The modified builder.
WithDailyCapFloor(bool)
Sets whether the caps and floors apply to the daily rates.
public OvernightLeg WithDailyCapFloor(bool dailyCapFloor = true)
Parameters
dailyCapFloorboolThe flag.
Returns
- OvernightLeg
The modified builder.
WithFloors(IEnumerable<double?>)
Sets the coupons' floors, null for none; the last one repeats past the end.
public OvernightLeg WithFloors(IEnumerable<double?> floors)
Parameters
floorsIEnumerable<double?>The floors.
Returns
- OvernightLeg
The modified builder.
WithFloors(double?)
Sets one floor for every coupon.
public OvernightLeg WithFloors(double? floor)
Parameters
floordouble?The floor, or null, QuantLib's
Null<Rate>(), for none: the coupons are then unfloored.
Returns
- OvernightLeg
The modified builder.
WithGearings(IEnumerable<double>)
Sets the coupons' gearings; the last one repeats past the end, and 1 applies when none is set.
public OvernightLeg WithGearings(IEnumerable<double> gearings)
Parameters
gearingsIEnumerable<double>The gearings.
Returns
- OvernightLeg
The modified builder.
WithGearings(double)
Sets one gearing for every coupon.
public OvernightLeg WithGearings(double gearing)
Parameters
gearingdoubleThe gearing.
Returns
- OvernightLeg
The modified builder.
WithLastRecentPeriod(Period?)
Sets the period before each rate computation's end where the computation starts, or null to compute over the whole period.
public OvernightLeg WithLastRecentPeriod(Period? lastRecentPeriod)
Parameters
lastRecentPeriodPeriod?The period.
Returns
- OvernightLeg
The modified builder.
WithLastRecentPeriodCalendar(Calendar?)
Sets the calendar of the last recent period; the schedule's when none is set.
public OvernightLeg WithLastRecentPeriodCalendar(Calendar? lastRecentPeriodCalendar)
Parameters
lastRecentPeriodCalendarCalendarThe calendar; the schedule's when null, QuantLib's empty calendar.
Returns
- OvernightLeg
The modified builder.
WithLockoutDays(int)
Sets the lockout days.
public OvernightLeg WithLockoutDays(int lockoutDays)
Parameters
lockoutDaysintThe lockout.
Returns
- OvernightLeg
The modified builder.
Exceptions
- ArgumentOutOfRangeException
The lockout is negative.
WithLookbackDays(int?)
Sets the lookback days.
public OvernightLeg WithLookbackDays(int? lookbackDays)
Parameters
lookbackDaysint?The lookback, or null, QuantLib's
Null<Natural>()and its default, for none: the coupons then fix by the index's fixing days.
Returns
- OvernightLeg
The modified builder.
Exceptions
- ArgumentOutOfRangeException
The lookback is negative.
WithNakedOption(bool)
Sets whether the capped coupons pay the options alone.
public OvernightLeg WithNakedOption(bool nakedOption)
Parameters
nakedOptionboolThe flag.
Returns
- OvernightLeg
The modified builder.
WithNotionals(IEnumerable<double>)
Sets the coupons' nominals; the last one repeats past the end.
public OvernightLeg WithNotionals(IEnumerable<double> notionals)
Parameters
notionalsIEnumerable<double>The nominals.
Returns
- OvernightLeg
The modified builder.
WithNotionals(double)
Sets one nominal for every coupon.
public OvernightLeg WithNotionals(double notional)
Parameters
notionaldoubleThe nominal.
Returns
- OvernightLeg
The modified builder.
WithObservationShift(bool)
Sets whether the observation shift applies.
public OvernightLeg WithObservationShift(bool applyObservationShift = true)
Parameters
applyObservationShiftboolThe flag.
Returns
- OvernightLeg
The modified builder.
WithPaymentAdjustment(BusinessDayConvention)
Sets the convention adjusting the payment dates.
public OvernightLeg WithPaymentAdjustment(BusinessDayConvention convention)
Parameters
conventionBusinessDayConventionThe convention.
Returns
- OvernightLeg
The modified builder.
WithPaymentCalendar(Calendar?)
Sets the payment calendar; the schedule's when none is set.
public OvernightLeg WithPaymentCalendar(Calendar? cal)
Parameters
calCalendarThe calendar; the schedule's when null, QuantLib's empty calendar, and WeekendsOnly when the schedule's is empty too.
Returns
- OvernightLeg
The modified builder.
WithPaymentDates(IEnumerable<Date>)
Sets explicit payment dates, one per period, in place of the lagged and adjusted accrual ends.
public OvernightLeg WithPaymentDates(IEnumerable<Date> paymentDates)
Parameters
paymentDatesIEnumerable<Date>The dates.
Returns
- OvernightLeg
The modified builder.
WithPaymentDayCounter(DayCounter?)
Sets the coupons' accrual day counter; the index's when none is set.
public OvernightLeg WithPaymentDayCounter(DayCounter? dc)
Parameters
dcDayCounterThe day counter; the index's when null, QuantLib's empty day counter. A period with a zero gearing then refuses the conversion, its fixed-rate coupon needing one, after every refusal QuantLib raises while it builds the leg.
Returns
- OvernightLeg
The modified builder.
WithPaymentLag(int)
Sets the payment lag, in business days after each accrual end.
public OvernightLeg WithPaymentLag(int lag)
Parameters
lagintThe lag.
Returns
- OvernightLeg
The modified builder.
WithRoundingPrecision(int)
Sets the decimal places the coupons' rates are rounded to before their amounts are computed.
public OvernightLeg WithRoundingPrecision(int roundingPrecision)
Parameters
roundingPrecisionintThe precision.
Returns
- OvernightLeg
The modified builder.
Exceptions
- ArgumentOutOfRangeException
The precision is outside [0, 16].
WithSpreads(IEnumerable<double>)
Sets the coupons' spreads; the last one repeats past the end, and 0 applies when none is set.
public OvernightLeg WithSpreads(IEnumerable<double> spreads)
Parameters
spreadsIEnumerable<double>The spreads.
Returns
- OvernightLeg
The modified builder.
WithSpreads(double)
Sets one spread for every coupon.
public OvernightLeg WithSpreads(double spread)
Parameters
spreaddoubleThe spread.
Returns
- OvernightLeg
The modified builder.
WithTelescopicValueDates(bool)
Sets QuantLib's telescopic value dates, which on averaged coupons select the averaging pricer's approximation; the value dates are the full daily list either way.
public OvernightLeg WithTelescopicValueDates(bool telescopicValueDates)
Parameters
telescopicValueDatesboolThe flag.
Returns
- OvernightLeg
The modified builder.
Operators
operator ==(OvernightLeg?, OvernightLeg?)
public static bool operator ==(OvernightLeg? left, OvernightLeg? right)
Parameters
leftOvernightLegrightOvernightLeg
Returns
operator !=(OvernightLeg?, OvernightLeg?)
public static bool operator !=(OvernightLeg? left, OvernightLeg? right)
Parameters
leftOvernightLegrightOvernightLeg