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.
Dateis au32newtype; range 1901-01-01..=2199-12-31. - Rule-based calendars. Composable holiday rules with a
fn(Date) -> boolescape 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.
- Act365
Fixed - 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’sActualActual::ISDA_Impl. - Bound
ActActICMA ActActICMAbound to a couponSchedulebyActActICMA::bind: the uniform two-dateDayCountAPI with stub handling driven by the schedule’s parallel reference dates, mirroringQuantLib’s schedule-carrying ISMA day counter.- Calendar
- A holiday calendar: a
Weekendconfiguration plus a sequence ofRules naming holidays’ natural dates. - Calendar
Builder - Owned counterpart to
Calendar;viewproduces a borrowedCalendarbacked by this builder’s storage. - Date
- A calendar date in the supported range 1901-01-01..=2199-12-31.
- Easter
Offset - A holiday rule fired
daysaway from Easter Sunday under a givenEasterMethod. Constructors default to Western (Gregorian) Easter; usenew_orthodoxfor Julian. - Fixed
Date - 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
Schedulewas generated from, retained so that schedule-defined day counts can extend its grid —QuantLib’sSchedulekeeps the same information in itstenor_andendOfMonth_members. - Last
Weekday - 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. - Schedule
Builder - Builder for
Schedule. Holds a borrowedCalendarfor the duration of the build call. - Thirty360
Bond - 30/360 Bond Basis (ISDA 2006). Matches
QuantLib’sThirty360::BondBasis. Not additive across splits. - Thirty360
European - 30E/360 (Eurobond Basis): both day-of-month values independently
capped at 30. Matches
QuantLib’sThirty360::EurobondBasis. - Thirty360ISDA
- 30E/360 (ISDA), a.k.a. 30/360 German:
Thirty360Europeanplus 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). MatchesQuantLib’sThirty360::ISDA. - Thirty360US
- 30/360 (US) — SIA convention: Bond Basis plus the
last-day-of-February rule, applied first. Matches
QuantLib’sThirty360::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 iffwis a weekend day. - Year
- A year in the range 1901..=2199.
- Year
Range - An inclusive range of
Years.
Enums§
- Business
DayConvention - How to roll a non-business date onto a business date.
- Date
Generation Rule - How to walk the schedule grid between effective and termination.
- Easter
Method - Which computus to use for Easter dates.
- Frequency
- How often cashflows recur per calendar year. Matches
QuantLib’s canonical frequencies;Frequency::per_yearis 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::Customholds a plainfnpointer to stayconst-constructible, which is whyRuleimplements neither serde traits norPartialEq. - Time
Error - Errors produced by
fasticonstructors. - Weekday
- Day of the week. Discriminants follow ISO 8601: Monday = 1 .. Sunday = 7.
- Weekend
Shift - Which way a fixed-date holiday moves when its natural date falls on a Saturday or Sunday.
Traits§
Functions§
- easter_
monday - Day-of-year of Easter Monday for
yearundermethod. - easter_
sunday - Day-of-year of Easter Sunday for
yearundermethod. This iseaster_mondayminus one.