lib/exonio/financial.rb in exonio-0.6.1 vs lib/exonio/financial.rb in exonio-0.7.0

- old
+ new

@@ -15,9 +15,25 @@ # def effect(rate, nper) (1 + rate / nper) ** nper - 1 end + # Calculates the nominal interest rate when given an effective annual interest rate and the number of compounding periods per year. + # The effective rate is the actual rate due to compounding. The nominal rate is typically the stated rate. + # + # @param rate [Float] The effective annual interest rate as decimal (not per cent). + # @param npery [Integer] Number of compounding periods per year. + # + # @return [Float] + # + # @example + # Exonio.nominal(0.05, 12 / 2) # ==> 0.04939015319191986 + # + def nominal(rate, npery) + npery * ((1 + rate)**(1.0/npery) - 1) + end + + # Calculates the future value of an annuity investment based on # constant-amount periodic payments and a constant interest rate. # # @param rate [Float] The interest rate as decimal (not per cent) per period # @param nper [Integer] The number of compounding periods