Python for Finance: Analyze Big Financial Data

(Elle) #1

Tools


The success and popularity of a programming language result to some extent from the


tools that are available to work with the language. It has long been the case that Python


was considered a nice, easy-to-learn and easy-to-use language, but without a compelling


set of tools for interactive analytics or development. This has changed. There are now a


large number of tools available that help analysts and developers to be as productive as


possible with Python. It is not possible to give even a somewhat exhaustive overview.


However, it is possible to highlight two of the most popular tools in use today: IPython


and Spyder.


[ 9 ]

Python


For completeness, let us first consider using the standard Python interpreter itself. From


the system shell/command-line interface, Python is invoked by simply typing python:


$   python
Python 2.7.6 |Anaconda 1.9.2 (x86_64)| (default, Feb 10 2014, 17:56:29)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>> print “Hello Python for Finance World.”
Hello Python for Finance World.
>>> exit()
$

Although you can do quite a bit of Python with the standard prompt, most people prefer to


use IPython by default since this environment provides everything that the standard


interpreter prompt offers, and much more on top of that.


IPython


IPython was used in Chapter 1 to present the first examples of Python code. This section


gives an overview of the capabilities of IPython through specific examples. A complete


ecosystem has evolved around IPython that is so successful and appealing that users of


other languages make use of the basic approach and architecture it provides. For example,


there is a version of IPython for the Julia language.


From shell to browser


IPython comes in three flavors:


Shell


The shell version is based on the system and Python shell, as the name suggests;


there are no graphical capabilities included (apart from displaying plots in a separate


window).


QT console

This version is based on the QT graphical user interface framework (cf. http://qt-


project.org), is more feature-rich, and allows, for example, for inline graphics.


Notebook

This is a JavaScript-based web browser version that has become the community


favorite for interactive analytics and also for teaching, presenting, etc.


The shell version is invoked by simply typing ipython in the shell:

Free download pdf