Skip to main content

LagAdjustment

Struct LagAdjustment 

pub struct LagAdjustment {
    pub offset: i32,
    pub unit: PaymentLagUnit,
    pub convention: BusinessDayConvention,
    pub calendar: Arc<dyn Calendar>,
}
Expand description

A payment-lag (or generic date) adjustment.

apply advances by offset × unit on the calendar and then rolls by the convention. A zero business-day offset is the identity on a date that is already a good business day, so “no lag” keeps the payment date equal to the accrual end.

Fields§

§offset: i32

Signed offset length in units; negative looks back.

§unit: PaymentLagUnit

The unit the offset is measured in.

§convention: BusinessDayConvention

The business-day convention applied after advancing.

§calendar: Arc<dyn Calendar>

The calendar the offset and convention roll against.

Implementations§

§

impl LagAdjustment

pub fn business_days( offset: i32, convention: BusinessDayConvention, calendar: Arc<dyn Calendar>, ) -> Self

A T+offset business-days lag against (convention, calendar).

pub fn from_payment_lag( lag: &Period, calendar: Arc<dyn Calendar>, ) -> Option<Self>

The adjustment a template’s payment lag implies, or None for a zero lag — which is the identity, and an identity adjustment is better left absent than applied.

This is the half of the reference-data layer’s payment-lag test that could not live there: the lag values are reference data, but what a lag means for a cashflow is this layer’s business.

pub fn apply(&self, date: NaiveDate) -> NaiveDate

Advances date by offset × unit on the calendar, then adjusts.

For PaymentLagUnit::BusinessDays each counted step already lands on a business day, so no post-adjustment is needed; for calendar units the advanced date is rolled by the convention.

Trait Implementations§

§

impl Clone for LagAdjustment

§

fn clone(&self) -> LagAdjustment

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 LagAdjustment

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for LagAdjustment

§

fn eq(&self, other: &Self) -> 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.

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.