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

Selected mathematical tools

Modern portfolio theory

Financial time series analysis

Pricing theory

Risk management

Machine learning

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

Date Summary
2021.3.3
  • Syllabus
  • (FYR) FRM Study Guide 2021
  • Development environment
  • (FYR) Preliminary knowledge about CS
  • Programming basics
    • Lecture notebook: notebook with pdf
    • Variables and naming
    • Simple data types (float, str, bool)
    • Arithmetic operators (+,-, *, /, //, %, **), assignment operator (=), rational operators (<, <=, ==, >, >=, !=), logical operators (and, or, not)
    • A collection of data: list
    • Branching (if-elif-else)
    • Iteration (for, while)
    • Applications: Monte Carlo simulation with random number generator, bisection method for root-finding
    • Jump statements (break, continue, pass)
    • Functions and lambda expressions
  • (FYR) Kronos Research, Kronos Webinar Trilogy #1 - Quant Trading 101, 2020.5.16
2020.3.6
  • Data acquisition, visualization, strategy development, & backtesting
    • Lecture notebook: notebook1, notebook2
    • Pandas: DataFrame
    • Data source: financial functions for Python (ffn)
    • Plotting: matplotlib, seaborn, mpl_finance, bokeh
    • Technical analysis: ta
    • Backtesting: backtrader
  • Homework: Lab 1 due by 3.13
2021.3.10
  • Mathematical tools
    • Lecture notebook: notebook1
    • Vectorization: numpy
    • Matrix computation: numpy & scipy
    • Interpolation: spline
    • Optimization: curve fitting, root-finding
  • (FYR) Jake VanderPlas, Python's data science stack, 2016
2021.3.13
  • Mathematical tools (cont'd)
2021.3.17
  • 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 by 3.20
2021.3.20 (2h0m)
  • 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 by 3.24
2021.3.24
  • 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
2021.3.27
2021.3.31
  • 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
  • Homework: Lab 5 due by 4.7
2021.4.3 (no class due to long weekend)
2021.4.7
  • 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
2021.4.10
  • Additional topics
    • Kelly formula: link
    • Seasonal ARIMA with exogenous regressors: link

Gradebook

References

A new list for references will be ready soon.

Python programming

Finance

Mathematics

Machine learning

Blockchain