- Definition
- Formula
- Present Value
- Net Present Value
- Python Code
- Case Study
- Present Value & Net Present Value Code

**This is not investment advice, there is no implication of any guarantee. All investment is risky and you should take advice from actual advisors. EDUCATION ONLY.**

## Definition

Because of inflation and profits from investment, money today is worth more than money tomorrow. Present value looks at the value today against its future value. Net Present Value is simply the future value minus today’s value.

## Formula

### Present Value

- FV = Future Value
- r = Rate of Return (discount rate)
- n = Number of Periods

### Net Present Value

- FV = Future Value
- PV = Present Value

## Python Code

### Case Study

Let’s say we are a wizard and we own a magic shop full of evil artifacts. We could invest in one of two evil totems. Each year, patrons of the totems will come by and donate a tribute. We want to sell our totem at the end of five years. Our discount rate is 4%.

Gozer Statue | Veigo Statue | |

Initial Cost | 100 | 100 |

Sell Value | 100 | 120 |

Annual Cash Flow | 10 | 5 |

So what do we want here? We want to understand for each year, what is the value being brought in, and how does it compare to what we could be making if we were to invest elsewhere.

### Present Value & Net Present Value Code

```
import numpy as np
import pandas as pd
statues = pd.DataFrame(np.array([['Gozer', 100, 100, 10, 0, 0], ['Veigo', 100, 120, 5, 0, 0]]),
columns=['Name', 'Buy', 'Sell', 'CashFlow','PV','NPV'])
annual = []
value = []
annual_pv = []
def present_value(statue_data, periods, dr):
for n in statue_data.index:
sale_period = int(len(range(periods)))-1
for x in range(periods):
time = x+1
#Calculate the Present Value. The if statement accounts for adding the sell value to the final period.
if x == sale_period:
annual_pv.append((float(statue_data.loc[n]['CashFlow']) + int(statues.loc[n]['Sell'])) / ((1+dr)**time))
else:
annual_pv.append(float(statue_data.loc[n]['CashFlow']) / ((1+dr)**time))
statues.loc[n]['PV'] = sum(annual_pv)
statues.loc[n]['NPV'] = sum(annual_pv) - float(statues.loc[n]['Buy'])
annual.clear()
value.clear()
annual_pv.clear()
present_value(statues, 5, .04)
print(statues)
```