How to calculate Net Present Value (NPV) with Python for Business and Finance analysis.


NPV in finance analysis is the result of calculations used to find today’s value of a future stream of payments.
Actually Net present value is the difference between the present value of cash inflows and the present value of cash outflows over a period of time.
Required TVM calculations can be easily realised with Python.

There is a Simple Decision Rule after NPV is known:
• Accept the Project if NPV > 0
• Reject the Project if NPV < 0

Interpretation of NPV:
• Pursue the Project: Increase Today´s Company Value by NPV
• Total Company Value is the sum of all Projects´ NPVs




Net Present Value (NPV) formula:


$$NPV = 𝐼𝑜 + \sum_{t = 1}^n \frac { CFt }{ (1 + r)^t }$$

Where:

NPV: Net Present Value
Io: Initial Investment (negative)
CFt: cashflow @ timestamp t
N: Total number of periods
r: required rate of return
t = timestamp (0, 1, …, N)


cf = [-180, 30, 50, 70, 80, 70]
f = 1.08
NPV = 0
for i in range(6):
    NPV += cf[i] / f**(i)
print(NPV)

You can also calculate NPV using NUMPY library which is much more simple way to do it.


import numpy as np
import numpy_financial as npf
cf = np.array([-200, 20, 50, 70, 100, 50])
r = 0.06
npf.npv(r, cf)

Intuition behind the Required Rate of Return:

• Opportunity Costs: (Expected) Return of comparable / alternative Projects

• Weighted Average Costs to fund Capital Outflow Io
− Cost of Debt (Interest Rate charged by Bondholders / Banks)
− Cost of Equity (Required Return by Shareholders)




See also related topics: