Skip to main content

PricingView

Struct PricingView 

pub struct PricingView<'a, R: Scalar> {
Show 36 fields pub factors: RiskFactors<'a>, pub as_of: NaiveDate, pub disc: ResolvedCurve<'a, R>, pub fwd: Option<ResolvedCurve<'a, R>>, pub credit: Option<ResolvedCredit<'a, R>>, pub fixings: FixingsView<'a, R>, pub fx: FxView<'a, R>, pub hull_white: Option<HullWhiteParameters<R>>, pub credit_intensity: Option<GaussianIntensity<R>>, pub credit_crisis: Option<CrisisParameters<R>>, pub hull_white_foreign: Option<HullWhiteParameters<R>>, pub cross_currency: Option<CrossCurrencyDynamics<R>>, pub foreign: Option<ResolvedCurve<'a, R>>, pub foreign_basket: Vec<ResolvedCurve<'a, R>>, pub fx_vol: Option<FxVolView<'a, R>>, pub swaption_vol: Option<RateSmileView<'a, R>>, pub bond_yield_vol: Option<RateVolView<'a, R>>, pub cap_vol: Option<RateSmileView<'a, R>>, pub credit_vol: Option<CreditVolView<'a, R>>, pub yoy_vol: Option<InflationVolView<'a, R>>, pub cpi_vol: Option<InflationVolView<'a, R>>, pub future_price: Option<R>, pub equity_spots: Vec<R>, pub future_option_vol: Option<FutureOptionVolView<'a, R>>, pub equity_vol: Option<FutureOptionVolView<'a, R>>, pub repo: Option<ResolvedCurve<'a, R>>, pub second_fwd: Option<ResolvedCurve<'a, R>>, pub inflation: Option<ResolvedInflation<'a, R>>, pub base_correlation: Option<BaseCorrelationView<'a, R>>, pub basket: Vec<ResolvedCredit<'a, R>>, pub repo_basket: Vec<Option<ResolvedCurve<'a, R>>>, pub basket_correlation: Option<R>, pub cms_spread_correlation: Option<CmsSpreadCorrelationView<'a, R>>, pub recovery_floor: Option<R>, pub copula_dof: Option<(R, R)>, pub projection_basket: Vec<ResolvedCurve<'a, R>>,
}
Expand description

The market data one valuation is priced against, resolved once and passed whole across the Priceable seam.

A later input is a new field, not a wider signature.

Fields§

§factors: RiskFactors<'a>

The declaration this view was resolved for.

The view carries its own key. A book’s table of resolved views is keyed by exactly this, and holding it beside the view rather than inside it made two things that must agree into two things kept in step by hand.

Borrowed on the same terms as the keys within it, and cloned rather than referenced: every field is a borrow or a Copy scalar, so a clone is a memcpy and resolution still allocates nothing. Carrying it does not make the declaration mode-parameterized — the type has no R, and one trade resolved at two modes yields two views carrying equal declarations.

§as_of: NaiveDate

The date this valuation prices as of — the market’s, not a property of whichever curve happened to be resolved for discounting.

§disc: ResolvedCurve<'a, R>

The discount curve resolved for the product’s collateral.

§fwd: Option<ResolvedCurve<'a, R>>

The projection curve for the product’s floating index, when it has one.

§credit: Option<ResolvedCredit<'a, R>>

The credit data, resolved only when the product reported an entity.

§fixings: FixingsView<'a, R>

The observed fixings this valuation may read.

Always present. An empty store and no store are different things: a coupon consults it only for a reset already past, so an empty store leaves every projected reset untouched while making a missing historical one observable instead of invisible.

§fx: FxView<'a, R>

The FX spot rates this valuation may read.

§hull_white: Option<HullWhiteParameters<R>>

The Hull-White parameters, resolved only when the product declared a lattice currency.

§credit_intensity: Option<GaussianIntensity<R>>

The credit entity’s Gaussian intensity, resolved only when the product declared it.

§credit_crisis: Option<CrisisParameters<R>>

The credit entity’s crisis parameters, resolved only when the product declared them.

