Closed dytttf closed 5 months ago
Hello @dytttf,
Both pyxirr and Excel utilize iterative algorithms for finding IRR. However, pyxirr additionally checks if the xnpv
is close to zero with a precision of 0.001. If it is not, pyxirr returns None
. In your case, it's impossible to represent IRR as a double
(float64
) number that is small enough for xnpv
to be close to zero. The minimum possible xnpv
value is 32 (you can verify this in your spreadsheet).
There is one trick that can help when working with large numbers: scaling. You can divide each amount by some constant value, for example, by the maximum amount:
scale_factor = max(map(abs, cashs[step:]))
# you can also simply divide by 1000 or 1000000 depending on your data
amounts = [x/scale_factor for x in cashs[step:]]
irr = xirr(dates[step:], amounts)
Thank you,It works.
Hello, I encountered some problems while calculating xirr. Could you please help me check if it is a bug。
This is data file: 3547的irr.xlsx
Firstly, when I use Excel to calculate xirr, I can get the results:
But,when I use pyxirr to calculate xirr, I can not get the results, it return None.
code in here: pyxirr==0.10.3
In line 4681 of the file, there is a significant negative value, which may be the reason why it cannot be calculated:
But Excel can calculate it, so I want to know where the difference is?