Skip to main content

Crate helixio_core

Crate helixio_core 

Expand description

Python bindings for helixrs.

This crate marshals and does not calculate. Every number it returns is produced by a helixrs entry point; no pricing, calibration or risk logic originates here. That rule is what makes the Python surface the f64 instantiation of the Rust one rather than a separate library that resembles it โ€” and it is checkable, not aspirational: the tests assert that what Python gets back is bit-identical to what the core produces, which nothing that recomputed on this side would survive.

ยงNo tape, anywhere

Python callers never encounter an AD tape, and there is no way to reach one: a value-only call instantiates the passive mode and activates nothing, and a risk call selects the reverse mode internally and returns numbers.

What that costs the caller is nothing. What it buys is that the mode stops being part of the API, so Python and Rust describe the same library.

Modulesยง

calendars ๐Ÿ”’
The date substrate a Python caller names directly: calendars, schedules, day counts, tenors and the roll families.
fpml ๐Ÿ”’
The FpML reader: a confirmation-view trade document into an instrument, with the cashflows the document itself states kept beside it.
indices ๐Ÿ”’
The index a Python caller names: its conventions, its dates, and its rate.
legs ๐Ÿ”’
The leg and coupon layer, crossed.
measures ๐Ÿ”’
The coreโ€™s named risk measures, and the scales a book reports them in.
products ๐Ÿ”’
One constructor per product family โ€” the bindingโ€™s spelling of the coreโ€™s own constructors.
records ๐Ÿ”’
The one table the Python surface hands back.
sabr ๐Ÿ”’
The SABR rate smile: the surface, the spec and fit that build one from a grid, the forwards a fit reads, and one point of the smile.
sources ๐Ÿ”’
The source ports crossed to Python: the records a source answers with, and the adapter that lets any Python object with the right method be one.
stores ๐Ÿ”’
The market stores a Python caller pins โ€” survival, inflation, base correlation, FX volatility โ€” and the bond handle three products are written on.
vocab ๐Ÿ”’
How a closed vocabulary crosses the boundary as a typed value.

Structsยง

CalibrationError
A calibration could not solve or verify its ladder.
ConvergenceError
A calibration or fit ran out of steps, sweeps or iterations.
CurveError
A curve could not be built or could not answer a query.
HelixError
Base for every failure originating in the helixrs core.
MarketDataError
A market-data lookup asked for a value that was never supplied.
MissingFixingError
No fixing was published for the index on the date; kind and key name it as MarketContext.contents() lists it.
MissingFxRateError
No FX rate was supplied for the pair; kind and key name it as MarketContext.contents() lists it.
MissingMarketInputError
A valuation found no curve, vol surface, correlation, scalar, fixing or FX rate in the market; kind and key name it as MarketContext.contents() lists it, trade the book trade it came from.
NoLadderError
A par basis was asked of an input no calibration ladder has a row for.
PricingError
A valuation could not be produced from the market it was given.
PyBook
A collection of trades valued together.
PyCalibratedBaseCorrelation
A base-correlation curve solved from a tranche capital structure, and how it was reached.
PyCalibratedInflation
An inflation curve solved from a ladder of zero-coupon inflation swaps, and how it was reached.
PyCalibratedSurvival
A survival curve solved from a ladder of credit default swaps, and how it was reached.
PyCalibration
A calibrated curve and how it was reached.
PyCounterparty
A trading counterparty: its acronym and the CSA governing its trades. The CSA is named by its overnight index, as with_csa accepts one; a code naming no overnight index raises ValueError.
PyCurveRecipe
How a market would build the curves under one key: its discount pillars and, per projection index, its own pillars or none where the index telescopes onto the discount curve. Read back from MarketContext.recipe.
PyDiscountCurve
A discount curve.
PyExplainReport
The step-revaluation explain: the prints that became known first, then one leg per axis in order, telescoping exactly from the value before to the value after.
PyHullWhiteFit
A fitted Hullโ€“White volatility and what the fit knows about it.
PyInstrument
A tradable instrument.
PyInterpolation
The scheme a discount curve reads between its pillars, as a value that carries its parameters: one member per parameter-free scheme, and tension_spline(sigma) / clamped_cubic(left, right) for the two that take them. A string code is accepted beside it wherever a scheme is named.
PyJointCalibration
Several curves solved together, each under the first role it was given, in the order given; with the Newton iterations taken and the largest rung residual left.
PyLens
A selection over a book: what a trade is, never what it is worth.
PyMarket
The market a valuation is priced against.
PyMeasure
A quantity a report asks for: Measure.Npv, or a first-order sensitivity on an axis against a basis, collapsed by an aggregation, in a scale โ€” what the grammar spells delta:<axis>[:<basis>[:<aggregation>]][:<scale>].
PyPredictedPnl
The predicted explain: first order from risk plus one directional second-order pass.
PyReconciliation
The two explains aligned by axis.
PyResetPnl
The reset step read per print: what each print the ending market holds and the starting market does not made against the forecast it replaced.
PyRiskFrame
One risk pass and the market it was taken against: what a measure resolves against, read as many ways as a desk needs.
PyRung
One rung of a ladder with its quote kind declared: the shape a triple cannot say. A triple stays the par shorthand.
PyScenario
A named perturbation of the market, in the units its quotes are made in.
PySmoothedCalibration
A discount curve fitted globally, trading repricing error for forward smoothness; it carries no ladder because it reprices no rung exactly.
PyTolerance
How hard a ladder solver tries: a residual in the instrumentโ€™s units, a Newton step on the parameter, and the iteration, backtrack and sweep budgets โ€” the coreโ€™s defaults unless overridden.
RateSmileArg ๐Ÿ”’
A rate smile as a binder takes it: a grid or a SABR surface.
RiskError
A risk pass failed in valuation or adjoint read-back.
RolesArg ๐Ÿ”’
One role or several: a curveโ€™s roles as a Python caller writes them.
SnapshotError
A snapshot built no market: gaps lists every strip, fixing, spot or curve the source did not supply, as family and key.
SolveError
A quote solve found no root in its bracket or did not converge.
SourceError
A market-data, recipe or calendar source itself failed โ€” transport, authentication, a payload it could not read โ€” as distinct from a key it does not hold.