§hull_white_foreign: Option<HullWhiteParameters<R>>

The bond currency’s Hull-White parameters, resolved only when the product declared a cross-currency simulation.

§cross_currency: Option<CrossCurrencyDynamics<R>>

The cross-currency correlations, resolved with them.

§foreign: Option<ResolvedCurve<'a, R>>

The other currency’s discount curve, resolved only when the product declared a foreign discount key — an FX product’s base-currency leg.

§foreign_basket: Vec<ResolvedCurve<'a, R>>

The further discount curves, one per declared foreign discount key in the basket’s order; empty when none was declared.

§fx_vol: Option<FxVolView<'a, R>>

The pair’s vol surface, resolved only when the product declared one.

§swaption_vol: Option<RateSmileView<'a, R>>

The currency’s swaption vol surface, resolved only when the product declared one.

§bond_yield_vol: Option<RateVolView<'a, R>>

The currency’s bond yield vol surface, resolved only when the product declared one.

§cap_vol: Option<RateSmileView<'a, R>>

The currency’s cap vol surface, resolved only when the product declared one.

§credit_vol: Option<CreditVolView<'a, R>>

The credit name’s vol surface, resolved only when the product declared one.

§yoy_vol: Option<InflationVolView<'a, R>>

The price index’s year-on-year optionlet vol surface, resolved only when the product declared one.

§cpi_vol: Option<InflationVolView<'a, R>>

The price index’s zero-coupon CPI option vol surface, resolved only when the product declared one.

§future_price: Option<R>

The quoted price of the listed future an option reads, in the mode.

§equity_spots: Vec<R>

The quoted spots of the equities a product reads, in declaration order, in the mode.

§future_option_vol: Option<FutureOptionVolView<'a, R>>

The listed future’s option vol surface, if the product reads one.

§equity_vol: Option<FutureOptionVolView<'a, R>>

The equity’s option vol surface, if the product reads one.

§repo: Option<ResolvedCurve<'a, R>>

The repo curve, resolved only when the product declared one — the carry curve a financing trade forwards its reference bond on.

§second_fwd: Option<ResolvedCurve<'a, R>>

The second projection curve, resolved only when the product declared a second index.

§inflation: Option<ResolvedInflation<'a, R>>

The inflation curve, resolved only when the product declared a price index.

§base_correlation: Option<BaseCorrelationView<'a, R>>

The base-correlation curve of the declared entity, resolved only when the product requires one, its correlations lifted with the market.

§basket: Vec<ResolvedCredit<'a, R>>

The basket’s credit data, one per declared entity in the basket’s order; empty when no basket was declared.

§repo_basket: Vec<Option<ResolvedCurve<'a, R>>>

The basket’s carry curves, one per declared repo key in the basket’s order; empty when no repo basket was declared. An entry is None where the market holds no curve under that key, which the pricer reads as the fall back to the discount curve rather than as a missing input.

§basket_correlation: Option<R>

The market basket correlation, lifted with the market, resolved only when the product declared a key.

§cms_spread_correlation: Option<CmsSpreadCorrelationView<'a, R>>

The market CMS spread correlation for the declared pair — a flat mark or a term structure by expiry — lifted with the market, resolved only when the product declared one.

§recovery_floor: Option<R>

The market recovery floor for the declared credit index, lifted with the market, resolved only when the product declared one.

§copula_dof: Option<(R, R)>

The market double-t degrees of freedom (factor, idiosyncratic) for the declared credit index, lifted with the market, resolved only when the product declared them.

§projection_basket: Vec<ResolvedCurve<'a, R>>

The projection curves beyond the first two, one per declared basket index in its order; empty when none was declared.

Implementations§

§

impl<'a, R: Scalar> PricingView<'a, R>

pub fn cms_spread_correlation_for( &self, first: &str, second: &str, expiry: f64, strike: Option<f64>, ) -> Result<R, PricingError>

The market’s CMS spread correlation for the swap indices first and second, in either order, at an option expiry of expiry years — the mark this view resolved for its declared pair, read from its lifted parameters (linear between pillars, flat beyond them).

§Errors

