rateslib/scheduling/
dcfs.rs

1use pyo3::{pyclass, pyfunction};
2use serde::{Deserialize, Serialize};
3use std::cmp::PartialEq;
4
5#[pyclass(module = "rateslib.rs", eq, eq_int)]
6#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)]
7pub enum Convention {
8    /// Return 1.0 for any period.
9    One,
10    /// Number of months between dates divided by 12.
11    OnePlus,
12    /// Actual days in period divided by 365.
13    Act365F,
14    /// Number of whole years plus actual days in fractional periods divided by 365.
15    Act365FPlus,
16    /// Actual days in period divided by 360.
17    Act360,
18    ThirtyE360,
19    Thirty360,
20    Thirty360ISDA,
21    ActActISDA,
22    ActActICMA,
23    Bus252,
24}
25
26#[pyfunction]
27pub(crate) fn _get_convention_str(convention: Convention) -> String {
28    match convention {
29        Convention::Act365F => "Act365F".to_string(),
30        Convention::Act365FPlus => "Act365F+".to_string(),
31        Convention::Act360 => "Act360".to_string(),
32        Convention::Thirty360 => "30360".to_string(),
33        Convention::ThirtyE360 => "30e360".to_string(),
34        Convention::Thirty360ISDA => "30e360ISDA".to_string(),
35        Convention::ActActISDA => "ActActISDA".to_string(),
36        Convention::ActActICMA => "ActActICMA".to_string(),
37        Convention::One => "1".to_string(),
38        Convention::OnePlus => "1+".to_string(),
39        Convention::Bus252 => "Bus252".to_string(),
40    }
41}