Quant Reading List Python Programming

This post is part of a series of reading lists for beginning quantitative analysts. Other posts in the series concentrate on Derivatives Pricing, C++ Programming and Numerical Methods.

Reading Lists for Beginning Quantitative Analysts

This post is part of a series of reading lists for beginner quantitative analysts. Other posts in the series concentrate on Derivatives Pricing, C++ Programming and Numerical Methods:

Python is now firmly entrenched in the quant finance world. It is used extensively within investment banks and quantitative hedge funds, both as a research tool and production implementation language. While C++ still plays a significant part in mission-critical derivatives pricing libraries it is now common to find these 'wrapped' in Python to allow straightforward modelling for the quant analyst or researcher.

This article has been written for both prospective quantitative analysts as well as those that are early in their career but have not had previous exposure to Python. It presents a list of textbooks that are suitable for learning Python from scratch through to an intermediate level.

In the financial world Python has often historically been introduced as a 'scripting' or 'glue' language, suitable for tying other large code bases together, themselves often written in C++ or Java. As the language itself matured, along with the development of a rich ecosystem of numerical and scientific libraries, Python adoption increased. It began forming more of the production components found in a typical institutional derivatives pricing or systematic trading 'stack'. Nowadays some quant firms utilise Python as their sole research and implementation langugage.

Many quants will already be seasoned in C++, R, MatLab or Java. What is the return on investment gained by studying Python? The list of benefits below sums up what the language has to offer:

  • Less Lines of Code - Python code is usually around a quarter of the length of code generated by C++ or Java. This means less typing, less debugging and less maintenance.
  • Interpreted - Python does not need to be compiled or linked, which allows for an interactive, iterative programming style that can suit both researchers and developers alike.
  • Libraries - Python comes with an extensive collection of standard libraries and a rich ecosystem of mature third-party projects. Data science, web development, scientific computing, operating system access, network scripting and quantitative finance are all supported.
  • Cross-Platform - Python is extremely portable. Code can be easily exchanged between Windows, macOS and Linux with little to no modification.
  • Interoperability - Python can talk with many other languages easily. It has support for invoking C, C++, Fortran, Java and R code and can itself be called from libraries written in these languages.
  • Career Prospects - Python is now one of the most widely used programming languages in both research and software development. Being an expert in Python will be a significant career benefit for many years to come.

Python presents a comprehensive list of benefits, but how does one begin learning the language? Fortunately there are plenty of high quality textbooks and guides available to help a beginner learn Python.

As with the previous article on C++ an initial consideration is which software framework to use when writing Python code. There are many Integrated Development Environments (IDE) that support Python. The main contenders are PyCharm by JetBrains, VSCode by Microsoft for software development or JupyterLab for interactive notebook style research.

Textbooks for Beginning Python

One of the best books to learn the syntax and basic usage of the language is Eric Matthes's Python Crash Course, 2nd Ed.. The book is split into two parts. The first part outlines the basic syntax of the language, along with its main constructs such as lists, dictionaries and control flow (if statements and loops). It then discusses wrapping statements into functions and the object-oriented concept of classes. The second part of the book takes these ideas and implements three very different projects. This book will give you a great introduction into how to use Python code effectively. It is particularly valuable for those who may never have coded before. However, if you are seasoned C++ quant you may want to skim the syntax chapters and jump straight to the projects.

Another complementary book from the same publisher is Al Sweigart's Automate the Boring Stuff with Python, 2nd Ed.. It covers similar ground to Python Crash Course but the project chapters are more relevant for those working in the financial industry. In particular it has a useful chapter on interfacing Python with Excel, a common operation in investment banking! In addition it has chapters on working with JSON, CSV and other data types that you are typically likely to encounter while working as a quant.

Python Textbooks for Seasoned Quants

Practising quants will generally be more interested in the 'data science' rather than the 'software engineering' side of using Python. However, the two are not necessary mutually exclusive. It is now relatively common for quantitative researchers to be writing high quality 'production' style code rather than just sending their prototype Jupyter notebooks to the quant developers!

One of the most common data science libraries in use by quants is Pandas. The author of the Pandas library, Wes McKinney, has written Python for Data Analysis, 2nd Ed., which covers various libraries in Python, but primarily intermediate usage of Pandas. It is worth picking up to gain a solid grounding how Pandas works. Much of a quant's day will be spent working with financial time series data and Pandas is highly suited to carrying out time-series based operations such as interpolation, resampling and calculating rolling statistics.

Yves Hilpisch's recent book Python for Finance, 2nd Ed. covers many topics for quants involved in both algorithmic trading and derivatives pricing. While the first and second sections of the book cover Python in general, with a look at some of the useful libraries, it is the third, fourth and fifth sections of the book that will appeal to quants. For quant analysts in particular the fifth section concentrates solely on derivatives pricing and how to implement valuation engines within Python.

For those who are practising quants but need to get up to speed with Python as applied to derivatives pricing Derivatives Analytics with Python, also by Yves Hilpisch helps bridge the gap. It provides theoretical coverage for those who are new to the field, but also sufficient scripts to implement the theory.

Finally, if you are serious about wanting to learn Python to an advanced level then Luciano Ramalho's Fluent Python will help get you there. The book is aimed primarly at software developers, rather than quants per se, but many of the topics are still highly relevant for those quants who spend a disproportionate amount of their time coding. The book was written in 2015, but is still very relevant. However, if you want something a little more up to date covering the latest features of the language the author is releasing a (highly anticipated!) second edition in January 2022.

Further Resources

Python forms the basis of some useful open source derivatives pricing libraries. In particular, the open source FinancePy provides many examples of advanced derivatives products and how to price them in Python. For those who are learning Python along with derivatives pricing the library's structure will provide some useful inspiration on how to write your own derivatives pricing tools.

Related Articles