PHPackages                             nyholm/effective-interest-rate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nyholm/effective-interest-rate

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

nyholm/effective-interest-rate
==============================

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

1.0.1(5y ago)24169.4k↑37.8%7[1 issues](https://github.com/Nyholm/effective-interest-rate/issues)MITPHPPHP &gt;=7.0CI failing

Since Apr 4Pushed 5y ago2 watchersCompare

[ Source](https://github.com/Nyholm/effective-interest-rate)[ Packagist](https://packagist.org/packages/nyholm/effective-interest-rate)[ Docs](http://tnyholm.se)[ RSS](/packages/nyholm-effective-interest-rate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Effective interest rate
=======================

[](#effective-interest-rate)

[![Latest Version](https://camo.githubusercontent.com/81a7f6e05358b956cfcd26386798bde72f77d7e41cf4208d71b7d5b82761b5fe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6e79686f6c6d2f6566666563746976652d696e7465726573742d726174652e7376673f7374796c653d666c61742d737175617265)](https://github.com/nyholm/effective-interest-rate/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/2a494aa9df614bd90ebba129a03a6868706784e6b58f39c2c4b3bcf1b59ec401/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4e79686f6c6d2f6566666563746976652d696e7465726573742d726174652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Nyholm/effective-interest-rate)[![Code Coverage](https://camo.githubusercontent.com/5b31c45c8f80b4f9ef8242e920720ffeb098aa456e7dc90767efcce62c540d23/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6e79686f6c6d2f6566666563746976652d696e7465726573742d726174652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/nyholm/effective-interest-rate)[![Quality Score](https://camo.githubusercontent.com/9782385d9ea2098f29ee38e3f9bec89657589d80819d25f7d54e22569da72ea0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6e79686f6c6d2f6566666563746976652d696e7465726573742d726174652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/nyholm/effective-interest-rate)[![Total Downloads](https://camo.githubusercontent.com/5b37b906f0eb0ddb326843c8d7bd50b29748b854b80b72dc25e1002663ae0274/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e79686f6c6d2f6566666563746976652d696e7465726573742d726174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nyholm/effective-interest-rate)

This is a library that calculates the effective interest rate. The effective interest could also be called XIRR or effective APR. This is the **PHP** library. You will find a JavaScript version of this library [here](https://github.com/Nyholm/effective-interest-rate-js).

Examples
--------

[](#examples)

### Equal payments

[](#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%.

```
use Nyholm\EffectiveInterest\Calculator;

$principal = 100000;
$payment = 2400;
$numberOfMonths = 48;
$guess = 0.03;
$calculator = new Calculator();

$interest = $calculator->withEqualPayments($principal, $payment, $numberOfMonths, $guess);

echo $interest; // 0.07115
```

Correct answer is 7.12%

### Specified payments

[](#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.

```
use Nyholm\EffectiveInterest\Calculator;

$principal = 100000;
$payment = 2400;
$guess = 0.03;
$startDate = '2017-04-30';
$calculator = new Calculator();

$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,
];

$interest = $calculator->withSpecifiedPayments($principal, $startDate, $payments, $guess);

echo $interest; // 0.084870
```

Correct answer is 8.49%

The mathematics
---------------

[](#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](https://raw.githubusercontent.com/Nyholm/effective-interest-rate/master/doc/images/xirr_equation.png)](https://raw.githubusercontent.com/Nyholm/effective-interest-rate/master/doc/images/xirr_equation.png)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1432 days

Total

2

Last Release

1898d ago

PHP version history (2 changes)1.0.0PHP ^7.0

1.0.1PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/401ccc5eea13c60cf807ae982af00e368e2166e2f26d8eb541dcd881a57385bc?d=identicon)[Nyholm](/maintainers/Nyholm)

---

Top Contributors

[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (28 commits)")[![JarJak](https://avatars.githubusercontent.com/u/4981490?v=4)](https://github.com/JarJak "JarJak (1 commits)")

---

Tags

financeinterestinterest-ratesmathematicseffective interest rateeffective interestXIRReffective APR

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/nyholm-effective-interest-rate/health.svg)

```
[![Health](https://phpackages.com/badges/nyholm-effective-interest-rate/health.svg)](https://phpackages.com/packages/nyholm-effective-interest-rate)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
