diff options
| author | zhang <zch921005@126.com> | 2022-08-08 22:46:45 +0800 |
|---|---|---|
| committer | zhang <zch921005@126.com> | 2022-08-08 22:46:45 +0800 |
| commit | 912916a56b7f6469ce1c4cbf430f7c48ff918a3c (patch) | |
| tree | 585f30a03d56eacf5b67520f1366f3529b330f41 /finance/discount_time_value.py | |
| parent | 1a83481394812c9f8dbebd60a04b3b66655cd01b (diff) | |
copy
Diffstat (limited to 'finance/discount_time_value.py')
| -rw-r--r-- | finance/discount_time_value.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/finance/discount_time_value.py b/finance/discount_time_value.py new file mode 100644 index 0000000..d3b88df --- /dev/null +++ b/finance/discount_time_value.py @@ -0,0 +1,14 @@ + + +def npv(pays, r): + return sum([pay/((1+r)**(i+1)) for i, pay in enumerate(pays)]) + + +if __name__ == '__main__': + pays = [236.8, 236.8+1000] + r = 0.2368 + print(npv(pays, r)) + + pays = [192.06, 192.06+1100] + r = 0.1746 + print(npv(pays, r)) |
