Get Finance NPV values as similar to Excel NPV function with Node package solution.
excel-npv makes it easy to incorporate common npv calculations into your application. The library is built on pure JavaScript without any dependencies.
This project is hosted on GitHub. You can report bugs and discuss features on the GitHub issues page.
npm install excel-npv --save
or
- Download or fork the repository from GitHub.
- Extract the file excel-npv from the project and include it in your application on the client side.
var Finance = require('excel-npv');
var finance = new Finance();
// To calculate NPV
finance.NPV(3.125, -100000, 50000, 40000, 30000, 20000);
// => 30,192.11
import { Finance } from 'excel-npv'
let finance = new Finance();
// To calculate NPV
finance.NPV(3.125, -100000, 50000, 40000, 30000, 20000);
// => 30,192.11
Net Present Value (NPV) compares the money received in the future to an amount of money received today, while accounting for time and interest [through the discount rate]. It's based on the principal of time value of money (TVM), which explains how time affects monetary value.1
[cash flows]
takes any number of projected cash flows.
// e.g., If discount rate is 10%, initial investment is -$1,000, cash flow in year 1 is $200,000, year 2 is $300,000, and year 3 is $200,000, the NPV is $80,015.03.
finance.NPV(10, -500000, 200000, 300000, 200000);
=> 72740.93
Contributions are welcome to aid in the expansion of the library. In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality, and please lint and test your code.