Module legs
Expand description
Legs: a compiled list of coupons, and how to value one.
A leg is built once and valued many times. Everything a calendar decides —
boundary rolls, payment lags, index windows, daily observation strips — is
resolved when the leg is constructed, so a valuation walks dates and never a
calendar. The stored leg is passive throughout; a mode enters only through
the curves passed to Leg::npv.
There is one leg type, not one per coupon kind. A floating coupon needs a curve to project and a fixed one does not, but with the coupon set closed and projection taking an optional forward curve, that distinction stops being a type and becomes a variant.
A leg does not take a projection curve: it takes a CurveByIndex and
asks it for each coupon’s curve by the index the coupon names. A single
curve serves a single-index leg through OneCurve; a pricing view serves
a leg on any number of declared indices; a leg of fixed coupons takes
NoCurve.
Structs§
- Leg
- A compiled leg: coupons in payment order, the side they are on, how they combine, and — for a non-deliverable leg — how they settle.
- LegTerms
- The terms every leg shares, whatever its coupons pay.
- NoCurve
- No projection curve at all — a leg of fixed coupons, or one whose every reset has already fixed.
- NonDeliverable
- How a leg’s payments settle when they are not paid in the currency they
accrue in: each converted into
settlement— a non-deliverable leg, as an NDS’s two legs and an NDCCS’s reference leg are. - Observation
Conventions - How an overnight coupon observes its index, beyond the plain daily strip:
the RFR conventions FpML states under
calculationParameters(lookback, observation period shift, lockout) and bounds on each daily rate. Every count is in business days of the strip’s calendar; the default is the plain strip. - OneCurve
- One curve for every index — the single-curve source.
- Payment
Rule - How a schedule’s periods become payment dates.
- Unknown
Stub Rule - The name a stub rule is not.
Enums§
- Accumulation
- How a leg’s coupons combine into what the leg is worth.
- Conversion
- How one payment of a non-deliverable leg converts into the settlement currency: at an FX fixing on a date, or at a rate agreed at trade.
- NonDeliverable
Error - Why a leg could not be made non-deliverable.
- Stub
Interpolation Error - Why a leg electing stub interpolation could not be built.
- Stub
Rule - How a term leg’s stubs read the index: over their own accrual period, or by ISDA 2006 §8.3 Linear Interpolation between two named Designated Maturities, as a confirmation elects it.
Constants§
- ROLL_
TOLERANCE_ 🔒DAYS - How far a period’s end may sit from its index maturity and still be a regular period. A business-day roll moves a boundary by a few days — a weekend and a holiday, Easter’s Friday and Monday — where a stub moves it by weeks.
Traits§
- Curve
ByIndex - Projection curves, by the index that names them.
Functions§
- accrued_
fixed_ 🔒leg - accumulated_
fixed_ leg - The fixed side of a zero-coupon swap: one coupon carrying
fixed_rateover[effective, maturity], accruing undercompoundinginto a single payment at maturity. - accumulated_
fixed_ leg_ by_ period accumulated_fixed_legwith its accrual measured period by period: the day count’s year fraction over each unadjustedfrequencyperiod fromeffectivetomaturity, summed. On1/1that counts one per sub-period — FpML’s1/1per calculation period — so an annual five-year leg compounds(1 + K)^5where the one-accrual reading compounds(1 + K)^1.- accumulated_
float_ leg - The floating side of a zero-coupon swap:
coupons’ rates compounding period by period into a single payment atpays. - fixed_
rate_ leg - Builds a fixed-rate leg over
schedule. - ibor_
leg - Builds an IBOR-style floating leg over
schedule. - ibor_
leg_ on_ index - Builds an IBOR-style floating leg over
schedulewhose coupons project as every term coupon does — a regular period over the index’s own window, a stub over its accrual — while each coupon accrues over its schedule period.ibor_legkeeps the accrual-window projection for a leg that names an index by string alone and so carries no tenor. - ibor_
leg_ with_ stubs ibor_leg_on_indexwith a stub rule: regular periods exactly as that builds them, and each stub — a period the index’s own window does not fit — reading the index asrulesays throughIborCoupon::with_stub, the seam the Python strip reads its stubs through too.- icma_
accruals 🔒 period_accrualsunderACT/ACT.ICMA, the one count that needs the schedule’s tenor.- index_
tenor_ 🔒window - The index’s full Designated Maturity window read by a period starting at
start, on its own calendar, convention and end-of-month rule, whatever the period it serves — anchored, like every index window, on the fixing’s value date rather than the raw boundary. - interpolated_
stub - The ISDA 2006 §8.3 interpolation a period on
indexreads betweenshorterandlonger, orNonefor a regular period — one the index’s own window fits, which reads the index alone. - is_
exchange 🔒 - Whether
couponis a principal exchange rather than a coupon. - multi_
reset_ leg - A floating leg over
schedulewhose coupons reset everyreset_tenoronindexand pay once per period, the resets combined bymethod— aMultiResetCouponper period, each final sub-period the reset tenor leaves short reading the index asstubsays. - overnight_
leg - Builds an overnight (RFR) floating leg over
schedule, accumulating the daily prints the wayaccumulationsays. - overnight_
leg_ with overnight_legobserving its index underconventions: a lookback, an observation shift, a rate cut-off, and bounds on each daily rate.- overnight_
observations - One observation per business day in
[start, end), each spanning to the next business day and capped atendso the strip accrues exactly the period and telescopes toDF(start)/DF(end)when fully projected. - par_
fixing_ window - The window a term coupon on
index, accruing fromstarttoaccrual_end, projects its rate over — the one rule every term-coupon builder applies, so a cap, a note and a swap on the same dates read the same forward. - period_
accruals 🔒 - Each period’s accrual under
day_count.ACT/ACT.ICMAneeds a reference period, which a bare pair of dates does not carry, so it is taken from the schedule’s tenor: the tenor here is the regular period the schedule’s own periods round to most often, and a short first period is measured against the tenor ending on its end, a short last one against the tenor starting on its start. Regular periods are the tenor’s share of a year either way; a long stub keeps the two-date reading. - term_
fixing_ 🔒window - yoy_
inflation_ leg - Builds a year-on-year inflation leg over
schedule: oneYoyInflationCouponper period onindex, each observing its own start and end atlag_months, payinggearing · YoY + spread.
Type Aliases§
- LegWalk 🔒
- What one pass over a leg’s future coupons produces: projected amounts, the discount factor at each payment, and — when asked for — each coupon’s basis-point weight. The two vectors a leg-level measure fuses over.