Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Financial Formulas
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00882538
Message ID:
00882723
Views:
19
>I have an application that now needs to work with various financial information and perform some calculations... such as, I know the principal amount, interest rate, number of payments and the amount of each payment... how do I calculate the interest charged as each payment is applied and thus find the amount to reduce the principal on an ongoing basis till the loan is complete... is there an fll/dll available or sample code available somewhere... thanx

This is one I used with fixed incomes. See Handbook of Fixed Income Securities, Fabozzi. It may be a bit elaborate - but that was necessary because prepayments (mortality/PSA/CPR) was another piece of the solution. But it does amortize the principal! PAYMENT() returns the toal period P/I:
* Amort.PRG
* CALL = Do Amort WITH 1000,5,12
*        do Amort with TotalLoaned,%Interest,Number of Payments
*
LPARAMETERS lnP,lnR,lnN
lnR=lnR/100/12 && Annualize and correct for percent
*!*	lnP=Original Principal or Face
*!*	lnR=Interest Rate
*!*	lnN=Number of payment periods
DIMENSION arAmort[lnN,5]
*arAmort(n,1)=Total Monthly Payment
*arAmort(n,2)=Interest payment
*arAmort(n,3)=Principal Payment
*arAmort(n,4)=Principal Balance
*arAmort(n,5)=Pricipal factor
lnPBal=lnP   && Pricipal Balance
FOR C=1 TO lnN
* Total Monthly payment
arAmort[c,1]=ROUND(lnPBal*(lnR*(1+lnR)**(lnN-C+1)) / ((1+lnR)**(lnN-C+1)-1),2)
* Interest portion of payment
arAmort[c,2]=ROUND(lnPBal*lnR,2)
* Principal Portion of payment
arAmort[c,3]=arAmort[c,1]-arAmort[c,2]
* Principal Balance (current face)
arAmort[c,4]=lnPBal-arAmort[c,3] && balance less period principal payment
* Principal Factor
arAmort[c,5]=ROUND(arAmort[c,4]/lnP,6)
* Principal balance for next period's calculation
lnPBal=arAmort[c,4] && Pricipal forward for next reiteration
ENDFOR 
*!*	lnTotalInterest=0
*!*	FOR c=1 TO lnN
*!*	lnTotalInterest=lnTotalInterest+arAmort[c,2]
*!*	ENDFOR
*!*	?lnTotalInterest
disp MEMORY LIKE arAmort
Imagination is more important than knowledge
Previous
Reply
Map
View

Click here to load this message in the networking platform