quantlib_rs 0.1.0

A ground-up, idiomatic Rust quantitative finance library inspired by QuantLib.
Documentation
//! Simple deterministic cash flow (e.g., principal redemption, fee).

use crate::cashflows::traits::CashFlow;
use crate::time::date::Date;

/// A simple deterministic cash flow with a fixed date and amount.
///
/// Typically used for principal bullet redemptions, initial disbursements, or upfront fees.
///
/// # Examples
/// ```
/// use quantlib_rs::cashflows::simple::SimpleCashFlow;
/// use quantlib_rs::cashflows::traits::CashFlow;
/// use quantlib_rs::time::date::{Date, Month};
///
/// let payment_date = Date::from_ymd(2034, Month::May, 15).unwrap();
/// let principal = SimpleCashFlow::new(100.0, payment_date);
///
/// assert_eq!(principal.amount(), 100.0);
/// assert_eq!(principal.date(), payment_date);
/// assert!(!principal.has_occurred(Date::from_ymd(2026, Month::September, 3).unwrap()));
/// ```
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SimpleCashFlow {
    amount: f64,
    date: Date,
}

impl SimpleCashFlow {
    /// Create a new simple cash flow.
    pub const fn new(amount: f64, date: Date) -> Self {
        Self { amount, date }
    }
}

impl CashFlow for SimpleCashFlow {
    #[inline]
    fn date(&self) -> Date {
        self.date
    }

    #[inline]
    fn amount(&self) -> f64 {
        self.amount
    }
}