Table of Contents

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

fromVanilla FixedVsFloatingSwap

The swap: a vanilla or an overnight-indexed swap.

context EvaluationContext

The 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

type SwapType

A payer swap pays the fixed leg; a receiver swap receives it.

fixedNominal IEnumerable<double>

The fixed leg's nominals, one per coupon.

floatingNominal IEnumerable<double>

The floating leg's nominals, one per coupon.

fixedSchedule Schedule

The fixed leg's schedule.

fixedRate IEnumerable<double>

The fixed rates, one per coupon.

fixedDayCount DayCounter

The fixed leg's day counter.

floatingSchedule Schedule

The floating leg's schedule.

iborIndex IborIndex

The floating leg's index; an overnight index builds compounded overnight coupons.

gearing IEnumerable<double>

The floating coupons' gearings, one per coupon.

spread IEnumerable<double>

The floating coupons' spreads, one per coupon.

floatingDayCount DayCounter

The floating leg's day counter; the index's when null, QuantLib's empty day counter.

context EvaluationContext

The evaluation context, whose at-par switch the Ibor leg reads.

intermediateCapitalExchange bool

Whether the nominals' changes are exchanged.

finalCapitalExchange bool

Whether the final nominals are exchanged.

paymentConvention BusinessDayConvention?

The payment convention; the floating schedule's when null.

paymentLag int

The payment lag, in business days.

paymentCalendar Calendar

The 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

type SwapType

A payer swap pays the fixed leg; a receiver swap receives it.

fixedNominal IEnumerable<double>

The fixed leg's nominals, one per coupon.

floatingNominal IEnumerable<double>

The floating leg's nominals, one per coupon.

fixedSchedule Schedule

The fixed leg's schedule.

fixedRate IEnumerable<double>

The fixed rates, one per coupon.

fixedDayCount DayCounter

The fixed leg's day counter.

floatingSchedule Schedule

The floating leg's schedule.

iborIndex IborIndex

The floating leg's index; an overnight index builds compounded overnight coupons.

gearing double

The floating coupons' gearing.

spread double

The floating coupons' spread.

floatingDayCount DayCounter

The floating leg's day counter; the index's when null, QuantLib's empty day counter.

context EvaluationContext

The evaluation context, whose at-par switch the Ibor leg reads.

intermediateCapitalExchange bool

Whether the nominals' changes are exchanged.

finalCapitalExchange bool

Whether the final nominals are exchanged.

paymentConvention BusinessDayConvention?

The payment convention; the floating schedule's when null.

paymentLag int

The payment lag, in business days.

paymentCalendar Calendar

The 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

DayCounter

FixedLeg

Gets the fixed leg.

public ImmutableArray<CashFlow> FixedLeg { get; }

Property Value

ImmutableArray<CashFlow>

FixedNominal

Gets the fixed leg's nominals, one per cash flow, a redemption's beside it.

public ImmutableArray<double> FixedNominal { get; }

Property Value

ImmutableArray<double>

FixedRate

Gets the fixed rates, one per cash flow, a redemption's 0.

public ImmutableArray<double> FixedRate { get; }

Property Value

ImmutableArray<double>

FixedSchedule

Gets the fixed leg's schedule.

public Schedule FixedSchedule { get; }

Property Value

Schedule

FloatingDayCount

Gets the floating leg's day counter; null for the index's.

public DayCounter? FloatingDayCount { get; }

Property Value

DayCounter

FloatingLeg

Gets the floating leg.

public ImmutableArray<CashFlow> FloatingLeg { get; }

Property Value

ImmutableArray<CashFlow>

FloatingNominal

Gets the floating leg's nominals, one per cash flow, a redemption's beside it.

public ImmutableArray<double> FloatingNominal { get; }

Property Value

ImmutableArray<double>

FloatingSchedule

Gets the floating leg's schedule.

public Schedule FloatingSchedule { get; }

Property Value

Schedule

Gearings

Gets the floating coupons' gearings, a zero one as machine epsilon.

public ImmutableArray<double> Gearings { get; }

Property Value

ImmutableArray<double>

IborIndex

Gets the floating leg's index.

public IborIndex IborIndex { get; }

Property Value

IborIndex

PaymentCalendar

Gets the payment calendar; null for each leg's schedule's.

public Calendar? PaymentCalendar { get; }

Property Value

Calendar

PaymentConvention

Gets the payment convention.

public BusinessDayConvention PaymentConvention { get; }

Property Value

BusinessDayConvention

PaymentLag

Gets the payment lag, in business days.

public int PaymentLag { get; }

Property Value

int

Spreads

Gets the floating coupons' spreads.

public ImmutableArray<double> Spreads { get; }

Property Value

ImmutableArray<double>

Type

Gets the swap's type: a payer swap pays the fixed leg.

public SwapType Type { get; }

Property Value

SwapType

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.