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

Negative IRR #24

Closed
aluyca opened this issue Jan 26, 2022 · 4 comments
Closed

Negative IRR #24

aluyca opened this issue Jan 26, 2022 · 4 comments

Comments

@aluyca
Copy link

aluyca commented Jan 26, 2022

Hi

Pyxirr is really a good package. The performance is really good. When we using irr function, got a weird issue. If we feed 241, 361, or 481 cash flows (including 1 initial loan, and 240,360, and 480 monthly paybacks) to irr function, we got a negative number (-23.848998449508812). Can you please take a look and help us to fix it?

Here is our testing code:

from pyxirr import irr
import numpy_financial as npf

cf = [-172545.848122807] + [787.735232517999] * 480

print(len(cf))
irr_rt= irr(cf)*12
print(irr_rt)

irr_rt = npf.irr(cf)*12
print(irr_rt)
@Anexen
Copy link
Owner

Anexen commented Jan 27, 2022

Hi @aluyca, it looks like the root finding algorithm found just one of several solutions to the equation.
An interesting point: LibreOffice shows the same result as pyxirr and mathematically it is correct because npv(pyxirr.irr(cf), cf) is close to zero and it's closer to zero than npv(npf.irr(cf), cf).
I'll see what I can do

@aluyca
Copy link
Author

aluyca commented Jan 27, 2022

Thanks a lot!

@Anexen
Copy link
Owner

Anexen commented Jan 28, 2022

Hi @aluyca , I've tweaked IRR so that it first tries to find a rate greater than zero. I hope this helps. Please try version 0.7.2.

@aluyca
Copy link
Author

aluyca commented Jan 28, 2022

Thanks!

@Anexen Anexen changed the title pyxirr has some weird issues Negative IRR Jan 30, 2022
@Anexen Anexen closed this as completed Jan 30, 2022
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