Skip to main content

DayCountFraction

Enum DayCountFraction 

pub enum DayCountFraction {
    Act360,
    Act365Fixed,
    Nl365,
    Thirty360,
    Thirty360Us,
    ThirtyE360,
    ThirtyE360Isda,
    ActActIsda,
    ActActIcma,
    ActActAfb,
    Bus252,
    One,
}
Expand description

Year-fraction conventions, named per the FpML day-count-fraction scheme.

Variants§

§

Act360

ACT/360 — actual days over 360.

§

Act365Fixed

ACT/365.FIXED — actual days over 365.

§

Nl365

NL/365 — actual days excluding any 29 February, over 365 (the JGB accrued basis; the no-leap variant of ACT/365.FIXED). A leap day strictly inside the window is not counted; a leap-day endpoint is treated as 28 February.

§

Thirty360

30/360 — the ISDA 2006 §4.16(f) bond basis: no February rule.

§

Thirty360Us

30U/360 — SIFMA’s 30/360 US for securities. The bond basis plus the February rules of an end-of-month security: when the period context states the schedule rolls on the month end, a start on the last day of February counts as the 30th, and so does an end on the last day of February when the start is one too. The end-of-month statement is PeriodContext::Scheduled’s end_of_month; without a context (the two-date form, PeriodContext::Simple) the February rules do not fire and the value is 30/360’s.

§

ThirtyE360

30E/360 — Eurobond 30/360.

§

ThirtyE360Isda

30E/360.ISDA — 30E/360 with the ISDA end-of-month rule.

§

ActActIsda

ACT/ACT.ISDA — actual/actual split across calendar years.

§

ActActIcma

ACT/ACT.ICMA — actual/actual reference-period basis. A scheduled context supplies the reference period; without one the two dates are their own reference period — a period of round(12·days/365) months.

§

ActActAfb

ACT/ACT.AFB — actual/actual French (AFB) basis.

§

Bus252

BUS/252 — business days over 252. BUS/252 is the Brazilian convention (B3, ANBIMA; ISDA’s Brazil business days), so the plain DayCountFraction::year_fraction counts BRBD business days; pass another calendar via DayCountFraction::year_fraction_with_calendar.

§

One

1/1 — one per period whatever its length (FpML’s 1/1): a zero-coupon period accrues its whole rate once. A zero-length span accrues 0, and a reversed one −1.

Implementations§

§

impl DayCountFraction

pub fn code(self) -> &'static str

The FpML scheme code string (e.g. "ACT/ACT.ISDA").

pub fn reads_end_of_month(self) -> bool

Whether this convention reads the period context’s end-of-month flag — 30U/360 alone, whose February rules apply to an end-of-month schedule. A caller measuring outside an accrual period (a yield’s time axis) hands the schedule’s flag only to a convention that reads it.

pub fn telescopes_daily(self) -> bool

Whether daily accrual fractions telescope: for contiguous dates d₀ < d₁ < … < dₙ, Σ year_fraction(dᵢ, dᵢ₊₁) = year_fraction(d₀, dₙ) exactly in real arithmetic (to ulps in floating point). True for the fixed-denominator date-difference counts — the RFR universe — where the fraction is actual_days / constant. False for the 30/360 family (day numbers snap, so consecutive-date fractions are not differences), the ACT/ACT family (per-interval denominators), and BUS/252 (business-day numerator needs a calendar walk). Consumers use this to collapse a summed daily grid into one end-to-end fraction (e.g. the overnight coupon’s deferred observation grid).

pub(crate) fn splits_additively(self) -> bool

Whether the context-free fraction splits additively at any interior date: year_fraction(a, m) + year_fraction(m, b) = year_fraction(a, b) for every a ≤ m ≤ b, in exact arithmetic.

True where each date maps to one day number whichever end of a span it is — the actual-day counts, 30E/360 and 30E/360.ISDA (both snap a 31st to the 30th either way) — and for ACT/ACT.ISDA and BUS/252, whose numerators are counts over the span. False for 30/360 and 30U/360, where a 31st stays the 31st at the end of a span that did not start on a 30th, for ACT/ACT.AFB, and for ACT/ACT.ICMA, whose denominators are the span’s own.

A bond’s yield time axis reads it: where the fraction does not split, a time is accumulated period by period.

pub fn year_fraction(self, start: NaiveDate, end: NaiveDate) -> f64

The accrual year fraction between start and end (end >= start).

This is the context-free convenience form: it is exact for the eight conventions that do not need period context (ACT/360, ACT/365.FIXED, NL/365, 30/360, 30E/360, ACT/ACT.ISDA, ACT/ACT.AFB, BUS/252). 30E/360.ISDA evaluates without the February-maturity exception (the common case), and 30U/360 without the end-of-month February rules.

ACT/ACT.ICMA has no reference period here, so the two dates are their own: a regular coupon period is exactly its share of a year. A bond’s accrual, whose reference period is the schedule’s, supplies a PeriodContext::Scheduled through DayCountFraction::year_fraction_with_context.

For BUS/252 this counts Brazilian (BRBD) business days, the calendar the convention belongs to; use DayCountFraction::year_fraction_with_calendar to count against another one.

pub fn year_fraction_with_context( self, start: NaiveDate, end: NaiveDate, context: PeriodContext, ) -> f64

The accrual year fraction between start and end, given the period context a period-aware convention may require.

The eight context-free conventions ignore context. ACT/ACT.ICMA measures against the context’s reference period, and under PeriodContext::Simple against the two dates themselves, as year_fraction does. 30E/360.ISDA consults the context’s schedule end to suppress the day-30 collapse at a February maturity. 30U/360 applies its February rules when the context states an end-of-month schedule.

pub fn year_fraction_with_calendar( self, start: NaiveDate, end: NaiveDate, calendar: &dyn Calendar, ) -> f64

The accrual year fraction between start and end, counting BUS/252 business days against calendar (so jurisdiction holidays are excluded, not just weekends). Every other convention is a deterministic function of the two dates and ignores calendar, delegating to DayCountFraction::year_fraction.

§

impl DayCountFraction

pub const ACCEPTED: &'static [&'static str]

Every spelling this vocabulary accepts, canonical forms first.

pub(crate) fn recognize(s: &str) -> Option<Self>

The value s spells, or None — the parse without its error, so probing a spelling that is not this vocabulary’s allocates nothing.

Trait Implementations§

§

impl Clone for DayCountFraction

§

fn clone(&self) -> DayCountFraction

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 Copy for DayCountFraction

§

impl Debug for DayCountFraction

§

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

Formats the value using the given formatter. Read more
§

impl Display for DayCountFraction

§

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

Formats the value using the given formatter. Read more
§

impl Eq for DayCountFraction

§

impl FromStr for DayCountFraction

§

type Err = VocabularyParseError

The associated error which can be returned from parsing.
§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
§

impl Hash for DayCountFraction

§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for DayCountFraction

§

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

impl StructuralPartialEq for DayCountFraction

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.