Python Programming in Finance


Location: Room 108, 德田館
Time: 1900 ~ 2200

``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, strategy development, & 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, 337 ]

Date Summary
2020.12.22
2020.12.25
  • 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 1/5
2020.12.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
2021.1.5
2021.1.8
  • Modern portfolio theory
    • Lecture notebook: pyf_4_modern_portfolio_theory.ipynb
    • Mean-variance framework: Markowitz efficient frontier
    • Capital asset pricing model (CAPM)
    • Arbitrage pricing theory (APT)
    • 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
  • Homework: Lab 2 due 1/15
2021.1.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
  • Homework: Lab 3 due 1/19
2021.1.15 (no class due to personal excuse)
2021.1.19
2021.1.22
  • 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
2021.1.26
  • 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
2021.1.29
  • 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

A new list for references will be ready soon.

Python programming

Finance

Mathematics

Machine learning

Blockchain