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

Wrong irr values #46

Closed
mohit-bn opened this issue Sep 7, 2023 · 3 comments · Fixed by #47
Closed

Wrong irr values #46

mohit-bn opened this issue Sep 7, 2023 · 3 comments · Fixed by #47

Comments

@mohit-bn
Copy link

mohit-bn commented Sep 7, 2023

We are getting very different irr values for slightly different cashflows.

cf1
out[16]: 
array([-1.44852555e+08,  1.28859998e+06,  1.27305118e+06,  1.25407349e+06,
        1.24199669e+06,  1.22647792e+06,  1.21095552e+06,  1.19206955e+06,
        1.17989821e+06,  1.16436524e+06,  1.14883185e+06,  1.12945217e+06,
        1.11780102e+06,  1.10228427e+06,  1.08671783e+06,  1.06755759e+06,
        1.05502327e+06,  1.03885451e+06,  1.02247003e+06,  1.00227444e+06,
        9.88024873e+05])
cf2
Out[17]: 
array([-1.44852555e+08,  1.41881733e+06,  1.40267049e+06,  1.38296290e+06,
        1.37042160e+06,  1.35430596e+06,  1.33818655e+06,  1.31857419e+06,
        1.30593472e+06,  1.28980433e+06,  1.27367350e+06,  1.25354845e+06,
        1.24144917e+06,  1.22533563e+06,  1.20917048e+06,  1.18927331e+06,
        1.17625690e+06,  1.15946627e+06,  1.14245161e+06,  1.12147927e+06,
        1.10668164e+06])

pyxirr.irr(cf1), pyxirr.irr(cf2)
Out[19]: (-0.13854127397889382, -1.761587679320197)
# comparison with numpy_financial
npf.irr(cf1), npf.irr(cf2)
Out[18]: (-0.13854127397889426, -0.1320937225730502)
@Anexen
Copy link
Owner

Anexen commented Sep 7, 2023

Hi, @mohit-bn. Thank you for submitting an issue. I agree that the result is a bit confusing.
Which pyxirr version do you use? The latest version gives me -1.761587679256444, a bit different value. Strictly speaking, -1.761587679256444 is the correct answer, because the function has two roots.
I'm currently working on improving IRR and I'm going to give the higher priority to a value closer to 0.

@mohit-bn
Copy link
Author

mohit-bn commented Sep 7, 2023

thanks @Anexen giving higher priority to value closer to 0 sounds good. We are using "0.7.3" version

@Anexen Anexen linked a pull request Oct 10, 2023 that will close this issue
@Anexen
Copy link
Owner

Anexen commented Oct 10, 2023

Hi @mohit-bn. Fixed in v0.9.3

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

Successfully merging a pull request may close this issue.

2 participants