Enumsยง

InterpolationArg ๐Ÿ”’
An interpolation scheme as a Python caller names it: the code as a string, or an Interpolation value in hand.
PyAggregation ๐Ÿ”’
How a sensitivity is collapsed for reporting: one row (Total), a row per tenor bucket, per curve, or per contribution (Ladder).
PyBasis ๐Ÿ”’
Whose quote a sensitivity is expressed against: the curve nodesโ€™ own (Zero) or the calibrating instrumentsโ€™ (Par).
PyHullWhitePin ๐Ÿ”’
A Hullโ€“White volatility as with_hull_white takes it: a float, or (date, ฯƒ) pieces.
PyRiskAxis ๐Ÿ”’
What a sensitivity is to: the risk axes a report and a frame read.
PyRungInput ๐Ÿ”’
What a calibrator accepts per rung: a declared Rung, or the par triple.
PyShiftType ๐Ÿ”’
Whether a scenario leg moves its inputs relatively, xยท(1 + s), or absolutely, x + s. Unset, each input keeps its own convention: curves absolute, FX spots and vols relative.
Trade ๐Ÿ”’
Whether a missing-input exception carries a trade attribute: a valuationโ€™s refusal does (the trade, or None outside a book), a lookupโ€™s does not.

Constantsยง

RESETTING_LEG ๐Ÿ”’
Why a cross-currency swapโ€™s resetting leg refuses to be valued alone.

Traitsยง

CoreError ๐Ÿ”’
A core error that knows which exception it raises as.

Functionsยง

