Class Finance
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFlag used to indicate that payment is made at the beginning of each period.static final intFlag used to indicate that payment is made at the end of each period. -
Method Summary
Modifier and TypeMethodDescriptionstatic doublecumipmt(double rate, int nper, double pv, int start, int end, int when) Returns the cumulative interest paid between two periods.static doublecumprinc(double rate, int nper, double pv, int start, int end, int when) Returns the cumulative principal paid between two periods.static doubledb(double cost, double salvage, int life, int period, int month) Returns the depreciation of an asset using the fixed-declining balance method.static doubleddb(double cost, double salvage, int life, int period, double factor) Returns the depreciation of an asset using the double-declining balance method.static doubledollarde(double fractionalDollar, int fraction) Converts a fractional price to a decimal price.static doubledollarfr(double decimalDollar, int fraction) Converts a decimal price to a fractional price.static doubleeffect(double nominalRate, int nper) Returns the effective annual interest rate.static doublefv(double rate, int nper, double pmt, double pv, int when) Returns the future value of an investment.static doublefvschedule(double principal, double[] schedule) Returns the future value of an initial principal taking into consideration a schedule of compound interest rates.static doubleipmt(double rate, int period, int nper, double pv, double fv, int when) Returns the interest payment for an investment for a given period.static doubleirr(double[] pmt) Returns the internal rate of return for a schedule of cash flows.static doubleirr(double[] pmt, double guess) Returns the internal rate of return for a schedule of cash flows.static doublemirr(double[] value, double financeRate, double reinvestRate) Returns the modified internal rate of return for a schedule of periodic cash flows.static doublenominal(double effectiveRate, int nper) Returns the nominal annual interest rate.static doublenper(double rate, double pmt, double pv, double fv, int when) Returns the number of periods for an investment for which periodic, and constant payments are made and the interest rate is constant.static doublenpv(double rate, double[] value) Returns the net present value of a stream of equal periodic cash flows, which are subject to a given discount rate.static doublepmt(double rate, int nper, double pv, double fv, int when) Returns the periodic payment for an investment.static doubleppmt(double rate, int period, int nper, double pv, double fv, int when) Returns the payment on the principal for a specified period.static doublepv(double rate, int nper, double pmt, double fv, int when) Returns the net present value of a stream of equal periodic cash flows, which are subject to a given discount rate.static doublerate(int nper, double pmt, double pv, double fv, int when) Returns the interest rate per period of an annuity.static doublerate(int nper, double pmt, double pv, double fv, int when, double guess) Returns the interest rate per period of an annuity with an initial guess.static doublesln(double cost, double salvage, int life) Returns the depreciation of an asset using the straight line method.static doublesyd(double cost, double salvage, int life, int per) Returns the depreciation of an asset using the sum-of-years digits method.static doublevdb(double cost, double salvage, int life, int start, int end, double factor, boolean no_sl) Returns the depreciation of an asset for any given period using the variable-declining balance method.static doubleReturns the internal rate of return for a schedule of cash flows.static doubleReturns the internal rate of return for a schedule of cash flows with a user supplied initial guess.static doubleReturns the present value for a schedule of cash flows.
-
Field Details
-
AT_END_OF_PERIOD
public static final int AT_END_OF_PERIODFlag used to indicate that payment is made at the end of each period.- See Also:
-
AT_BEGINNING_OF_PERIOD
public static final int AT_BEGINNING_OF_PERIODFlag used to indicate that payment is made at the beginning of each period.- See Also:
-
-
Method Details
-
cumipmt
public static double cumipmt(double rate, int nper, double pv, int start, int end, int when) Returns the cumulative interest paid between two periods. It is computed using the following:$$\sum\limits_{i = {\it start}}^{\it end} {\it interest}_i$$
where \({\it interest}_i$$ is computed fromipmtfor the \(i\)th period.- Parameters:
rate- adouble, the interest ratenper- anint, the total number of payment periodspv- adouble, the present valuestart- anint, the first period in the caclulation. Periods are numbered starting with one.end- anint, the last period in the calculationwhen- anint, the time in each period when the payment is made, eitherAT_END_OF_PERIODorAT_BEGINNING_OF_PERIOD- Returns:
- a
double, the cumulative interest paid between the first period and the last period - See Also:
-
cumprinc
public static double cumprinc(double rate, int nper, double pv, int start, int end, int when) Returns the cumulative principal paid between two periods. It is computed using the following:$$\sum\limits_{i = {\it start}}^{\it end} {\it principal}_i$$
where \({\it principal}_i\) is computed fromppmtfor the \(i\)th period.- Parameters:
rate- adouble, the interest ratenper- anint, the total number of payment periodspv- adouble, the present valuestart- anint, the first period in the calculation. Periods are numbered starting with one.end- anint, the last period in the calculationwhen- anint, the time in each period when the payment is made, eitherAT_END_OF_PERIODorAT_BEGINNING_OF_PERIOD.- Returns:
- a
double, the cumulative principal paid between the first period and the last period - See Also:
-
db
public static double db(double cost, double salvage, int life, int period, int month) Returns the depreciation of an asset using the fixed-declining balance method. Methoddbvaries depending on the specified value for the argument period, see table below.If period = 1, $${\rm{cost}} \times {\rm{rate}} \times {{{\rm{month}}} \over {12}}$$
where
If period = life, $$\left( {{\rm{cost}} - {\rm{total}}\,{\rm{depreciation}}\,{\rm{from}}\,{\rm{periods}}} \right) \times {\rm{rate}} \times {{12{\rm{ - month}}} \over {12}}$$
If period other than 1 or life, $$\,\left( {{\rm{cost}} - {\rm{total}}\,{\rm{depreciation}}\,{\rm{from}}\, {\rm{prior periods}}} \right) \times rate$$$$\,rate\, = 1 - \left( {{{{\rm{salvage}}} \over {{\rm{cost}}}}} \right)^{\left( {{1 \over {life}}} \right)}$$
NOTE: \(rate\) is rounded to three decimal places.
- Parameters:
cost- adouble, the initial cost of the assetsalvage- adouble, the salvage value of the assetlife- anint, the number of periods over which the asset is being depreciatedperiod- anint, the period for which the depreciation is to be computedmonth- anint, the number of months in the first year- Returns:
- a
double, the depreciation of an asset for a specified period using the fixed-declining balance method - See Also:
-
ddb
public static double ddb(double cost, double salvage, int life, int period, double factor) Returns the depreciation of an asset using the double-declining balance method. It is computed using the following:$$\left[ {{\it cost} - {\it salvage}\left( {\it {total\,depreciation\,from\,prior\,periods}} \right)} \right]\, {{{\it factor} \over {\it life}}}$$
- Parameters:
cost- adouble, the initial cost of the assetsalvage- adouble, the salvage value of the assetlife- anint, the number of periods over which the asset is being depreciatedperiod- anint, the periodfactor- adouble, the rate at which the balance declines- Returns:
- a
double, the depreciation of an asset for a specified period - See Also:
-
dollarde
public static double dollarde(double fractionalDollar, int fraction) Converts a fractional price to a decimal price. It is computed using the following:$${\it idollar} + \left( {{\it fractionalDollar} - {\it idollar}} \right) \times {{10^{\left( {{\it ifrac} + 1} \right)} } \over {\it fraction}}$$
where \({\it idollar}\) is the integer part of \({\it fractionalDollar}\), and \({\it ifrac}\) is the integer part of \({\rm {log}}({\it fraction})\).
- Parameters:
fractionalDollar- adouble, a fractional numberfraction- anint, the denominator- Returns:
- a
double, the dollar price expressed as a decimal number - See Also:
-
dollarfr
public static double dollarfr(double decimalDollar, int fraction) Converts a decimal price to a fractional price. It is computed using the following:$${\it idollar} + {{{\it decimalDollar} - {\it idollar}} \over {10^{\left( {{\it ifrac} + 1} \right)} / {\it fraction}}}$$
where \({\it idollar}\) is the integer part of the \({\it decimalDollar}\), and \({\it ifrac}\) is the integer part of \(log({\it fraction})\).- Parameters:
decimalDollar- adouble, a decimal numberfraction- anint, the denominator- Returns:
- a
double, a dollar price expressed as a fraction - See Also:
-
effect
public static double effect(double nominalRate, int nper) Returns the effective annual interest rate. The nominal interest rate is the periodically-compounded interest rate as stated on the face of a security. The effective annual interest rate is computed using the following:$$\left( {1 + {{\it nominalRate} \over {\it nper}}} \right)^{\it nper} - 1$$
- Parameters:
nominalRate- adouble, the nominal interest ratenper- anint, the number of compounding periods per year- Returns:
- a
double, the effective annual interest rate - See Also:
-
fv
public static double fv(double rate, int nper, double pmt, double pv, int when) Returns the future value of an investment. The future value is the value, at some time in the future, of a current amount and a stream of payments. It can be found by solving the following:If \(rate = 0\), $${\it pv} + {\it pmt} \times {\it nper} + {\it fv} = 0$$
If \(rate \ne 0\), $${\it pv} (1 + {\it rate})^{\it nper} + {\it pmt} \left[ {1 + {\it rate} \left( {\it when} \right)} \right] {{(1 + {\it rate})^{\it nper} - 1} \over {\it rate}} + {\it fv} = 0$$
- Parameters:
rate- adouble, the interest ratenper- anint, the total number of payment periodspmt- adouble, the payment made in each periodpv- adouble, the present valuewhen- anint, the time in each period when the payment is made, eitherAT_END_OF_PERIODorAT_BEGINNING_OF_PERIOD- Returns:
- a
double, the future value of an investment - See Also:
-
fvschedule
public static double fvschedule(double principal, double[] schedule) Returns the future value of an initial principal taking into consideration a schedule of compound interest rates. It is computed using the following:$$\sum\limits_{i = 1}^{\it count} {\left( {{\it principal} \times {\it schedule}_i } \right)}$$
where \({\it schedule}_i =\) interest rate at the \(i\)th period, and the count isschedule.length.- Parameters:
principal- adouble, the present valueschedule- adoublearray of interest rates to apply- Returns:
- a
double, the future value of an initial principal - See Also:
-
ipmt
public static double ipmt(double rate, int period, int nper, double pv, double fv, int when) Returns the interest payment for an investment for a given period. It is computed using the following:$$\left\{ {{\it pv}\left( {1 + {\it rate}} \right)^{{\it nper} - 1} + {\it pmt} \left( {1 + {\it rate} \times {\it when}} \right) {{{\left( {1 + {\it rate}} \right)^{{\it nper} - 1} } \over {\it rate}}} } \right\} {\it rate}$$
- Parameters:
rate- adouble, the interest rateperiod- anint, the payment periodnper- anint, the total number of periodspv- adouble, the present valuefv- adouble, the future valuewhen- anint, the time in each period when the payment is made, eitherAT_END_OF_PERIODorAT_BEGINNING_OF_PERIOD- Returns:
- a
double, the interest payment for a given period for an investment - See Also:
-
irr
public static double irr(double[] pmt) Returns the internal rate of return for a schedule of cash flows. It is found by solving the following:$$0 = \sum\limits_{i = 1}^{\it count} {{{\it value}_i } \over {\left( {1 + {\it rate}} \right)^i }}$$
where \({\it value}_i\) = the \(ith\) cash flow, \({\it rate}\) is the internal rate of return, and count ispmt.length.- Parameters:
pmt- adoublearray which contains cash flow values which occur at regular intervals- Returns:
- a
double, the internal rate of return - See Also:
-
irr
public static double irr(double[] pmt, double guess) Returns the internal rate of return for a schedule of cash flows. It is found by solving the following:$$0 = \sum\limits_{i = 1}^{\it count} {{{\it value}_i } \over {\left( {1 + {\it rate}} \right)^i }}$$
where \({\it value}_i\) = the \(ith\) cash flow, \({\it rate}\) is the internal rate of return.- Parameters:
pmt- adoublearray which contains cash flow values which occur at regular intervalsguess- adoublevalue which represents an initial guess at the return value from this function- Returns:
- a
double, the internal rate of return
-
mirr
public static double mirr(double[] value, double financeRate, double reinvestRate) Returns the modified internal rate of return for a schedule of periodic cash flows. The modified internal rate of return differs from the ordinary internal rate of return in assuming that the cash flows are reinvested at the cost of capital, not at the internal rate of return. It also eliminates the multiple rates of return problem. It is computed using the following:$${\left\{ {{{ - \left( {\it pnpv} \right)\left( {1 + {\it reinvestRate}} \right)^{\it nper} } \over {\left( {\it nnpv} \right)\left( {1 + {\it financeRate}} \right)}}} \right\}^{{1 \over {{\it nper} - 1}}} } - 1$$
where \({\it pnpv}\) is calculated fromnpvfor positive values invalueusingreinvestRate, \({\it nnpv}\) is calculated fromnpvfor negative values invalueusingfinanceRate, andnper=value.length.- Parameters:
value- adoublearray of cash flowsfinanceRate- adouble, the interest you pay on the money you borrowreinvestRate- adouble, the interest rate you receive on the cash flows- Returns:
- a
double, the modified internal rate of return - See Also:
-
nominal
public static double nominal(double effectiveRate, int nper) Returns the nominal annual interest rate. The nominal interest rate is the interest rate as stated on the face of a security. It is computed using the following:$$\left[ {\left( {1 + {\it effectiveRate}} \right)^{^{{1 \over {\it nper}}} } - 1} \right] \times {\it nper}$$
- Parameters:
effectiveRate- adouble, the effective interest ratenper- anint, the number of compounding periods per year- Returns:
- a
double, the nominal annual interest rate - See Also:
-
nper
public static double nper(double rate, double pmt, double pv, double fv, int when) Returns the number of periods for an investment for which periodic, and constant payments are made and the interest rate is constant. It can be found by solving the following:If \(rate = 0\), $${\it pv} + {\it pmt} \times {\it nper} + {\it fv} = 0$$
If \(rate \ne 0\), $${\it pv} (1 + {\it rate})^{\it nper} + {\it pmt} \left[ {1 + {\it rate} \left( {\it when} \right)} \right] {{(1 + {\it rate})^{\it nper} - 1} \over {\it rate}} + {\it fv} = 0$$
- Parameters:
rate- adouble, the interest ratepmt- adouble, the paymentpv- adouble, the present valuefv- adouble, the future valuewhen- anint, the time in each period when the payment is made, eitherAT_END_OF_PERIODorAT_BEGINNING_OF_PERIOD- Returns:
- an
int, the number of periods for an investment - See Also:
-
npv
public static double npv(double rate, double[] value) Returns the net present value of a stream of equal periodic cash flows, which are subject to a given discount rate. It is found by solving the following:$$\sum\limits_{i = 1}^{count} {{{\it value}_i} \over {\left( {1 + {\it rate}} \right)}^i }$$
where \({\it value}_i\) = the \(i\)th cash flow, and count isvalue.length.- Parameters:
rate- adouble, the interest rate per period. It must not be -1.value- adoublearray of equally-spaced cash flows- Returns:
- a
double, the net present value of the investment - See Also:
-
pmt
public static double pmt(double rate, int nper, double pv, double fv, int when) Returns the periodic payment for an investment. It can be found by solving the following:If \(rate = 0\), $${\it pv} + {\it pmt} \times {\it nper} + {\it fv} = 0$$
If \({\it rate} \ne 0\), $$ {\it pv}(1 + {\it rate})^{\it nper} + {\it pmt} \left[ {1 + {\it rate} \left( {\it when} \right)} \right] {{(1 + {\it rate})^{\it nper} - 1} \over {\it rate}} + {\it fv} = 0$$
- Parameters:
rate- adouble, the interest ratenper- anint, the total number of periodspv- adouble, the present valuefv- adouble, the future valuewhen- anint, the time in each period when the payment is made, eitherAT_END_OF_PERIODorAT_BEGINNING_OF_PERIOD- Returns:
- a
double, the interest payment for a given period for an investment - See Also:
-
ppmt
public static double ppmt(double rate, int period, int nper, double pv, double fv, int when) Returns the payment on the principal for a specified period. It is computed using the following:$${\it payment}_i - {\it interest}_i$$
where \({\it payment}_i\) is computed frompmtfor the \(i\)th period, \({\it interest}_i\) is calculated fromipmtfor the \(i\)th period.- Parameters:
rate- adouble, the interest rateperiod- anint, the payment periodnper- anint, the total number of periodspv- adouble, the present valuefv- adouble, the future valuewhen- anint, the time in each period when the payment is made, eitherAT_END_OF_PERIODorAT_BEGINNING_OF_PERIOD- Returns:
- a
double, the payment on the principal for a given period - See Also:
-
pv
public static double pv(double rate, int nper, double pmt, double fv, int when) Returns the net present value of a stream of equal periodic cash flows, which are subject to a given discount rate. It can be found by solving the following:If \({\it rate} = 0\), $${\it pv} + {\it pmt} \times {\it nper} + {\it fv} = 0$$
If \({\it rate} \ne 0\), $$ {\it pv}(1 + {\it rate})^{\it nper} + {\it pmt} \left[ {1 + {\it rate} \left( {\it when} \right)} \right] {{(1 + {\it rate})^{\it nper} - 1} \over {\it rate}} + {\it fv} = 0$$
- Parameters:
rate- adouble, the interest rate per periodnper- anint, the number of periodspmt- adouble, the payment made each periodfv- adouble, the annuity's value after the last paymentwhen- anint, the time in each period when the payment is made, eitherAT_END_OF_PERIODorAT_BEGINNING_OF_PERIOD- Returns:
- a
double, the present value of the investment - See Also:
-
rate
public static double rate(int nper, double pmt, double pv, double fv, int when) Returns the interest rate per period of an annuity. rate is calculated by iteration and can have zero or more solutions. It can be found by solving the following:If \({\it rate} = 0\), $${\it pv} + {\it pmt} \times {\it nper} + {\it fv} = 0$$
If \({\it rate} \ne 0\), $$ {\it pv}(1 + {\it rate})^{\it nper} + {\it pmt} \left[ {1 + {\it rate} \left( {\it when} \right)} \right] {{(1 + {\it rate})^{\it nper} - 1} \over {\it rate}} + {\it fv} = 0$$
- Parameters:
nper- anint, the number of periodspmt- adouble, the payment made each periodpv- adouble, the present valuefv- adouble, the annuity's value after the last paymentwhen- anint, the time in each period when the payment is made, eitherAT_END_OF_PERIODorAT_BEGINNING_OF_PERIOD- Returns:
- a
double, the interest rate per period of an annuity - See Also:
-
rate
public static double rate(int nper, double pmt, double pv, double fv, int when, double guess) Returns the interest rate per period of an annuity with an initial guess. rate is calculated by iteration and can have zero or more solutions. It can be found by solving the following:If \({\it rate} = 0\), $${\it pv} + {\it pmt} \times {\it nper} + {\it fv} = 0$$
If \({\it rate} \ne 0\), $$ {\it pv}(1 + {\it rate})^{\it nper} + {\it pmt} \left[ {1 + {\it rate} \left( {\it when} \right)} \right] {{(1 + {\it rate})^{\it nper} - 1} \over {\it rate}} + {\it fv} = 0$$
- Parameters:
nper- anint, the number of periodspmt- adouble, the payment made each periodpv- adouble, the present valuefv- adouble, the annuity's value after the last paymentwhen- anint, the time in each period when the payment is made, eitherAT_END_OF_PERIODorAT_BEGINNING_OF_PERIODguess- adoublevalue which represents an initial guess at the interest rate per period of an annuity- Returns:
- a
double, the interest rate per period of an annuity - See Also:
-
sln
public static double sln(double cost, double salvage, int life) Returns the depreciation of an asset using the straight line method. It is computed using the following:$${{\it cost} - {\it salvage}} / {\it life}$$
- Parameters:
cost- adouble, the initial cost of the assetsalvage- adouble, the salvage value of the assetlife- anint, the number of periods over which the asset is being depreciated- Returns:
- a
double, the straight line depreciation of an asset for one period - See Also:
-
syd
public static double syd(double cost, double salvage, int life, int per) Returns the depreciation of an asset using the sum-of-years digits method. It is computed using the following:$$({\it cost} - {\it salvage})({\it per})\,\, {{({\it life} + 1)\left( {\it life} \right)} \over 2}$$
- Parameters:
cost- adouble, the initial cost of the assetsalvage- adouble, the salvage value of the assetlife- anint, the number of periods over which the asset is being depreciatedper- anint, the period- Returns:
- a
double, the sum-of-years digits depreciation of an asset - See Also:
-
vdb
public static double vdb(double cost, double salvage, int life, int start, int end, double factor, boolean no_sl) Returns the depreciation of an asset for any given period using the variable-declining balance method. It is computed using the following:If \(no\_sl = 0\), $$ \sum\limits_{i = {\it start} + 1}^{\it end} {{\it ddb}_i }$$
If \(no\_sl \ne 0\), $$A + \sum\limits_{i = k}^{\it end} {{{{{\it cost}} - A - {\it salvage}} \over {{\it end} - k + 1}}}$$
where \({\it ddb}_i\) is computed fromddbfor the \(i\)th period. \(k\) = the first period where straight line depreciation is greater than the depreciation using the double-declining balance method.$$A = \sum\limits_{i = {\it start} + 1}^{k - 1} {{\it ddb}_i}$$
- Parameters:
cost- adouble, the initial cost of the assetsalvage- adouble, the salvage value of the assetlife- anint, the number of periods over which the asset is being depreciatedstart- anint, the initial period for the calculationend- anint, the final period for the calculationfactor- adouble, the rate at which the balance declinesno_sl- abooleanflag. If true, do not switch to straight-line depreciation even when the depreciation is greater than the declining balance calculation.- Returns:
- a
double, the depreciation of the asset - See Also:
-
xirr
Returns the internal rate of return for a schedule of cash flows. It is not necessary that the cash flows be periodic. It can be found by solving the following:$$0 = \sum\limits_{i = 1}^{\it count} {{{{\it value}_i } \over {\left( {1 + {\it rate}} \right)^{{{d_i - d_1 } \over {365}}} }}}$$
In the equation above, \(d_i\) represents the \(i\)th payment date. \(d_1\) represents the 1st payment date. \({\it value}\) represents the \(i\)th cash flow. \({\it rate}\) is the internal rate of return, and count ispmt.length.- Parameters:
pmt- adoublearray which contains cash flow values which correspond to a schedule of payments in datesdates- aDatearray which contains a schedule of payment dates- Returns:
- a
double, the internal rate of return - See Also:
-
xirr
Returns the internal rate of return for a schedule of cash flows with a user supplied initial guess. It is not necessary that the cash flows be periodic. It can be found by solving the following:$$0 = \sum\limits_{i = 1}^{\it count} {{{{\it value}_i } \over {\left( {1 + {\it rate}} \right)^{{{d_i - d_1 } \over {365}}} }}}$$
In the equation above, \(d_i\) represents the \(i\)th payment date. \(d_1\) represents the 1st payment date. \({\it value}\) represents the \(i\)th cash flow. \({\it rate}\) is the internal rate of return. Count ispmt.length.- Parameters:
pmt- adoublearray which contains cash flow values which correspond to a schedule of payments in datesdates- aDatearray which contains a schedule of payment datesguess- adoublevalue which represents an initial guess at the return value from this function- Returns:
- a
double, the internal rate of return
-
xnpv
Returns the present value for a schedule of cash flows. It is not necessary that the cash flows be periodic. It is computed using the following:$$\sum\limits_{i = 1}^{\it count} {{{{\it value}_i } \over {\left( {1 + {\it rate}} \right)^{\left( {d_i - d_1 } \right)/365}}}}$$
In the equation above, \(d_i\) represents the \(i\)th payment date, \(d_1\) represents the first payment date, \({\it value}_i\) represents the \(i\)th cash flow. and count isvalue.length- Parameters:
rate- adouble, the interest ratevalue- adoublearray containing the cash flowsdates- aDatearray which contains a schedule of payment dates- Returns:
- a
double, the present value - See Also:
-