npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

effective-interest-rate

v0.1.0

Published

A library to calculate effective interest rate. Also know as XIRR or effective APR.

Downloads

135

Readme

Effective interest rate

Latest Version Software License Build Status

This is a library that calculates the effective interest rate. The effective interest could also be called XIRR or effective APR. This is the JavaScript library. You will find a PHP version of this library here.

Examples

Equal payments

If you are do a car loan of 100 000 Money. The loan is for 48 months and you pay 2 400 Money every month. What is the effective interest?

We guess that it is somewhere around 3%.


let principal = 100000;
let payment = 2400;
let numberOfMonths = 48;
let guess = 0.03;

let interest = EffectiveInterestCalculator.withEqualPayments(principal, payment, numberOfMonths, guess);

console.log(interest); // 0.07115

Correct answer is 7.12%

Specified payments

What if the payments are not equal? The first payment has an administration fee of 400 Money and we like to pay the rest of the loan after 36 months. So the 36th payment will be 31 200 Money.

let principal = 100000;
let payment = 2400;
let guess = 0.03;
let startDate = '2017-04-30';

let payments = {
    '2017-04-30': payment + 400,
    '2017-05-31': payment,
    '2017-06-30': payment,
    '2017-07-31': payment,
    // More dates
    '2019-12-31': payment,
    '2020-01-31': payment,
    '2020-02-28': payment,
    '2020-03-31': 31200,
};

let interest = EffectiveInterestCalculator.withSpecifiedPayments(principal, startDate, payments, guess);

console.log(interest);  // 0.084870

Correct answer is 8.49%

The mathematics

We are using the same formula that Excel's XIRR function is using. We are also using NewtonRaphsons method to numerically find the interest we are looking for.

Effective interest formula

Build

# Install depnendencies
npm install

# Build a mnified file
npm run build

To run the test

# Build the project (no minified files)
npm run dev

# Run test once
npm run test

# Start test listener
npm run watch