Skip to content

Would be nice to have an "excel" version of XIRR #7

Description

@ragnarkurmwunder

The problem

When having a continuous buy and sell system (like online trading) then the "principal" is meaningless.
Spreadsheet XIRR is desired.

The solution

Implement a version that accepts a stream of transactions (positive and negative).

An alternative 1

Use composer require phpoffice/phpspreadsheet and the following code:

use \PhpOffice\PhpSpreadsheet\Calculation\Financial;
$xirr = Financial::XIRR($values, $dates, 0.1);

Note, that dates can have many formats. It does not accept epoch, however. But epoch/(24 * 60 * 60) works.
Note, that phpoffice/phpspreadsheet is a fairly large package, and installing it only for XIRR, is a bit overkill.
Note, that this package is maintained, and is well tested.

An alternative 2

There is a manually downloadable package that performs the desired XIRR:
https://www.phpclasses.org/package/892-PHP-Financial-functions-with-the-Excel-function-names-.html
But the downside is that one must register to download it manually, and from there on maintain it oneself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions