I am trying to calculate the IRR for a month using numpy_financial, but I am not succeeding. At which position in the array am I making a mistake?
For example:
initial_balance = 579676.18
final_balance = 2921989.17
From what I understand from the documentation, the final balance should be treated as a withdrawal (positive value) on the last day because it calculates as zero.
The cash flows are an array of 31, corresponding to the number of days in that month:
[0, 22700.00, 0 ,0 ,0 ,5320.00 ,0 ,0 ,-39900.00 ,0 ,0 ,0 ,0 ,0 ,0 ,-2278500.00 ,0, 31472.00, -42000.00, 0 , 0 , 0, -70300.00, 0, 0, 0, 0, 0, 0,36650.00, 0]
So, from what I understand from the documentation, the final array should be an array of 32? With the first being the initial balance and the other 31 being the daily cash flows + final balance?
[initial_balance, 0, 22700.00, 0, 0, 0, 5320.00, 0, 0, -39900.00, 0, 0, 0, 0, 0, 0, -2278500.00, 0, 31472.00, -42000.00, 0, 0, 0, -70300.00, 0, 0, 0, 0, 0, 0, 36650.00, final_balance]
The correct IRR for this is 0.0001465, but the output is 0.001685. What am I doing wrong?
from numpy_financial import irr
final_array = [initial_balance, 0, 22700.00, 0, 0, 0, 5320.00, 0, 0, -39900.00, 0, 0, 0, 0, 0, 0, -2278500.00, 0, 31472.00, -42000.00, 0, 0, 0, -70300.00, 0, 0, 0, 0, 0, 0, 36650.00, final_balance]
irr(final_array)
According to the document:
Thus, for example, at least the first element of values, which represents the initial investment, will typically be negative.
Your initial_balance
should be negative, rest everything is correct in your example.
from numpy_financial import irr
final_array = [-initial_balance, 0, 22700.00, 0, 0, 0, 5320.00, 0, 0, -39900.00, 0, 0, 0, 0, 0, 0, -2278500.00, 0, 31472.00, -42000.00, 0, 0, 0, -70300.00, 0, 0, 0, 0, 0, 0, 36650.00, final_balance] # see negative sign before initial_balance
irr(final_array)
#Output
0.00014651601147774862