Skip to main content

PyMarket

Struct PyMarket 

pub struct PyMarket {
    pub(crate) inner: MarketContext,
}
Expand description

The market a valuation is priced against.

Fields§

§inner: MarketContext

Implementations§

§

impl PyMarket

pub(crate) fn check_date(&self, key: &str, reference: NaiveDate) -> PyResult<()>

Refuses a curve as of another date than this market, naming the key.

Every binder below calls this before it pins, so a misdated curve is a ValueError at the bind — the input never reached a valuation — where the core’s infallible builders defer the same refusal to the view.

pub(crate) fn inflating( &self, key: &str, curve: &PyInflationCurve, ) -> PyResult<Self>

Pins curve as the inflation curve for key, from Rust.

The sibling of projecting, and for the same reason: the Python entry point takes an untyped argument so it can accept a spelling or an Index, and the crate’s own tests state a key directly rather than building a Python object to hold one.

pub(crate) fn projecting( &self, index: impl Into<ProjectionKey>, curve: &PyDiscountCurve, ) -> PyResult<Self>

Pins curve as the projection curve for index, from Rust.

The Python entry point takes an untyped argument so it can accept a code or an Index. This is the typed form the crate’s own tests use, so they state a key directly rather than building a Python object to hold one.

§

impl PyMarket

pub(crate) fn new(as_of: Option<NaiveDate>) -> Self

An empty market as of as_of — or, with no date, an undated market holding reference data only (recipes, counterparties, meeting schedules, the data source) and the fixing history.

A market holds a snapshot per date and is at one of them: every curve pinned is checked against that date, and an undated market takes no dated input until it is moved to a date with on. The process default data source (hlx.set_data_source) is copied in here.

pub(crate) fn as_of(&self) -> Option<NaiveDate>

The date this market is at, or None for an undated market.

pub(crate) fn on(&self, date: NaiveDate) -> Self

This market at date: the same reference data and fixing history, with the snapshot held at date current (an empty one where none is held). The snapshot current until now is kept, and comes back when the market is moved to its date again.

pub(crate) fn dates(&self) -> Vec<NaiveDate>

The dates this market holds a snapshot for, the current one included.

pub(crate) fn without(&self, date: NaiveDate) -> Self

This market without its snapshot at date.

pub(crate) fn fixing_history(&self) -> PyRecords

Every version of every print the market has seen, as (index, date, known_on, source, value): known_on the date the version was known on, source "fetched" or "pinned" — a pin, known from the market’s date when it was given, is read over any fetched version.

