O'Reilly logo
live online training icon Live Online training

Python for Finance

Building Quantitative Finance models using Python

Atul Tripathi

The ability to create and understand models is one of the most valued skills in business and finance today. It is an expertise that will stand you in good stead in the area of quantitative finance, where numbers are important. This course combines relevant material from quantitative finance and sets up your interface for modeling using Python. In this course, you will learn the application of Python as a programming language for building quantitative finance models.

We will cover the fundamentals of Python – installation of the Python environment, syntax, variables, casting operators, strings, lists, tuples, sets, dictionaries, loops, arrays, and data modification. We will then dive deep into building quantitative finance models covering topics such as CAPM and arbitrage pricing model, option pricing, trees and finite difference methods, Monte Carlo simulations for building option pricing models, modeling of Black Scholes Greeks, and currency options. At the initial stage of each section, the theoretical and mathematical background of each of the topics will be covered. Then we will cover the algorithmic design to give you clarity on the approach required to build these models.

_Why Python for Finance? _

Derivative modeling is at the heart of quantitative research and practitioners (that is, trading desk quants) and academics alike spend much research, money, and time to develop effective models for pricing, hedging, and trading equity and fixed-income derivatives. Many of these models involve complicated algorithms and numerical methods that require lots of computational power. However, often the implementations/“how-to”s of these models are quite esoteric to the model creators and developers due to their algorithmic complexity.

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built-in data structures, combined with dynamic typing and dynamic binding, make it very attractive for use as a scripting language to connect existing components together. Python’s simple and easy-to-learn syntax emphasizes readability and therefore reduces the cost of program maintenance.

What you'll learn-and how you can apply it

  • Application of Python as a programming language for modeling in quantitative finance – portfolio theory and investment analysis, derivative pricing, risk management
  • Develop dynamic financial models using Python
  • Build models for risk management techniques such as extreme value theory

This training course is for you because...

You are a finance professional who wants to use Python for simplifying your financial operations. You might also be a software developer, data scientist, or student who is working or wishes to work in the finance industry and needs to design financial models using Python.

Prerequisites

  • Basic understanding of portfolio theory, investment analysis, derivative pricing, and risk management
  • Basic understanding of Python

Recommended preparation

Python for Finance - Second Edition

Materials, downloads, or supplemental content needed in advance

Install - Python Development Environment

About your instructor

  • Atul Tripathi has spent more than 16 years in the fields of artificial intelligence, machine learning, and quantitative finance. He has researched, worked and developed models for Value at Risk, Extreme Value Theorem, Option Pricing, and Energy Derivatives using Monte Carlo simulation techniques. He has worked on advanced machine learning techniques, such as neural networks and Markov models. While working on these techniques, he has solved problems related to image processing, telecommunications, human speech recognition, and natural language processing. He has also developed tools for text mining using neural networks.

    He is the author of a book titled Machine Learning Cookbook by PACKT Publication. The book has been translated into Chinese.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

DAY 1

Section 1: Introduction to Python (1 hour)

  • Python Overview: This section will cover the installation of the Python environment, syntax, variables, casting operators, strings, lists, tuples, sets, dictionaries, loops, arrays, and data modification.

  • Lab - Building the Application: Use Python as a programming language for: building an application, manipulation of strings and arrays, use of date functions and loops.

  • Q&A

  • Break (10 min)

Section 2: CAPM and Arbitrage Pricing Model (1 hour)

  • Theory about Building CAPM and Arbitrage Pricing Model: Arbitrage Pricing Theory (APT) is an alternative to the CAPM and it uses fewer assumptions. In this section, we will practically understand the building of such models using the Python programming language and its well-known libraries.

  • Lab – Building the Application: Use Python as a programming language, to: implement the Capital Asset Pricing Model, use Markowitz portfolio optimization to construct a portfolio, compare the results with other conventional market strategies, such as an equal-weighted portfolio.

  • Q&A

  • Break (10 min)

Section 3: Exotic Options (1 hour)

  • Theory about Building Exotic Options (10 min): An exotic option is an option that differs in structure from the more common American options or European options in terms of the underlying asset or the calculation of how or when the investor receives a certain payoff. Starting with the basics, we move up to understanding the core functionalities of exotic options and practically understand the process by building an application-based model using Python as a programming language.

  • Lab - Building the Application: Use Python as a programming language for modeling barrier options, modeling arithmetic averaging, pricing seasoned Asian options.

  • Q&A

  • Break (10 min)

Section 4: Energy Options on Forwards (1 hour)

  • Theory about Building Energy Options on Forwards Using Python: In this lecture, we will cover the approach to building models for energy options on forwards using Python as a programming language. We will start with understanding energy options on Forwards and then move towards practically understanding the working model.

  • Lab - Building the Application: Use Python as a programming language: energy options on forwards for calls and puts, understand the adjustments that are particular to energy and commodity valuations.

  • Q&A (5 min)

DAY 2

Section 5: Trees and Finite Difference Methods (1 hour)

  • Theory about Building Binomial Option Pricing Using Trees: The lecture will cover the fundamental concepts of binomial option pricing using trees. And also, the approach to building the models for BOP using: Python as a programming language, the libraries to be used, and the approach to building the models.

  • Lab - Building the Application: Use Python as a programming language: binomial option pricing using trees for one underlying asset, understand the numerical methods that are useful to price options and other derivatives securities, understand the method to construct a recombining binomial tree that discretizes and approximates geometric Brownian motion.

  • Q&A

  • Break (10 min)

Section 6: Monte Carlo for Callable Options (1 hour)

  • Theory about Building Models for Using Callable Options Based on Monte Carlo Simulation: This lecture will cover the approach to building the models for callable options based on Monte Carlo simulations using Python as a programming language.

  • Lab - Building the Application: Use Python as a programming language: callable options, simulate stochastic process, Monte Carlo simulations where the natural logarithm of the underlying asset follows Brownian motion.

  • Q&A

  • Break (10 min)

Section 7: Black Scholes Greeks (1 hour)

  • Theory about Building Models for Greeks: The lecture will cover the fundamental concepts of Greeks: Delta Greeks, Gamma Greeks, Vega Greeks, Theta Greeks.

  • Lab - Building the Application: Use Python as a programming language: understand the sensitivity of option price to a small change in the parameter, develop an algorithm for calculating the Greeks, Greeks – Delta Greeks, Gamma Greeks, Vega Greeks, Theta Greeks.

  • Q&A

  • Break

Section 8: Currency Translated Options (1 hour)

  • Theory about Building Models for Currency Translated Options: We will start with understanding the fundamental concepts of currency translated options. Then we will cover the approach to building the models for these options using Python as a programming language and also understand the libraries to be used.

  • Lab - Building the Application: Use Python as a programming language for: currency translated options, algorithms for currency translated options, option pricing formulae for currency translated options

  • Q&A (5 min)