esmeralinnn
v1.0.0
Published
Build a library for performing common financial calculations such as loan amortization, compound interest, and investment portfolio analysis.
Downloads
11
Readme
Financial Calculations
This is a JavaScript library for common financial calculations such as compound interest and loan amortization.
Installation
You can install this package via npm:
npm install financial-calculations
Usage
const { compoundInterest, loanAmortization } = require('financial-calculations');
// Example usage for compound interest calculation
const principal = 1000;
const rate = 0.05; // 5%
const time = 5; // years
const futureValue = compoundInterest(principal, rate, time);
console.log('Future value:', futureValue);
// Example usage for loan amortization calculation
const loanPrincipal = 5000;
const annualRate = 0.06; // 6%
const loanTime = 3; // years
const monthlyPayment = loanAmortization(loanPrincipal, annualRate, loanTime);
console.log('Monthly payment:', monthlyPayment);
Functions
compoundInterest(principal, rate, time)
Calculates the future value of an investment with compound interest.
principal
: Initial investment amount.rate
: Annual interest rate (as a decimal).time
: Time period in years.
loanAmortization(principal, rate, time)
Calculates the monthly payment for a loan based on its principal, annual interest rate, and time period.
principal
: Loan amount.rate
: Annual interest rate (as a decimal).time
: Time period in years.
License
This project is licensed under the MIT License - see the LICENSE file for details.