2

I'm developing a new web-based financial application for our company that provides online real-time non-post-back calculation of IRR, and PMT. So, I'm looking for the implementation/library which provides the IRR and PMT functionality in JavaScript. Please kindly suggest.

Thanks

William

William X
  • 6,751
  • 6
  • 31
  • 50
  • IRR and PMT because everyone knows what they stand for ;) – Halcyon Jun 02 '11 at 17:42
  • 1
    [IRR](http://office.microsoft.com/en-us/excel-help/irr-HP005209146.aspxn) (internal rate of return) and [PMT](http://office.microsoft.com/en-us/excel-help/pmt-HP005209215.aspx) (payment) are pretty common in financial circles. IRR is very common in business discussions. – Peter K. Jun 02 '11 at 17:47
  • @William Choi: Why not just implement [what's on Wikipedia](http://en.wikipedia.org/wiki/Internal_rate_of_return) for IRR? – Peter K. Jun 02 '11 at 17:48
  • @Peter, two reasons, first, proven as accurate, and time-to-market. Our development team involves only 2 developers. – William X Jun 02 '11 at 17:52
  • @William Choi: It's can be done as a one-line formula in both cases... and you prove accuracy by test cases! You do prove accuracy by test cases, don't you? – Peter K. Jun 02 '11 at 17:53
  • @Peter, thanks. I think I've to implement & test if I don't find any wheels. – William X Jun 02 '11 at 18:06

5 Answers5

1

About PMT,you can simply implement by yourself. The detail for PMT(rate, nper, pv): rate is monthly rate, means annual rate/12. nper is the loan terms,like 12,24,36. pv means loan amount.

fv=pv * pow((1 + rate), nper);

PMT=(fv * rate) / (pow((1 + rate), nper) - 1);
Ding
  • 61
  • 4
1

IRR: I just had a poke around and found the class org.apache.poi.ss.formula.functions.Irr, and there is a listing of it here.

Just make sure that you can abide by the license.

That library doesn't appear to have a direct implementation of PMT.

Peter K.
  • 8,028
  • 4
  • 48
  • 73
0

There is a gem in Ruby called Exonio: https://github.com/Noverde/exonio.

This gem implements some of the Excel financial formulas.

You can take a look at this gem and converts the calculations to Javascript.

rizidoro
  • 13,073
  • 18
  • 59
  • 86
0

check out: https://formulajs.info/

I was able to use this library to perform the built in Microsoft excel functions (such as IRR) needed

  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/29994421) – j__carlson Oct 05 '21 at 01:18
0

Here's a function that calculates the periodic payment for a loan, given the loan amount, interest rate, the number of payments, and the loan future value:

def pmt(rate, nper, pv, fv=0)
  pmt = rate * (fv + pv * (1 + rate)**nper) / ((1 + rate)**nper - 1)
  return -pmt
end

The rate parameter represents the interest rate per period, the nper parameter represents the total number of payment periods, the pv parameter represents the present value of the loan, and the fv parameter represents the future value of the loan at the end of the payment period.

For example, if you wanted to calculate the monthly payment for a $10,000 loan with a 5% interest rate over 3 years (36 months) with a future value of $5,000, you could call the function like this:

pmt(0.05/12, 36, 10000, 5000)

This would return the value of the monthly payment that you would need to make on the loan to pay off both the present value and the future value of the loan.

Jeremy Lynch
  • 6,780
  • 3
  • 52
  • 63