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
impl DayCountFraction
pub fn reads_end_of_month(self) -> bool
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
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
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
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
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
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
impl DayCountFraction
Trait Implementations§
§impl Clone for DayCountFraction
impl Clone for DayCountFraction
§fn clone(&self) -> DayCountFraction
fn clone(&self) -> DayCountFraction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DayCountFraction
§impl Debug for DayCountFraction
impl Debug for DayCountFraction
§impl Display for DayCountFraction
impl Display for DayCountFraction
impl Eq for DayCountFraction
§impl FromStr for DayCountFraction
impl FromStr for DayCountFraction
§impl Hash for DayCountFraction
impl Hash for DayCountFraction
§impl PartialEq for DayCountFraction
impl PartialEq for DayCountFraction
§fn eq(&self, other: &DayCountFraction) -> bool
fn eq(&self, other: &DayCountFraction) -> bool
self and other values to be equal, and is used by ==.