use crate::{
cashflows::cashflow::{Cashflow, Side},
currencies::enums::Currency,
rates::interestrate::RateDefinition,
};
use super::{instrument::RateType, traits::Structure};
#[derive(Debug, Clone)]
pub struct Leg {
structure: Structure,
rate_type: RateType,
rate_value: f64,
rate_definition: RateDefinition,
currency: Currency,
side: Side,
discount_curve_id: Option<usize>,
forecast_curve_id: Option<usize>,
cashflows: Vec<Cashflow>,
}
impl Leg {
#[allow(clippy::missing_const_for_fn)]
#[must_use]
#[allow(clippy::too_many_arguments)]
pub fn new(
structure: Structure,
rate_type: RateType,
rate_value: f64,
rate_definition: RateDefinition,
currency: Currency,
side: Side,
discount_curve_id: Option<usize>,
forecast_curve_id: Option<usize>,
cashflows: Vec<Cashflow>,
) -> Self {
Self {
structure,
rate_type,
rate_value,
rate_definition,
currency,
side,
discount_curve_id,
forecast_curve_id,
cashflows,
}
}
#[must_use]
pub fn cashflows(&self) -> &[Cashflow] {
&self.cashflows
}
#[must_use]
pub const fn structure(&self) -> Structure {
self.structure
}
#[must_use]
pub const fn rate_type(&self) -> RateType {
self.rate_type
}
#[must_use]
pub const fn rate_value(&self) -> f64 {
self.rate_value
}
#[must_use]
pub const fn rate_definition(&self) -> RateDefinition {
self.rate_definition
}
#[must_use]
pub const fn currency(&self) -> Currency {
self.currency
}
#[must_use]
pub const fn side(&self) -> Side {
self.side
}
#[must_use]
pub const fn discount_curve_id(&self) -> Option<usize> {
self.discount_curve_id
}
#[must_use]
pub const fn forecast_curve_id(&self) -> Option<usize> {
self.forecast_curve_id
}
pub fn clear(&mut self) {
self.cashflows.clear();
}
}