BaseLeg#

class rateslib.legs.BaseLeg(effective, termination, frequency, *, stub=NoInput.blank, front_stub=NoInput.blank, back_stub=NoInput.blank, roll=NoInput.blank, eom=NoInput.blank, modifier=NoInput.blank, calendar=NoInput.blank, payment_lag=NoInput.blank, notional=NoInput.blank, currency=NoInput.blank, amortization=NoInput.blank, convention=NoInput.blank, payment_lag_exchange=NoInput.blank, initial_exchange=False, final_exchange=False)#

Bases: object

Abstract base class with common parameters for all Leg subclasses.

Parameters:
  • effective (datetime) – The adjusted or unadjusted effective date.

  • termination (datetime or str) – The adjusted or unadjusted termination date. If a string, then a tenor must be given expressed in days (“D”), months (“M”) or years (“Y”), e.g. “48M”.

  • frequency (str in {"M", "B", "Q", "T", "S", "A", "Z"}, optional) – The frequency of the schedule.

  • stub (str combining {"SHORT", "LONG"} with {"FRONT", "BACK"}, optional) – The stub type to enact on the swap. Can provide two types, for example “SHORTFRONTLONGBACK”.

  • front_stub (datetime, optional) – An adjusted or unadjusted date for the first stub period.

  • back_stub (datetime, optional) – An adjusted or unadjusted date for the back stub period. See notes for combining stub, front_stub and back_stub and any automatic stub inference.

  • roll (int in [1, 31] or str in {"eom", "imm", "som"}, optional) – The roll day of the schedule. Inferred if not given.

  • eom (bool, optional) – Use an end of month preference rather than regular rolls for inference. Set by default. Not required if roll is specified.

  • modifier (str, optional) – The modification rule, in {“F”, “MF”, “P”, “MP”}

  • calendar (calendar or str, optional) – The holiday calendar object to use. If str, looks up named calendar from static data. See get_calendar().

  • payment_lag (int, optional) – The number of business days to lag payments by on regular accrual periods.

  • notional (float, optional) – The leg notional, which is applied to each period.

  • currency (str, optional) – The currency of the leg (3-digit code).

  • amortization (float, optional) – The amount by which to adjust the notional each successive period. Should have sign equal to that of notional if the notional is to reduce towards zero.

  • convention (str, optional) – The day count convention applied to calculations of period accrual dates. See dcf().

  • payment_lag_exchange (int) – The number of business days by which to delay notional exchanges, aligned with the accrual schedule.

  • initial_exchange (bool) – Whether to also include an initial notional exchange.

  • final_exchange (bool) – Whether to also include a final notional exchange and interim amortization notional exchanges.

Notes

See also Schedule for a more thorough description of some of these scheduling arguments.

The (optional) initial cashflow notional is set as the negative of the notional. The payment date is set equal to the accrual start date adjusted by the payment_lag_exchange.

The final cashflow notional is set as the notional. The payment date is set equal to the final accrual date adjusted by payment_lag_exchange.

If amortization is specified an exchanged notional equivalent to the amortization amount is added to the list of periods as interim exchanges if final_exchange is True. Payment dates adhere to the payment_lag_exchange.

Examples

See Leg Examples

schedule#
Type:

Schedule

currency#
Type:

str

convention#
Type:

str

periods#
Type:

list

initial_exchange#
Type:

bool

final_exchange#
Type:

bool

payment_lag_exchange#
Type:

int

See also

FixedLeg

Create a fixed leg composed of FixedPeriod s.

FloatLeg

Create a floating leg composed of FloatPeriod s.

IndexFixedLeg

Create a fixed leg composed of IndexFixedPeriod s.

ZeroFixedLeg

Create a zero coupon leg composed of a FixedPeriod.

ZeroFloatLeg

Create a zero coupon leg composed of a FloatPeriod s.

ZeroIndexLeg

Create a zero coupon leg composed of IndexFixedPeriod.

CustomLeg

Create a leg composed of user specified periods.

Attributes Summary

amortization

notional

Methods Summary

analytic_delta(*args, **kwargs)

Return the analytic delta of the Leg via summing all periods.

cashflows(*args, **kwargs)

Return the properties of the Leg used in calculating cashflows.

npv(*args, **kwargs)

Return the NPV of the Leg via summing all periods.

Attributes Documentation

amortization#
notional#

Methods Documentation

analytic_delta(*args, **kwargs)#

Return the analytic delta of the Leg via summing all periods.

For arguments see BasePeriod.analytic_delta().

cashflows(*args, **kwargs)#

Return the properties of the Leg used in calculating cashflows.

For arguments see BasePeriod.cashflows().

npv(*args, **kwargs)#

Return the NPV of the Leg via summing all periods.

For arguments see BasePeriod.npv().