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ยง
- Calibration
Error - A calibration could not solve or verify its ladder.
- Convergence
Error - A calibration or fit ran out of steps, sweeps or iterations.
- Curve
Error - A curve could not be built or could not answer a query.
- Helix
Error - Base for every failure originating in the helixrs core.
- Market
Data Error - A market-data lookup asked for a value that was never supplied.
- Missing
Fixing Error - No fixing was published for the index on the date;
kindandkeyname it asMarketContext.contents()lists it. - Missing
FxRate Error - No FX rate was supplied for the pair;
kindandkeyname it asMarketContext.contents()lists it. - Missing
Market Input Error - A valuation found no curve, vol surface, correlation, scalar, fixing or FX rate in the market;
kindandkeyname it asMarketContext.contents()lists it,tradethe book trade it came from. - NoLadder
Error - A par basis was asked of an input no calibration ladder has a row for.
- Pricing
Error - A valuation could not be produced from the market it was given.
- PyBook
- A collection of trades valued together.
- PyCalibrated
Base Correlation - A base-correlation curve solved from a tranche capital structure, and how it was reached.
- PyCalibrated
Inflation - An inflation curve solved from a ladder of zero-coupon inflation swaps, and how it was reached.
- PyCalibrated
Survival - 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_csaaccepts one; a code naming no overnight index raisesValueError. - PyCurve
Recipe - 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. - PyDiscount
Curve - A discount curve.
- PyExplain
Report - 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.
- PyHull
White Fit - 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. - PyJoint
Calibration - 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 spellsdelta:<axis>[:<basis>[:<aggregation>]][:<scale>]. - PyPredicted
Pnl - The predicted explain: first order from risk plus one directional second-order pass.
- PyReconciliation
- The two explains aligned by axis.
- PyReset
Pnl - 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.
- PyRisk
Frame - 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.
- PySmoothed
Calibration - 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.
- Rate
Smile ๐Arg - A rate smile as a binder takes it: a grid or a SABR surface.
- Risk
Error - A risk pass failed in valuation or adjoint read-back.
- Roles
Arg ๐ - One role or several: a curveโs roles as a Python caller writes them.
- Snapshot
Error - A snapshot built no market:
gapslists every strip, fixing, spot or curve the source did not supply, asfamilyandkey. - Solve
Error - A quote solve found no root in its bracket or did not converge.
- Source
Error - 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ยง
- Interpolation
Arg ๐ - An interpolation scheme as a Python caller names it: the code as a string,
or an
Interpolationvalue 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). - PyHull
White ๐Pin - A HullโWhite volatility as
with_hull_whitetakes it: a float, or(date, ฯ)pieces. - PyRisk
Axis ๐ - What a sensitivity is to: the risk axes a report and a frame read.
- PyRung
Input ๐ - What a calibrator accepts per rung: a declared
Rung, or the par triple. - PyShift
Type ๐ - 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
tradeattribute: a valuationโs refusal does (the trade, orNoneoutside a book), a lookupโs does not.
Constantsยง
- RESETTING_
LEG ๐ - Why a cross-currency swapโs resetting leg refuses to be valued alone.
Traitsยง
- Core
Error ๐ - 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:
measureisclean_priceordirty_price(per cent of par) oryield(a decimal underyield_convention,defaultbeing the bondโs own frequency); the pillar is the bondโs maturity and the money per unit quote isface / 100. Aspreadis refused: it presupposes the benchmark the rung would calibrate.referenceis 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
ValueErrornaming the missing legs, a fetchโs refusal as a snapshotโs, the attributionโs aspnl_err. - calibrate ๐
- Calibrates a self-discounting curve from
(pillar_date, instrument)rungs quoted at par, reading fixings and FX frommarketwhen 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โsdiscountandsurvivalcurves.recoveryis 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 frommarket. - 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 ondiscount, reading the base fixings frommarket. - calibrate_
jointly ๐ - Solves several curves together:
curvesare(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 ascalibratetakes them. Returns aJointCalibrationholding 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 plussmoothnesstimes the squared jumps in the segment forward; self-discounting, or projecting overdiscount. - calibrate_
survival ๐ - Calibrates an ISDA survival curve from
(maturity, instrument, spread)rungs of spread-quoted credit default swaps, discounted on an already-builtdiscountcurve.recoveryis 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 ascalibrate_survivaltakes them, and the result theCalibratedSurvivalit 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/USDorCDX.NA.IG.45v1. A refusal is the coreโs, raised asValueErroras 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
explainuses when given none. - delta ๐
- The typed spelling of
delta:<axis>[:<basis>[:<aggregation>]][:<scale>]: a first-order sensitivity onaxis, againstbasis, collapsed byaggregation, inscalewhere one is stated. Each part takes its class or its string. - discount_
key ๐ - The discount key for
currencyundercollateral, the currencyโs own wherecollateralis omitted. - err ๐
- Turns a core error into its Python exception, message forwarded.
- explain ๐
- The step-revaluation explain of
bookbetween two markets, moving the axes inorder(the coreโs default order whenNone). - 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._coreextension module โ the native half of thehelixiopackage. 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_monthsputs beforedateโ 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
bookbetween two markets of the same shape, a print theaftermarket 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โshelixrs::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.pynames. - reset_
pnl ๐ - The reset P&L of
bookfrombeforetoafter: one row per printafterholds andbeforedoes 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_swapandTemplate.vanilla_swapforward 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
kindandkey, and โ for a valuationโs refusal โ the book trade it came from astrade(Noneoutside a book).