Skip to content

Instantly share code, notes, and snippets.

@andrewschoen
Created May 3, 2012 18:18
Show Gist options
  • Select an option

  • Save andrewschoen/2587812 to your computer and use it in GitHub Desktop.

Select an option

Save andrewschoen/2587812 to your computer and use it in GitHub Desktop.

Revisions

  1. andrewschoen revised this gist May 3, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion future_value.py
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ def sliding_payment_fv(start_pmt=100, annual_pmt_increase=100, max_pmt=300,
    future_value = 0
    pmt = start_pmt
    for year in range(years):
    yearly_increase = np.fv(interest_rate/12, 1*12, -pmt, -present_value)
    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,
  2. andrewschoen renamed this gist May 3, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. andrewschoen revised this gist May 3, 2012. 2 changed files with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions future_value.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    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,
    File renamed without changes.
  4. andrewschoen created this gist May 3, 2012.
    19 changes: 19 additions & 0 deletions future_value.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    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, 1*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()
    21 changes: 21 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    $ 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