Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Avhz RustQuant DateRollingConvention

From Leeroopedia


Knowledge Sources
Domains Calendar, Time_Value_of_Money
Last Updated 2026-02-07 19:00 GMT

Overview

Concrete tool for adjusting payment and settlement dates that fall on non-business days provided by the RustQuant library.

Description

The DateRollingConvention module defines the DateRollingConvention enum and its associated date adjustment methods. In finance, date rolling occurs when a payment day or accrual date falls on a holiday or weekend. The date must be moved forward or backward to a valid business day according to a specified convention.

The enum supports six conventions:

  • Actual -- the date is used as-is, even if it falls on a non-business day. This is the default convention.
  • Following -- the date is rolled forward to the next business day.
  • ModifiedFollowing -- the date is rolled forward to the next business day, but if that would push the date into the next calendar month, it is instead rolled backward to the previous business day. This is widely used by institutions with month-end accounting procedures.
  • Preceding -- the date is rolled backward to the previous business day.
  • ModifiedPreceding -- the date is rolled backward to the previous business day, but if that would push the date into the previous calendar month, it is instead rolled forward to the next business day.
  • ModifiedRolling -- the date is rolled forward to the next business day, and the adjusted date is used cumulatively for subsequent coupon dates (excluding month changes).

Each convention is implemented as a static method that takes a Date and a reference to a Calendar, and returns the adjusted Date. The implementations use the next_business_day and previous_business_day utility functions internally.

The enum is annotated with #[pyclass] and #[pymethods] for Python interoperability via PyO3. The Default trait is implemented, returning Actual.

Usage

Use this when adjusting payment dates, settlement dates, or coupon dates to valid business days. The convention is typically specified as part of a financial contract's terms and passed to Calendar::roll_date or Calendar::roll_dates.

Code Reference

Source Location

Signature

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[pyclass]
pub enum DateRollingConvention {
    Actual,
    Following,
    ModifiedFollowing,
    Preceding,
    ModifiedPreceding,
    ModifiedRolling,
}

impl Default for DateRollingConvention {
    fn default() -> Self { DateRollingConvention::Actual }
}

impl DateRollingConvention {
    pub(crate) fn roll_date_actual(date: Date, _calendar: &Calendar) -> Date;
    pub(crate) fn roll_date_following(date: Date, calendar: &Calendar) -> Date;
    pub(crate) fn roll_date_modified_following(date: Date, calendar: &Calendar) -> Date;
    pub(crate) fn roll_date_preceding(date: Date, calendar: &Calendar) -> Date;
    pub(crate) fn roll_date_modified_preceding(date: Date, calendar: &Calendar) -> Date;
    pub(crate) fn roll_date_modified_rolling(date: Date, calendar: &Calendar) -> Date;
}

Import

use RustQuant::time::date_rolling::DateRollingConvention;

I/O Contract

Inputs

Name Type Required Description
date Date Yes The date to adjust (roll) to a business day
calendar &Calendar Yes The market calendar used to determine business days and holidays

Outputs

Name Type Description
adjusted_date Date The date adjusted to a valid business day according to the convention

Usage Examples

use time::macros::date;
use RustQuant::time::calendar::{Calendar, Market};
use RustQuant::time::date_rolling::DateRollingConvention;

let calendar = Calendar::new(Market::UnitedStates);

// A Saturday falls on a non-business day.
let saturday = date!(2024-03-09);

// Following: rolls to the next business day (Monday March 11).
let following = calendar.roll_date(saturday, DateRollingConvention::Following);

// Preceding: rolls to the previous business day (Friday March 8).
let preceding = calendar.roll_date(saturday, DateRollingConvention::Preceding);

// Actual: returns the date unchanged.
let actual = calendar.roll_date(saturday, DateRollingConvention::Actual);
assert_eq!(actual, saturday);

// ModifiedFollowing: rolls forward unless it crosses a month boundary.
let end_of_month = date!(2024-03-30); // Saturday
let modified = calendar.roll_date(end_of_month, DateRollingConvention::ModifiedFollowing);
// If Monday April 1 is in a new month, rolls back to Friday March 29 instead.

// Roll multiple dates at once.
let dates = vec![date!(2024-03-09), date!(2024-03-10), date!(2024-03-16)];
let rolled = calendar.roll_dates(dates, DateRollingConvention::Following);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment