Class NonstandardSwap
- Namespace
- NanoQL.Instruments
- Assembly
- NanoQL.dll
A vanilla swap, but possibly with period-dependent nominals, fixed rates, gearings and spreads.
public sealed class NonstandardSwap : Swap
- Inheritance
-
NonstandardSwap
- Inherited Members
Remarks
The constructors build the legs, as QuantLib's do: a fixed leg, and an Ibor leg with the index's default pricer, which reads the context's at-par switch, so they take the context; or, for an overnight index, a compounded overnight leg. A zero gearing becomes QuantLib's machine epsilon, so that the floating leg is built of floating coupons. With the capital exchanges, a redemption follows each coupon whose nominal changes after it, and the last, the nominals and fixed rates repeated (the rate as 0) beside each, as QuantLib's inspectors give them. The fixed leg is paid by a payer swap.
Converted from a fixed-versus-floating swap, it keeps an overnight-indexed swap's observation conventions, as
QuantLib's does, and its rounding precision, which QuantLib's conversion drops, so a rounded swap's coupons would
differ from the source's: the converted swap is worth the source's, QuantLib's own identity
(testNonstandardSwapConversionPreservesObservationConventions).
Constructors
NonstandardSwap(FixedVsFloatingSwap, EvaluationContext)
Initializes a new instance of the NonstandardSwap class from a fixed-versus-floating swap: each leg's nominals, the last repeated to the leg's length, its rate and spread repeated on every coupon, a unit gearing.
public NonstandardSwap(FixedVsFloatingSwap fromVanilla, EvaluationContext context)
Parameters
fromVanillaFixedVsFloatingSwapThe swap: a vanilla or an overnight-indexed swap.
contextEvaluationContextThe evaluation context, whose at-par switch the Ibor leg reads.
Remarks
Each leg's nominals are QuantLib's master's (#2956), where QuantLib 1.44 repeats the swap's constant
nominal and refuses an amortizing swap (Divergences/NonstandardSwapUpstreamFixesTests.cs).
Exceptions
- ArgumentNullException
An argument is null.
NonstandardSwap(SwapType, IEnumerable<double>, IEnumerable<double>, Schedule, IEnumerable<double>, DayCounter, Schedule, IborIndex, IEnumerable<double>, IEnumerable<double>, DayCounter?, EvaluationContext, bool, bool, BusinessDayConvention?, int, Calendar?)
Initializes a new instance of the NonstandardSwap class with a gearing and a spread per coupon.
public NonstandardSwap(SwapType type, IEnumerable<double> fixedNominal, IEnumerable<double> floatingNominal, Schedule fixedSchedule, IEnumerable<double> fixedRate, DayCounter fixedDayCount, Schedule floatingSchedule, IborIndex iborIndex, IEnumerable<double> gearing, IEnumerable<double> spread, DayCounter? floatingDayCount, EvaluationContext context, bool intermediateCapitalExchange = false, bool finalCapitalExchange = false, BusinessDayConvention? paymentConvention = null, int paymentLag = 0, Calendar? paymentCalendar = null)
Parameters
typeSwapTypeA payer swap pays the fixed leg; a receiver swap receives it.
fixedNominalIEnumerable<double>The fixed leg's nominals, one per coupon.
floatingNominalIEnumerable<double>The floating leg's nominals, one per coupon.
fixedScheduleScheduleThe fixed leg's schedule.
fixedRateIEnumerable<double>The fixed rates, one per coupon.
fixedDayCountDayCounterThe fixed leg's day counter.
floatingScheduleScheduleThe floating leg's schedule.
iborIndexIborIndexThe floating leg's index; an overnight index builds compounded overnight coupons.
gearingIEnumerable<double>The floating coupons' gearings, one per coupon.
spreadIEnumerable<double>The floating coupons' spreads, one per coupon.
floatingDayCountDayCounterThe floating leg's day counter; the index's when null, QuantLib's empty day counter.
contextEvaluationContextThe evaluation context, whose at-par switch the Ibor leg reads.
intermediateCapitalExchangeboolWhether the nominals' changes are exchanged.
finalCapitalExchangeboolWhether the final nominals are exchanged.
paymentConventionBusinessDayConvention?The payment convention; the floating schedule's when null.
paymentLagintThe payment lag, in business days.
paymentCalendarCalendarThe payment calendar; each leg's schedule's when null, QuantLib's empty calendar.
Exceptions
- ArgumentNullException
A sequence, a schedule, a day counter but the floating one, the index or the context is null.
- ArgumentOutOfRangeException
The type or the payment convention isn't a member of its type.
- ArgumentException
A sequence's size doesn't match its leg's coupons.
NonstandardSwap(SwapType, IEnumerable<double>, IEnumerable<double>, Schedule, IEnumerable<double>, DayCounter, Schedule, IborIndex, double, double, DayCounter?, EvaluationContext, bool, bool, BusinessDayConvention?, int, Calendar?)
Initializes a new instance of the NonstandardSwap class with one gearing and one spread.
public NonstandardSwap(SwapType type, IEnumerable<double> fixedNominal, IEnumerable<double> floatingNominal, Schedule fixedSchedule, IEnumerable<double> fixedRate, DayCounter fixedDayCount, Schedule floatingSchedule, IborIndex iborIndex, double gearing, double spread, DayCounter? floatingDayCount, EvaluationContext context, bool intermediateCapitalExchange = false, bool finalCapitalExchange = false, BusinessDayConvention? paymentConvention = null, int paymentLag = 0, Calendar? paymentCalendar = null)
Parameters
typeSwapTypeA payer swap pays the fixed leg; a receiver swap receives it.
fixedNominalIEnumerable<double>The fixed leg's nominals, one per coupon.
floatingNominalIEnumerable<double>The floating leg's nominals, one per coupon.
fixedScheduleScheduleThe fixed leg's schedule.
fixedRateIEnumerable<double>The fixed rates, one per coupon.
fixedDayCountDayCounterThe fixed leg's day counter.
floatingScheduleScheduleThe floating leg's schedule.
iborIndexIborIndexThe floating leg's index; an overnight index builds compounded overnight coupons.
gearingdoubleThe floating coupons' gearing.
spreaddoubleThe floating coupons' spread.
floatingDayCountDayCounterThe floating leg's day counter; the index's when null, QuantLib's empty day counter.
contextEvaluationContextThe evaluation context, whose at-par switch the Ibor leg reads.
intermediateCapitalExchangeboolWhether the nominals' changes are exchanged.
finalCapitalExchangeboolWhether the final nominals are exchanged.
paymentConventionBusinessDayConvention?The payment convention; the floating schedule's when null.
paymentLagintThe payment lag, in business days.
paymentCalendarCalendarThe payment calendar; each leg's schedule's when null, QuantLib's empty calendar.
Exceptions
- ArgumentNullException
A sequence, a schedule, a day counter but the floating one, the index or the context is null.
- ArgumentOutOfRangeException
The type or the payment convention isn't a member of its type.
- ArgumentException
A sequence's size doesn't match its leg's coupons.
Properties
FixedDayCount
Gets the fixed leg's day counter.
public DayCounter FixedDayCount { get; }
Property Value
FixedLeg
Gets the fixed leg.
public ImmutableArray<CashFlow> FixedLeg { get; }
Property Value
FixedNominal
Gets the fixed leg's nominals, one per cash flow, a redemption's beside it.
public ImmutableArray<double> FixedNominal { get; }
Property Value
FixedRate
Gets the fixed rates, one per cash flow, a redemption's 0.
public ImmutableArray<double> FixedRate { get; }
Property Value
FixedSchedule
Gets the fixed leg's schedule.
public Schedule FixedSchedule { get; }
Property Value
FloatingDayCount
Gets the floating leg's day counter; null for the index's.
public DayCounter? FloatingDayCount { get; }
Property Value
FloatingLeg
Gets the floating leg.
public ImmutableArray<CashFlow> FloatingLeg { get; }
Property Value
FloatingNominal
Gets the floating leg's nominals, one per cash flow, a redemption's beside it.
public ImmutableArray<double> FloatingNominal { get; }
Property Value
FloatingSchedule
Gets the floating leg's schedule.
public Schedule FloatingSchedule { get; }
Property Value
Gearings
Gets the floating coupons' gearings, a zero one as machine epsilon.
public ImmutableArray<double> Gearings { get; }
Property Value
IborIndex
Gets the floating leg's index.
public IborIndex IborIndex { get; }
Property Value
PaymentCalendar
Gets the payment calendar; null for each leg's schedule's.
public Calendar? PaymentCalendar { get; }
Property Value
PaymentConvention
Gets the payment convention.
public BusinessDayConvention PaymentConvention { get; }
Property Value
PaymentLag
Gets the payment lag, in business days.
public int PaymentLag { get; }
Property Value
Spreads
Gets the floating coupons' spreads.
public ImmutableArray<double> Spreads { get; }
Property Value
Type
Gets the swap's type: a payer swap pays the fixed leg.
public SwapType Type { get; }
Property Value
Methods
Gearing()
The floating coupons' gearing, when one was given.
public double Gearing()
Returns
- double
The gearing.
Exceptions
- NanoQLException
A gearing per coupon was given.
Spread()
The floating coupons' spread, when one was given.
public double Spread()
Returns
- double
The spread.
Exceptions
- NanoQLException
A spread per coupon was given.