Finance.js

repository·master·Indexed 22 days ago

https://github.com/ebradyjobory/finance.js

A pure JavaScript library (version 4.1.0) for common financial calculations without external dependencies. It provides a Finance class with methods to calculate Amortization (AM), Compound Annual Growth Rate (CAGR), Compound Interest (CI), Discount Factor (DF), Future Value (FV), Internal Rate of Return (IRR and XIRR), Leverage Ratio (LR), Net Present Value (NPV), Payback Period (PP), Present Value (PV), Profitability Index (PI), Return on Investment (ROI), Rule of 72 (R72), Weighted Average Cost of Capital (WACC), Loan Payment (PMT), Inflation-adjusted Return (IAR), CAPM, and Stock Present Value.

Tokens
2.3K
Snippets
2
Records
37
Agent score
29%

What's inside financejs

  1. Initialize Finance.js in JavaScript or TypeScript

    master

    To use the library, require or import the Finance class and instantiate it with new Finance().

    var Finance = require('financejs');
    var finance = new Finance();

    For TypeScript users:

    import { Finance } from 'financejs';
    let finance = new Finance();
  2. Install Finance.js

    master

    You can install Finance.js via npm to use it in your Node.js or frontend projects.

    Alternatively, you can download or fork the repository from GitHub, extract the finance.js file, and include it directly in your client-side application.

    npm install financejs --save
  3. Calculate XIRR with `finance.XIRR()`

    master

    Determines the Internal Rate of Return when cash flows occur at irregular intervals.

    Signature: finance.XIRR([cash flows], [dates], guess);

    • [cash flows]: Array of cash flow amounts.
    • [dates]: Array of Date objects corresponding to the cash flows.
    • guess: An initial guess for the IRR.
  4. Calculate Weighted Average Cost of Capital (WACC) with `finance.WACC()`

    master

    Calculates the rate that a company is expected to pay on average to all its security holders to finance its assets.

    Signature: finance.WACC(market value of equity, market value of debt, cost of equity, cost of debt, tax rate);