Archive

Archive for September, 2009

Loan Payoff Calculator

September 5th, 2009 No comments

This has probably been done before, but this script fixes two problems I’ve noticed with loan calculators:

  1. They assume monthly interest compounding (most loans are compounded daily)
  2. They don’t allow you to calculate the payments if you’re splitting your payment (eg: paying $200 twice a month instead of $400 once a month)
  3. 
    #/usr/bin/env python
    import math
    
    # Remaining amount on the loan
    toPayOff = 12345.67
    # Interest rate
    intRate = 12.34
    # Amount of your payment
    payAmt = 200
    # Making the payment every x days
    payEvery = 15
    # Maximum amount you're willing to pay extra to just "pay it off"
    balloonMax = 200
    # Days til the next payment
    runUpDays = 15
    
    # Do not edit below this line
    days = 0
    pmtNum = 0
    dailyInt = (intRate / 100) /365
    origToPayOff = toPayOff
    totalPaid = 0
    while (runUpDays > 0):
        toPayOff = (math.ceil((toPayOff * (1 + dailyInt))*100))/100
        runUpDays -= 1
    while (toPayOff > 0):
        days += 1
        toPayOff = (math.ceil((toPayOff * (1 + dailyInt))*100))/100
        if (days % payEvery == 0):
            toPayOff = (math.ceil(toPayOff * 100))/100
            if (toPayOff < (payAmt + balloonMax)):
                payAmt = toPayOff
            toPayOff -= payAmt
            pmtNum += 1
            totalPaid += payAmt
            print "Payment #%s\tPayment Amt: $%s\tBalance:%s" % (pmtNum,payAmt,toPayOff)
    print "Over %s payments, you will pay a total of $%s ($%s in interest)" % (pmtNum,totalPaid,(totalPaid-origToPayOff))
    
Categories: Uncategorized Tags:

dork-e.com is Stephen Fry proof thanks to caching by WP Super Cache