Python Programming in Finance


Location: Room 223B, 德田館
Time: 1300 ~ 1600

``All money is a matter of belief.''
-- Adam Smith

``Money often costs too much.''
-- Ralph Waldo Emerson

``One of the things I like about doing science,
the thing that is the most fun, is coming up with something that
seems ridiculous when you first hear it
but finally seems obvious when you're finished.''
-- Fischer S. Black (1938–1995)

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

``It’s a Marathon, not a sprint.''
-- Anonymous

Instructor Information

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).

Wi-Fi Access

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).

Course Prerequisites

Overview

Python crash course

Data acquisition, visualization, signal generation, & backtesting

Mathematical tools

Modern portfolio theory

Financial time series analysis

Pricing theory

Risk management

Machine learning

Misc

TODO list

Wish list

Schedule [ 298, 300, 305, 310, 312, 319, 325, 328, 330, 336 ]

Date Summary
2020.11.21
2020.11.22
  • Programming basics (cont'd)
    • Lecture notebook: pyf_1_python_programming_2.ipynb
    • Flow controls
      • Jump statements (break, continue, pass)
      • Looping techniques: enumerate, zip, reverse, sorted
      • Comprehensions
    • Functions
      • User-defined function
      • Variable scope
      • Default arguments
      • Positional & keyword arguments
      • Lambda expressions
      • Functional programming (map, filter)
      • Advanced usage: iterator (next) & generator (yield)
    • Object-oriented programming
      • Class & object
      • Applications: string, file i/o (with-as), date & time, exceptions (try-except-else-finally)
  • Data acquisition, visualization & backtesting
  • Homework: Lab 1 due 11/29 (you may take a look at other students' work here)
2020.11.28 no class
2020.11.29
  • (FYR) Jake VanderPlas, Python's data science stack, 2016
  • Mathematical tools
    • Lecture notebook: pyf_3_math.ipynb
    • Vectorization: numpy
    • Matrix computation: numpy & scipy
    • Interpolation: spline
    • Optimization: curve fitting, root-finding
2020.12.5
2020.12.6
  • Modern portfolio theory
    • Lecture notebook: pyf_4_modern_portfolio_theory.ipynb
    • Mean-variance framework: Markowitz efficient frontier
    • Capital asset pricing model (CAPM)
    • Fama-French 3-factor model
    • More similar models: Barra risk factor analysis, Smart beta
    • Black-Litterman model: a Bayesian approach
    • (FYR) Prof. Rogers, stochastic financial models, 2012
2020.12.12
  • Financial time series analysis
    • Lecture notebook: pyf_5_financial_time_series_analysis.ipynb
    • Autocorrelation
    • Stationaryness
    • Autoregressive moving-average (ARMA) model
    • Generalized autoregressive conditional heteroskedasticity (GARCH) model
    • Vector autoregression (VAR) model
    • Cointegrated VAR using vector error correction (VEC) model
    • Granger causality
2020.12.13
  • Pricing theory
    • Lecture slides: pricing_theory.pdf
    • Lecture notebook: pyf_6_pricing_theory.ipynb
    • Arbitrage-free principle
    • Complete market
    • Valuation framework: fundamental theorem of asset pricing
    • Binomial option pricing model (BOPM)
    • Stochastic calculus: Wiener process & Ito's formula
2020.12.19
  • (FYR) FRM Study Guide 2021
  • Pricing theory (cont'd)
    • Random walk: Brownian motion
    • Black-Scholes formula
    • Case study: option pricing with negative strikes by using Bachelier model (Chadv20-152)
    • Monte Carlo simulation
      • European options
      • American options using least-square Monte Carlo (LSM)
    • More stochastic processes with simulation
      • Mean-reverting process: Ornstein-Uhlenbeck (OU) model, Vasicek model
      • Mean-reverting square-root process: Cox-Ingersoll-Ross (CIR) model
      • Stochastic volatility model: Heston model
      • Jump-diffusion process: Merton's model
      • Term-structure of interest rates: Hull-White (HW) model, Heath-Jarrow-Morton (HJM) framework, LIBOR market model
    • QuantLib tutorial
    • Model calibration
      • Implied volatility
      • CIR model
2020.12.20
  • Risk management
    • Lecture notebook: pyf_7_risk_management.ipynb
    • Value at risk (VaR) and Expected shortfall (ES)
    • Sensitivity analysis: Greeks
    • Dynamic hedging
    • Case study: VIX
2020.12.26
  • Machine learning tutorial
    • Lecture notebook: pyf_8_machine_learning_tutorial_1.ipynb
    • Regression with regularization: ridge regression & LASSO regression
    • Logistic regression
    • Support vector machine (SVM)
    • Decision tree, random forest, and AdaBoost
    • Principal component analysis (PCA)
    • K-means clustering
    • Reinforcement learning: Q-learning
    • Lecture notebook: pyf_machine_learning_tutorial_2.ipynb
    • Recurrent neural network (RNN)
    • Long-short term memory (LSTM) model
  • Performance issues
    • Lecture notebook: pyf_9_misc.ipynb
    • Row major vs. column major
    • Performance profiling
    • Multiprocessing/multithreading and Amdahl's law
    • Dynamic compiling

Gradebook

References

Python programming

Finance

Mathematics

Machine learning

Blockchain