Amortization program (with source)

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
blueb
Addict
Addict
Posts: 1116
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Amortization program (with source)

Post by blueb »

Here's a small amortization program I wrote that includes source.
It can probably be modified for non-windows use.

https://www.dropbox.com/s/q1p9p1zean6x340/Amortize.zip

blueb
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Amortization program (with source)

Post by netmaestro »

In Canada, most home mortgage loans are paid monthly but compounded semi-anually. I don't see where I can choose compounds per year with your program (which is quite nice btw). If you would like to add compounds/year to it, this is the math I use, sample data provided should yield a monthly payment of $650.81:

Code: Select all

p=60000      ; Principal
j.f=0.1275   ; Interest rate
y=25         ; Years of loan
f=12         ; frequency of payments per year (12 for monthly, 52 for weekly, etc.)
m=2          ; compounds per year

a.d =  p * (Pow(1+j/m, m/f) - 1) / (1 - Pow(1+j/m,-y*m))

Debug StrD(a,2)
Your program yields $665.43, which means you're always compounding monthly.
BERESHEIT
User avatar
blueb
Addict
Addict
Posts: 1116
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Amortization program (with source)

Post by blueb »

I forgot to allow for our beloved Canadians, who are probably waiting for spring to arrive, and who are as sharp as tacks. :mrgreen:

Yes, I'll work on a maple leaf version.

Actually there may be situations where it's feasible to have:
- blended quarterly payments
- blended semi-annual payments (Canada)
- blended annual payments

So the program works for part of the world, until I can make some adjustments.

Funny, I double-checked my results with:
"Loan Payments Handbook" that I've owned forever.
publisher: Computofacts
address: Willowdale, Ontario, Canada :wink:
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Post Reply