Skip to main content

Crate fasti

Crate fasti 

Source
Expand description

Dates, calendars, business-day conventions, and day-count fractions.

fasti is a standalone Rust time library for financial code, designed after QuantLib’s ql/time. Runtime deps: thiserror only; #![no_std]-compatible with alloc. Opt-in features: serde (derives) and chrono (conversions).

§Design principles

  • No float arithmetic. Day-count fractions return integer rationals.
  • Const-first. Primitive constructors and built-in calendars are const.
  • Integer serial dates. Date is a u32 newtype; range 1901-01-01..=2199-12-31.
  • Rule-based calendars. Composable holiday rules with a fn(Date) -> bool escape hatch.

§Roadmap

Landed today: date primitives (Date, Year, Month, Weekday, Ordinal, DateRange), holiday rules (Rule and friends), Easter tables (easter_monday, easter_sunday), YearRange, Calendar / CalendarBuilder with built-ins under calendars, Period / Frequency arithmetic, BusinessDayConvention with Calendar::adjust and Calendar::advance, the Fraction type, the DayCount trait and its conventions, Schedule / ScheduleBuilder, and the TimeError type.

Planned:

  • CDS/IMM schedule rules and the long-tail day counts

Modules§

calendars
Built-in calendars, grouped by country / market. Every calendar is a pub const Calendar<'static>, passed by value (Copy).

Structs§

Act360
Actual/360: calendar days over 360. Standard for USD money-market and most floating-rate structured-credit accruals.
Act365Fixed
Actual/365 (Fixed): calendar days over 365, regardless of leap years. Standard for GBP money markets.
ActActICMA
Actual/Actual (ICMA), ICMA Rule 251 — the standard for fixed-rate bond accruals: a regular coupon period accrues exactly 1 / frequency, days accrue proportionally against their period’s actual length, and stubs accrue against a notional coupon grid.
ActActISDA
Actual/Actual (ISDA): splits at calendar-year boundaries, weighting leap-year days by 1/366 and others by 1/365. Matches QuantLib’s ActualActual::ISDA_Impl.
BoundActActICMA
ActActICMA bound to a coupon Schedule by ActActICMA::bind: the uniform two-date DayCount API with stub handling driven by the schedule’s parallel reference dates, mirroring QuantLib’s schedule-carrying ISMA day counter.
Calendar
A holiday calendar: a Weekend configuration plus a sequence of Rules naming holidays’ natural dates.
CalendarBuilder
Owned counterpart to Calendar; view produces a borrowed Calendar backed by this builder’s storage.
Date
A calendar date in the supported range 1901-01-01..=2199-12-31.
EasterOffset
A holiday rule fired days away from Easter Sunday under a given EasterMethod. Constructors default to Western (Gregorian) Easter; use new_orthodox for Julian.
FixedDate
A fixed-date holiday rule.
Fraction
An integer rational numerator / denominator, stored in reduced form (no common factor between |numerator| and denominator).
Generation
The parameters a Schedule was generated from, retained so that schedule-defined day counts can extend its grid — QuantLib’s Schedule keeps the same information in its tenor_ and endOfMonth_ members.
LastWeekday
A holiday rule that fires on the last occurrence of a weekday in a month.
NthWeekday
A holiday rule that fires on the Nth occurrence of a weekday in a month (e.g. “Third Monday of January”).
OneOff
A holiday observed on exactly one date.
Schedule
Parallel lists of business-day-adjusted dates in chronological order, each of length periods + 1: the coupon dates, and the reference dates of the regular coupon grid.
ScheduleBuilder
Builder for Schedule. Holds a borrowed Calendar for the duration of the build call.
Thirty360Bond
30/360 Bond Basis (ISDA 2006). Matches QuantLib’s Thirty360::BondBasis. Not additive across splits.
Thirty360European
30E/360 (Eurobond Basis): both day-of-month values independently capped at 30. Matches QuantLib’s Thirty360::EurobondBasis.
Thirty360ISDA
30E/360 (ISDA), a.k.a. 30/360 German: Thirty360European plus February handling — a last-of-February day counts as 30, except an end date equal to the instrument’s termination date (hence the constructor argument). Matches QuantLib’s Thirty360::ISDA.
Thirty360US
30/360 (US) — SIA convention: Bond Basis plus the last-day-of-February rule, applied first. Matches QuantLib’s Thirty360::USA.
Weekend
The set of weekdays a calendar treats as non-business days on weekly cadence (independent of any holiday rule). Bit layout: bit (w.get() - 1) is set iff w is a weekend day.
Year
A year in the range 1901..=2199.
YearRange
An inclusive range of Years.

Enums§

BusinessDayConvention
How to roll a non-business date onto a business date.
DateGenerationRule
How to walk the schedule grid between effective and termination.
EasterMethod
Which computus to use for Easter dates.
Frequency
How often cashflows recur per calendar year. Matches QuantLib’s canonical frequencies; Frequency::per_year is always positive.
Month
A month of the year, discriminant 1..=12.
Ordinal
An ordinal position within a month for nth-weekday rules. “First” = first occurrence, “Fifth” = fifth (which may not exist in every month).
Period
A signed duration tagged by its calendar unit.
Rule
A holiday rule matching a holiday’s natural date. Rule::Custom holds a plain fn pointer to stay const-constructible, which is why Rule implements neither serde traits nor PartialEq.
TimeError
Errors produced by fasti constructors.
Weekday
Day of the week. Discriminants follow ISO 8601: Monday = 1 .. Sunday = 7.
WeekendShift
Which way a fixed-date holiday moves when its natural date falls on a Saturday or Sunday.

Traits§

DateRange
Date-aware operations on a half-open range start..end.
DayCount
A day-count convention.

Functions§

easter_monday
Day-of-year of Easter Monday for year under method.
easter_sunday
Day-of-year of Easter Sunday for year under method. This is easter_monday minus one.