use crate::currency::Currency;
use crate::handle::Handle;
use crate::indexes::iborindex::OvernightIndex;
use crate::settings::Settings;
use crate::shared::Shared;
use crate::termstructures::yieldtermstructure::YieldTermStructure;
use crate::time::calendars::target::Target;
use crate::time::date::Date;
use crate::time::daycounters::actual360::Actual360;
pub struct Estr;
impl Estr {
#[allow(clippy::new_ret_no_self)]
pub fn new(
forwarding: Handle<dyn YieldTermStructure>,
settings: Shared<Settings<Date>>,
) -> OvernightIndex {
OvernightIndex::new(
"ESTR".into(),
0,
Currency::eur(),
Target::new(),
Actual360::new(),
forwarding,
settings,
)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::indexes::index::Index;
use crate::indexes::interestrateindex::InterestRateIndex;
use crate::shared::shared;
use crate::time::businessdayconvention::BusinessDayConvention;
use crate::time::period::Period;
use crate::time::timeunit::TimeUnit;
#[test]
fn estr_matches_the_quantlib_construction_table() {
let settings = shared(Settings::<Date>::new());
let index = Estr::new(Handle::empty(), settings);
assert_eq!(index.name(), "ESTRON Actual/360");
assert_eq!(index.fixing_days(), 0);
assert_eq!(*index.currency(), Currency::eur());
assert_eq!(index.fixing_calendar().name(), "TARGET");
assert_eq!(index.day_counter().name(), "Actual/360");
assert_eq!(index.tenor(), Period::new(1, TimeUnit::Days));
assert_eq!(
index.business_day_convention(),
BusinessDayConvention::Following
);
assert!(!index.end_of_month());
}
}