PricingError::MissingCmsSpreadCorrelation naming the pair where the view was not resolved with it.

pub fn discounted_by( collateral: &'a CollateralSpec, disc: &'a Curve, fixings: &'a FixingStore, fx: &'a FxRates, ) -> PricingView<'a, R>

A view over disc, with everything else absent or empty.

pub fn under_base_correlation(self, curve: BaseCorrelationView<'a, R>) -> Self

This view with a base-correlation curve.

pub fn in_basket(self, basket: Vec<ResolvedCredit<'a, R>>) -> Self

This view with a basket of credit data.

pub fn financed_on_basket( self, basket: Vec<Option<ResolvedCurve<'a, R>>>, ) -> Self

This view with a basket of carry curves, one per declared repo key.

pub fn indexed_on(self, curve: &'a Inflation) -> Self

This view with an inflation curve.

pub fn also_projecting(self, fwd: &'a Curve) -> Self

This view with a second projection curve.

pub fn financed_on(self, repo: &'a Curve) -> Self

This view with a repo curve.

pub fn also_discounted_by(self, foreign: &'a Curve) -> Self

This view with a second discount curve, for the other currency of an FX pair.

pub fn also_discounted_by_each(self, basket: Vec<ResolvedCurve<'a, R>>) -> Self

This view with further discount curves, one per declared foreign discount key in the basket’s order.

pub fn discount_for( &self, collateral: &CollateralSpec, ) -> Option<&ResolvedCurve<'a, R>>

The discount curve this view resolved for collateral: the product’s own, its foreign one, or one of the basket’s — by the declaration the view carries, so a key the product did not declare is None.

pub fn credit_for( &self, credit: &CreditCurveId, ) -> Option<&ResolvedCredit<'a, R>>

The credit data this view resolved for credit: the product’s entity, or one of the basket’s — by the declaration the view carries, so an identity the product did not declare is None.

pub fn under_hull_white(self, parameters: HullWhiteParameters<R>) -> Self

This view with Hull-White parameters.

pub fn under_credit_intensity(self, intensity: GaussianIntensity<R>) -> Self

This view with the credit entity’s Gaussian intensity.

pub fn projecting(self, fwd: &'a Curve) -> Self

This view with a projection curve.

pub fn referencing(self, credit: &'a Survival, recovery: Option<f64>) -> Self

This view with credit data.

pub fn projection(&self) -> &ResolvedCurve<'a, R>

The projection curve, falling back to the discount curve.

The single-curve case is not a special case: a product with no separate projection curve projects off the curve it discounts on.

pub fn projection_of( &self, index: &str, ) -> Result<&ResolvedCurve<'a, R>, PricingError>

The projection curve declared for index, by name.

The view carries the declaration it was resolved for, so this is the lookup a pricer makes instead of reading a slot by position: the index declared as projection answers with the first curve, the one declared as second_projection with the second. A product that declared no projection at all projects every index off the curve it discounts on, as projection does.

§Errors

PricingError::UndeclaredProjection naming index where the product declared projections and none is this one: the product asked for a curve it did not declare, which is a defect in the product rather than a gap in the market.

pub fn curve_for(&self, index: &str) -> Result<OneCurve<'_, R>, PricingError>

projection_of as a single-curve source for a leg whose every coupon names index.

A single-index leg looks its curve up once, here, by name, and then projects every coupon off it through OneCurve — rather than asking the view per coupon, which is two string compares a coupon that a thousand-swap book measures. A leg on more than one index passes the view itself.

§Errors

As projection_of.

fn declared_projection(&self, index: &str) -> Option<&ResolvedCurve<'a, R>>

The slot index was declared under. Two string compares; no allocation.

A view declaring no projection at all answers every index with projection: the first projection slot where one was filled, else the discount curve. That is the single-curve fallback, and it is also what a view built by hand rather than resolved — a calibration ladder’s, which fills the slots by role and carries no declaration — means by its first slot.

§

impl<'a, R: Scalar> PricingView<'a, R>

pub fn observed_index_level( &self, index: &str, lag_months: u32, date: NaiveDate, product: &'static str, ) -> Result<R, PricingError>

The price-index level a flow paying on date is scaled by: the level at the lagged observation, a published fixing first and the projected curve otherwise.

One implementation, for every product that indexes. A linker’s coupons, a zero-coupon inflation swap’s single ratio and a year-on-year swap’s annual strip all read the index through this, so the lag rule and the fixings-before-curve precedence cannot come to mean one thing on a bond and another on a swap. product names the caller in the refusal, which is the only thing that differs between them.

§Errors

PricingError::UnsupportedForProduct where no inflation curve was resolved and no fixing covers the observation; otherwise whatever the curve reports.

pub fn observed_index_level_under( &self, index: &str, lag_months: u32, interpolation: Option<IndexInterpolation>, date: NaiveDate, product: &'static str, ) -> Result<R, PricingError>

observed_index_level under interpolation where a product states its own, and the index’s registered one where it is None.

§Errors

As observed_index_level.

pub fn spread_free(&self) -> Self

This view with the security spread its discounting carries taken off again: the risk-free market a spread-marked product’s coupons project through. A CMS coupon’s annuity and a collar’s caplets read the view’s discount curve, and the issuer’s spread is no part of either — it marks what the issuer’s promise is worth, not where the index fixes.

pub fn passive(&self) -> PricingView<'a, f64>

The derivative-free projection. The same market data, carrying no derivatives.

Every component re-lifts from the storage this view already borrows — nothing is resolved again, and the passive lift borrows its parameters, so no allocation is made for them. &self is taken by reference and unchanged, so the caller keeps pricing through the original afterwards with its risk attribution intact.

This is what replaces suspending the recording at runtime. An iterative kernel evaluated through the result records nothing, because there is nothing active in it to record — a property, not a mechanism, and one the tests assert by statement count.

Trait Implementations§

§

impl<'a, R: Clone + Scalar> Clone for PricingView<'a, R>

§

fn clone(&self) -> PricingView<'a, R>

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<R: Scalar> CurveByIndex<R> for PricingView<'_, R>

§

fn curve(&self, index: &str) -> Option<&dyn YieldCurve<R>>

By the declaration this view was resolved for; see PricingView::projection_of.

§

fn distinguishes_indices(&self) -> bool

Only a view resolved for a declaration tells indices apart; one built by hand answers every index with its first slot.

§

fn cms_rate( &self, coupon: &CmsCoupon, _as_of: NaiveDate, ) -> Option<Result<R, CashflowError>>

A CMS coupon’s rate by cms_coupon_rate, when this view was resolved with its currency’s swaption vols: the discount curve, the swaption smile and the projection are all here.

§

fn yoy_vol(&self, index: &str) -> Option<&InflationVolView<'_, R>>

The YoY vols this view was resolved for, when they are index’s.

§

fn cpi_vol(&self, index: &str) -> Option<&InflationVolView<'_, R>>

The zero-coupon CPI vols this view was resolved for, when they are index’s.

§

fn cap_vol(&self, currency: Currency) -> Option<&RateSmileView<'_, R>>

The cap vols this view was resolved for, when they are currency’s.

§

fn index_level( &self, index: &str, lag_months: u32, date: NaiveDate, ) -> Result<Option<R>, CashflowError>

The index level through observed_index_level, when this view was resolved for index: the one observation every indexed product makes.

§

fn curve_of(&self, index: Option<&str>) -> Option<&dyn YieldCurve<R>>

curve for a coupon’s own index, which a fixed coupon does not have.
§

impl<'a, R: Debug + Scalar> Debug for PricingView<'a, R>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, R> !Freeze for PricingView<'a, R>

§

impl<'a, R> !RefUnwindSafe for PricingView<'a, R>

§

impl<'a, R> !Sync for PricingView<'a, R>

§

impl<'a, R> Send for PricingView<'a, R>

§

impl<'a, R> Unpin for PricingView<'a, R>
where R: Unpin,

§

impl<'a, R> UnsafeUnpin for PricingView<'a, R>
where R: UnsafeUnpin,

§

impl<'a, R> UnwindSafe for PricingView<'a, R>

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.

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.

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.