Skip to main content

FixingStore

Struct FixingStore 

pub struct FixingStore {
    keys: Vec<(String, NaiveDate)>,
    rates: Vec<f64>,
}
Expand description

Published fixings, keyed by index and date.

Keys are held sorted rather than hashed, which buys three things: the free parameters have a stable index a risk ladder can key a row by, two stores built from the same observations compare equal regardless of insertion order, and a lookup binary-searches a borrowed &str without allocating one.

Fields§

§keys: Vec<(String, NaiveDate)>

Sorted, index-aligned with rates.

§rates: Vec<f64>

The free parameters, in key order.

Implementations§

§

impl FixingStore

pub fn new() -> Self

An empty store.

Empty is not absent. A valuation carrying an empty store reads no past fixing and reports one that is missing; a valuation carrying no store at all cannot tell the two apart. The distinction is what makes a missing historical reset observable rather than silently projected.

pub fn from_observations( observations: &[(&str, NaiveDate, f64)], ) -> Result<Self, MarketDataError>

Builds a store from (index, date, rate) observations.

§Errors

MarketDataError::Malformed if a rate is not finite, or if the same index and date are supplied twice with different rates — one observation cannot have printed two numbers.

pub fn from_observations_checked( observations: &[(FixingKey, NaiveDate, f64)], ) -> Result<Self, MarketDataError>

Builds a store from (key, date, rate) observations, refusing a typed key the registry does not carry.

The checked form of from_observations, mirroring the market’s with_projection_checked for the same namespace: a fixing published under a spelling no coupon reads is accepted, kept, and never matched — the store matches literally — so the mistype is caught where the observation is published rather than surfacing much later, elsewhere, as a missing fixing (or, where the fixing is not required, surfacing never).

A FixingKey::Typed spelling must be a registered index code in its registered casing, a well-formed FX key (see is_well_formed_fx_key — FX fixings are a namespace with no registry behind it, checked for shape), an equity key (EQ-<NAME>), a dividend key (DIV-<NAME>), or a swap index key (see is_swap_index_key — a registered swap template and a tenor). A FixingKey::Resolved key came from an index value and no lookup happens: nothing must be registered to publish a fixing.

§Errors

MarketDataError::UnknownFixingIndex naming the offending observation’s key and date and the registered codes; MarketDataError::Malformed as from_observations.

pub fn parameters(&self) -> &[f64]

The free parameters — one published rate per observation, in key order.

pub fn len(&self) -> usize

How many observations the store holds.

pub fn is_empty(&self) -> bool

Whether the store holds no observations.

pub fn parameter_keys(&self) -> Vec<(&str, NaiveDate)>

The (index, date) each parameter belongs to, in parameter order — how a risk ladder labels a fixing row.

fn position(&self, index: &str, date: NaiveDate) -> Option<usize>

Where (index, date) sits in the parameter vector, if it was published.

pub fn view<R: Scalar>(&self) -> FixingsView<'_, R>

This store lifted into mode R.

pub fn view_with<'a, R: Scalar>( &'a self, params: &'a [R], ) -> Result<FixingsView<'a, R>, MarketDataError>

This store lifted into mode R over params, in place of its stored ones — the substituted lift a risk pass registers handles through.

§Errors

MarketDataError::ParameterCountMismatch if params is not exactly as long as the store’s own parameter vector.

Trait Implementations§

§

impl Clone for FixingStore

§

fn clone(&self) -> FixingStore

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 Debug for FixingStore

§

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

Formats the value using the given formatter. Read more
§

impl Default for FixingStore

§

fn default() -> FixingStore

Returns the “default value” for a type. Read more
§

impl PartialEq for FixingStore

§

fn eq(&self, other: &FixingStore) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl StructuralPartialEq for FixingStore

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.

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.