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
impl FixingStore
pub fn new() -> Self
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>
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>
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]
pub fn parameters(&self) -> &[f64]
The free parameters — one published rate per observation, in key order.
pub fn parameter_keys(&self) -> Vec<(&str, NaiveDate)>
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>
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>
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>
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
impl Clone for FixingStore
§fn clone(&self) -> FixingStore
fn clone(&self) -> FixingStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more