pub(crate) fn data_source(&self, py: Python<'_>) -> Option<PyObject>

The object this market fetches from, or None where it is offline or none was ever set.

pub(crate) fn with_data_source( &self, source: Option<&Bound<'_, PyAny>>, ) -> PyResult<Self>

This market fetching from source — any object with fetch(demand, as_of), and recipes(ask) where it serves recipes — or, with None, offline: it never fetches, even where a default source is set.

pub(crate) fn with_curve_helpers( &self, py: Python<'_>, rungs: Vec<PyRungInput>, notional: f64, interpolation: InterpolationArg, tension: Option<f64>, end_slopes: Option<(f64, f64)>, tolerance: Option<&PyTolerance>, ) -> PyResult<Self>

This market with every curve a list of helpers solves pinned under its roles. A helper is a Rung from calibration.helpers (or par_rungs, cross_currency_rungs, bond_rung); the rungs are grouped by the curve each solves — an overnight index’s rungs pin discount(ccy) and projection(index) as one curve, a term index’s pin its projection over the discount this market holds, a deposit’s pin discount(ccy), a tenor basis rung pins its spread leg’s projection over the held discount and base projection, a cross-currency basis rung pins the quoted leg’s collateral discount — solved in turn, or together where one group reads a curve another solves. Two rungs on one pillar raise ValueError naming both; a held curve this market lacks raises MissingMarketInputError naming it. with_recipe_quotes is this verb on the helpers a quote sheet binds to.

pub(crate) fn with_recipe_quotes( &self, py: Python<'_>, key: &str, quotes: &Bound<'_, PyDict>, notional: f64, interpolation: InterpolationArg, tension: Option<f64>, end_slopes: Option<(f64, f64)>, tolerance: Option<&PyTolerance>, ) -> PyResult<Self>

This market with the curves its recipe for key describes solved from quotes and pinned. quotes is the sheet as a desk reads it, {template: {locator: value}}: a locator is a tenor ("4Y"), a contract code ("SEP27"), a decision date, or a window as "2026-10-29 - 2026-12-10", "SEP27 - DEC27", or a (start, end) pair; the sheet is the grid. A template the recipe does not list, or a locator shape the template cannot take, raises ValueError naming it.

pub(crate) fn demand(&self, book: &PyBook) -> PyResult<PyDemand>

What book needs from outside to price on this market: the quote strips its curves’ recipes name, the fixings its resets read, the FX spots its currencies convert through — and the curves no recipe builds. What this market already holds is not demanded. A source’s fetch(demand, as_of) answers it.

pub(crate) fn with_recipes_from( &self, py: Python<'_>, book: &PyBook, source: &Bound<'_, PyAny>, ) -> PyResult<Self>

This market with the recipes source (any object with a recipes(ask) method) holds for book’s keys joined in — only for keys this market’s own recipes do not set, so the caller’s win and a source’s beat the shipped ones. The first step of snapshot, for an async connector that runs the rest itself.

pub(crate) fn with_market_data( &self, py: Python<'_>, demand: &PyDemand, data: &PyMarketData, ) -> PyResult<Self>

This market with what data carries of demand built in — spots, fixings, then every curve — or, where anything demanded is missing, a SnapshotError whose gaps names every one. The receiver is unchanged. The last step of snapshot, and where an async connector hands back what it awaited.

pub(crate) fn recipe_rungs( &self, key: &str, quotes: &Bound<'_, PyDict>, notional: f64, ) -> PyResult<Vec<PyRung>>

The helpers quotes binds to under this market’s recipe for key, in sheet order and unsolved, each built on notional — what with_recipe_quotes solves, for checking that every quote reprices on the market it marked. with_recipe_quotes(key, quotes) is with_curve_helpers(recipe_rungs(key, quotes)). Refuses exactly as with_recipe_quotes does, with the same ValueError.

pub(crate) fn with_discount( &self, currency: &str, curve: &PyDiscountCurve, collateral: Option<&str>, ) -> PyResult<Self>

Pins curve as the discount curve for cash flows in currency under collateral — the currency’s own curve where collateral is omitted or is currency, the key {currency}-CSA-{collateral} otherwise.

pub(crate) fn with_projection( &self, index: &Bound<'_, PyAny>, curve: &PyDiscountCurve, ) -> PyResult<Self>

Pins curve as the projection curve for index.

index is either a registry code — checked, and refused naming the registered set if it names nothing — or an Index, which has already established what it is and needs no lookup. An index built from conventions is therefore pinnable without being registered first; the check exists to catch a mistyped string, and a value is not one.

pub(crate) fn with_repo_curve( &self, key: &str, curve: &PyDiscountCurve, ) -> PyResult<Self>

Pins curve as the repo (financing) curve under key.

pub(crate) fn with_repo_spread( &self, key: &str, curve: &Bound<'_, PyAny>, base: &str, ) -> PyResult<Self>

Pins curve under repo(KEY) declared over base — a discount key spelled discount(USD) or another repo key spelled repo(USD) — so a special sits over GC and GC over the overnight curve. Resolving the key adds the spreads in simple-rate space, 1/P = 1/P_base + Σ s·τ; the base’s risk stays on its own axis and each spread’s lands on the repo axis. curve is a RepoSpreadCurve, or a curve read back from curve("repo(KEY)").

pub(crate) fn with_discount_via( &self, currency: &str, via: &str, collateral: &str, ) -> PyResult<Self>

Cash flows in currency under collateral discounted through hub currency via: discount({currency}-CSA-{collateral}) reads D(collateral) · D(currency under via) / D(collateral under via), composed at pricing from the three keys, so its risk lands on them.

pub(crate) fn discount_via( &self, currency: &str, collateral: &str, ) -> PyResult<Option<String>>

The hub currency under collateral was declared derived through (with_discount_via), or None for a curve held any other way — beside its discount row in contents(), what declares it again.

pub(crate) fn repo_base(&self, key: &str) -> Option<String>

The key repo(KEY) is declared over — discount(USD), repo(USD) — or None for a whole repo curve or an absent key.

pub(crate) fn with_security_spread( &self, key: &str, curve: &PySpreadCurve, ) -> PyResult<Self>

Pins curve as the security spread under key — dated or flat.

pub(crate) fn with_credit_curve( &self, credit: &str, curve: &PySurvivalCurve, recovery: Option<f64>, ) -> PyResult<Self>

Pins the survival curve under credit — a credit identity spelled ENTITY/SENIORITY/DOCCLAUSE/CCY for a single name or FAMILY.SERIESvVERSION for an index — with its market recovery when given. A bare entity is refused: the identity fills no tier or clause in, so two curves on one issuer cannot collide.

pub(crate) fn with_inflation_curve( &self, index: &Bound<'_, PyAny>, curve: &PyInflationCurve, ) -> PyResult<Self>

Pins curve as the index-level curve for inflation index.

pub(crate) fn with_credit_vols( &self, credit: &str, surface: &PyCreditVolSurface, ) -> PyResult<Self>

Pins surface as the credit vol surface for credit — the identity its credit curve is under, a single name’s or an index’s — what a CDS option on it reads.

pub(crate) fn with_base_correlation( &self, credit_index: &str, curve: &PyBaseCorrelation, ) -> PyResult<Self>

Pins curve as the base-correlation skew for the credit index credit_index, spelled FAMILY.SERIESvVERSION ("CDX.NA.IG.46v1").

pub(crate) fn with_basket_correlation( &self, key: &str, value: f64, ) -> PyResult<Self>

Pins a basket’s asset correlation under key — what an nth-to-default basket booked with correlation_key=key reads — as one risk parameter on the correlation axis. A correlation outside [0, 1) raises ValueError.

pub(crate) fn with_recovery_floor( &self, credit_index: &str, value: f64, ) -> PyResult<Self>

Pins a credit index’s Amraoui–Hitier recovery floor — what a tranche booked with recovery_floor="Market" on that index reads — as one risk parameter on the recovery axis. credit_index is the index the base correlation is keyed by ("CDX.NA.IG.46v1"). A floor outside [0, 1) raises ValueError.

pub(crate) fn with_copula_dof( &self, credit_index: &str, factor_dof: f64, idiosyncratic_dof: f64, ) -> PyResult<Self>

Pins a credit index’s double-t degrees of freedom — what a tranche booked with factor_dof="Market", idiosyncratic_dof="Market" on that index reads — as two risk parameters on the correlation axis. A degree of freedom not above 2 raises ValueError.

pub(crate) fn with_cms_spread_correlation( &self, index: &str, other: &str, value: PyCmsSpreadCorrelationInput, ) -> PyResult<Self>

Pins the correlation between two swap indices’ rates — what a CMS spread coupon booked with correlation="Market" on those indices reads — on the correlation axis. index and other are swap-index codes ("EUR-EURIBOR-6M-IRS-10Y"), in either order. value is a number (the flat mark, one risk parameter) or a curves.CmsSpreadCorrelationCurve by option expiry (one per pillar, read at each coupon’s fixing). A correlation outside [-1, 1] raises ValueError.

pub(crate) fn with_fixings( &self, observations: Vec<(Bound<'_, PyAny>, NaiveDate, f64)>, ) -> PyResult<Self>

Pins past fixings as (index, date, value) observations.

They replace the prints pinned before; a print pinned again keeps what earlier dates knew of it, so pinning the full set each day leaves every earlier date as it was.

The key is validated where it is published, exactly as with_projection validates its own — the two binders key the same namespace. A string must be a registered index code in its registered casing, or a well-formed FX key such as "FX-EURUSD" (FX fixings are a namespace no registry holds, so their keys are checked for shape); anything else raises naming the offending observation and the registered indices, because a fixing stored under a spelling no coupon carries is never read. An Index value publishes without a lookup, under the name a leg on that index would carry, and so does a string naming a curve this market already pins — an inflation key, or the code of a bespoke index bound as a value.

pub(crate) fn fixing(&self, index: &str, date: NaiveDate) -> PyResult<f64>

The rate index fixed at on date.

Raises when the observation was never published, naming both — a historical reset that should have been observed and was not is a data problem, and returning a zero or projecting one hides it. Use try_fixing where absence is an ordinary answer.

The key is the one the observation was pinned under, which is also the one the pricer reads: a coupon carries the index string its leg was built from, and the store is keyed by that string literally. Reading under a different spelling of the same index would hand back a number the pricer could not find.

pub(crate) fn try_fixing(&self, index: &str, date: NaiveDate) -> Option<f64>

The rate index fixed at on date, or None if it was never published.

For deciding whether a reset has been observed, where absence is an ordinary answer rather than a failure. The distinction the core draws between absent and failed survives the crossing.

pub(crate) fn with_meetings(&self, schedule: &PyMeetingSchedule) -> Self

This market carrying schedule as the bank’s calendar of decisions: reference data, not a market input, so it moves no value and leaves equality untouched. A policy window opened on one of its effective dates is named by that decision on the curve, in risk rows and in the par ladder; where no schedule is pinned the seeded 2026–2027 one answers.

pub(crate) fn meetings(&self, bank: &str) -> Option<PyMeetingSchedule>

The schedule pinned for bank, the seeded one where none is, or None for a bank with neither.

pub(crate) fn with_counterparties( &self, counterparties: Vec<PyRef<'_, PyCounterparty>>, ) -> Self

This market carrying counterparties as the master a draft’s counterparty is resolved from: reference data, not a market input, so it moves no value and leaves equality untouched.

pub(crate) fn counterparty(&self, acronym: &str) -> Option<PyCounterparty>

The counterparty under acronym, or None on a market given no master or an acronym it does not hold.

pub(crate) fn recipes(&self) -> PyRecords

How the curves this market does not hold would be built, as (key, curve, role, template, window).

One row per recipe segment, plus one per projection source. The key column carries the canonical collateral spelling, so every listed row is addressable through recipe rather than merely readable. A bare market lists the shipped base.

pub(crate) fn contents(&self) -> Vec<(String, String)>

Every stored input’s identifier, as (kind, key) pairs.

The kinds name the pins that fill the stores, so a row reads as the call that would put it back, and the keys are the spellings a risk row prints and a scenario leg parses — so every listed row is addressable, not merely readable.

Recipes are not listed: they describe curves this market does not hold, and are read through recipes() and recipe(key). The as_of date is not a row either — every market has one, so it is a property of the listing rather than an entry in it, and as_of() reports it.

pub(crate) fn __repr__(&self) -> String

pub(crate) fn __eq__(&self, other: &Self) -> bool

pub(crate) fn repo_discount(&self, key: &str, date: NaiveDate) -> PyResult<f64>

The discount factor a trade financed on repo(KEY) reads on date: a spread chain composed onto its base, 1/P = 1/P_base + Σ s·τ, as pricing composes it; a whole repo curve as pinned. curve("repo(KEY)") reads back what was pinned, which for a spread is the spread alone.

pub(crate) fn discount_factor( &self, currency: &str, date: NaiveDate, collateral: Option<&str>, ) -> PyResult<f64>

The discount factor cash flows in currency under collateral read on date, as pricing reads it: a curve derived via a hub composed from its three sources, any other as pinned. collateral defaults to the currency’s own.

pub(crate) fn curve(&self, id: &str) -> PyResult<PyDiscountCurve>

The curve pinned under id, with the ladder it was pinned with reattached — so a curve read out of one market and pinned into another still carries the par risk a ladder reads.

id is the spelling contents() lists and a risk row prints, e.g. discount(USD) or projection(USD-SOFR).

§Errors

ValueError for an unparseable id; PricingError naming the held keys for a curve this market does not hold. A credit(...) or inflation(...) id is refused naming the reader that serves it — those are different curve types and cross as different classes.

pub(crate) fn credit_curve( &self, credit: &str, ) -> PyResult<(PySurvivalCurve, Option<f64>)>

The survival curve and stated recovery pinned for entity.

The recovery comes back with the curve because it is the assumption the quote carries: a survival curve without it has unrecoverable units.

§Errors

PricingError naming the identity where the market pins no credit for it; ValueError for a spelling that is no identity.

pub(crate) fn credit_vols(&self, credit: &str) -> PyResult<PyCreditVolSurface>

The credit volatility surface pinned for credit.

§Errors

PricingError naming the identity where the market pins no surface.

pub(crate) fn base_correlation( &self, credit_index: &str, ) -> PyResult<PyBaseCorrelation>

The base correlation pinned under credit_index.

§Errors

PricingError naming the index where the market pins none.

pub(crate) fn basket_correlation(&self, key: &str) -> PyResult<f64>

The basket correlation pinned under key.

§Errors

PricingError naming the key where the market pins none.

pub(crate) fn recovery_floor(&self, credit_index: &str) -> PyResult<f64>

The recovery floor pinned for credit_index.

§Errors

PricingError naming the index where the market pins none.

pub(crate) fn copula_dof(&self, credit_index: &str) -> PyResult<(f64, f64)>

The double-t degrees of freedom (factor_dof, idiosyncratic_dof) pinned for credit_index.

§Errors

PricingError naming the index where the market pins none.

pub(crate) fn cms_spread_correlation( &self, index: &str, other: &str, ) -> PyResult<PyCmsSpreadCorrelationCurve>

The CMS spread correlation pinned for the swap indices index and other, in either order — the flat mark or the term structure.

§Errors

PricingError naming the pair where the market pins none.

pub(crate) fn fx_rate(&self, base: &str, quote: &str) -> PyResult<f64>

The FX rate pinned for base/quote, as it was given.

What was pinned, not what can be derived. A cross the market reaches only by triangulating through a pivot is a valuation-time derivation; this reports the input, so a market can be rebuilt from its own contents without inventing quotes it never held. A pinned EURUSD does not make USDEUR readable here.

§Errors

PricingError naming the pair where the market pins no quote for it.

pub(crate) fn fx_vols( &self, base: &str, quote: &str, ) -> PyResult<PyFxVolSurface>

The FX volatility surface pinned for base/quote.

Takes the pair because the store holds one surface per pair, which is what with_fx_vols puts there — the surface carries its own pair.

§Errors

PricingError naming the pair where the market pins no surface.

pub(crate) fn swaption_vols(&self, currency: &str) -> PyResult<PyRateVolSurface>

The swaption volatility surface pinned for currency.

§Errors

PricingError naming the currency where the market pins no surface.

pub(crate) fn bond_yield_vols(&self, key: &str) -> PyResult<PyRateVolSurface>

The bond-yield volatility surface pinned under key: a currency code, or the security an option names.

§Errors

PricingError naming the key where the market pins no surface.

pub(crate) fn cap_vols(&self, currency: &str) -> PyResult<PyRateVolSurface>

The cap volatility surface pinned for currency.

§Errors

PricingError naming the currency where the market pins no surface.

pub(crate) fn yoy_vols(&self, index: &str) -> PyResult<PyYoyVolSurface>

The year-on-year inflation optionlet vol surface pinned for the price index index.

§Errors

PricingError naming the index where the market pins no surface.

pub(crate) fn cpi_vols(&self, index: &str) -> PyResult<PyCpiVolSurface>

The zero-coupon CPI option vol surface pinned for the price index index.

§Errors

PricingError naming the index where the market pins no surface.

pub(crate) fn future_option_vols( &self, contract: &str, ) -> PyResult<PyFutureOptionVolSurface>

The option vol surface pinned for the listed future contract ("CBOT-ZN-2027-03").

§Errors

PricingError naming the contract where the market pins no surface; ValueError for a contract that does not parse.

pub(crate) fn equity_vols( &self, equity: &str, ) -> PyResult<PyFutureOptionVolSurface>

The option vol surface pinned for the equity.

§Errors

PricingError naming the equity where the market pins no surface.

pub(crate) fn equity_spot(&self, equity: &str) -> Option<f64>

The quoted price of the listed future contract, per 100, or None.

pub(crate) fn future_price(&self, contract: &str) -> PyResult<Option<f64>>

The quoted price of the listed future contract, per 100, or None.

pub(crate) fn inflation_curve(&self, index: &str) -> PyResult<PyInflationCurve>

The inflation curve pinned under index.

§Errors

PricingError naming the index where the market pins no inflation curve.

pub(crate) fn recipe(&self, key: &str) -> Option<PyCurveRecipe>

How a curve under key would be built, as a one-line summary, or None where this market carries no recipe for it.

key is the collateral spelling a discount pin and a risk row use — "USD", or "EUR-CSA-USD" for a cross-collateral key. A key naming no currency pair has no recipe, because the registry is keyed by pairs.

pub(crate) fn fixings(&self) -> PyRecords

Every fixing as known on this market’s date, as (index, date, value): for each print dated on or before it, the latest version known on or before it.

The shape with_fixings accepts, so the pair round-trips: a market’s observations can be read out and pinned back unchanged.

pub(crate) fn with_fx_rates( &self, quotes: Vec<(String, String, f64)>, ) -> PyResult<Self>

Pins spot FX as (base, quote, rate) quotes — rate units of quote per one base.

pub(crate) fn with_swaption_vols( &self, currency: &str, surface: RateSmileArg, ) -> PyResult<Self>

Pins a currency’s swaption volatility surface — a grid (RateVolSurface) or a SABR smile (SabrVolSurface) — what a European swaption reads.

pub(crate) fn with_bond_yield_vols( &self, key: &str, surface: &PyRateVolSurface, ) -> PyResult<Self>

Pins a bond yield volatility surface under key — a currency code, or the security an option names: the same grid type, read at a forward modified duration on its second axis.

pub(crate) fn with_cap_vols( &self, currency: &str, surface: RateSmileArg, ) -> PyResult<Self>

Pins a currency’s cap volatility surface — a grid (RateVolSurface) or a SABR smile (SabrVolSurface) — read at each caplet’s fixing and the index tenor on its second axis.

pub(crate) fn with_yoy_vols( &self, index: &str, surface: &PyYoyVolSurface, ) -> Self

Pins a price index’s year-on-year inflation optionlet vol surface — what a YoY cap, floor or collared YoY coupon on index reads.

pub(crate) fn with_future_price( &self, contract: &str, price: f64, ) -> PyResult<Self>

Pins the listed future contract’s quoted price, per 100 face — one lifted input on the futures-price axis, what an option on the future reads as its underlying.

pub(crate) fn with_equity_spot( &self, equity: &str, price: f64, ) -> PyResult<Self>

Pins the equity’s quoted spot — one lifted input on the equity axis, what an equity total return swap reads.

pub(crate) fn with_equity_vols( &self, equity: &str, surface: &PyFutureOptionVolSurface, ) -> Self

Pins the equity’s option vol surface — listed expiry × strike, what every option on the equity reads.

pub(crate) fn with_future_option_vols( &self, contract: &str, surface: &PyFutureOptionVolSurface, ) -> PyResult<Self>

Pins the listed future contract’s option vol surface — what every option exercising into it reads.

pub(crate) fn with_cpi_vols( &self, index: &str, surface: &PyCpiVolSurface, ) -> Self

Pins a price index’s zero-coupon CPI option vol surface — what a zero-coupon inflation cap, floor or collared CPI notional on index reads.

pub(crate) fn with_fx_vols(&self, surface: &PyFxVolSurface) -> Self

Pins an FX volatility surface.

pub(crate) fn with_credit_intensity( &self, credit: &str, currency: &str, mean_reversion: f64, vol: f64, correlation: f64, ) -> PyResult<Self>

Pins credit’s Gaussian intensity — its mean reversion, volatility and correlation with currency’s Hull–White factor — under the labels a correlated repack gap reads.

pub(crate) fn with_fx_rate_correlation( &self, base: &str, quote: &str, currency: &str, correlation: f64, ) -> PyResult<Self>

Pins the correlation between the FX pair base/quote and currency’s Hull–White factor, which a cross-currency repack simulation reads on the correlation axis.

pub(crate) fn with_fx_credit_correlation( &self, base: &str, quote: &str, credit: &str, correlation: f64, ) -> PyResult<Self>

Pins the correlation between the FX pair base/quote and credit’s intensity.

pub(crate) fn with_rate_correlation( &self, currency: &str, other: &str, correlation: f64, ) -> PyResult<Self>

Pins the correlation between two currencies’ Hull–White factors.

pub(crate) fn with_credit_crisis( &self, credit: &str, rate: f64, jump_mean: f64, default_probability: f64, ) -> PyResult<Self>

Pins credit’s crises — the rate κ they arrive at, the mean m of the spread jump each brings, and the probability p that one defaults the issuer at once — under the labels a simulated repack gap reads.

pub(crate) fn with_hull_white( &self, currency: &str, mean_reversion: f64, sigma: PyHullWhitePin, ) -> PyResult<Self>

Pins the Hull–White mean reversion and volatility for code’s rates: sigma a float, or (date, σ) pieces — each date its piece’s interval end, the last extending flat. Pinning either spelling removes the other for the currency.

pub(crate) fn pin_input(&self, label: &str, value: f64) -> Self

Pins an exogenous input under label — a number the market watches and risks on its own axis.

pub(crate) fn with_flat_swaption_vol( &self, currency: &str, expiry: NaiveDate, end: NaiveDate, normal_vol: f64, ) -> PyResult<Self>

Pins one ATM swaption’s normal volatility, for the option expiring at expiry on a swap ending at end — under the label the core spells, which is what a Hull–White calibration looks for.

Named with_flat_swaption_vol rather than with_swaption_vol because it pins a single point, where with_swaption_vols pins a whole surface. Two members one letter apart that take different data are a pair a caller cannot tell apart by reading.

pub(crate) fn pinned_input(&self, label: &str) -> Option<f64>

The value pinned under label, or None if the market carries none.

pub(crate) fn under(&self, scenario: &PyScenario) -> PyResult<Self>

This market under scenario: every admitted input wrapped in its family’s shock, everything else carried through.

A market like any other — value, risk, report and attribution all run against it, and it lifts to the base’s parameter vector, so a risk vector taken under a scenario lines up with the base’s row for row. The receiver is untouched.

§

impl PyMarket

pub(crate) unsafe fn __pymethod___eq____( py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

§

impl PyMarket

pub(crate) unsafe extern "C" fn __pymethod___richcmp____( slf: *mut PyObject, other: *mut PyObject, op: c_int, ) -> *mut PyObject

Trait Implementations§

§

impl Clone for PyMarket

§

fn clone(&self) -> PyMarket

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl DerefToPyAny for PyMarket

§

impl IntoPy<Py<PyAny>> for PyMarket

§

fn into_py(self, py: Python<'_>) -> PyObject

Performs the conversion.
§

impl PyClass for PyMarket

§

type Frozen = False

Whether the pyclass is frozen. Read more
§

impl PyClassImpl for PyMarket

§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
§

type BaseType = PyAny

Base class
§

type ThreadChecker = SendablePyClass<PyMarket>

This handles following two situations: Read more
§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
§

fn items_iter() -> PyClassItemsIter

§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

§

fn dict_offset() -> Option<isize>

§

fn weaklist_offset() -> Option<isize>

§

impl PyClassNewTextSignature<PyMarket> for PyClassImplCollector<PyMarket>

§

fn new_text_signature(self) -> Option<&'static str>

§

impl PyClass__eq__SlotFragment<PyMarket> for PyClassImplCollector<PyMarket>

§

unsafe fn __eq__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a PyMarket

§

type Holder = Option<PyRef<'py, PyMarket>>

§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut PyMarket

§

type Holder = Option<PyRefMut<'py, PyMarket>>

§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

§

impl PyMethods<PyMarket> for PyClassImplCollector<PyMarket>

§

fn py_methods(self) -> &'static PyClassItems

§

impl PyTypeInfo for PyMarket

§

const NAME: &'static str = "MarketContext"

Class name.
§

const MODULE: Option<&'static str>

Module name, if any.
§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
§

fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
§

fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
§

fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromPyObject<'_> for T
where T: PyClass + Clone,

§

fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
§

impl<'py, T> FromPyObjectBound<'_, 'py> for T
where T: FromPyObject<'py>,

§

fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PyErrArguments for T
where T: IntoPy<Py<PyAny>> + Send + Sync,

§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Ungil for T
where T: Send,