Calculating the APR
up vote
1
down vote
favorite
I'm using the Microsoft.VisualBasic Assembly to use rate
and Pmt
for some reason when i run my code it keeps giving me a completely wrong number
I've thoroughly read the docs and cant seem to identify the issue:
origFee30YearRate = 0.04875M;
double Nper = 360;
double Pmt = Financial.Pmt((double)(origFee30YearRate / 12), Nper, 100000);
double PV = ((Pmt * Nper) * -1) - 1775.25;
var org30APR = (Financial.Rate(Nper, Pmt, PV)) * 12;
The values come out to be:
Nper: 360
Pmt: -529.20822384932933
PV: 188739.71058575856
I'm not sure whats going wrong here with calculating the Rate
The output from Rate
is: 0.0006268633835987544
where is should be 5.14
c#
|
show 2 more comments
up vote
1
down vote
favorite
I'm using the Microsoft.VisualBasic Assembly to use rate
and Pmt
for some reason when i run my code it keeps giving me a completely wrong number
I've thoroughly read the docs and cant seem to identify the issue:
origFee30YearRate = 0.04875M;
double Nper = 360;
double Pmt = Financial.Pmt((double)(origFee30YearRate / 12), Nper, 100000);
double PV = ((Pmt * Nper) * -1) - 1775.25;
var org30APR = (Financial.Rate(Nper, Pmt, PV)) * 12;
The values come out to be:
Nper: 360
Pmt: -529.20822384932933
PV: 188739.71058575856
I'm not sure whats going wrong here with calculating the Rate
The output from Rate
is: 0.0006268633835987544
where is should be 5.14
c#
you should change the magic numbers in yourPV
assignment statement todouble
s (i.e.15
->15d
), especially the ones that are being used for division. e.g. the(1/100)
part will always result in the RHS of the first-
being-1775.25
.
– Tau
Nov 9 at 15:16
@Charles - FWIW...I worked for a bank a year ago and had to build a loan proposal app which required APR to be calculated on the fly based changes to the loan...ie...amount, interest rate, term, etc. I spent over a month working to get it right with multiple loan officers checking my work along the way. The only way to accurately do what you are after is to calculate the amortization schedule for the life of the loan and use the remaining balance to identify the APR over the term. Financial.Rate looks promising, but will not get you what you need. The code to get it right is a beast.
– user1011627
Nov 9 at 17:40
@user1011627 any way you have that code?
– Charles
Nov 9 at 17:41
What is PV, what are you trying to calculate? 360 payments @ $529.21 is $190,515.16, your calculated PV is $188,789.71. Does that sound like 5.14% to you? Fix your PV and your call toFinancial.Rate
should fix itself.
– Derrick Moeller
Nov 9 at 18:08
@DerrickMoeller PV is the value of the loan, i guess i cant seem to figure out PV correctly from my understanding its the life of the loan(360) * the monthly payment(529.21) subtracting the lending fees. Not sure why this isn't adding up
– Charles
Nov 9 at 18:13
|
show 2 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm using the Microsoft.VisualBasic Assembly to use rate
and Pmt
for some reason when i run my code it keeps giving me a completely wrong number
I've thoroughly read the docs and cant seem to identify the issue:
origFee30YearRate = 0.04875M;
double Nper = 360;
double Pmt = Financial.Pmt((double)(origFee30YearRate / 12), Nper, 100000);
double PV = ((Pmt * Nper) * -1) - 1775.25;
var org30APR = (Financial.Rate(Nper, Pmt, PV)) * 12;
The values come out to be:
Nper: 360
Pmt: -529.20822384932933
PV: 188739.71058575856
I'm not sure whats going wrong here with calculating the Rate
The output from Rate
is: 0.0006268633835987544
where is should be 5.14
c#
I'm using the Microsoft.VisualBasic Assembly to use rate
and Pmt
for some reason when i run my code it keeps giving me a completely wrong number
I've thoroughly read the docs and cant seem to identify the issue:
origFee30YearRate = 0.04875M;
double Nper = 360;
double Pmt = Financial.Pmt((double)(origFee30YearRate / 12), Nper, 100000);
double PV = ((Pmt * Nper) * -1) - 1775.25;
var org30APR = (Financial.Rate(Nper, Pmt, PV)) * 12;
The values come out to be:
Nper: 360
Pmt: -529.20822384932933
PV: 188739.71058575856
I'm not sure whats going wrong here with calculating the Rate
The output from Rate
is: 0.0006268633835987544
where is should be 5.14
c#
c#
edited Nov 9 at 18:11
Derrick Moeller
2,46721331
2,46721331
asked Nov 9 at 15:10
Charles
5681723
5681723
you should change the magic numbers in yourPV
assignment statement todouble
s (i.e.15
->15d
), especially the ones that are being used for division. e.g. the(1/100)
part will always result in the RHS of the first-
being-1775.25
.
– Tau
Nov 9 at 15:16
@Charles - FWIW...I worked for a bank a year ago and had to build a loan proposal app which required APR to be calculated on the fly based changes to the loan...ie...amount, interest rate, term, etc. I spent over a month working to get it right with multiple loan officers checking my work along the way. The only way to accurately do what you are after is to calculate the amortization schedule for the life of the loan and use the remaining balance to identify the APR over the term. Financial.Rate looks promising, but will not get you what you need. The code to get it right is a beast.
– user1011627
Nov 9 at 17:40
@user1011627 any way you have that code?
– Charles
Nov 9 at 17:41
What is PV, what are you trying to calculate? 360 payments @ $529.21 is $190,515.16, your calculated PV is $188,789.71. Does that sound like 5.14% to you? Fix your PV and your call toFinancial.Rate
should fix itself.
– Derrick Moeller
Nov 9 at 18:08
@DerrickMoeller PV is the value of the loan, i guess i cant seem to figure out PV correctly from my understanding its the life of the loan(360) * the monthly payment(529.21) subtracting the lending fees. Not sure why this isn't adding up
– Charles
Nov 9 at 18:13
|
show 2 more comments
you should change the magic numbers in yourPV
assignment statement todouble
s (i.e.15
->15d
), especially the ones that are being used for division. e.g. the(1/100)
part will always result in the RHS of the first-
being-1775.25
.
– Tau
Nov 9 at 15:16
@Charles - FWIW...I worked for a bank a year ago and had to build a loan proposal app which required APR to be calculated on the fly based changes to the loan...ie...amount, interest rate, term, etc. I spent over a month working to get it right with multiple loan officers checking my work along the way. The only way to accurately do what you are after is to calculate the amortization schedule for the life of the loan and use the remaining balance to identify the APR over the term. Financial.Rate looks promising, but will not get you what you need. The code to get it right is a beast.
– user1011627
Nov 9 at 17:40
@user1011627 any way you have that code?
– Charles
Nov 9 at 17:41
What is PV, what are you trying to calculate? 360 payments @ $529.21 is $190,515.16, your calculated PV is $188,789.71. Does that sound like 5.14% to you? Fix your PV and your call toFinancial.Rate
should fix itself.
– Derrick Moeller
Nov 9 at 18:08
@DerrickMoeller PV is the value of the loan, i guess i cant seem to figure out PV correctly from my understanding its the life of the loan(360) * the monthly payment(529.21) subtracting the lending fees. Not sure why this isn't adding up
– Charles
Nov 9 at 18:13
you should change the magic numbers in your
PV
assignment statement to double
s (i.e. 15
->15d
), especially the ones that are being used for division. e.g. the (1/100)
part will always result in the RHS of the first -
being -1775.25
.– Tau
Nov 9 at 15:16
you should change the magic numbers in your
PV
assignment statement to double
s (i.e. 15
->15d
), especially the ones that are being used for division. e.g. the (1/100)
part will always result in the RHS of the first -
being -1775.25
.– Tau
Nov 9 at 15:16
@Charles - FWIW...I worked for a bank a year ago and had to build a loan proposal app which required APR to be calculated on the fly based changes to the loan...ie...amount, interest rate, term, etc. I spent over a month working to get it right with multiple loan officers checking my work along the way. The only way to accurately do what you are after is to calculate the amortization schedule for the life of the loan and use the remaining balance to identify the APR over the term. Financial.Rate looks promising, but will not get you what you need. The code to get it right is a beast.
– user1011627
Nov 9 at 17:40
@Charles - FWIW...I worked for a bank a year ago and had to build a loan proposal app which required APR to be calculated on the fly based changes to the loan...ie...amount, interest rate, term, etc. I spent over a month working to get it right with multiple loan officers checking my work along the way. The only way to accurately do what you are after is to calculate the amortization schedule for the life of the loan and use the remaining balance to identify the APR over the term. Financial.Rate looks promising, but will not get you what you need. The code to get it right is a beast.
– user1011627
Nov 9 at 17:40
@user1011627 any way you have that code?
– Charles
Nov 9 at 17:41
@user1011627 any way you have that code?
– Charles
Nov 9 at 17:41
What is PV, what are you trying to calculate? 360 payments @ $529.21 is $190,515.16, your calculated PV is $188,789.71. Does that sound like 5.14% to you? Fix your PV and your call to
Financial.Rate
should fix itself.– Derrick Moeller
Nov 9 at 18:08
What is PV, what are you trying to calculate? 360 payments @ $529.21 is $190,515.16, your calculated PV is $188,789.71. Does that sound like 5.14% to you? Fix your PV and your call to
Financial.Rate
should fix itself.– Derrick Moeller
Nov 9 at 18:08
@DerrickMoeller PV is the value of the loan, i guess i cant seem to figure out PV correctly from my understanding its the life of the loan(360) * the monthly payment(529.21) subtracting the lending fees. Not sure why this isn't adding up
– Charles
Nov 9 at 18:13
@DerrickMoeller PV is the value of the loan, i guess i cant seem to figure out PV correctly from my understanding its the life of the loan(360) * the monthly payment(529.21) subtracting the lending fees. Not sure why this isn't adding up
– Charles
Nov 9 at 18:13
|
show 2 more comments
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
To start your origFee30YearRate
appears to be incorrect. 4.75% should be assigned as 0.0475 not 4.75. Also, you appear to be incorrectly changing the sign of the payment.
double origFee30YearRate = 0.0475;
double Nper = 360;
double Pmt = Financial.Pmt(origFee30YearRate / 12, Nper, 100000);
double PV = (100000 - (100000 * origFee30YearRate / 365 * 15) - (100000 * (1 / 100)) - 1775.25);
var org30APR = Financial.Rate(Nper, Pmt, PV) * 12;
This returns an interest rate of 4.92%, presumably you're trying to calculate back to 4.75%?
The reason you don't get 4.75% is because PVal
is how much you borrowed and I'm not entirely sure why you're calculating it.
double origFee30YearRate = 0.0475;
double Nper = 360;
double Pmt = Financial.Pmt(origFee30YearRate / 12, Nper, 100000);
var org30APR = Financial.Rate(Nper, Pmt, 100000) * 12;
Also, if you want to change your units back to %, simply multiply by 100.
var org30APR = (Financial.Rate(Nper, Pmt, 100000) * 12) * 100;
For APR, I believe you just need to subtract the fees.
var apr = (Financial.Rate(Nper, Pmt, (100000 - 1775.25)) * 12) * 100;
please refer to my comment on OP's post.PV
will have the wrong value if you do integer division.
– Tau
Nov 9 at 16:56
@DerrickMoeller with a interest rate of 4.75% should return an APR of 5.04%. This algorithm is returning 4.75%
– Charles
Nov 9 at 18:18
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
To start your origFee30YearRate
appears to be incorrect. 4.75% should be assigned as 0.0475 not 4.75. Also, you appear to be incorrectly changing the sign of the payment.
double origFee30YearRate = 0.0475;
double Nper = 360;
double Pmt = Financial.Pmt(origFee30YearRate / 12, Nper, 100000);
double PV = (100000 - (100000 * origFee30YearRate / 365 * 15) - (100000 * (1 / 100)) - 1775.25);
var org30APR = Financial.Rate(Nper, Pmt, PV) * 12;
This returns an interest rate of 4.92%, presumably you're trying to calculate back to 4.75%?
The reason you don't get 4.75% is because PVal
is how much you borrowed and I'm not entirely sure why you're calculating it.
double origFee30YearRate = 0.0475;
double Nper = 360;
double Pmt = Financial.Pmt(origFee30YearRate / 12, Nper, 100000);
var org30APR = Financial.Rate(Nper, Pmt, 100000) * 12;
Also, if you want to change your units back to %, simply multiply by 100.
var org30APR = (Financial.Rate(Nper, Pmt, 100000) * 12) * 100;
For APR, I believe you just need to subtract the fees.
var apr = (Financial.Rate(Nper, Pmt, (100000 - 1775.25)) * 12) * 100;
please refer to my comment on OP's post.PV
will have the wrong value if you do integer division.
– Tau
Nov 9 at 16:56
@DerrickMoeller with a interest rate of 4.75% should return an APR of 5.04%. This algorithm is returning 4.75%
– Charles
Nov 9 at 18:18
add a comment |
up vote
2
down vote
accepted
To start your origFee30YearRate
appears to be incorrect. 4.75% should be assigned as 0.0475 not 4.75. Also, you appear to be incorrectly changing the sign of the payment.
double origFee30YearRate = 0.0475;
double Nper = 360;
double Pmt = Financial.Pmt(origFee30YearRate / 12, Nper, 100000);
double PV = (100000 - (100000 * origFee30YearRate / 365 * 15) - (100000 * (1 / 100)) - 1775.25);
var org30APR = Financial.Rate(Nper, Pmt, PV) * 12;
This returns an interest rate of 4.92%, presumably you're trying to calculate back to 4.75%?
The reason you don't get 4.75% is because PVal
is how much you borrowed and I'm not entirely sure why you're calculating it.
double origFee30YearRate = 0.0475;
double Nper = 360;
double Pmt = Financial.Pmt(origFee30YearRate / 12, Nper, 100000);
var org30APR = Financial.Rate(Nper, Pmt, 100000) * 12;
Also, if you want to change your units back to %, simply multiply by 100.
var org30APR = (Financial.Rate(Nper, Pmt, 100000) * 12) * 100;
For APR, I believe you just need to subtract the fees.
var apr = (Financial.Rate(Nper, Pmt, (100000 - 1775.25)) * 12) * 100;
please refer to my comment on OP's post.PV
will have the wrong value if you do integer division.
– Tau
Nov 9 at 16:56
@DerrickMoeller with a interest rate of 4.75% should return an APR of 5.04%. This algorithm is returning 4.75%
– Charles
Nov 9 at 18:18
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
To start your origFee30YearRate
appears to be incorrect. 4.75% should be assigned as 0.0475 not 4.75. Also, you appear to be incorrectly changing the sign of the payment.
double origFee30YearRate = 0.0475;
double Nper = 360;
double Pmt = Financial.Pmt(origFee30YearRate / 12, Nper, 100000);
double PV = (100000 - (100000 * origFee30YearRate / 365 * 15) - (100000 * (1 / 100)) - 1775.25);
var org30APR = Financial.Rate(Nper, Pmt, PV) * 12;
This returns an interest rate of 4.92%, presumably you're trying to calculate back to 4.75%?
The reason you don't get 4.75% is because PVal
is how much you borrowed and I'm not entirely sure why you're calculating it.
double origFee30YearRate = 0.0475;
double Nper = 360;
double Pmt = Financial.Pmt(origFee30YearRate / 12, Nper, 100000);
var org30APR = Financial.Rate(Nper, Pmt, 100000) * 12;
Also, if you want to change your units back to %, simply multiply by 100.
var org30APR = (Financial.Rate(Nper, Pmt, 100000) * 12) * 100;
For APR, I believe you just need to subtract the fees.
var apr = (Financial.Rate(Nper, Pmt, (100000 - 1775.25)) * 12) * 100;
To start your origFee30YearRate
appears to be incorrect. 4.75% should be assigned as 0.0475 not 4.75. Also, you appear to be incorrectly changing the sign of the payment.
double origFee30YearRate = 0.0475;
double Nper = 360;
double Pmt = Financial.Pmt(origFee30YearRate / 12, Nper, 100000);
double PV = (100000 - (100000 * origFee30YearRate / 365 * 15) - (100000 * (1 / 100)) - 1775.25);
var org30APR = Financial.Rate(Nper, Pmt, PV) * 12;
This returns an interest rate of 4.92%, presumably you're trying to calculate back to 4.75%?
The reason you don't get 4.75% is because PVal
is how much you borrowed and I'm not entirely sure why you're calculating it.
double origFee30YearRate = 0.0475;
double Nper = 360;
double Pmt = Financial.Pmt(origFee30YearRate / 12, Nper, 100000);
var org30APR = Financial.Rate(Nper, Pmt, 100000) * 12;
Also, if you want to change your units back to %, simply multiply by 100.
var org30APR = (Financial.Rate(Nper, Pmt, 100000) * 12) * 100;
For APR, I believe you just need to subtract the fees.
var apr = (Financial.Rate(Nper, Pmt, (100000 - 1775.25)) * 12) * 100;
edited Nov 9 at 19:51
answered Nov 9 at 15:27
Derrick Moeller
2,46721331
2,46721331
please refer to my comment on OP's post.PV
will have the wrong value if you do integer division.
– Tau
Nov 9 at 16:56
@DerrickMoeller with a interest rate of 4.75% should return an APR of 5.04%. This algorithm is returning 4.75%
– Charles
Nov 9 at 18:18
add a comment |
please refer to my comment on OP's post.PV
will have the wrong value if you do integer division.
– Tau
Nov 9 at 16:56
@DerrickMoeller with a interest rate of 4.75% should return an APR of 5.04%. This algorithm is returning 4.75%
– Charles
Nov 9 at 18:18
please refer to my comment on OP's post.
PV
will have the wrong value if you do integer division.– Tau
Nov 9 at 16:56
please refer to my comment on OP's post.
PV
will have the wrong value if you do integer division.– Tau
Nov 9 at 16:56
@DerrickMoeller with a interest rate of 4.75% should return an APR of 5.04%. This algorithm is returning 4.75%
– Charles
Nov 9 at 18:18
@DerrickMoeller with a interest rate of 4.75% should return an APR of 5.04%. This algorithm is returning 4.75%
– Charles
Nov 9 at 18:18
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228333%2fcalculating-the-apr%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
you should change the magic numbers in your
PV
assignment statement todouble
s (i.e.15
->15d
), especially the ones that are being used for division. e.g. the(1/100)
part will always result in the RHS of the first-
being-1775.25
.– Tau
Nov 9 at 15:16
@Charles - FWIW...I worked for a bank a year ago and had to build a loan proposal app which required APR to be calculated on the fly based changes to the loan...ie...amount, interest rate, term, etc. I spent over a month working to get it right with multiple loan officers checking my work along the way. The only way to accurately do what you are after is to calculate the amortization schedule for the life of the loan and use the remaining balance to identify the APR over the term. Financial.Rate looks promising, but will not get you what you need. The code to get it right is a beast.
– user1011627
Nov 9 at 17:40
@user1011627 any way you have that code?
– Charles
Nov 9 at 17:41
What is PV, what are you trying to calculate? 360 payments @ $529.21 is $190,515.16, your calculated PV is $188,789.71. Does that sound like 5.14% to you? Fix your PV and your call to
Financial.Rate
should fix itself.– Derrick Moeller
Nov 9 at 18:08
@DerrickMoeller PV is the value of the loan, i guess i cant seem to figure out PV correctly from my understanding its the life of the loan(360) * the monthly payment(529.21) subtracting the lending fees. Not sure why this isn't adding up
– Charles
Nov 9 at 18:13