IRR is the discount rate resulting in a zero NPV. The IRR rule is that if our project's IRR is bigger than our cost of capital, we accept the project. Otherwise, we reject it, as shown in the following conditions:
The Python code to estimate an IRR is as follows:
def IRR_f(cashflows,interations=100): rate=1.0 investment=cashflows[0] for i in range(1,interations+1): rate*=(1-npv_f(rate,cashflows)/investment) return rate
At this stage, this program is quite complex. If a user cannot grasp its meaning, it this won't impact on them understanding the rest of the chapter. The range(1,100+1)
statement will give us the range from 1
to 101
. The i
variable takes values from 1
to 101
. In other words, the fifth line will repeat 101 times. An assumption behind the fifth line is that R and NPV are negatively correlated. In other words, an increase in discount rate R leads to a smaller NPV value.
The key is the fifth line, rate...