Calculating IRR Using Python And Numpy

Overview:

  • Like NPV the IRR also helps in making investment decisions.
  • NPV formula has several elements that are summed together. The corresponding element for t=0 is called the initial investment or the cash flow when t=0.
  • The cash flow at t=0 is denoted with a negative sign since it is an outflow from point of view of the investor.
  • The future cash flows correspond to t=1, t=2 and so on till t=N.
  • The name 'internal' in IRR refers to the fact that the IRR does not account for external factors like inflation.
  • IRR is the discount rate which makes Present Value of t0=Present Value of t1+t2+…+tn. IRR is the discount rate that makes the Present Value of cash inflows equal to the Present Value of cash outflows.
  • Equating the Present Value of cash outflows to the Present Value of cash inflows and solving for the discount rate obtain IRR.
  • Similarly, the discount rate associated with the Present Value of the future cash flows provides the Required Rate of Return (RRR).
  • Companies typically select any investment for which the Internal Rate of Return (IRR) is greater than the Required Rate of Return (RRR).

Example:

import numpy as np

 

initialInvestment   = -100; # Negative, since it results in an outflow of cash

cashFlows           = [initialInvestment, 20, 30, 40, 50];

 

# Calculate the IRR

irr = round(np.irr(cashFlows),4);

 

print("Internal rate of return:%3.4f"%irr);

 

Output:

Internal rate of return:0.1283

 


Copyright 2020 © pythontic.com