Charles L.
Charles L.

Reputation: 1970

Calculating the APR

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

Upvotes: 1

Views: 608

Answers (1)

Derrick Moeller
Derrick Moeller

Reputation: 4960

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;

Upvotes: 2

Related Questions