Struct TimeGrid
pub struct TimeGrid {
pub dates: Vec<NaiveDate>,
pub times: Vec<f64>,
}Expand description
The lattice time grid: slice dates and their year fractions from valuation.
Built uniform (build) or with mandatory dates
(build_with_mandatory) — schedule dates
(coupons, call dates) inserted as exact slices with the gaps between them
subdivided at the requested density, so exercise is applied on the true
date with no snapping error. Steps are locally non-uniform; the lattice
geometry handles per-step Δt exactly.
Fields§
§dates: Vec<NaiveDate>Slice dates, dates[0] = valuation, ascending. A mandatory date
appears verbatim; interpolated slices carry the rounded calendar date
of their year fraction.
times: Vec<f64>Year fraction of each slice from valuation, ascending.
Implementations§
§impl TimeGrid
impl TimeGrid
pub fn build(
valuation: NaiveDate,
horizon: NaiveDate,
steps_per_year: u32,
) -> Result<TimeGrid, CurveError>
pub fn build( valuation: NaiveDate, horizon: NaiveDate, steps_per_year: u32, ) -> Result<TimeGrid, CurveError>
Builds a uniform grid from valuation to horizon at ≈ steps_per_year.
§Errors
CurveError::InvertedDates if horizon is on or before valuation.
pub fn build_with_mandatory(
valuation: NaiveDate,
horizon: NaiveDate,
steps_per_year: u32,
mandatory: &[NaiveDate],
) -> Result<TimeGrid, CurveError>
pub fn build_with_mandatory( valuation: NaiveDate, horizon: NaiveDate, steps_per_year: u32, mandatory: &[NaiveDate], ) -> Result<TimeGrid, CurveError>
Builds a grid whose slices contain every mandatory date in
(valuation, horizon) exactly (plus the horizon itself), with each
gap between consecutive anchors subdivided uniformly at
≈ steps_per_year density. Mandatory dates outside the open interval
are ignored — the horizon is an anchor by construction, and earlier
dates are history.
§Errors
CurveError::InvertedDates if horizon is on or before valuation.
pub fn step_of(&self, date: NaiveDate) -> Option<usize>
pub fn step_of(&self, date: NaiveDate) -> Option<usize>
The slice index of date: exact when date is a grid slice (every
mandatory date is), else the nearest slice by year fraction, or None
if date is outside the grid.
§Panics
Never in practice: construction always leaves at least the valuation slice, which is what the internal expect states.