Module store
Expand description
The stored market, the lift that turns it into a mode view, and the risk read-back that comes off the lift.
§A market is lifted, never armed
MarketContext is passive, immutable, shareable data — term structures,
vol surfaces, observations and model marks, four families by shape, all
holding f64. Nothing in it knows about a tape.
Taking risk against it is MarketContext::lift — one flat vector of the mode’s
scalars, registered once, handed to a MarketView that borrows both
the vector and the storage.
That replaces arming. There is no second registry of duplicated market objects, no lock guarding one, no per-curve deep copy, and nothing to de-arm afterwards: the handles live in the vector the caller owns, so dropping the view is the whole of the cleanup and the stored market was never touched. Two threads may lift the same market at the same time, because neither writes to it.
§One vector, one order
The lift lays every free parameter of every stored input end to end, in a
fixed order the market itself defines. A Span records where each input’s
parameters begin and how many there are, and the read-back walks the same
spans to label each adjoint. One walk, so a risk row cannot be labelled with
a pillar the lift installed somewhere else.
§The pass
risk_with is the twelve lines the design asked for: one forward
pass, one seed, one reverse sweep, one collection. It takes the tape by
reference so a caller valuing repeatedly reuses one allocation.
Structs§
- Build
Record 🔒 - How the market was, or would be, built. Addressed by the keys the pricing seam declares, and contributing no lifted parameter: never read by the lift, never compared.
- Credit
Entry 🔒 - An entity’s credit data as the market stores it.
- Degenerate
Hub - A triangulated discount declared through a hub that is one of its key’s own currencies, which collapses the triangle onto the key itself.
- IdStore 🔒
- A family’s inputs sorted by identity.
- Lifted
Market - A market’s parameters lifted into one mode, with the layout that labels them.
- Market
Context - The stored market: passive, immutable, shareable.
- Market
State 🔒 - The stored state a lift reads, as four families by shape — what the machinery branches on, not the asset class, which stays a label derived from each input’s risk axis. The walk is the families in this order, each family in its identity’s own order.
- Market
View - A
MarketContextresolved at one mode. - Observations 🔒
- The observed inputs: facts already printed, with no identity to key a map by and nothing to calibrate. A struct of two fields rather than a map, so each yields its span unconditionally.
- Pinned
Curve - A curve on its way into a market, together with whatever it knows about how it was built.
- Pinned
Inflation - An inflation curve on its way into a market, with whatever ladder it
carries — the third pin, shaped like
PinnedCurveandPinnedSurvival. - Pinned
Survival - A survival curve on its way into a market, with whatever ladder it carries —
the credit twin of
PinnedCurve, so aCalibratedSurvivalpins the way aCalibrateddoes and a bare curve pins with no ladder. - Provenance
Mismatch - A ladder attached to a curve it does not describe.
- Reference
Date Mismatch - A curve was bound to a market that is as of another date.
- Snapshot 🔒
- One date’s snapshot, set aside while the market is at another date: the state as of that date (its fixings excepted, which live in the history), the ladders and refits behind its curves, its misdated record, and the data it was fetched from.
- Span 🔒
- Where one input’s parameters sit in the lifted vector.
Enums§
- Curve
IdRef 🔒 - A curve key by reference — what a lookup compares against, so resolving a trade owns no string to name a curve the instrument already names.
- Diagnostics
- What a product’s valuation resolved to on a market, one variant per product that states it: the inputs and parts its value is built from.
- Input 🔒
- One stored input as the lift reads it, with the key it is stored under.
- InputId 🔒
- The input a span of the lifted vector came from: the family identity itself, owned by the span, plus the one span a family contributes beside its identity — a survival term’s recovery.
- Mark 🔒
- One model mark as the store holds it: the payload a
MarkIdmaps to. A mark is a parameter someone chose rather than a curve calibrated from instruments or a fact already printed — a correlation, a floor, a degree of freedom, a watched scalar — and the identity decides its shape: a base correlation is a curve over detachments, a CMS spread correlation a flat mark or a term structure, a copula’s degrees of freedom a pair, the rest one number. - Mark
IdRef 🔒 - A mark identity by reference, for the same reason. Variants in
MarkId’s order. - Projection
Key - What a projection curve may be keyed under.
- Sigma
Pin - The volatility
MarketContext::with_hull_whitepins: one flat value, or dated pieces(interval end, σ), the last extending flat beyond its date. - Source
Ref 🔒 - An input identity by reference — what a lookup on the resolution path compares a span against, so resolving a trade owns no key.
- Term 🔒
- One term structure as the store holds it: the payload a
CurveIdmaps to. The identity’s role decides the arm — the four rate roles a rate curve,Credita survival curve with its stated recovery,Inflationan inflation curve — which is what lets the three former stores be one map in the identity’s one order. - VolSurface 🔒
- One vol surface as the store holds it: the payload a
VolSurfaceIdmaps to. The threeRateVolSurfaceregistries — swaption, cap, bond yield — share one arm and are told apart by the identity alone, which is what lets the seven former stores be one map. - VolSurface
IdRef 🔒 - A vol surface identity by reference — what a lookup on the resolution
path compares against, so resolving a trade owns no string to name a
surface the instrument already names. Variants in
VolSurfaceId’s order, so the two compare alike.
Functions§
- at_
the_ 🔒money - cms_
spread_ 🔒correlation_ labels - A CMS spread correlation’s parameter labels: one keyed by the pair alone for a flat mark, one per pillar for a term structure, one per (expiry, strike) node for a surface.
- copula_
dof_ 🔒labels - A credit index’s double-t degrees-of-freedom labels: the factor’s, then each name’s, in the order the pair lifts.
- curve_
date 🔒 - The date a rate curve is a curve as of — what a bind checks it against.
- declared_
needs 🔒 - The curves a declaration cannot be valued without, as their keys: every curve it names except a repo basket’s, whose missing tiers fall back to the discount curve by design.
- extend_
family 🔒 - Appends
family’s parameters tooutinparameter_ownersorder — the orderview_withconsumes them — flattening a composition through the owner visit so a market of leaves fills one vector, not one per curve. - family_
labels 🔒 family’s parameter labels as risk-vector keys underid.- family_
refusal 🔒 family’s refusal, if any, named by the ididbuilds — built only on refusal, so the common case owns no string.- from_
labels 🔒 - One curve’s labels turned into risk-vector keys under
id. - inflation_
date 🔒 - The date an inflation curve is a curve as of.
- inflation_
vol_ 🔒labels - One inflation vol surface’s node labels, in parameter order: YoY nodes or, for a zero-coupon CPI surface, CPI nodes.
- mark_
labels 🔒 - A mark’s parameter labels, under the identity it is stored by.
- npv
- The value of one book against
market, with no derivatives taken. - on_axis 🔒
- A registry whose reader names one kind of strike coordinate takes a smile quoted on that axis and no other. A swaption knows its forward and so reads spreads; a cap knows only its strike.
- positive_
semidefinite 🔒 - Whether a symmetric matrix is positive semi-definite, by an
LDLᵀwalk that allows a zero pivot only on a zero remainder. - refuse_
spread 🔒 - Refuses a repo spread pinned as a rate curve: it is pinned over its base
with
with_repo_spread, and read alone it discounts off the spread. - risk_
with - The risk pass. One forward pass, one seed, one reverse sweep, one collection.
- sabr_
labels 🔒 - A SABR surface’s node labels under
registryandcurrency. - smile_
store 🔒 - A registry whose read names no rate strike takes a surface quoted at the money; a smile there would silently price off one of its columns. A rate smile as the store holds it.
- survival_
date 🔒 - The date a survival curve is a curve as of.
- vol_
labels 🔒 - A vol surface’s node labels, under the identity it is stored by: the
identity, not the payload, decides which node key a
RateVolSurfacereports, because three registries share that one grid type.
Type Aliases§
- Term
Store 🔒 - Every term structure in one store, sorted by curve identity.