use crate::time::day_counter::DayCounter;
use crate::time::schedule::Schedule;
use std::sync::Arc;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum SwapType {
#[default]
Payer,
Receiver,
}
#[derive(Clone)]
pub struct VanillaSwap {
swap_type: SwapType,
nominal: f64,
fixed_schedule: Schedule,
fixed_rate: f64,
fixed_day_counter: Arc<dyn DayCounter>,
floating_schedule: Schedule,
floating_day_counter: Arc<dyn DayCounter>,
spread: f64,
}
impl VanillaSwap {
#[allow(clippy::too_many_arguments)]
pub fn new(
swap_type: SwapType,
nominal: f64,
fixed_schedule: Schedule,
fixed_rate: f64,
fixed_day_counter: Arc<dyn DayCounter>,
floating_schedule: Schedule,
floating_day_counter: Arc<dyn DayCounter>,
spread: f64,
) -> Self {
Self {
swap_type,
nominal,
fixed_schedule,
fixed_rate,
fixed_day_counter,
floating_schedule,
floating_day_counter,
spread,
}
}
pub fn swap_type(&self) -> SwapType {
self.swap_type
}
pub fn nominal(&self) -> f64 {
self.nominal
}
pub fn fixed_schedule(&self) -> &Schedule {
&self.fixed_schedule
}
pub fn fixed_rate(&self) -> f64 {
self.fixed_rate
}
pub fn fixed_day_counter(&self) -> &dyn DayCounter {
self.fixed_day_counter.as_ref()
}
pub fn floating_schedule(&self) -> &Schedule {
&self.floating_schedule
}
pub fn floating_day_counter(&self) -> &dyn DayCounter {
self.floating_day_counter.as_ref()
}
pub fn spread(&self) -> f64 {
self.spread
}
}