Struct RateConvention
pub struct RateConvention {
pub day_count: DayCountFraction,
pub compounding: Compounding,
pub frequency: Frequency,
}Expand description
A rate quotation convention: the (day_count, compounding, frequency) triple
that determines how a rate relates to a discount factor over a period.
frequency is read only when compounding is Compounding::Compounded;
for Compounding::Simple and Compounding::Continuous it is ignored.
Fields§
§day_count: DayCountFractionHow the accrual period is measured.
compounding: CompoundingHow interest accrues over the period.
frequency: FrequencyThe compounding frequency (used only for Compounding::Compounded).
Implementations§
§impl RateConvention
impl RateConvention
pub fn new(
day_count: DayCountFraction,
compounding: Compounding,
frequency: Frequency,
) -> Self
pub fn new( day_count: DayCountFraction, compounding: Compounding, frequency: Frequency, ) -> Self
Builds a rate convention from its components.
pub fn rate_from_discount<R: Real<Passive = f64>>(&self, df: R, tau: f64) -> R
pub fn rate_from_discount<R: Real<Passive = f64>>(&self, df: R, tau: f64) -> R
The rate implied by a discount factor df over a year fraction tau,
under this convention’s compounding. Returns 0 for tau <= 0.
Generic in the AD mode: df may be a passive f64, a forward dual, or a
tape-registered reverse-mode scalar, and the rate comes back in the same
mode. The conversion is the same arithmetic either way — only the caller
decides whether a derivative rides along.
pub fn discount_from_rate<R: Real<Passive = f64>>(&self, rate: R, tau: f64) -> R
pub fn discount_from_rate<R: Real<Passive = f64>>(&self, rate: R, tau: f64) -> R
The discount factor implied by a rate rate over a year fraction tau,
under this convention’s compounding. Returns 1 for tau <= 0.
The inverse of rate_from_discount, and
generic in the AD mode for the same reason.
Trait Implementations§
§impl Clone for RateConvention
impl Clone for RateConvention
§fn clone(&self) -> RateConvention
fn clone(&self) -> RateConvention
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more