Some financial functions.
double NetPresentValue(double discountRate, const Vector<double> &cf)
Calculates the Net present value.with discountRate discount rate, and cf cash flow.
Vector<double> InternalRateOfReturn(const Vector<double> &cf, double lowRate, double highRate, int maxIteration, double precisionReq)
Calculates the Internal rate of return of an investment. The arguments are:
cf is the cash flow.
lowRate is the initial rate with which we compute the NPV.
highRate is the highest rate up to which we should consider for computing NPV.
maxIteration: There is always a possibility of not able to arrive at the rate for certain cash flows. This variable acts as a stopper for the number of iterations the code should check for NPV so as to ensure that the program does not go for an infinite loop
precisionReq : NPV value will not normally hit zero. We can find the NPV value with a precision upto certain value. When the computed NPV is below this value, the calculation stop and the rate used will be the IRR.
double PMT(double rate, double nper, double pv).
Calculates the payment for a loan based on constant payments and a constant interest rate. The arguments are:
rate is the interest rate for the loan.
nper is the total number of payments for the loan.
pv is the present value, or the total amount that a series of future payments is worth now; also known as the principal.
|