OK. I'm brand new to this site so "Hello All"! Well I've been wrestling with a difficult problem for the last week and I would appreciate any help you can give me.
I know there are many formulas out there to calculate APR but I've tested many formulas and they do not handle Odd-Days properly for closed-end (consumer loans). The government has attempted to give us mere mortals some help with this by publishing an Appendix J to their truth-in-lending act. It can be found here: https://www.fdic.gov/regulations/laws/rules/6500-3550.html
If you're brave (!!), you can see the formulas they provide which will solve for the APR, including the Odd-Days of the loan. Odd-Days are the days at the beginning of the loan that isn't really covered by a regular period payment but interest is still being charged. For example, you take a loan for $1,000.00 on 01/20/2012 and your first payment is 03/01/2012. You have 10 odd-days from 01/20/2012 to 01/30/2012. All months are 30 days for their calcs.
What I'm hoping for is someone with a significant background in Calculus who can interpret the the formulas you'll find about half way down Appendix J. And interpret the Actuarial method they're using to solve these formulas. I understand the iterative process. I first tried to solve this using the Newton-Raphson method but my formula for the APR did not account for the Odd-days. It worked great in the unlikely trivial case where there are no odd days, but struggled with odd-days.
I know that reading this document is very difficult! I've made some headway but there are certain things I just can't figure out how they're doing. They seem to introduce a few things as if by magic.
Anyways thanks ahead of time for helping! :)
Alright, you weren't kidding about the document being a bit hard to read. The solution is actually not that bad though, depending on implementation. I failed repeatedly trying to use their various simplified forumulae and eventually got it using the general formula up top(8). Technically this is a simplification. The actual general formula would take arrays of length
period
for the other arguments and use their indexes in the loop. You use this method to get A' and A'' for the iteration step. Odd days are handled by(1.0 + fractions*rate)
, which appears as1 + f i
in the document. Rate is the rate per period, not overall apr.Iteration behaves just as the document says in its example(9).
Note that as a general rule it is BAD to use double for monetary calculations as I have done here, but I'm writing a SO example, not production code. Also, it's java instead of .net, but it should help you with the algorithm.
I got me a Python (3.4) translation here. And since my application takes dates as inputs, not full and partial payment periods, I threw in a way to calculate those. I referenced a document by one of the guys that wrote the OCC's APRWIN, and I'd advise others to read it if you need to re-translate this.
My tests come straight from the Reg Z examples. I haven't done further testing with APRWIN yet. An edge case I don't have to deal with (so haven't coded for) is when you only have 2 installments and the first is an irregular period. Check the document above if that's a potential use case for your app. I also haven't fully tested most of the payment schedules because my app only needs monthly and quarterly. The rest are just there to use Reg Z's examples.
Tho this is an old thread, I'd like to help others avoid wasting time on this - translating the code to PHP (or even javascript), gives wildly inaccurate results, causing me to wonder if it really worked in Java -
APR: 12.5000% Total Financial Charges: $1,695.32 Amount Financed: $10,000.00 Total Payments: $11,695.32 Total Loan: $10,000.00 Monthly Payment: $389.84 Total Interest: $1,695.32