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 statistics:

These techniques will be essential in program/algorihmic trading, which is also my personal purpose.

Prerequisites

Text

Overview

Python crash course

Data preprocessing, visualization, and backtesting

Mathematical tools

Financial time series analysis

Pricing models & calibration

Risk management

Performance issues

Machine learning

Wish list

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

Date Summary
2019.5.22
  • syllabus
  • using jupyter notebook
  • live code: pyf20190522.ipynb
  • 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.5.25
  • live code: pyf20190525.ipynb
  • 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
2019.5.29
  • live code: pyf20190529.ipynb
  • 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
  • scripts, modules, import
2019.6.1
  • notebook: pyf20190601.ipynb
  • using spyder (spyder official website)
  • data acquisition
    • data crawlers (or you can buy financial data from those famous information suppliers)
  • pandas: dataframe
  • data visualization
    • matplotlib, seaborn, pygal, mpl_finance
    • technical analysis
2019.6.5
2019.6.12
  • notebook: pyf20190612.ipynb
  • statistical models
    • multivariate linear regression: capital asset pricing model (CAPM), Fama-French 3-factor model
    • autoregressive moving-average (ARMA) model
    • generalized autoregressive conditional heteroskedasticity (GARCH) model
    • vector autoregression (VAR) model
    • cointegrated VAR using vector error correction (VEC) model
2019.6.15
  • notebook: pyf20190615.ipynb
  • 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)
2019.6.19
  • notebook: pyf20190619.ipynb
  • QuantLib tutorial
  • model calibration
    • implied volatility
    • CIR model
    • Heston model
2019.6.22
  • notebook: pyf20190622.ipynb
  • risk management
    • value at risk (VaR)
    • dynamic delta hedging
  • performance issues
    • row major vs. column major
    • performance profiling
    • multiprocess/multithreading and Amdhal's law
    • dynamic compiling
2019.6.26
  • notebook: pyf20190626.ipynb
  • machine learning tutorial
    • LASSO regression and ridge regression
    • logistic regression
    • support vector machine (SVM)
    • decision tree and random forest
    • principal component analysis (PCA)
    • k-mean/clustering
    • reinforcement learning: Q-learning
  • feedback

Sample code

Gradebook

References

Python programming

Financial markets & asset pricing

Financial time series analysis & optimization

Portfolio management

Program/algorithmic trading

Machine learning

Blockchain

Misc