[][src]Function finance_solution::convert_ear_to_apr

pub fn convert_ear_to_apr(ear: f64, compounding_periods_in_year: u32) -> f64

Convert an EAR to APR. Returns f64.

Related Functions:

  • ear to convert EAR to all forms of rate conversion, and return a custom type with additional functionality and extra information available in the dbg!().
  • convert_ear_to_apr_solution to convert EAR to APR and return a custom type with additional functionality and extra information available in the dbg!().

The formula is:

Note: This formula involves converting the EAR to EPR first, and then converting the EPR to APR.

Arguments

  • rate - The input rate, expressed as a floating point number. For instance 0.05 would mean 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 0.

Example

Convert effective annual rate (EAR) to annual percentage rate (APR).

use finance_solution::*;
// The effective annual rate is 3.4534%
// There are 12 compounding periods per year.
let effective_annual_rate = 0.03453486936;
let periods = 12;

let nominal_rate = convert_rate::convert_ear_to_apr(effective_annual_rate, periods);
 
// Confirm that the APR is correct.
assert_approx_equal!(0.034, nominal_rate);