
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
FinMaster: The ultimate toolkit for advanced financial calculations and analysis, designed to empower financial professionals and developers alike.
FinMaster is a comprehensive financial calculation library for Node.js, providing functions to calculate Present Value (PV), Future Value (FV), Payment (PMT), Net Present Value (NPV), Internal Rate of Return (IRR), Rate (RATE) and other Advance functions.
To install FinMaster, use npm:
npm install finmaster
First, install FinMaster from npm:
npm install finmaster
Then, import FinMaster into your project:
const FinMaster = require("finmaster");
const finMaster = new FinMaster();
let pv = finMaster.PV(0.05, 10, 1000);
console.log("Present Value:", pv);
If you are using ES6 modules (recommended for newer Node.js projects or with TypeScript):
npm install finmaster
Import FinMaster into your project:
import FinMaster from "finmaster";
const finMaster = new FinMaster();
let pv = finMaster.PV(0.05, 10, 1000);
console.log("Present Value:", pv);
For TypeScript users, ensure you have typings installed:
npm install finmaster
Then, import and use FinMaster:
import { FinMaster } from "finmaster";
const finMaster = new FinMaster();
let pv = finMaster.PV(0.05, 10, 1000);
console.log("Present Value:", pv);
The PV (Present Value) function is used to calculate the present value of an investment or loan based on a series of future payments. This is particularly useful in financial analysis to determine how much a series of future payments is worth in today's terms, given a specific interest rate.
const pv = finMaster.PV(rate, nper, pmt, fv, type);
Imagine you want to find out the present value of receiving $1,000 annually for 5 years with an annual interest rate of 5%.
const pv = finMaster.PV(0.05, 5, -1000);
This function returns approximately -$4329.48, meaning the present value of receiving $1,000 annually for 5 years at a 5% interest rate is about $4329.48 today.
Suppose you are considering an investment that pays $500 per month for the next 3 years and the interest rate is 6% annually. You want to find out the present value of this investment.
The function in Javascript:
const pv = finMaster.PV(0.005, 36, -500);
This function will give you the present value of the investment based on the specified parameters.
By understanding and using the PV function, you can make more informed financial decisions by comparing the value of different investments or loans.
The FV (Future Value) function is used to calculate the future value of an investment based on periodic, constant payments and a constant interest rate. This function helps in determining how much an investment will grow over time.
const fv = finMaster.FV(rate, nper, pmt, pv, type);
Imagine you want to find out the future value of saving $200 monthly for 5 years with an annual interest rate of 5%.
The function in Javascript would look like this:
const fv = finMaster.FV(0.004167, 60, -200);
This function returns approximately $13,243.44, meaning the future value of saving $200 monthly for 5 years at a 5% annual interest rate is about $13,243.44.
Suppose you are planning to save $500 monthly for 10 years in an investment account that offers a 6% annual interest rate compounded monthly. You want to find out how much you will have at the end of the 10 years.
The function in Javascript:
const fv = finMaster.FV(0.005, 120, -500);
This function will give you the future value of the investment based on the specified parameters.
By understanding and using the FV function, you can plan for future financial goals, such as saving for retirement, a down payment on a house, or other long-term objectives.
The PMT function is used to calculate the payment for a loan based on constant payments and a constant interest rate. This function is helpful in determining the regular payment amount needed to pay off a loan or an investment over a specified period.
const pmt = finMaster.PMT(rate, nper, pv, fv, type);
Imagine you take out a loan of $10,000 to be paid back over 5 years with an annual interest rate of 6%.
const pmt = finMaster.PMT(0.005, 60, 10000);
This function returns approximately -$193.33, meaning the monthly payment to pay off the $10,000 loan over 5 years at a 6% annual interest rate is about $193.33.
Suppose you are planning to save $15,000 over 3 years in an investment account that offers a 4% annual interest rate compounded monthly. You want to find out how much you need to deposit each month.
The function in Javascript:
const pmt = finMaster.PMT(0.00333, 36, 0, 15000);
This function will give you the monthly payment amount needed to reach your savings goal based on the specified parameters.
By using the PMT function, you can plan and manage your loan repayments or savings deposits efficiently, ensuring that you meet your financial goals.
The NPV (Net Present Value) function is used to calculate the net present value of an investment based on a series of periodic cash flows and a discount rate. It is particularly useful for evaluating the profitability of an investment or project by determining the present value of future cash flows minus the initial investment.
const npv = finMaster.NPV(rate, cashFlows);
Imagine you want to evaluate an investment that requires an initial investment of $10,000 and provides annual returns of $3,000, $4,000, $5,000, and $6,000 over the next four years. You want to calculate the NPV of these cash flows assuming a discount rate of 8%.
The initial investment of $10,000 should be subtracted from the result of the NPV function.
The function in Javascript would look like this:
let rate = 0.08;
let cashFlow = [3000, 4000, 5000, 6000];
const npv = finMaster.NPV(rate, cashFlow) - 10000;
This function returns approximately $4586.47 meaning the net present value of the investment, considering the initial $10,000 investment and the 8% discount rate, is about $4586.47.
Suppose you are considering a project that requires an initial investment of $20,000 and will generate annual returns of $5,000, $7,000, $8,000, and $10,000 over the next four years. You want to calculate the NPV with a discount rate of 10%.
The initial investment of $20,000 should be subtracted from the result of the NPV function.
The function in Javascript:
let rate = 0.1;
let cashFlow = [5000, 7000, 8000, 10000];
const npv = finMaster.NPV(rate, cashFlow) - 20000;
This function will give you the net present value of the project based on the specified parameters.
By understanding and using the NPV function, you can assess whether an investment or project will meet your financial goals and provide a satisfactory return, accounting for the time value of money.
The IRR (Internal Rate of Return) function is used to calculate the internal rate of return for a series of cash flows (both incoming and outgoing). The IRR is the discount rate that makes the net present value (NPV) of the cash flows equal to zero. It is commonly used to evaluate the profitability of investments or projects.
let cashFlow = [-20000, 5000, 7000, 8000, 10000];
let guess = 0.1; //Optional
const irr = finMaster.IRR(cashFlow, guess);
Imagine you are considering an investment that requires an initial investment of $10,000 and provides annual returns of $3,000, $4,000, $5,000, and $6,000 over the next four years. You want to calculate the IRR of these cash flows.
The function would look like this:
let cashFlow = [-10000, 3000, 4000, 5000, 6000];
const irr = finMaster.IRR(cashFlow);
This function returns approximately 24.88%, meaning the internal rate of return for this series of cash flows is about 24.88%.
Suppose you are considering a project that requires an initial investment of $20,000 and will generate annual returns of $5,000, $7,000, $8,000, and $10,000 over the next four years. You want to calculate the IRR for these cash flows.
The function in Javascript:
let cashFlow = [-20000, 5000, 7000, 8000, 10000];
const irr = finMaster.IRR(cashFlow);
This function will give you the internal rate of return for the project based on the specified parameters.
The RATE function is used to calculate the interest rate per period of an annuity. An annuity is a series of equal cash flows occurring at regular intervals. This function is helpful for determining the periodic interest rate required to pay off a loan or to reach a specific investment goal.
const rate = finMaster.RATE(nper, pmt, pv, fv, type, guess);
Imagine you take out a loan of $10,000 to be paid back over 5 years with monthly payments of $200. You want to find out the monthly interest rate.
The function would look like this:
const rate = finMaster.RATE(60,-200,10000);
This function returns approximately 0.004867, meaning the monthly interest rate is about 0.4867%.
To convert this to an annual interest rate, you can multiply by 12:
const rate = finMaster.RATE(60,-200,10000) * 12;
This gives an annual interest rate of approximately 5.84%.
Suppose you are planning to save $500 monthly for 10 years to reach a future value of $100,000. You want to find out the monthly interest rate required to reach this goal.
The function in Javascript:
const rate = finMaster.RATE(120, -500, 0, 100000);
This function will give you the monthly interest rate needed to achieve the future value of $100,000 based on the specified parameters.
By understanding and using the RATE function, you can determine the periodic interest rate required for various financial scenarios, such as loan repayments or investment growth, ensuring you meet your financial goals effectively.
The getRemainingLoanTerm function calculates the remaining term of a loan given its start date, term length, and term unit. This is useful for determining how much time is left before a loan is fully paid off.
/**
* Calculates the remaining loan term in months.
* @param startDateStr - The start date of the loan in the format "MM YYYY", "MMM YYYY".
* @param loanTerm - The length of the loan term (either in years or months).
* @param loanTermUnit - The unit of the loan term ("Years" or "Months").
* @returns The remaining loan term in months, or 0 if the loan is already paid off.
* @throws Will throw an error if the loan term unit is invalid.
*/
declare function getRemainingLoanTerm(
startDateStr: string,
loanTerm: number,
loanTermUnit: "Years" | "Months"
): number;
startDateStr (string): The start date of the loan in the format "MM YYYY" ("06 2020"), "MMM YYYY" ("Jun 2020).loanTerm (number): The length of the loan term (either in years or months).loanTermUnit ("Years" | "Months"): The unit of the loan term ("Years" or "Months").number: The remaining loan term in months, or 0 if the loan is already paid off.Here is an example of how to use the getRemainingLoanTerm function:
// Assuming the function is imported or available in your project
const remainingTerm = finMaster.getRemainingLoanTerm("06 2020", 5, "Years");
console.log(`Remaining loan term: ${remainingTerm} months`);
This function is especially useful for financial applications where users need to track the duration of their loans and understand how much time remains before they are paid off.
If you like my work, you can buy me a coffee by clicking the button below:
Contributions are welcome! Please feel free to submit a pull request or open an issue to improve the library.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
FinMaster: The ultimate toolkit for advanced financial calculations and analysis, designed to empower financial professionals and developers alike.
We found that finmaster demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.