Skip to main content

Module legs

Module legs 

Expand description

The leg and coupon layer, crossed.

A leg is the finest thing this library values. Below an instrument and above a cashflow, it is what a desk actually reasons about — the fixed side is worth this, the floating side that — and until now a Python caller could read one after the fact through Instrument.cashflow_records and compose none.

Two rules shape everything here.

  • The leg a caller composes is the leg the instrument prices. Not a parallel implementation that agrees to a tolerance: the same Leg::npv, over the same resolved view, through the same record writer. A second valuation path that nearly agrees is worse than no leg surface, because it invites risk to be built on it.
  • The closed coupon set stays closed. AnyCoupon holds four kinds and this module carries one constructor for each, no more and no fewer. A caller cannot introduce a fifth, and a fifth added to the core fails the census in every_variant_of_the_closed_set_reaches_python rather than being silently absent here.

A leg carries no discount curve of its own — an instrument’s collateral is the instrument’s — so the class takes the discount key at construction and declares it the way every product does. The projection index is read off the coupons, because they are the things that name one.

Structs§

PyAnyCoupon 🔒
One coupon of the closed set.
PyLeg 🔒
A compiled leg: coupons in payment order, the side they are on, and the discount key they are valued under.
SpreadCorrelationArg 🔒
Where a CMS spread’s correlation comes from, as a Python caller names it: a number, the contract’s correlation, or "Market", the market’s mark for the coupon’s pair of swap indices — Rust’s CmsSpreadCorrelation.

Enums§

PyAccrualCompounding 🔒
How an overnight leg accumulates its prints over a period: Simple (averaged), Compounded, or Continuous.
PyDirection 🔒
Which side of a leg the holder is on: Receive or Pay.
PyResetCompounding 🔒
How a multi-reset coupon combines its resets into one payment: the ISDA 2006 methods Straight, Flat and SpreadExclusive, or Averaged.
StripNotional 🔒
A strip’s notional: one for every period, or one per period in schedule order — an amortising leg.
StubArg 🔒
How a multi-reset coupon’s final short sub-period reads the index: a name ("index_tenor", "own_accrual") or the (shorter, longer) pair of registered term indices an ISDA 2006 §8.3 interpolated stub blends.
WindowArg 🔒
The window an IBOR coupon’s rate spans: explicit dates, or a name the registered index resolves ("value_dates").

Functions§

