Jump to content

Loan amortization


 Share

Recommended Posts

I need some help with this and it is driving me crazy. I know there are probably about 50 different ways to make this but i really would like this way to work. When it is ran it starts out with 208.82 for the Interest paid and it should be 208.81 so it throws all the calculations off and it ends up giving a -4.06 balance at the end.

If someone would please take a look and see if i have done something completely wrong or if the rounding needs to be done in a specific spot. I have tried just about everything i can think of.

Thanks for any help

B

;Found formula here http://www.hughchou.org/calc/formula.html

$TA = 200000  ;Total loan amount
$I = 5.75     ;Interest percent
$L = 30      ;Length in years

$N = $L*12          ;chages length from years to months
$J = $I/(12*100)    ;Changes interest to decimal
;MsgBox(0,"",$J)
$M = $TA * ( $J / ( 1 - (( 1 + $J ) ^ -$N)))
;MsgBox(0,"",$M)

For $s = $N to 1 Step -1        ;tells total number of payments based on length $L
$IP = Round($TA * $J, 2)        ;Interest paid
$PP = Round($M - $IP, 2)        ;Principal Paid
$RB = Round($TA - $PP, 2)       ;Remaining Balance
FileWrite("test.txt", $PP & "   |   " & $IP & " |   " & $RB & @CRLF)
 $TA = $RB                      ;Sets original loan amount to RB for next calculation
Next
Link to comment
Share on other sites

$TA = 200000  ;Total loan amount
$I = 5.75     ;Interest percent
$L = 30      ;Length in years

$N = $L*12          ;chages length from years to months
$J = $I/(12*100)    ;Changes interest to decimal
;MsgBox(0,"",$J)
$M = $TA * ( $J / ( 1 - (( 1 + $J ) ^ -$N)))
;MsgBox(0,"",$M)

For $s = $N to 1 Step -1        ;tells total number of payments based on length $L
$IP = ($TA * $J)        ;Interest paid
$PP = Round($M - $IP, 2)        ;Principal Paid
$RB = Round($TA - $PP, 2)       ;Remaining Balance
FileWrite("test.txt", $PP & "   |   " & $IP & " |   " & $RB & @CRLF)
 $TA = $RB                      ;Sets original loan amount to RB for next calculation
Next

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

$TA = 200000  ;Total loan amount
$I = 5.75     ;Interest percent
$L = 30      ;Length in years

$N = $L*12          ;chages length from years to months
$J = $I/(12*100)    ;Changes interest to decimal
;MsgBox(0,"",$J)
$M = $TA * ( $J / ( 1 - (( 1 + $J ) ^ -$N)))
;MsgBox(0,"",$M)

For $s = $N to 1 Step -1        ;tells total number of payments based on length $L
$IP = ($TA * $J)        ;Interest paid
$PP = Round($M - $IP, 2)        ;Principal Paid
$RB = Round($TA - $PP, 2)       ;Remaining Balance
FileWrite("test.txt", $PP & "   |   " & $IP & " |   " & $RB & @CRLF)
 $TA = $RB                      ;Sets original loan amount to RB for next calculation
Next

So is there a way to make the interest rate round out when it writes to a file without messing up the final result? Was hoping there was a opt that made all the numbers go 2 decimal places but no such thing.
Link to comment
Share on other sites

So is there a way to make the interest rate round out when it writes to a file without messing up the final result? Was hoping there was a opt that made all the numbers go 2 decimal places but no such thing.

You answered your own question there. Use Round().
Link to comment
Share on other sites

You answered your own question there. Use Round().

But did you see what the first post did it comes out with a -4.06 instead of 0.00 so you cant round it out without getting a bogus answer. That is why i was asking if there is a way around it. I guess you will have to take the number and round it after the calculation is performed to get it to work and give the correct balance of 0.00

I would really like it to round out to the 2 decimal place on everything but it just appears it si not going to happen in autoit unless im missing something...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...