Skip to main content

TimeGrid

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

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>

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 n_steps(&self) -> usize

The number of steps (dates.len() − 1).

pub fn dt(&self, i: usize) -> f64

The step size t_{i+1} − t_i of step i.

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.

Trait Implementations§

§

impl Clone for TimeGrid

§

fn clone(&self) -> TimeGrid

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 TimeGrid

§

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

Formats the value using the given formatter. Read more

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.