Class MakeMultipleResetsSwap
- Namespace
- NanoQL.Instruments
- Assembly
- NanoQL.dll
A helper building multiple-resets swaps: QuantLib's MakeMultipleResetsSwap.
public sealed record MakeMultipleResetsSwap : IEquatable<MakeMultipleResetsSwap>
- Inheritance
-
MakeMultipleResetsSwap
- Implements
- Inherited Members
Remarks
An immutable builder: each method returns a modified copy, and ToSwap(EvaluationContext) builds the swap under a context, in place of QuantLib's conversion operators. By default the fixed leg's frequency is the coupons' period, the index's tenor times the resets per coupon. With no fixed rate given, the swap is built at its par rate, priced by the engine set, or by DiscountingSwapEngine on the index's forwarding curve; the engine is never stored on the swap, where QuantLib's builder attaches it. A builder has no value equality. An option the builder isn't given that QuantLib's builder fixes takes the builder's provider's default (Defaults(ConventionProvider)), read when the swap is built: QuantLib's values with nothing configured.
Constructors
MakeMultipleResetsSwap(Period, IborIndex, int)
Initializes a new instance of the MakeMultipleResetsSwap record.
public MakeMultipleResetsSwap(Period tenor, IborIndex iborIndex, int resetsPerCoupon)
Parameters
tenorPeriodThe swap's tenor.
iborIndexIborIndexThe index whose fixings the floating coupons combine.
resetsPerCouponintThe number of resets per floating coupon.
Exceptions
- ArgumentNullException
iborIndexis null.- ArgumentOutOfRangeException
resetsPerCouponisn't positive.
Methods
Defaults(ConventionProvider)
The defaults a builder takes under a provider for the options it isn't given.
public static MultipleResetsSwapDefaults Defaults(ConventionProvider provider)
Parameters
providerConventionProviderThe provider, the index's, which a builder on the index takes.
Returns
- MultipleResetsSwapDefaults
The provider's defaults; QuantLib's under QuantLib.
Exceptions
- ArgumentNullException
provideris null.- ArgumentException
The provider has no defaults (a set without QuantLib's presets).
Equals(MakeMultipleResetsSwap?)
public bool Equals(MakeMultipleResetsSwap? other)
Parameters
otherMakeMultipleResetsSwap
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
GetHashCode()
public override int GetHashCode()
Returns
ReceiveFixed(bool)
Sets whether the fixed rate is received.
public MakeMultipleResetsSwap ReceiveFixed(bool flag = true)
Parameters
flagboolWhether it is.
Returns
- MakeMultipleResetsSwap
The modified builder.
ToString()
public override string ToString()
Returns
ToSwap(EvaluationContext)
Builds the swap.
public MultipleResetsSwap ToSwap(EvaluationContext context)
Parameters
contextEvaluationContextThe evaluation context, whose evaluation date the start is counted from.
Returns
- MultipleResetsSwap
The swap.
Exceptions
- ArgumentNullException
contextis null.- NanoQLException
Both a start date and settlement days were given; or, with no fixed rate given, the index has no forwarding curve and no engine was set, or the engine gives no fair rate; each with QuantLib's text.
WithAveragingMethod(RateAveragingType)
Sets how the floating fixings combine.
public MakeMultipleResetsSwap WithAveragingMethod(RateAveragingType m)
Parameters
mRateAveragingTypeThe method.
Returns
- MakeMultipleResetsSwap
The modified builder.
Exceptions
- ArgumentOutOfRangeException
The method isn't a member of the enum.
WithDiscountingTermStructure(YieldTermStructure?)
Sets DiscountingSwapEngine on a discount curve, without the settlement date's flows, as the engine that computes the par rate when no fixed rate is given.
public MakeMultipleResetsSwap WithDiscountingTermStructure(YieldTermStructure? d)
Parameters
dYieldTermStructureThe discount curve, or null, QuantLib's empty handle: the engine then refuses to price, so a build at the par rate is refused.
Returns
- MakeMultipleResetsSwap
The modified builder.
WithEffectiveDate(Date?)
Sets the start date, in place of the settlement days.
public MakeMultipleResetsSwap WithEffectiveDate(Date? d)
Parameters
Returns
- MakeMultipleResetsSwap
The modified builder.
WithFixedLegConvention(BusinessDayConvention)
Sets the fixed leg's convention.
public MakeMultipleResetsSwap WithFixedLegConvention(BusinessDayConvention bdc)
Parameters
bdcBusinessDayConventionThe convention.
Returns
- MakeMultipleResetsSwap
The modified builder.
Exceptions
- ArgumentOutOfRangeException
The convention isn't a member of the enum.
WithFixedLegDayCount(DayCounter)
Sets the fixed leg's day counter, the index's by default.
public MakeMultipleResetsSwap WithFixedLegDayCount(DayCounter dc)
Parameters
dcDayCounterThe day counter.
Returns
- MakeMultipleResetsSwap
The modified builder.
Exceptions
- ArgumentNullException
dcis null.
WithFixedLegFrequency(Frequency)
Sets the fixed leg's frequency, the coupons' period by default.
public MakeMultipleResetsSwap WithFixedLegFrequency(Frequency f)
Parameters
fFrequencyThe frequency, or NoFrequency for the default.
Returns
- MakeMultipleResetsSwap
The modified builder.
Exceptions
- ArgumentOutOfRangeException
The frequency isn't a member of the enum.
WithFixedRate(double?)
Sets the fixed rate; with none the swap is built at its par rate.
public MakeMultipleResetsSwap WithFixedRate(double? fixedRate)
Parameters
Returns
- MakeMultipleResetsSwap
The modified builder.
WithFloatingLegSpread(double)
Sets the spread added to each floating fixing.
public MakeMultipleResetsSwap WithFloatingLegSpread(double sp)
Parameters
spdoubleThe spread.
Returns
- MakeMultipleResetsSwap
The modified builder.
WithForwardStart(Period)
Sets the forward start from the spot date.
public MakeMultipleResetsSwap WithForwardStart(Period fwdStart)
Parameters
fwdStartPeriodThe forward start.
Returns
- MakeMultipleResetsSwap
The modified builder.
WithNominal(double)
Sets the nominal.
public MakeMultipleResetsSwap WithNominal(double n)
Parameters
ndoubleThe nominal.
Returns
- MakeMultipleResetsSwap
The modified builder.
WithPricingEngine(Func<FixedVsFloatingSwap, EvaluationContext, FixedVsFloatingSwapResults>?)
Sets the engine that computes the par rate when no fixed rate is given; it is never stored on the swap.
public MakeMultipleResetsSwap WithPricingEngine(Func<FixedVsFloatingSwap, EvaluationContext, FixedVsFloatingSwapResults>? engine)
Parameters
engineFunc<FixedVsFloatingSwap, EvaluationContext, FixedVsFloatingSwapResults>The engine, or null for the default: a DiscountingSwapEngine on the index's forwarding curve.
Returns
- MakeMultipleResetsSwap
The modified builder.
WithSettlementDays(int?)
Sets the settlement days from the evaluation date to the start, the index's fixing days by default.
public MakeMultipleResetsSwap WithSettlementDays(int? settlementDays)
Parameters
Returns
- MakeMultipleResetsSwap
The modified builder.
Exceptions
- ArgumentOutOfRangeException
The days are negative.
WithTerminationDate(Date?)
Sets the end date, in place of the tenor.
public MakeMultipleResetsSwap WithTerminationDate(Date? d)
Parameters
Returns
- MakeMultipleResetsSwap
The modified builder.
WithType(SwapType)
Sets whether the fixed rate is paid or received.
public MakeMultipleResetsSwap WithType(SwapType type)
Parameters
typeSwapTypeThe type.
Returns
- MakeMultipleResetsSwap
The modified builder.
Exceptions
- ArgumentOutOfRangeException
The type isn't a member of the enum.
Operators
operator ==(MakeMultipleResetsSwap?, MakeMultipleResetsSwap?)
public static bool operator ==(MakeMultipleResetsSwap? left, MakeMultipleResetsSwap? right)
Parameters
leftMakeMultipleResetsSwaprightMakeMultipleResetsSwap
Returns
operator !=(MakeMultipleResetsSwap?, MakeMultipleResetsSwap?)
public static bool operator !=(MakeMultipleResetsSwap? left, MakeMultipleResetsSwap? right)
Parameters
leftMakeMultipleResetsSwaprightMakeMultipleResetsSwap