Python Programming in Finance

Location: Room 223A, 德田館
Time: 1900 ~ 2200


``In the business world, the rearview mirror is always clearer than the windshield.''
-- Warren Buffett

Instructor Information

Installation & Wi-Fi

Recording Classroom Lectures Policy Recording of classroom lectures is prohibited unless advance written permission is obtained from the class instructor and any guest presenter(s).

Objectives

This course is an inter-disciplinary course in the fields of computer science, finance, and (a lot of) math:

These techniques are essential both in P & Q quant. Just for the record, this course is not to teach you how to get rich in your life but get rich in knowledge (such that you may get rich in the future).

Prerequisites

Text

Overview

Python crash course

Data preprocessing, visualization, and backtesting

Mathematical tools

Financial time series analysis

Pricing models & calibration

Risk management

Machine learning

Automated execution

Performance issues

Wish list

Schedule [ 298, 300, 305, 310, 312, 319 ]

Date Summary
2019.8.7
  • self-assessment
  • syllabus
  • using jupyter notebook (some tips to use jupyter notebook)
  • programming basic
    • computation model (CPU and memory)
    • variables and naming
    • simple data types (int, float, str)
    • arithmetic operators (+-*/, //, %, **)
    • first built-in data structure: list with slicing
    • assignment operator (=), rational operators (<, ==, >), logical operators (and/or)
    • selection (if-elif-else)
    • iteration (for-in, while) with jump statements (break, continue, pass)
    • application: Monte Carlo simulation, bisection method for root-finding
2019.8.10
  • programming basic (cont'd)
    • data structures
      • list, tuple, dictionary, and set
      • looping techniques: enumerate, zip, reverse, sorted
      • list/dictionary/tuple/set comprehension
    • functions
      • user-defined function
      • variable scope
      • default arguments
    • functional programming
      • functional programming (map, filter)
      • lambda expressions
      • generator (yield)
    • object-oriented programming
      • class and object: ... in python, everything is an object.
      • user-defined class: attributes and methods
      • magic methods
      • (single) inheritance and method overriding
      • file I/O and with-as
      • try-except-else-finally
      • applications: file i/o, exceptions, datetime
  • data processing
    • data acquisition
      • data crawlers (or you can buy financial data from those famous information suppliers)
    • pandas: dataframe
2019.8.14 (no class due to personal excuse)
2019.8.17
  • data processing (cont'd)
    • data visualization
      • using packages: matplotlib, seaborn, mpl_finance, pygal, bokeh
      • technical analysis
    • backtesting
      • net present value
      • maximum draw down (MDD)
      • Sharpe ratio
2019.8.21
  • numerical and scientific packages
    • vectorization
    • matrix computation
    • interpolation
    • optimization
    • application: modern portfolio theory
    • statistics
2019.8.24
  • financial time series analysis
    • multivariate linear regression: capital asset pricing model (CAPM), Fama-French 3-factor model
    • autoregressive moving-average (ARMA) model
2019.8.28
  • financial time series analysis (cont'd)
    • generalized autoregressive conditional heteroskedasticity (GARCH) model
    • vector autoregression (VAR) model
    • cointegrated VAR using vector error correction (VEC) model
  • stochastic processes
    • random walk: geometric Brownian motion
    • square-root and mean-reverting process: CIR model
    • stochastic volatility model: Heston model
    • jump-diffusion process: Merton's model
  • option basics and pricing models
    • valuation framework
    • Monte Carlo simulation
    • binomial option pricing model (BOPM)
    • QuantLib tutorial
2019.8.31
  • model calibration
    • implied volatility
    • CIR model
    • Heston model
  • risk management
    • value at risk (VaR)
    • dynamic delta hedging
2019.9.4
  • machine learning tutorial
    • regression with regularization: ridge regression & LASSO regression
    • logistic regression
    • support vector machine (SVM)
2019.9.7
  • Granger causality: granger.ipynb
  • machine learning tutorial (cont'd)
    • decision tree and random forest
    • principal component analysis (PCA)
2019.9.11
  • machine learning tutorial (cont'd)
    • k-means clustering
    • reinforcement learning: Q-learning
  • performance issues
    • row major vs. column major
    • performance profiling
    • multiprocessing/multithreading and Amdahl's law
    • dynamic compiling

Sample code

Gradebook

References

Python programming

Financial markets & asset pricing

Financial time series analysis & optimization

Portfolio management

Program/algorithmic trading

Machine learning

Blockchain

Misc