10.12.2019 Views

Python for Finance

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 2

2010-01-08 110.929466

>> >df.tail()

>>>

Open High Low Close Volume

Date

2016-11-16 158.460007 159.550003 158.029999 159.289993 2244100

2016-11-17 159.220001 159.929993 158.850006 159.800003 2256400

2016-11-18 159.800003 160.720001 159.210007 160.389999 2958700

2016-11-21 160.690002 163.000000 160.369995 162.770004 4601900

2016-11-22 163.000000 163.000000 161.949997 162.669998 2707900

Adj Close

Date

2016-11-16 159.289993

2016-11-17 159.800003

2016-11-18 160.389999

2016-11-21 162.770004

2016-11-22 162.669998

>>>

This module will be explained again in more detail in Chapter 4, Sources of Data.

Two financial calculators

In the next chapter, many basic financial concepts and formulas will be introduced

and discussed. Usually, when taking corporate finance or financial management,

students rely on either Excel or a financial calculator to conduct their estimations.

Since Python is the computational tool, a financial calculator written in Python

would definitely enhance our understanding of both finance and Python.

Here is the first financial calculator, written in Python, from Numpy.lib.financial;

see the following code:

>>> import numpy.lib.financial as fin

>>> dir(fin)

['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__

loader__', '__name__', '__package__', '__spec__', '_convert_when',

'_g_div_gp', '_rbl', '_when_to_num', 'absolute_import', 'division',

'fv', 'ipmt', 'irr', 'mirr', 'np', 'nper', 'npv', 'pmt', 'ppmt',

'print_function', 'pv', 'rate']

>>>

[ 61 ]

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

Saved successfully!

Ooh no, something went wrong!