Finance.ts
Introduction
Finance.ts makes it easy to incorporate common financial calculations into your application. The library is built in Typescript without any dependencies.
This is a fork of https://github.com/ebradyjobory/finance.js.
Major differences:
- Written in Strict Typescript
- ESM and CJS compatible
- No more classes, just pure functions
- Functions are written without using arguments and rest parameters
- Functions with more than 3 parameters uses object parameters instead
- Functions uses booleans and enums instead of integer flags
Getting Started
``lang=bash
npm install @founderpath/financets --save
`
Example Usage
`lang=ts
import { AM } from "@founderpath/financets"
AM({
principal: 20000,
rate: 7.5,
period: 5,
yearOrMonth: "year",
payAtBeginning: false,
});
// => 400.76
``
Available Functions
These are the available functions. Please refer to the typescript definition itself and/or tests for usage.
$3
Amortization (AM) is the paying off of debt with a fixed repayment schedule in regular installments over a period of time.
$3
Compound Annual Growth Rate (CAGR) is the year-over-year growth rate of an investment over a specified period of time.
$3
Capital Asset Pricing Model (CAPM) describes the relationship between systematic risk, or the general perils of investing, and expected return for assets, particularly stocks.
$3
Compound Interest (CI) is the interest calculated on the initial principal and also on the accumulated interest of previous periods of a deposit or loan.
$3
Discount Factor (DF) is the factor by which a future cash flow must be multiplied in order to obtain the present value.
$3
Future Value (FV) is the value of an asset or cash at a specified date in the future that is equivalent in value to a specified sum today
$3
Inflation-adjusted return (IAR) measures the return taking into account the time period's inflation rate
$3
Internal Rate of Return (IRR) is the discount rate often used in capital budgeting that makes the net present value of all cash flows from a particular project equal to zero.
$3
Leverage Ratio (LR) is used to calculate the financial leverage of a company or individual to get an idea of the methods of financing or to measure ability to meet financial obligations.
$3
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.
$3
Profitability Index (PI) is an index that attempts to identify the relationship between the costs and benefits of a proposed project through the use of a ratio calculated.
$3
Loan Payment per Period (PMT) calculates payment for a loan based on constant payments and a constant interest rate
$3
Payback Period (PP) is the length of time required to recover the cost of an investment.
$3
Present Value (PV) is the current worth of a future sum of money or stream of cash flows given a specified rate of return
$3
Rule of 72 (R72) is a rule stating that in order to find the number of years required to double your money at a given interest rate, you divide the compound return into 72.
$3
Return on Investment (ROI) is a simple calculation that tells you the bottom line return of any investment.
$3
Weighted Average Cost of Capital (WACC) is the rate that a company is expected to pay on average to all its security holders to finance its assets.
$3
XIRR is used to determine the Internal Rate of Return when the cash flows are at Irregular intervals.