Created
May 3, 2012 18:18
-
-
Save andrewschoen/2587812 to your computer and use it in GitHub Desktop.
Future value calculation with a increasing amount of contribution annually, up to X amount.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import locale | |
locale.setlocale(locale.LC_ALL, '') | |
def sliding_payment_fv(start_pmt=100, annual_pmt_increase=100, max_pmt=300, | |
years=10, interest_rate=0.05, present_value=100): | |
future_value = 0 | |
pmt = start_pmt | |
for year in range(years): | |
yearly_increase = np.fv(interest_rate/12, 12, -pmt, -present_value) | |
future_value += yearly_increase | |
print "amount of contribution / month for year %s: %d" % (year+1, pmt) | |
print "value for year %d %s" % (year+1, | |
locale.currency(future_value, grouping=True)) | |
if pmt < max_pmt: | |
pmt += annual_pmt_increase | |
if __name__ == "__main__": | |
sliding_payment_fv() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python future_value.py | |
amount of contribution / month for year 1: 100 | |
value for year 1 $1,333.00 | |
amount of contribution / month for year 2: 200 | |
value for year 2 $3,893.89 | |
amount of contribution / month for year 3: 300 | |
value for year 3 $7,682.66 | |
amount of contribution / month for year 4: 300 | |
value for year 4 $11,471.43 | |
amount of contribution / month for year 5: 300 | |
value for year 5 $15,260.21 | |
amount of contribution / month for year 6: 300 | |
value for year 6 $19,048.98 | |
amount of contribution / month for year 7: 300 | |
value for year 7 $22,837.75 | |
amount of contribution / month for year 8: 300 | |
value for year 8 $26,626.53 | |
amount of contribution / month for year 9: 300 | |
value for year 9 $30,415.30 | |
amount of contribution / month for year 10: 300 | |
value for year 10 $34,204.07 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment