forked from lewisfogden/heavylight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_cashflow.py
43 lines (31 loc) · 897 Bytes
/
basic_cashflow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# %%
from heavylight import Model
# %%
class SimpleModel(Model):
def t(self, t):
return t
def num_pols_if(self, t):
if t == 0:
return 1
else:
return self.num_pols_if(t - 1) * 0.98
def cashflow(self, t):
return self.num_pols_if(t) * 100
def v(self, t):
"""discount factor for time t --> time 0"""
if t == 0:
return 1
else:
return self.v(t - 1) / (1 + self.forward_rate(t))
def forward_rate(self, t):
return 0.04
def pv_cashflow(self, t):
"""present value of the cashflow occuring at time t"""
return self.cashflow(t) * self.v(t)
# %%
if __name__ == "__main__":
model = SimpleModel(do_run = True, proj_len = 10)
print(model.pv_cashflow.sum())
print(model.v.values)
df = model.ToDataFrame()
print(df)