Closed Hvass-Labs closed 1 year ago
Thank you for submitting an issue.
I agree that there is a problem with the function being slow when there is no solution. This happens because several algorithms for finding roots are used internally. I'm working on the efficiency of finding roots to return None
as soon as possible. I'm not sure that I can give the ability to control precision. As I wrote above, IRR uses several algorithms for finding roots and they use a different number of iterations and tolerance.
Hi @Hvass-Labs, I fixed an issue with IRR being slow when there is no solution in v0.9.3 + improved an overall performance. I didn't add the ability to control the precision, because IRR uses several root-finding algorithms and they use a different number of iterations and tolerance. I'll probably add the ability to select an algorithm instead of trying different options automatically.
Thanks! I actually ended up making my own Cython version, but I appreciate your effort and I'm sure someone else will find it useful! :-)
Thanks for making this library!
Your
irr
function is about 15x faster thannumpy_financial
on my data.Would it be possible to add arguments for the convergence-tolerance and max number of iterations for the root-finding algorithm? It seems they have recently added these to
numpy_financial
but it is not yet released.I would like to try and make
irr
run even faster by sacrificing some precision of the result, and also to ensure the time-usage is limited and predictable. Because I need to run this on many thousands of arrays of data, as fast as possible, and I only need a few digits of precision.There also seems to be a problem when the first number of the array is positive but there are negative numbers for some of the future amounts. This example runs 400x slower than normal and does not return a value or raise an exception:
I need it to return
np.nan
when a result could not be found within the max number of iterations allowed and the error is not within the given tolerance level.By the way,
pyxirr.__version__
is apparently also missing.I hope you can make these small changes.
Thanks!