public class Finance extends Object
Modifier and Type | Field and Description |
---|---|
static int |
AT_BEGINNING_OF_PERIOD
Flag used to indicate that payment is made at the beginning of each period.
|
static int |
AT_END_OF_PERIOD
Flag used to indicate that payment is made at the end of each period.
|
Modifier and Type | Method and Description |
---|---|
static double |
cumipmt(double rate,
int nper,
double pv,
int start,
int end,
int when)
Returns the cumulative interest paid between two periods.
|
static double |
cumprinc(double rate,
int nper,
double pv,
int start,
int end,
int when)
Returns the cumulative principal paid between two periods.
|
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.
|
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.
|
static double |
dollarde(double fractionalDollar,
int fraction)
Converts a fractional price to a decimal price.
|
static double |
dollarfr(double decimalDollar,
int fraction)
Converts a decimal price to a fractional price.
|
static double |
effect(double nominalRate,
int nper)
Returns the effective annual interest rate.
|
static double |
fv(double rate,
int nper,
double pmt,
double pv,
int when)
Returns the future value of an investment.
|
static double |
fvschedule(double principal,
double[] schedule)
Returns the future value of an initial principal taking
into consideration a schedule of compound interest rates.
|
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.
|
static double |
irr(double[] pmt)
Returns the internal rate of return for a schedule of cash flows.
|
static double |
irr(double[] pmt,
double guess)
Returns the internal rate of return for a schedule of cash flows.
|
static double |
mirr(double[] value,
double financeRate,
double reinvestRate)
Returns the modified internal rate of return for a schedule of periodic
cash flows.
|
static double |
nominal(double effectiveRate,
int nper)
Returns the nominal annual interest rate.
|
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.
|
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.
|
static double |
pmt(double rate,
int nper,
double pv,
double fv,
int when)
Returns the periodic payment for an investment.
|
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.
|
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.
|
static double |
rate(int nper,
double pmt,
double pv,
double fv,
int when)
Returns the interest rate per period of an annuity.
|
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.
|
static double |
sln(double cost,
double salvage,
int life)
Returns the depreciation of an asset using the straight line method.
|
static double |
syd(double cost,
double salvage,
int life,
int per)
Returns the depreciation of an asset using the sum-of-years digits method.
|
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.
|
static double |
xirr(double[] pmt,
Date[] dates)
Returns the internal rate of return for a schedule of cash flows.
|
static double |
xirr(double[] pmt,
Date[] dates,
double guess)
Returns the internal rate of return for a schedule of cash flows
with a user supplied initial guess.
|
static double |
xnpv(double rate,
double[] value,
Date[] dates)
Returns the present value for a schedule of cash
flows.
|
public static final int AT_END_OF_PERIOD
public static final int AT_BEGINNING_OF_PERIOD
public static double cumipmt(double rate, int nper, double pv, int start, int end, int when)
$$\sum\limits_{i = {\it start}}^{\it end} {\it interest}_i$$
where \({\it interest}_i$$ is computed fromipmt
for the \(i\)th period.rate
- a double
, the interest ratenper
- an int
, the total number of payment periodspv
- a double
, the present valuestart
- an int
, the first period in the caclulation.
Periods are numbered starting with one.end
- an int
, the last period in the calculationwhen
- an int
, the time in each period when the payment is made,
either Finance.AT_END_OF_PERIOD
or Finance.AT_BEGINNING_OF_PERIOD
double
, the cumulative interest paid between
the first period and the last periodpublic static double cumprinc(double rate, int nper, double pv, int start, int end, int when)
$$\sum\limits_{i = {\it start}}^{\it end} {\it principal}_i$$
where \({\it principal}_i\) is computed fromppmt
for the \(i\)th period.rate
- a double
, the interest ratenper
- an int
, the total number of payment periodspv
- a double
, the present valuestart
- an int
, the first period in the calculation.
Periods are numbered starting with one.end
- an int
, the last period in the calculationwhen
- an int
, the time in each period when the payment is made,
either Finance.AT_END_OF_PERIOD
or Finance.AT_BEGINNING_OF_PERIOD
.double
, the cumulative principal paid between the
first period and the last periodpublic static double db(double cost, double salvage, int life, int period, int month)
db
varies 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}}$$
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.
cost
- a double
, the initial cost of the assetsalvage
- a double
, the salvage value of the assetlife
- an int
, the number of periods over which the asset
is being depreciatedperiod
- an int
, the period for which the depreciation is to be computedmonth
- an int
, the number of months in the first yeardouble
, the depreciation of an asset for a specified period
using the fixed-declining balance methodpublic static double ddb(double cost, double salvage, int life, int period, double factor)
$$\left[ {{\it cost} - {\it salvage}\left( {\it {total\,depreciation\,from\,prior\,periods}} \right)} \right]\, {{{\it factor} \over {\it life}}}$$
cost
- a double
, the initial cost of the assetsalvage
- a double
, the salvage value of the assetlife
- an int
, the number of periods over which the asset
is being depreciatedperiod
- an int
, the periodfactor
- a double
, the rate at which the balance declinesdouble
, the depreciation of an asset for a specified periodpublic static double dollarde(double fractionalDollar, int fraction)
$${\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})\).
fractionalDollar
- a double
, a fractional numberfraction
- an int
, the denominatordouble
, the dollar price expressed as
a decimal numberpublic static double dollarfr(double decimalDollar, int fraction)
$${\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})\).decimalDollar
- a double
, a decimal numberfraction
- an int
, the denominatordouble
, a dollar price expressed
as a fractionpublic static double effect(double nominalRate, int nper)
$$\left( {1 + {{\it nominalRate} \over {\it nper}}} \right)^{\it nper} - 1$$
nominalRate
- a double
, the nominal interest ratenper
- an int
, the number of compounding periods per yeardouble
, the effective annual interest ratepublic static double fv(double rate, int nper, double pmt, double pv, int when)
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$$
rate
- a double
, the interest ratenper
- an int
, the total number of payment periodspmt
- a double
, the payment made in each periodpv
- a double
, the present valuewhen
- an int
, the time in each period when the payment is made,
either Finance.AT_END_OF_PERIOD
or Finance.AT_BEGINNING_OF_PERIOD
double
, the future value of an investmentpublic static double fvschedule(double principal, double[] schedule)
$$\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
.principal
- a double
, the present valueschedule
- a double
array of interest rates to applydouble
, the future value of an initial principalpublic static double ipmt(double rate, int period, int nper, double pv, double fv, int when)
$$\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}$$
rate
- a double
, the interest rateperiod
- an int
, the payment periodnper
- an int
, the total number of periodspv
- a double
, the present valuefv
- a double
, the future valuewhen
- an int
, the time in each period when the payment is made,
either Finance.AT_END_OF_PERIOD
or Finance.AT_BEGINNING_OF_PERIOD
double
, the interest payment for a given period for
an investmentpublic static double irr(double[] pmt)
$$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
.pmt
- a double
array which contains cash flow values
which occur at regular intervalsdouble
, the internal rate of returnpublic static double irr(double[] pmt, double guess)
$$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.pmt
- a double
array which contains cash flow values
which occur at regular intervalsguess
- a double
value which represents an initial guess
at the return value from this functiondouble
, the internal rate of returnpublic static double mirr(double[] value, double financeRate, double reinvestRate)
$${\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 fromnpv
for positive values in value
using reinvestRate
,
\({\it nnpv}\) is calculated from npv
for
negative values in value
using financeRate
, and nper
= value.length
.value
- a double
array of cash flowsfinanceRate
- a double
, the interest you pay
on the money you borrowreinvestRate
- a double
, the interest rate you
receive on the cash flowsdouble
, the modified internal
rate of returnpublic static double nominal(double effectiveRate, int nper)
$$\left[ {\left( {1 + {\it effectiveRate}} \right)^{^{{1 \over {\it nper}}} } - 1} \right] \times {\it nper}$$
effectiveRate
- a double
, the effective interest ratenper
- an int
, the number of compounding periods per yeardouble
, the nominal annual interest ratepublic static double nper(double rate, double pmt, double pv, double fv, int when)
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$$
rate
- a double
, the interest ratepmt
- a double
, the paymentpv
- a double
, the present valuefv
- a double
, the future valuewhen
- an int
, the time in each period when the payment is made,
either Finance.AT_END_OF_PERIOD
or Finance.AT_BEGINNING_OF_PERIOD
int
, the number of periods for an investmentpublic static double npv(double rate, double[] value)
$$\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
.rate
- a double
, the interest rate per period.
It must not be -1.value
- a double
array of equally-spaced cash flowsdouble
, the net present value of the investmentpublic static double pmt(double rate, int nper, double pv, double fv, int when)
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$$
rate
- a double
, the interest ratenper
- an int
, the total number of periodspv
- a double
, the present valuefv
- a double
, the future valuewhen
- an int
, the time in each period when the payment is made,
either Finance.AT_END_OF_PERIOD
or Finance.AT_BEGINNING_OF_PERIOD
double
, the interest payment for a given period for
an investmentpublic static double ppmt(double rate, int period, int nper, double pv, double fv, int when)
$${\it payment}_i - {\it interest}_i$$
where \({\it payment}_i\) is computed frompmt
for the \(i\)th period,
\({\it interest}_i\) is calculated from ipmt
for the \(i\)th period.rate
- a double
, the interest rateperiod
- an int
, the payment periodnper
- an int
, the total number of periodspv
- a double
, the present valuefv
- a double
, the future valuewhen
- an int
, the time in each period when the payment is made,
either Finance.AT_END_OF_PERIOD
or Finance.AT_BEGINNING_OF_PERIOD
double
, the payment on the principal for a given periodpublic static double pv(double rate, int nper, double pmt, double fv, int when)
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$$
rate
- a double
, the interest rate per periodnper
- an int
, the number of periodspmt
- a double
, the payment made each periodfv
- a double
, the annuity's value after the last paymentwhen
- an int
, the time in each period when the payment is made,
either Finance.AT_END_OF_PERIOD
or Finance.AT_BEGINNING_OF_PERIOD
double
, the present value of the investmentpublic static double rate(int nper, double pmt, double pv, double fv, int when)
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$$
nper
- an int
, the number of periodspmt
- a double
, the payment made each periodpv
- a double
, the present valuefv
- a double
, the annuity's value after the last paymentwhen
- an int
, the time in each period when the payment is made,
either Finance.AT_END_OF_PERIOD
or Finance.AT_BEGINNING_OF_PERIOD
double
, the interest rate per period of an annuitypublic static double rate(int nper, double pmt, double pv, double fv, int when, double guess)
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$$
nper
- an int
, the number of periodspmt
- a double
, the payment made each periodpv
- a double
, the present valuefv
- a double
, the annuity's value after the last paymentwhen
- an int
, the time in each period when the payment is made,
either Finance.AT_END_OF_PERIOD
or Finance.AT_BEGINNING_OF_PERIOD
guess
- a double
value which represents an initial
guess at the interest rate per period of an annuitydouble
, the interest rate per period of an annuitypublic static double sln(double cost, double salvage, int life)
$${{\it cost} - {\it salvage}} / {\it life}$$
cost
- a double
, the initial cost of the assetsalvage
- a double
, the salvage value of the assetlife
- an int
, the number of periods over which the asset
is being depreciateddouble
, the straight line depreciation of an asset
for one periodpublic static double syd(double cost, double salvage, int life, int per)
$$({\it cost} - {\it salvage})({\it per})\,\, {{({\it life} + 1)\left( {\it life} \right)} \over 2}$$
cost
- a double
, the initial cost of the assetsalvage
- a double
, the salvage value of the assetlife
- an int
, the number of periods over which the asset
is being depreciatedper
- an int
, the perioddouble
, the sum-of-years digits depreciation of
an assetpublic static double vdb(double cost, double salvage, int life, int start, int end, double factor, boolean no_sl)
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 fromddb
for 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}$$
cost
- a double
, the initial cost of the assetsalvage
- a double
, the salvage value of the assetlife
- an int
, the number of periods over which the asset
is being depreciatedstart
- an int
, the initial period for the calculationend
- an int
, the final period for the calculationfactor
- a double
, the rate at which the balance declinesno_sl
- a boolean
flag. If true, do not switch to straight-line
depreciation even when the depreciation is greater
than the declining balance calculation.double
, the depreciation of the assetpublic static double xirr(double[] pmt, Date[] dates)
$$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
.pmt
- a double
array which contains cash flow values
which correspond to a schedule of payments in datesdates
- a Date
array which contains a schedule of payment
datesdouble
, the internal rate of returnpublic static double xirr(double[] pmt, Date[] dates, double guess)
$$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
.pmt
- a double
array which contains cash flow values
which correspond to a schedule of payments in datesdates
- a Date
array which contains a schedule of payment
datesguess
- a double
value which represents an initial guess
at the return value from this functiondouble
, the internal rate of returnpublic static double xnpv(double rate, double[] value, Date[] dates)
$$\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
rate
- a double
, the interest ratevalue
- a double
array containing the cash flowsdates
- a Date
array which contains a schedule of payment
datesdouble
, the present valueCopyright © 2020 Rogue Wave Software. All rights reserved.