The Payments Class¶
TmVal offers a Payments
class, which is exactly what you think it is, a collection of transfers of money from one entity to another. Since we don’t really care who is getting what at the moment, a Payments
object in TmVal is simply a collection of payment amounts, payment times, and a growth rate object.
The growth rate object can be a float, in which case we assume compound effective interest. You can also provide a Rate
object for other interest patterns, including compound effective interest. It can also be an Accumulation object, which gives you an option if the growth pattern you want to model is more complex.
While simple, Payments
constitutes a core data type in TmVal. It is used, along with the fundamentals of interest theory that we have developed so far, to construct more complex financial instruments and transactions, such as annuities
and loans
.
Examples¶
Suppose we have payments of 1,000, 2,000, and 3,000 that occur at times 1, 2, and 3, respectively. If we have 5% compound interest, construct a Payments
object and explore its contents.
To declare a Payments
class, pass the payment amounts, times, and interest rate to the arguments amounts
, times
, and gr
, respectively. Let’s use dir
to see what attributes and methods we can explore.
In [1]: from tmval import Payments
In [2]: pmts = Payments(amounts=[1000, 2000, 3000], times=[1, 2, 3], gr=.05)
In [3]: dir(pmts)
Out[3]:
['__add__',
'__class__',
'__delattr__',
'__dict__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__le__',
'__lt__',
'__module__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'__weakref__',
'amounts',
'append',
'dw_approx',
'eq_val',
'equated_time',
'gr',
'group_payments',
'irr',
'npv',
'pt_bal',
'set_accumulation',
'time_weighted_yield',
'times']
First, we notice the amounts and times we provided to the object. We also see some methods such as npv()
, eq_val()
, irr()
, dollar_weighted_yield()
, and time_weighted_yield()
, which we’ll explore in the subsequent sections.
Note that we can also supply an Accumulation
or Rate
object to the argument gr
. The following declarations are equivalent to the previous one:
In [4]: from tmval import Accumulation, Rate
In [5]: pmts = Payments(amounts=[1000, 2000, 3000], times=[1, 2, 3], gr=Accumulation(.05))
In [6]: pmts = Payments(amounts=[1000, 2000, 3000], times=[1, 2, 3], gr=Rate(.05))
This might seem superficial at first glance, but its usefulness becomes apparent if we have something more complicated than compound interest, such as
In [7]: def f(t):
...: return t ** 5 + 3 * t ** 4 + 2 * t + 4
...:
In [8]: pmts = Payments(amounts=[1000, 2000, 3000], times=[1, 2, 3], gr=Accumulation(gr=f))