Sure, if you click the link to the APR tool, click the continue button at the bottom and on the next page, enter 975 for the amount financed, and a number for the disclosed apr. Leave installment loan radio button and monthly as is and click continue. On this next page input 340 for the payment and 3 for the number of payments. This is the one and only payment stream for this loan. You will see that there is a link to add a payment stream. Unit periods will auto calc as you enter additional payment streams. Leave the odd days blank. This is for extra days for when a loan begins on a day that is not the 1st of the month or the last day of the month. Once you click continue the tool calculates the apr and displays the information on the next page. The response agrees with the calculation in the pdf document (page 5) which as I mentioned you can find through the help link.
If you look at the code, the step 1 step 2 step 3 are found on page 39 of the document. It does interpolation to derive the apr using iteration to solve the general equation. So if you feed this into the code you will get the same answer 27.48% for the 1 payment stream of 3 payments of 340 on a loan of $1000 with a $25 finance charge.
Dim apr1 As Double = 0
Dim amount As Double = Convert.ToDouble(txtamtfin.Text)
'apr1 = findAPRGEQ(amount, pmtarray(0), pmtterm(0), 12, (Noterate / 12) + 0.1, 0, 1)
apr1 = findAPRGEQ(975,340, 3, 12, 10, 0, 1)
In my code, I created arrays, pmtarray to store the payments and pmtterm to store the number of these payments. I could loop through these 2 arrays and feed each one into the findAPRGEQ but I'm unclear on how to calculate the final result. According to the general equation shown on page 8 and 9, you are supposed to solve for i by using 975=340/(1+i) power 1 + 340/(1+i) power 2 + 340/(1+i) power 3
This is a simple example using the same payment 340 for 3 payments. Assuming the loan was for 6 year, the equation would be 975= payment 1/(1+i) power 1 +payment 2/(1+i) power 2 + ... payment12/(1+i) power 6
This is the equation for the loan above shown on page 9 of the documents. Extending this out to 6 payments and changing the payments to $100 X 3 and $300 X 3 ($1200 total) it would like this:
975 = 100/(1+i) power 1 + 100/(1+i) power 2 + 100/(1+i) power 3 +300/(1+i) power 4 + 300/(1+i) power 5 + 300/(1+i) power 6
How can the code be modified to accept more than 1 payment stream? Should each payment stream be fed into the function with a loop and store each result into an array and when finished do another loop to add up all the numbers in the result array?
The tool gives these results for these 2 payments streams:
Amount Financed
975. 00
Finance Charge
225. 00
Total of Payments
1,200.00
Annual Percentage Rate
60. 9555
Loan Regularity
Irregular