Struct PyMarket
pub struct PyMarket {
pub(crate) inner: MarketContext,
}Expand description
The market a valuation is priced against.
Fields§
§inner: MarketContextImplementations§
§impl PyMarket
impl PyMarket
pub(crate) fn check_date(&self, key: &str, reference: NaiveDate) -> PyResult<()>
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>
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>
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
impl PyMarket
pub(crate) fn new(as_of: Option<NaiveDate>) -> Self
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>
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
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>
pub(crate) fn dates(&self) -> Vec<NaiveDate>
The dates this market holds a snapshot for, the current one included.
pub(crate) fn fixing_history(&self) -> PyRecords
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>
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>
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>
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>
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>
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>
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>
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>>
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>
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>
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>
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>
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>
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>>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
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>
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
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>
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
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)>
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>
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>
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>
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>)>
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>
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>
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>
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>
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)>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>>
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>
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>
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
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>
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>
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>
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>
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
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>
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>
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
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>
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
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
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>
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>
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>
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>
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>
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>
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
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>
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>
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>
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.
Trait Implementations§
impl DerefToPyAny for PyMarket
§impl PyClassImpl for PyMarket
impl PyClassImpl for PyMarket
§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
§type ThreadChecker = SendablePyClass<PyMarket>
type ThreadChecker = SendablePyClass<PyMarket>
§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
§impl PyClassNewTextSignature<PyMarket> for PyClassImplCollector<PyMarket>
impl PyClassNewTextSignature<PyMarket> for PyClassImplCollector<PyMarket>
fn new_text_signature(self) -> Option<&'static str>
§impl PyMethods<PyMarket> for PyClassImplCollector<PyMarket>
impl PyMethods<PyMarket> for PyClassImplCollector<PyMarket>
fn py_methods(self) -> &'static PyClassItems
§impl PyTypeInfo for PyMarket
impl PyTypeInfo for PyMarket
§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.