numberOfPeriods¶
Evaluates the number of periods for an investment for which periodic and constant payments are made and the interest rate is constant.
Synopsis¶
numberOfPeriods (rate, payment, presentValue, futureValue, when)
Required Arguments¶
- float
rate
(Input) - Interest rate on the investment.
- float
payment
(Input) - Payment made on the investment.
- float
presentValue
(Input) - The current value of a stream of future payments, after discounting the payments using some interest rate.
- float
futureValue
(Input) - The value, at some time in the future, of a current amount and a stream of payments.
- int
when
(Input) - Time in each period when the payment is made, either
AT_END_OF_PERIOD
orAT_BEGINNING_OF_PERIOD
. For a more detailed discussion onwhen
see the Usage Notes section of this chapter.
Return Value¶
The number of periods for an investment.
Description¶
Function numberOfPeriods
computes the number of periods for an
investment based on periodic, constant payment and a constant interest rate.
It can be found by solving the following:
If rate
=0
\[\textit{presentValue} + (\textit{payment})(\textit{nPeriods}) + \textit{futureValue} = 0\]
If rate
≠ 0
\[\begin{split}\begin{array}{l}
\mathit{presentValue}(1+\mathit{rate})^{\mathit{nPeriods}} + \\
\mathit{payment}[1 + \mathit{rate}(\mathit{when})]
\frac{(1+\mathit{rate})^{\mathit{nPeriods}}-1}{\mathit{rate}} +
\mathit{futureValue} = 0
\end{array}\end{split}\]
Example¶
In this example, numberOfPeriods
computes the number of periods needed
to pay off a $20,000 loan with a monthly payment of $350 and an annual
interest rate of 7.25%. The payment is made at the beginning of each period.
from __future__ import print_function
from numpy import *
from pyimsl.math.numberOfPeriods import numberOfPeriods, AT_BEGINNING_OF_PERIOD
rate = 0.0725 / 12
payment = -350.00
present_value = 20000
future_value = 0.
when = AT_BEGINNING_OF_PERIOD
number_of_periods = numberOfPeriods(rate, payment,
present_value, future_value, when)
print("Number of payment periods = %f." % (number_of_periods))
Output¶
Number of payment periods = 70.000000.