General Accumulation Functions¶
The annuities supported by TmVal need not be limited to the main growth patterns supported by the Rate class. TmVal can also handle annuities governed by more complex growth patterns, such as polynomial growth.
Examples¶
Suppose we have a basic, 5-year term annuity-immediate governed by the following growth pattern:
What is the present value of the annuity?
We can solve this problem by defining a function for the quadratic growth pattern and then passing it to the Accumulation class, which in turn is passed to the Annuity class:
In [1]: from tmval import Accumulation, Annuity
In [2]: def f(t):
...: return .05 * t ** 2 + .02 * t + 1
...:
In [3]: ann = Annuity(gr=Accumulation(gr=f), n=5)
In [4]: print(ann.pv())
3.36072951629534
What is the accumulated value?
In [5]: print(ann.sv())
7.897714363294049