Module products
Expand description
Product construction: turning a template and a few trade terms into an instrument, and saying what market data it will need.
This is the assembly layer. It reaches into every layer below — schedules and conventions from the reference data, legs from the cashflow layer, instruments from theirs — which is why it ports last rather than first.
It takes no scalar type parameter, and that is the point. The reference library’s equivalent held 59 active-scalar references at 7.7k lines, which is why the original plan filed it with the passive layers and had to be corrected. Every one of those references was a contract term — a notional, a rate, a spread — and contract terms are passive here, so the layer that assembles them is passive too. A builder that had to know the pricing mode would mean the trade knew it.
What a product needs from the market is derived from the product, not
declared alongside it: market_data_needs asks the assembled instrument.
Two statements of the same fact would eventually disagree, and the one that
resolves the curves is the one that matters.
Structs§
- IrsIndex
Entry 🔒 - One irs-group template’s floating index, with the code to rebuild it.
- Product
Builder - Assembles one product from its terms.
- Schedule
Conventions - The schedule conventions a leg is generated under.
- Side
Parse Error - A spelling that is not a swap side.
- Swap
Conventions 🔒 - The conventions one swap template supplies to a
ProductBuilder. - Tenor
Dating 🔒 - What a forward tenor is read against: the trade date, and the template’s spot rule — its calendar, spot lag and business-day convention.
- Termination
Parse Error - Why a spelling is neither a date nor a forward tenor.
- Window
Terms 🔒 - What a one-period window swap is built from, read off either overnight template: the meeting template and the plain OIS template differ in what they know about a window’s identity, not in how the swap over it is built.
Enums§
- Future
Contract - Which listed contract a futures rung is quoted on.
- FxSwap
Quote - How an FX-swap pillar is quoted: the far outright, or forward points over the spot, both in the pair’s quoting units (collateral per one foreign).
- Locator
- Where a quote sits on its curve, in the spellings a quote sheet uses: a
tenor (
4Y), a date (2027-03-18), a contract code (SEP27), or a window of two dates or two codes (2026-10-29 - 2026-12-10,SEP27 - DEC27, also spelled with..). The sheet binder and the helpers dispatch on its shape. - Meeting
Locator - Which window a meeting-dated swap covers.
- NdfError
- Why a non-deliverable forward could not be drafted from a template.
- NdoError
- Why a non-deliverable option could not be drafted from a template.
- NdsError
- Why a non-deliverable swap could not be drafted from a template.
- Product
Family - Which product a builder is assembling.
- Rung
Build Error - Why a basis ladder could not be built from a template.
- Side
- Which side of a swap draft the fixed leg is on: a payer pays fixed and
receives floating, a receiver the reverse. The word the desk uses, and
the word the Python draft’s
with_sidetakes. - Swap
Legs Error - Why two legs do not make a fixed-versus-floating swap.
- Termination
- Where a swap draft ends: a stated date, or a forward tenor such as
5Yor2Y2Yread from the draft’s trade date and its template’s spot, exactly asswap_dates_from_tenorreads one. - Window
End - One end of a window locator: a date, or a quarterly IMM contract code standing for its third Wednesday.
Traits§
- Swap
Template Arg - A swap template as
par_rungstakes it: a registry code, or a(code, &template)value, registered or customised,codethe name a refusal calls it by. - Xccy
Template Arg - A cross-currency template as
cross_currency_rungstakes it: a registry code, or a template value, registered or customised.
Functions§
- check_
outright 🔒 - An FX rung’s outright, refused where it cannot be one: not finite and
positive; more than three times spot or under a third of it — forward
points, or a quote in other units; or more than 10% from spot and nearer
1/spotthan spot — the pair quoted the other way round. A curve solved on either is nonsense, and both are unmistakable against spot, so the rung is refused before anything is solved. - cross_
currency_ rungs - The spread rungs of a collateral ladder, built from a basis-swap template —
what a recipe’s
Basissegment declares, given its quotes. - cross_
currency_ 🔒rungs_ resolved cross_currency_rungsonce its template is resolved.- deposit_
rung - The par rung of a money-market deposit on a deposit template value: lent
on
valuation, maturingtenoron under the template’s calendar and convention, on the template’s day count, quoted atrate. Noded at the maturity, which is where a deposit pays, and labelled by its tenor. - fixings_
needed_ 🔒of - fra_
rung - The par rung of a forward-rate agreement on a FRA template value: the
accrual starts
startafter the index’s spot date and runs one index period, fixing on the index’s lag, quoted atrate. Noded at the accrual end and labelled<start>x<end>in months (3x6) where both are whole months, else by its start tenor. - future_
rung - The par rung of a listed rate future on a future template value, quoted at
its price (
95.90): the rung’s quote is the futures rate(100 − price)/100, so the ladder’s residual is rate-scaled like its neighbours, and the instrument carriesconvexityas its adjustment — the curve fits the futures rate less the adjustment. Zero is a statement that future and forward coincide, not a neutral default. Noded at the contract’s accrual end and labelled by the contract. - fx_
settlement_ 🔒fixings - A cash-settled FX forward’s or option’s settlement fixing, every key of it, once the fixing date has passed — the line the pricer reads it at.
- fx_
swap_ rung - The par rung of an FX swap on an FX-swap template value: the near leg on
the valuation date at
spot— where both discount factors are one, so the near exchange is worth exactly zero whatever the two curves — and the far leg ontenoradvanced from the pair’s spot date (two business days on the template’s calendar) under its convention, at the quoted outright. The foreign leg’s collateral is the foreign currency under the template’s collateral currency, so the rung solvesdiscount(<foreign>-CSA-<coll>); its quote is the outright, which the swap’s fair far rate verifies, and its residual is covered interest parity on the far date anchored at the valuation date —FxImplied’s reading from the same spot and outrights. - irs_
index 🔒 - The irs-group templates indexed by the floating index each references, built once per process. The registry is static, so this cannot go stale; a lookup is a scan over a dozen entries comparing names, and exactly one template is then constructed — the one asked for — rather than every template in the group until one matches.
- market_
data_ needs - What an assembled product will need from the market.
- meeting_
overnight_ swap - A meeting-dated overnight swap: one fixed coupon on the template’s fixed
day count against one compounded overnight coupon over the window
locatorresolves to, both paid the template’s payment lag after the window end (two business days for USD, as its OIS pays). It is anOvernightIndexedSwap— the product the family already prices, quotes and risks — over a single meeting-to-meeting period. - meeting_
rung - The par rung of a meeting-dated swap: the swap
locatorresolves to atrate, noded at the window’s end — where its accrual ends, not where it pays: the knot is the decision — its pillar carrying the deciding meeting’s identity where the window starts on one, and labelled by bank and meeting date (FED 2026-12-09). - meeting_
window - The window a locator names on a meeting-OIS template, resolved against
schedule— the bank’s seeded schedule where none is given — as(start, end, meeting):Window { start, end }as given, stamped with the decision whose effective datestartis where the schedule has one;Ordinal(n)from the effective date of the n-th decision strictly aftervaluationto the effective date of the next;Meeting(decision)from that decision’s effective date to the next’s. - ndf_
fixing_ source - The fixing an NDF row settles on: the pair’s canonical key, settlement
currency first (
FX-USDKRW,FX-EURXOF); on a cross-currency row, the cross of the reference currency’s key against USD and the settlement currency’s (FX-USDKRW×FX-EURUSD). - ndf_
rung - The par rung of an NDF on an NDF template value: an FX swap whose far leg
is the cash-settled forward
AnyTemplate::ndfdrafts at the quoted outright — spot, value and fixing dates from the template’s own calendars and lag — turned to quote the reference currency as base, and whose near leg is the physical opposite on the valuation date atspot, where both discount factors are one, asfx_swap_rung’s is. The rung’s quote is the swap’s own far rate, settlement units per reference unit: the reciprocal of the sheet’s outright. The reference currency’s leg discounts under the settlement currency’s collateral, so the rung solvesdiscount(<ref>-CSA-<settle>): the NDF-implied curve. Before its fixing a cash-settled forward values as the physical one, so the residual is covered interest parity at the value date, and the swap’s fair far rate verifies the quote. Quoted, as the template is, in reference units per settlement unit (KRW per USD). - nds_
rung - The par rung of an NDS on an NDS template value: the swap
AnyTemplate::ndsdrafts atpar_rate, receiving fixed, noded at its last payment. It discounts in the settlement currency and reads the local currency’s curve under that collateral for its conversions, so it solvesdiscount(<ref>-CSA-<settle>)past the forward market’s reach, against the floating index’s projection the market already holds. - nds_
settlement 🔒 - What an NDS row settles in, the fixing it converts at, and the local swap
a
tenortrade draws on: the source’s own, or — under a settlement override — the cross through USD into it, the swap paying on its settlement centre’s days too. - non_
deliverable_ 🔒fixings - A non-deliverable leg reads its FX fixing for every payment still to be valued once the fixing date has passed — the NDF’s rule.
- not_
family 🔒 - par_
rungs - The par rungs of a single-currency swap ladder, built from a swap template
— the sibling of
cross_currency_rungsfor the commonest curve there is. - par_
rungs_ 🔒resolved par_rungsonce its template is resolved.- payment_
rule 🔒 - A lag, a convention and a calendar as one payment rule.
- still_
valued 🔒 - Whether a valuation on
valuationstill valuescouponofleg, and so still reads its resets. A non-summing leg pays once: every coupon counts until that payment and none after (Leg::npv). A summing leg skips a coupon paid on or before the valuation date (Leg::walk). - swap_
builder_ on_ index - A
ProductBuilderpre-loaded with the registered conventions forindex’s standard single-currency swap — calendar, frequency, roll, business-day convention, day counts, and payment lag all come from the template registry, restated nowhere. - swap_
builder_ on_ overnight_ template - A swap builder from a named template, for the markets where an index alone does not determine the swap.
- swap_
builder_ on_ template - The currency and the floating day count come from the template’s own
index, not from a second registry lookup.
template_index_matches_the_registry_indexpins that this is the same index the code-keyed path resolved, so routing through here changes no number. - swap_
builder_ on_ tenor - A swap on a template value from a forward tenor:
swap_dates_from_tenorthenswap_builder_on_template. - swap_
dates_ from_ tenor - A
ProductBuilderpre-loaded with the conventions of a resolved swap template value, rather than of a template named by code. - swap_
from_ legs - A fixed-versus-floating swap from two compiled legs.
- swap_
index_ code - The registered index code a swap template’s floating leg projects on, or
Nonefor a template that is not a swap. - tenor_
basis_ rung - The spread rung of a tenor basis swap on a tenor-basis template value: the
swap from spot — the term leg’s fixing lag where a leg is a term index, two
business days otherwise — to
tenoron, carryingspreadon its spread leg, noded at its final payment and labelled by tenor. - turn_
rung - The par rung of a turn-of-period window
[start, end]on a meeting-OIS template, quoted at the simple forward over the window — the surrounding level plus the jump, as a desk states a year-end turn — noded atendand carryingKnotKind::Turn(start); labelledturn <start>. A turn is a window, not an instant: the curve needs a pillar atstarttoo, which a meeting rung or a plain window rung ending there supplies. - window_
rung - The par rung of a one-period forward swap over
[start, end]on an OIS template — the IMM-dated forward a vendor sheet quotes asSEP27 - DEC27, or any forward-starting window — built as the meeting-dated swap is, with the template’s payment lag, noded at the window end, labelled<start>..<end>, carrying no knot. A window on a meeting template ismeeting_rung. - window_
swap 🔒 - The single-period swap over
[start, end]on an overnight template’s terms: one fixed coupon against one compounded overnight coupon, both paid the template’s lag after the window end.