Struct FixingHistory
pub struct FixingHistory {
prints: BTreeMap<(String, NaiveDate), Vec<Version>>,
}Expand description
Every print a market has seen, each with the date it was known on.
A store answers one value per (index, date); a history keeps every
version, so a restatement learnt later sits beside the value learnt
first rather than in its place. A version learnt by a fetch is known on
the fetch’s date; a version pinned by hand is known from the market’s date
when it was pinned, or the print’s own date where that is later. What a
market at a date reads is as_known_on that date: the
latest pin known by then, else the latest fetched version.
Fields§
§prints: BTreeMap<(String, NaiveDate), Vec<Version>>(index, date) to its versions, ascending by knowledge date.
Implementations§
§impl FixingHistory
impl FixingHistory
pub fn new() -> Self
pub fn new() -> Self
An empty history.
fn insert(
&mut self,
index: &str,
date: NaiveDate,
known: NaiveDate,
pinned: bool,
value: f64,
)
fn insert( &mut self, index: &str, date: NaiveDate, known: NaiveDate, pinned: bool, value: f64, )
Inserts one version, keeping the versions in knowledge order; a version already held with the same knowledge date and kind is replaced.
fn pick(versions: &[Version], on: NaiveDate) -> Option<Version>
fn pick(versions: &[Version], on: NaiveDate) -> Option<Version>
The version a market at on reads: the latest pin known by on, else
the latest fetched version known by on.
fn visible(
&self,
index: &str,
date: NaiveDate,
on: NaiveDate,
) -> Option<Version>
fn visible( &self, index: &str, date: NaiveDate, on: NaiveDate, ) -> Option<Version>
The version of (index, date) a market at on reads, for a print
dated on or before it.
pub fn as_known_on(&self, on: NaiveDate) -> FixingStore
pub fn as_known_on(&self, on: NaiveDate) -> FixingStore
What a market at on has seen: per print dated on or before on, the
version it reads.
pub fn learnt_before(&self, index: &str, date: NaiveDate, on: NaiveDate) -> bool
pub fn learnt_before(&self, index: &str, date: NaiveDate, on: NaiveDate) -> bool
Whether the version of (index, date) a market at on reads was
learnt by a fetch on an earlier date — a value that may since have
been restated, and so one a fetch at on asks again. A pin is never
asked again.
fn pinned_on(date: NaiveDate, at: Option<NaiveDate>) -> NaiveDate
fn pinned_on(date: NaiveDate, at: Option<NaiveDate>) -> NaiveDate
When a pin of a print dated date is known: the market’s date at, or
the print’s own date where that is later or the market is undated.
pub fn with_pinned(self, store: FixingStore, at: Option<NaiveDate>) -> Self
pub fn with_pinned(self, store: FixingStore, at: Option<NaiveDate>) -> Self
This history with its prints pinned by hand replaced by store’s,
pinned at the market date at; versions a fetch returned are kept.
store decides which prints are pinned, not what earlier dates knew:
a print it pins again keeps its pins known before the new one, and a
value equal to the one pinned by then adds no version — so pinning the
full set again on a later date leaves every earlier date as it was.
pub fn with_pinned_added(
self,
store: &FixingStore,
at: Option<NaiveDate>,
) -> Self
pub fn with_pinned_added( self, store: &FixingStore, at: Option<NaiveDate>, ) -> Self
This history with store’s prints added as pins at the market date
at, a pin already held from that date replaced.
pub fn with_fetched(
self,
prints: &[(String, NaiveDate, f64)],
on: NaiveDate,
) -> Self
pub fn with_fetched( self, prints: &[(String, NaiveDate, f64)], on: NaiveDate, ) -> Self
This history with prints learnt by a fetch on on. A print that
repeats the value a market at on already reads adds no version, so a
long-lived market re-asking unchanged prints does not grow.
pub fn without_fetched_on(self, on: NaiveDate) -> Self
pub fn without_fetched_on(self, on: NaiveDate) -> Self
This history without the versions a fetch on on learnt, so a fetch
at on asks for those prints again; pins and versions learnt on
other dates are kept. What a same-day re-fetch needs: without it, a
print corrected during the day was never asked for, as the demand
re-asks only what an earlier date learnt.
Trait Implementations§
§impl Clone for FixingHistory
impl Clone for FixingHistory
§fn clone(&self) -> FixingHistory
fn clone(&self) -> FixingHistory
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more