Skip to content

Instantly share code, notes, and snippets.

@freespace
Created June 4, 2014 10:05

Revisions

  1. freespace created this gist Jun 4, 2014.
    42 changes: 42 additions & 0 deletions hecs-repayment-years.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    # -*- coding: utf-8 -*-
    """
    Created on Sat May 31 11:35:04 2014
    @author: freespace
    """

    def repayment_pc(earning):
    thresholds = [ [59421, 0.04],
    [65497, 0.045],
    [68939, 0.05],
    [74105, 0.055],
    [80257, 0.06],
    [84481, 0.065],
    [92970, 0.07],
    [99069, 0.075],
    ]
    for upperthres, pc in thresholds:
    if earning < upperthres:
    return pc
    # this is the max repayment rate
    return 0.08

    debt=50e3
    interest = 0.06
    earning = 60e3
    max_earning = 65e3
    yearly_raise = 0.03
    years = 0
    max_years= 100

    while debt > 0:
    payment = repayment_pc(earning) * earning
    debt -= payment
    debt *= (1+interest)
    earning *= (1+yearly_raise)
    earning = min(earning, max_earning)
    years += 1
    print years, debt, interest, earning, payment

    if years > max_years:
    break