Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XIRR incorrect values for very large datasets #48

Open
harzkr opened this issue Apr 23, 2020 · 2 comments
Open

XIRR incorrect values for very large datasets #48

harzkr opened this issue Apr 23, 2020 · 2 comments

Comments

@harzkr
Copy link

harzkr commented Apr 23, 2020

XIRR value is being calculated incorrectly for transactions of order 40k-50k, the incorrectness increases when the number of transactions increase say 80k-90k

This I had checked with other xirr packages which were returning the same value as well as Excel, which confirmed the calculations. The value calculated by this package was incorrect

@jadfls
Copy link

jadfls commented Oct 21, 2020

I can confirm this issue. Sample code:

const Finance = require('financejs');
var finance = new Finance();
var start = new Date(Date.parse("2013-12-31"));
var end = new Date(Date.parse("2014-05-15"));
var irr = finance.XIRR([-37987348, 21191041], [start, end], 0);
console.log(irr);    //will not calculate

However, if you (somehow) correctly guess the initial guess close to the result, it will work.

var irr = finance.XIRR([-37987348, 21191041], [start, end], -0.8);
console.log(irr);    //-79.36

@harzkr did you find a solution to your problem?

@harzkr
Copy link
Author

harzkr commented Oct 30, 2020

Hi @jadfls

Nice find on the guess value part that you mentioned, but yeah it does pose the difficulty of correctly assuming an initial close value.

I have kept the usage of this package limited to any fallback calls(if others fail), and have shifted my primary package to
webcarrot/xirr, which is based on the XIRR function call from the LibreOffice Software

Since it is closely associated with the MS Office Excel etc., softwares, it correctly calculates values for 99.9% of the use cases, for others, there's usually a problem with improper set of transactions, else, I use fallback calls to this and other XIRR packages to get a value. But mostly those are very corner cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants