Financial Algorithms Cookbook | Time Value of Money
Amortization
Amortization Amortization is a method for repaying a loan in equal installments. Part of each payment goes toward interest due for the period and the remainder is used to reduce the principal (the loan balance). As the balance of the loan is gradually reduced, a progressively larger portion of each payment goes toward reducing principal.
Use amort to calculate the sums applied towards the priciple and to the interest from a single or series of payments.
#Algorithm:
def round(x):
return x
r = floor(100.0*fabs(x)+0.5)
r /=100.0
return r*(fabs(x)/x)
def amort(i, PV, PMT, n):
i /=100.0
sign = int(PMT/fabs(PMT))
i *=sign
interestPaid =0
principlePaid =0
remainingPrinciple=PV
period=1
forInterest = remainingPrinciple * i
forPrinciple = PMT - forInterest
remainingPrinciple += forPrinciple
interestPaid +=forInterest
principlePaid += forPrinciple
period +=1
while period <= n:
forInterest = remainingPrinciple * i
forPrinciple = PMT - forInterest
remainingPrinciple += forPrinciple
interestPaid +=forInterest
principlePaid += forPrinciple
period +=1
return fabs(interestPaid), fabs(principlePaid), PV-fabs(principlePaid)
Example
You have mortgage for $500,000 at a fixed annual interest of 13.25%. Your payments are 5733.5 per at the end of each month. Find the amount that you would have paid to interest and to the principle after second year.
>> PV=500000 >> i=13.25/12 >> PMT = 5733.50 >> n = 24 >> amort(i, PV, PMT, n) >> (131230.45596198068, 6373.5440380193058, 493626.45596198068)
If you need an An amortization schedule use the following snippet:
>> pvj = PV
>> j =1
>> while j <= n:
intj, prnj, pvj = amort3(1.10, pvj, -573.35, 1)
j +=1
>>
Here is the schedual of the first year from the above example:
| Period (j) | Interest Paid | Principle Paid | Principle Remaining |
| 1 | 5500.00 | 233.50 | 499766.50 |
| 2 | 5497.43 | 236.07 | 499530.43 |
| 3 | 5494.83 | 238.67 | 499291.77 |
| 4 | 5492.21 | 241.29 | 499050.48 |
| 5 | 5489.56 | 243.94 | 498806.53 |
| 6 | 5486.87 | 246.63 | 498559.90 |
| 7 | 5484.16 | 249.34 | 498310.56 |
| 8 | 5481.42 | 252.08 | 498058.48 |
| 9 | 5478.64 | 254.86 | 497803.62 |
| 10 | 5475.84 | 257.66 | 497545.96 |
| 11 | 5473.01 | 260.49 | 497285.47 |
| 12 | 5470.14 | 263.36 | 497022.11 |
References
- Gallager, T; Andrew Jr., J., Financial Management: Principals and Practices, Upper Saddle River, NJ: Prentice Hall, 1996
- HP-12C Business Calculator Owner's Manual, Hewlett Packard, 1984
- HP-10B Business Calculator Owner's Manual, Hewlett Packard, 1994
