Sort Term Loan APR Calculator

Hi All,
I'd like some help with putting together a short term loan apr calculator.

Most of the solutions I have found online ony work with Months/Years I need one that will work with days.

i.e.
Loan = £100
Repayment = £150
Period = 20 days
In this instance the Interest would be 50% but what would the (UK) APR be ?

Input should be Loan, Period and Int. Rate giving a result of the APR.

I would prefer PHP, but if someone has something hidden away in Javascript that would work as well..

Thanks Experts
LVL 11
maeltarAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ZvonkoConnect With a Mentor Systems architectCommented:
"Where do you get the 18 from ?"

You did NOT read this: http:#36573014

The 18 is the multiplier.
If your interests was for 20 days and you assume the year has 360 days then is the factor for 20 days this:
360 / 20 :== 18

The number of days to be 360 is a German bank calculation method to assume 12 months by 30 days.

But I think you see the question far too complicated.
All APR calculators try to solve the decrease of loan amount by monthly payment and increase of interest rate because you pay same amount every month for the interest.

But in your question you do not have monthly payments.
You confuse it because you have amount of days but you still pay back at once. So the APR is simply that percentage for repayment multiplied by the factor. In your example the factor is: 18

You see the 42 in the title of my example? That number is my favorite answer :-) Enter that number into Google and see what you get: 42 is the answer to all and everything if you know the question ;-)

0
 
ZvonkoSystems architectCommented:
You did not state what APR you calculate on paper.
I do get 900% when I calculate twelve months by thirty days.
And this is my page:
<html>
<head>
<title>Zvonko &#42;</title>
<script>
function getAPR(theForm){
  var theLoan = theForm.inpLoan.value*1;
  var thePay = theForm.inpRepaiment.value*1;
  var theDays = theForm.inpDays.value*1;
  theForm.outApr.value="";
  if(theLoan&&thePay&&theDays){
    theAPR=(thePay-theLoan)/theLoan*100*360/theDays;
	theForm.outApr.value=theAPR.toFixed(2);
  }
}
</script>
</head>
<body>
<form onKeyUp="getAPR(this)">
<table>
<tr><td>Loan</td><td>
<input type="text" name="inpLoan" ></td></tr>
<tr><td>Repaiment</td><td>
<input type="text" name="inpRepaiment" ></td></tr>
<tr><td>Days</td><td>
<input type="text" name="inpDays" ></td></tr>
<tr><td>APR[%]</td><td>
<input type="text" name="outApr" readonly></td></tr>
</table>
</form>
</body>
</html>

Open in new window

0
 
maeltarAuthor Commented:
The APR should be in the region of 4200%

I have been using the following Javascript....

The refrence to Issac's magic is to : http://en.wikipedia.org/wiki/Newton%27s_method

setPPA(52)

function CalcRate() {
  var p = getVal(document.input.credit.value);
  var i=getVal(document.input.initial.value);
  var a=getVal(document.input.repay.value);
  var n=Math.floor(getVal(document.input.number.value));
  var f=getVal(document.input.last.value);

  //Isaac's magic ...

  var x=1.0001; var fx=0; var dx=0; var z=0;
  do {
    fx=i+a*(Math.pow(x,n+1)-x)/(x-1)+f*Math.pow(x,n)-p;
    dx=a*(n*Math.pow(x,n+1)-(n+1)*Math.pow(x,n)+1)/Math.pow(x-1,2)+n*f*Math.pow(x,n-1);
    z=fx/dx; x=x-z;
    //alert("fx="+fx+"\ndx="+dx+"\nz="+z+"\nx="+x)
    }
    while (Math.abs(z)>1e-9);
     r=100*(Math.pow(1/x,m)-1);

  document.input.credit.value=TwoDP(p);
  document.input.initial.value=TwoDP(i);
  document.input.repay.value=TwoDP(a);
  document.input.number.value=n;
  document.input.last.value=TwoDP(f);

  document.getElementById('showapr').innerHTML = "APR : " + OneDP(r) + " %";
  document.getElementById('showapr').style.visibility = 'visible';

}

Open in new window

0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
maeltarAuthor Commented:
Oh, I did not write that, code.

From what I understand the setPPA() is the payment periods per annum (a guess)
0
 
ZvonkoSystems architectCommented:
Take paper and pencil and write down what you expect.
I do this:
The Year has 360 days and you pay interessts for 20 days and therefore you have to multiply the intersts percents by: 18
You see so far?
And then is 50% multiplied by 18: 900%
And not 4200 percent.

The 4200 percent from the calculation above is something else that you perhaps want but that I do not know how to calculate: if you calculate the interest not only for the Loan but also for the DAILY!!! interesst that you owe then it gets that high at the end of the day.
0
 
maeltarAuthor Commented:
Where do you get the 18 from ?

0
 
ZvonkoSystems architectCommented:
Read this:
http://en.wikipedia.org/wiki/Annual_percentage_rate

Read that and that write down how you want to calculate your percentages.
I can transform anything that you can calculate to JavaScript.
But JavaScript does not have the guess_what_I_nead() function, at least not yet <|;-)

0
 
maeltarAuthor Commented:
Zvonko, yes I think you are correct in that I am seeing it as more complicated that it actually is. However I am sure it is not as easy as you show.

I got my approximation of 4200% apr from http://www.wonga.com (using that as an example).
Note, that Wonga also only allow one payment.

Using 365 as days in the year :

365/20 == 18.25

18.25 * 50% = 912.50%

I have read the wiki page a number of times and maybe I am looking at the wrong place, but :

http://en.wikipedia.org/wiki/Annual_percentage_rate#European_Union

Shows the formula using the Newton-Raphson method which I believe I need to calculate it correctly (to meet legal requirements).

So the formula that I need turning into code is :

http://upload.wikimedia.org/math/f/4/a/f4a38e606f03ce70c274fe4e4f30f26f.png
0
 
ZvonkoSystems architectCommented:
You do not have a Sigma over one to N payments because your payment is done once.

And for the 365 change that days number in my example from 360 to 365 and you are done.

0
 
maeltarAuthor Commented:
Ok, fair enough, can you tell me how wonga.com achieved their 4214% apr please ?
0
 
ZvonkoSystems architectCommented:
No, I cannot tell you how they get that fantasy number.
Read this page section three:
http://www.wonga.com/money/is-this-apr-expensive

Then you will understand why they confuse the customers with that fantasy number.
Legally they are bound to tell you the APR. But they cannot.
The only thing is that they calculate 360% interests per anum. That is already extra orbital. But to hide that extra orbital interests they confuse the customer with even much higher percentage number to bring you back to trust their sliders and decide on your own whether you want to pay 360% percents (one percent for every day) or you do not want.

In Germany are such business forbidden.

0
 
maeltarAuthor Commented:
Ahhh  now that is an excellent find :-)

But that's because the calculation required by law means that, where a loan is not taken out for a year, the interest rate must be compounded the same number of times the actual loan period would fit into a year.

So I just need to compound the rate and I will get the apr, ok, thank you very much for your time and patience helping me to understand this ...
0
 
ZvonkoSystems architectCommented:
You are welcome <|:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.