[][src]Function finance_solution::convert_epr_to_ear_solution

pub fn convert_epr_to_ear_solution(
    epr: f64,
    compounding_periods_in_year: u32
) -> ConvertRateSolution

Convert a periodic rate (EPR) to effective annual rate (EAR), returning a solution struct with additionality information and features.

Related Functions:

The formula is:

Arguments

  • epr - The input rate (periodic rate), expressed as a floating point number. For instance 0.05 indicates 5%. Often appears as r or i in formulas.
  • periods - The number of compounding periods in a year. Often appears as n or t.

Panics

  • periods - must be a u32 value greater than or equal to 1.

Example

Convert a periodic rate to effective annual rate.

use finance_solution::*;
// The periodic rate is 3.4534%. There are 12 compounding periods per year.
let (periodic_rate, periods) = (0.034, 12);

let epr_to_ear_solution = convert_rate::convert_epr_to_ear_solution(periodic_rate, periods);
 
// Confirm that the EAR is correct.
assert_approx_equal!(0.49364182107104493, epr_to_ear_solution.ear());