Skip to content

Commit

Permalink
Using a 100-based rate on PMT, just like all other functions - and re…
Browse files Browse the repository at this point in the history
…turning the value without changing the sign, as usual
  • Loading branch information
igorsantos07 committed Jan 20, 2017
1 parent 47ee481 commit b6d7dbe
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions finance.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Finance.PV = function (rate, cf1) {

/**
* Present Value of Annuity.
* @param rate Rate of interest, 100-based (15% = 15)
* @param cf0 Initial cash flow
* @param rate Rate of interest, 100-based (15% = 15), per period
* @param cf0 Initial cash flow
* @param numOfPeriod
* @returns {number}
* @see http://www.financeformulas.net/Present_Value_of_Annuity.html
Expand Down Expand Up @@ -195,9 +195,17 @@ Finance.WACC = function(marketValueOfEquity, marketValueOfDebt, costOfEquity, co
return Math.round(WACC * 1000) / 10;
};

// PMT calculates the payment for a loan based on constant payments and a constant interest rate
Finance.PMT = function(fractionalRate, numOfPayments, principal) {
return -principal * fractionalRate/(1-Math.pow(1+fractionalRate,-numOfPayments))
/**
* Loan Payment calculation.
* @param rate Rate of interest, 100-based (15% = 15), per period
* @param principal Loan amount
* @param numOfPayments
* @see http://www.financeformulas.net/Loan_Payment_Formula.html
*/
Finance.PMT = function (rate, numOfPayments, principal) {
var rate = rate/100, pmt;
pmt = (principal * rate) / (1 - Math.pow(1 + rate, -numOfPayments))
return Math.round(pmt * 100) / 100;
};

// IAR calculates the Inflation-adjusted return
Expand Down

0 comments on commit b6d7dbe

Please sign in to comment.