quantlib_rs 0.1.0

A ground-up, idiomatic Rust quantitative finance library inspired by QuantLib.
Documentation
//! Cash flow traits and interfaces.

use crate::time::date::Date;

/// Common trait for all financial cash flows.
///
/// Implementors must be `Send + Sync` to support multi-threaded portfolio
/// discounting and curve calibration without lock contention.
pub trait CashFlow: Send + Sync {
    /// Return the payment date of the cash flow.
    fn date(&self) -> Date;

    /// Return the cash flow amount.
    fn amount(&self) -> f64;

    /// Return true if the cash flow has occurred strictly on or before `ref_date`.
    #[inline]
    fn has_occurred(&self, ref_date: Date) -> bool {
        self.date() <= ref_date
    }
}