__pyfunction_bond_rung ๐Ÿ”’ โš 
__pyfunction_calibrate ๐Ÿ”’ โš 
__pyfunction_calibrate_base_correlation ๐Ÿ”’ โš 
__pyfunction_calibrate_cross_currency ๐Ÿ”’ โš 
__pyfunction_calibrate_inflation ๐Ÿ”’ โš 
__pyfunction_calibrate_jointly ๐Ÿ”’ โš 
__pyfunction_calibrate_smoothed ๐Ÿ”’ โš 
__pyfunction_calibrate_survival ๐Ÿ”’ โš 
__pyfunction_calibrate_survival_density ๐Ÿ”’ โš 
__pyfunction_default_order ๐Ÿ”’ โš 
__pyfunction_delta ๐Ÿ”’ โš 
__pyfunction_explain ๐Ÿ”’ โš 
__pyfunction_lagged_observation ๐Ÿ”’ โš 
__pyfunction_predicted_pnl ๐Ÿ”’ โš 
__pyfunction_reconcile ๐Ÿ”’ โš 
__pyfunction_reset_pnl ๐Ÿ”’ โš 
__pyfunction_vanilla_swap ๐Ÿ”’ โš 
axis_name ๐Ÿ”’
bond_rung ๐Ÿ”’
A priced rung on a bullet bond from a market quote: measure is clean_price or dirty_price (per cent of par) or yield (a decimal under yield_convention, default being the bondโ€™s own frequency); the pillar is the bondโ€™s maturity and the money per unit quote is face / 100. A spread is refused: it presupposes the benchmark the rung would calibrate. reference is the quoteโ€™s settlement, which may follow the curveโ€™s own reference date: the ladder then compares the quote with the bondโ€™s value forwarded to it.
book_pnl_err ๐Ÿ”’
A bookโ€™s P&L refusal: across days a ValueError naming the missing legs, a fetchโ€™s refusal as a snapshotโ€™s, the attributionโ€™s as pnl_err.
calibrate ๐Ÿ”’
Calibrates a self-discounting curve from (pillar_date, instrument) rungs quoted at par, reading fixings and FX from market when given.
calibrate_base_correlation ๐Ÿ”’
Calibrates a base-correlation curve from a contiguous capital structure of cdo_tranche(...) instruments, each carrying its own quote, on the indexโ€™s discount and survival curves. recovery is the indexโ€™s market recovery; a tranche that fixes its own needs none.
calibrate_cross_currency ๐Ÿ”’
Calibrates the discount curve of the rungsโ€™ receive leg under its collateral โ€” EUR under a USD CSA from EUR/USD basis swaps โ€” from (pillar, instrument, basis) rungs, against the pay legโ€™s discount and both legsโ€™ projection curves; the FX spot comes from market.
calibrate_inflation ๐Ÿ”’
Calibrates an inflation curve from (pillar, instrument, quote) rungs of zero-coupon inflation swaps โ€” the pillar at each swapโ€™s lagged observation โ€” discounted on discount, reading the base fixings from market.
calibrate_jointly ๐Ÿ”’
Solves several curves together: curves are (roles, rungs) pairs, a role spelled as a risk row spells a curve ("discount(EUR)", "projection(EUR-EURIBOR-3M)") โ€” one, or a list for a curve pinned under several (a self-discounting overnight curve is both) โ€” and the rungs as calibrate takes them. Returns a JointCalibration holding each solved curve under its role, in the order given โ€” the answer the sequential solve gives where the ladders can be ordered, and one where they cannot (a discount curve quoted only through basis swaps).
calibrate_smoothed ๐Ÿ”’
Fits a log-linear curve to (pillar, instrument, quote) rungs globally, minimising the quote residuals plus smoothness times the squared jumps in the segment forward; self-discounting, or projecting over discount.
calibrate_survival ๐Ÿ”’
Calibrates an ISDA survival curve from (maturity, instrument, spread) rungs of spread-quoted credit default swaps, discounted on an already-built discount curve. recovery is the entityโ€™s market recovery; a contract that fixes its own needs none.
calibrate_survival_density ๐Ÿ”’
Calibrates a default-density survival curve to a ladder of credit default swaps โ€” one density per pillar, the first segment flat โ€” discounted on discount; the rungs as calibrate_survival takes them, and the result the CalibratedSurvival it returns, ladder and refit included.
calibration_verb_err ๐Ÿ”’
How a market-pinning calibration verb raises: the marketโ€™s own missing-curve refusal as it would come from a valuation; an overlap, an unbuildable ladder or an unresolvable recipe as ValueError; the solveโ€™s own failures as themselves.
chained ๐Ÿ”’
A core errorโ€™s source chain as Python exceptions, each link raised as its own class โ€” the one it raises as when raised directly โ€” with its own core message and the next link its cause.
collateral ๐Ÿ”’
The currency a collateral= argument names: collateral is always a currency code, never an index or a discount key.
collateral_key ๐Ÿ”’
The coreโ€™s default unless a tolerance was given. A recipe key as the market spells it: a currency, else a named CSA. The parse is total, so there is nothing to refuse.
credit_bump_err ๐Ÿ”’
A credit bump that could not be taken: a revaluation keeps its own class, and a bump out of its inputโ€™s domain is a risk-pass failure.
credit_id ๐Ÿ”’
A construction refusal from a product-level core error: the input never reached a valuation, so it is the callerโ€™s ValueError, as a bad currency code is. A credit curve identity from its printed spelling โ€” ACME/SeniorUnSec/XR14/USD or CDX.NA.IG.45v1. A refusal is the coreโ€™s, raised as ValueError as every malformed caller input is.
credit_index_id ๐Ÿ”’
A credit index identity from its printed spelling โ€” CDX.NA.IG.45v1.
currency ๐Ÿ”’
default_order ๐Ÿ”’
The axis order explain uses when given none.
delta ๐Ÿ”’
The typed spelling of delta:<axis>[:<basis>[:<aggregation>]][:<scale>]: a first-order sensitivity on axis, against basis, collapsed by aggregation, in scale where one is stated. Each part takes its class or its string.
discount_key ๐Ÿ”’
The discount key for currency under collateral, the currencyโ€™s own where collateral is omitted.
err ๐Ÿ”’
Turns a core error into its Python exception, message forwarded.
explain ๐Ÿ”’
The step-revaluation explain of book between two markets, moving the axes in order (the coreโ€™s default order when None).
finite_quantity ๐Ÿ”’
A NaN or infinite quantity turns the whole bookโ€™s value to NaN, naming no trade; refuse it naming the trade.
helixio_core ๐Ÿ”’
The helixio._core extension module โ€” the native half of the helixio package. The name is private on purpose: the package re-exports everything, and no caller imports this module directly.
lagged_observation ๐Ÿ”’
The observation date a lag of lag_months puts before date โ€” where an inflation swap reads the index, and therefore where its rungโ€™s pillar sits.
parse_day_count ๐Ÿ”’
parse_interpolation ๐Ÿ”’
The interpolation scheme a caller gave, with the parameters the scheme carrying them needs.
parse_period ๐Ÿ”’
pnl_err ๐Ÿ”’
A P&L failure: two markets of different shape, or differing by more than an attribution can move, are the callerโ€™s ValueError; a pricing, risk or curve failure inside the attribution keeps its own class.
predicted_pnl ๐Ÿ”’
The predicted explain of book between two markets of the same shape, a print the after market alone holds being the reset step rather than a difference of shape.
quote_sheet ๐Ÿ”’
The sheet a desk reads, {template: {locator: value}}, as the coreโ€™s helixrs::QuoteSheet โ€” one parser for the recipe verb and its binder.
reconcile ๐Ÿ”’
The two explains aligned by axis.
register_exceptions ๐Ÿ”’
Every exception class the module registers, by name.
register_vocabularies ๐Ÿ”’
The closed vocabularies that cross as classes, in one place: a class a module forgets to register is a class the stub declares and the module lacks, which test_stub_parity.py names.
reset_pnl ๐Ÿ”’
The reset P&L of book from before to after: one row per print after holds and before does not, or holds at another value, each the exact revaluation from the forecast it replaced to the print, beside the move and the bookโ€™s sensitivity to it.
rungs_of ๐Ÿ”’
scenario_err ๐Ÿ”’
A scenario failure: a selector or shape the scenario has no shock for is the callerโ€™s ValueError; a malformed shock or a pricer failure keeps its own class.
selector ๐Ÿ”’
A selector by the coreโ€™s own spellings: an axis name, a curve, or fx(BASE/QUOTE) โ€” parsed by the core, which owns the vocabulary.
stores_of ๐Ÿ”’
swap_from_builder ๐Ÿ”’
The swap tail both the code-keyed vanilla_swap and Template.vanilla_swap forward to: the terms, the accrual-compounding override and its two refusals, the side, and the build.
tolerance_of ๐Ÿ”’
value_err ๐Ÿ”’
vanilla_swap ๐Ÿ”’
Builds a fixed-versus-floating interest-rate swap on indexโ€™s registered conventions.
with_missing ๐Ÿ”’
A raised exception carrying the missing inputโ€™s listing row as kind and key, and โ€” for a valuationโ€™s refusal โ€” the book trade it came from as trade (None outside a book).