__pyfunction_accumulated_fixed_leg 🔒 ⚠
__pyfunction_accumulated_float_leg 🔒 ⚠
__pyfunction_cms_coupon 🔒 ⚠
__pyfunction_cms_leg 🔒 ⚠
__pyfunction_cms_spread_coupon 🔒 ⚠
__pyfunction_cms_spread_leg 🔒 ⚠
__pyfunction_cpi_coupon 🔒 ⚠
__pyfunction_cpi_leg 🔒 ⚠
__pyfunction_cpi_redemption 🔒 ⚠
__pyfunction_fixed_rate_coupon 🔒 ⚠
__pyfunction_fixed_rate_leg 🔒 ⚠
__pyfunction_ibor_coupon 🔒 ⚠
__pyfunction_ibor_leg 🔒 ⚠
__pyfunction_multi_reset_coupon 🔒 ⚠
__pyfunction_multi_reset_leg 🔒 ⚠
__pyfunction_overnight_coupon 🔒 ⚠
__pyfunction_overnight_leg 🔒 ⚠
__pyfunction_range_accrual_coupon 🔒 ⚠
__pyfunction_range_accrual_leg 🔒 ⚠
__pyfunction_redemption 🔒 ⚠
__pyfunction_yoy_inflation_coupon 🔒 ⚠
__pyfunction_yoy_inflation_leg 🔒 ⚠
accumulated_fixed_leg 🔒
The fixed side of a zero-coupon swap: one coupon carrying fixed_rate over [effective, maturity], accruing under accrual_compounding into a single payment at maturity.
accumulated_float_leg 🔒
The floating side of a zero-coupon swap: coupons’ rates compounding period by period into a single payment at pays.
cms_coupon 🔒
A CMS coupon: notional · τ · (gearing · CMS + spread), the CMS rate of the swap index template at tenor fixing in advance of accrual_start by the index’s fixing lag, convexity-adjusted by linear TSR at mean_reversion and paid on payment_date. A leg holding it declares the currency’s swaption vols; a published print under the swap index’s key settles it.
cms_leg 🔒
A CMS coupon strip over schedule, one coupon per calculation period: cms_coupon per period, as Rust’s cms_leg builds it.
cms_spread_coupon 🔒
A CMS spread coupon: notional · τ · (gearing · (CMS(tenor) − CMS(minus_tenor)) + spread) on the swap index template, both rates fixing in advance and joined by correlation — a number, the contract’s, with no risk row, or "Market", the market’s mark for the pair of swap indices, with one.
cms_spread_leg 🔒
A CMS spread coupon strip over schedule, one coupon per calculation period, as Rust’s cms_spread_leg builds it; correlation as cms_spread_coupon takes it.
cpi_coupon 🔒
One CPI coupon: notional × fixed_rate × accrual fraction × I(end)/base_index, accruing from accrual_start to accrual_end under day_count and paid on payment_date in currency.
cpi_leg 🔒
A CPI coupon strip over schedule, one coupon per calculation period: cpi_coupon per period, computing nothing it does not.
cpi_redemption 🔒
A CPI leg’s indexed notional paid on payment_date: notional × (I/base_index − 1) where only the growth is paid (the default) or notional × I/base_index, I the index observed for observation (the payment date when None) lag_months back (the index’s own lag when None) under its own interpolation. base_date is the date the base level stands for: a collar on the notional (Leg.with_collar) is struck in annualised zero-coupon rates from it, so a floor at 0 is a linker’s deflation floor.
fixed_rate_coupon 🔒
One fixed-rate coupon: notional × fixed_rate × accrual fraction, accruing from accrual_start to accrual_end under day_count and paid on payment_date in currency.
fixed_rate_leg 🔒
A fixed-rate coupon strip over schedule, one coupon per calculation period.
ibor_coupon 🔒
An IBOR-style coupon: one fixing of index per period, geared and spread.
ibor_leg 🔒
An IBOR coupon strip over schedule, one coupon per calculation period.
kind_of 🔒
The variant’s name — the same string the cashflow table’s kind column carries, read off the core rather than spelled again here.
multi_reset_coupon 🔒
A multi-reset coupon: index resets every reset_tenor over the accrual and the resets combine into one payment under compounding — "straight", "flat", "spread_exclusive" (the ISDA 2006 methods) or "averaged".
multi_reset_leg 🔒
A multi-reset coupon strip over schedule, one coupon per calculation period, each resetting every reset_tenor and each final short sub-period reading the index as stub says (see multi_reset_coupon).
overnight_coupon 🔒
A compounded overnight coupon on index, observed over calendar.
overnight_leg 🔒
An overnight coupon strip over schedule, one coupon per calculation period.
payment_dates 🔒
A fixed-rate coupon: notional · rate · tau, paid on payment_date.
projections_of 🔒
The distinct indices a leg’s floating coupons name, in first-seen order: the core’s reading.
range_accrual_coupon 🔒
One range accrual: notional × fixed_rate × accrual fraction × (days in range) / (days), every calendar day from accrual_start to accrual_end observing the fixing of index (a registered term index) on the latest business day on or before it, in range when it lies in [lower, upper] (a bound left None is open).
range_accrual_leg 🔒
A range accrual strip over schedule, one coupon per calculation period: range_accrual_coupon per period, computing nothing it does not.
redemption 🔒
A dated payment of a known amount — a redemption, a fee, a notional exchange. It accrues over nothing and pays no rate.
register 🔒
registered_ibor 🔒
A registered term index by code, or a ValueError naming it.
registered_price 🔒
The registered price index code names, refused by name otherwise.
wrap 🔒
wrap_unvalued 🔒
wrap for a leg handed out for its schedule alone, refusing to be valued for reason.
yoy_inflation_coupon 🔒
One year-on-year inflation coupon: notional × accrual fraction × (gearing × (I(end)/I(start) − 1) + spread), accruing from accrual_start to accrual_end under day_count and paid on payment_date in currency, on a ratio of index levels.
yoy_inflation_leg 🔒
A year-on-year inflation coupon strip over schedule, one coupon per calculation period: yoy_inflation_coupon per period, as Rust’s yoy_inflation_leg builds it.