10.12.2019 Views

Python for Finance

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3

On the right-hand side of the preceding equation, the first one is the present value

of one future cash flow, while the second part is the present value of annuity. The

variable type takes a value of zero (default value); it is the present value of a normal

annuity, while it is an annuity due if type takes a value of 1. The negative sign is

for the sign convention. If using the same notation as that used for the functions

contained in SciPy and numpy.lib.financial, we have the following formula:

Here are several examples using both Equation (14) and the pv() function from

SciPy. James intends to invest x dollars today for the next 10 years. His annual rate

of return is 5%. During the next 10 years, he will withdraw $5,000 at the beginning of

each year. In addition, he hopes that he will have $7,000 at the end of his investment

horizon. How much must he invest today, that is, what is the value of x? By applying

the preceding equation manually, we have the following result. Please pay attention

to the negative sign:

>>> -(7000/(1+0.05)**10 + 5000/0.05*(1-1/(1+0.05)**10)*(1+0.05))

-44836.501153005614

The result is the same as when the scipy.pv() function is called; see the

following code:

>>> import scipy as sp

>>> sp.pv(0.05,10,5000,7000,1)

-44836.5011530056

To separate normal annuity from annuity due, we have the following two equations.

For a normal annuity, we have the following equation:

[ 93 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!