Skip to content

Instantly share code, notes, and snippets.

@rgkimball
Created January 21, 2017 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgkimball/4b0b3175d70d58cf13869596f6158ee1 to your computer and use it in GitHub Desktop.
Save rgkimball/4b0b3175d70d58cf13869596f6158ee1 to your computer and use it in GitHub Desktop.
Future Value of a stream of cash flows and an initial investment
# In 000's
pv = 400
savings_rate = 0.10
ir = 0.025
periodicity = 4
years = 20
cf = pv * savings_rate
nper = periodicity * years
irper = ir / periodicity
cfper = cf / periodicity
terminal_value = pv * (1 + irper) ** nper
sum_of_cfs = 0
for n in range(nper):
this_cf = cfper * ((1 + irper) ** n)
print("CF in period %d = %0.2f" % (n, this_cf))
sum_of_cfs += this_cf
fv = terminal_value + sum_of_cfs
print("FV of savings = ${:,.2f}".format(fv))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment