Net Present Value (NPV) On Python Using Numpy
Net present value (NPV) is the difference between the present value of cash inflows and the present value of cash outflows over a period of time.

NPV is used in capital budgeting and investment planning.
The NPV Rule is:-
If NPV > 0 Then the project is Accepted
If NPV < 0 Then the project is Rejected
The formula for calculating NPV is -
= | net present value | |
= | net cash flow at time t | |
= | discount rate | |
= | time of the cash flow |
This is how NPV is calculated manually with the generic formula, now we are going to use NumPy for calculating the NPV of a project.
Here is an example. The initial investment is $100. The cash inflows in the next five
years are $50, $60, $70, $100, and $20, starting from year one. If the discount rate is
11.2%, what is the project's NPV value?
NPV = 0
Now we are going to calculate NPV by using 2 methods, first one is where we will create a function for calculating NPV and in the second method we will use a predefined function of NumPy for calculating NPV
FIRST Method:-
#writing own function to calculate npv
def npv(interestrate,cashflows):
npv=0
for i in range(len(cashflows)):
npv = npv + cashflows[i]/(1+interestrate)**i
return npv
npv(interestrate,cashflows)
SECOND Method:-
This is how NPV is calculated in Python using Numpy or you can use SciPy too for doing the same.
Comments
Post a Comment