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

法規遵循聲明 本課程係金融財務學門之學術研習課程,提供國內對金融市場與投資有興趣者科學方法與技術。本課程嚴格遵守金管證投字第1070100230號,無涉及證券投資顧問或期貨顧問事業之任何內容,即本課程並無直接、間接提供證券投資、期貨交易之分析、推介、建議,並無對個別有價證券提供買賣價位、停損停利價位、買賣轉折價位、未來趨勢研判之推薦或建議,並無對個別期貨契約提供未來交易價為研判、建議、或交易策略等任何內容。本課程為提供科學基礎知識,任何相關投資均需使用者自行依照知識基礎自行分析,課程不包含任何證券投資顧問或期貨顧問之範圍,且不直接或間接提供個別有價證券或個別期貨交易契約之價值分析、不提供未來交易價位研判分析或推介建議。本課程非涉及經營證券投資顧問或期貨顧問之範疇;本課程僅依循世界頂尖院校培養頂尖金融機構投資者之教學方式編寫。

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

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 ]

Date Summary
2020.4.22
2020.4.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)
2020.4.29
  • Data acquisition, visualization & backtesting
    • Lecture notebook: pyf_data_acquisition_visualization_backtesting.ipynb
    • Customized data crawlers (or you can buy financial data from those famous information suppliers)
    • High-level data structure: Dataframe of Pandas
    • Another package based on Pandas: financial functions for Python (ffn)
    • Plotting: matplotlib, seaborn, mpl_finance, pygal, bokeh
    • Signal generation: technical analysis using ta
    • Backtesting
2020.5.2
  • (FYR) Jake VanderPlas, Python's data science stack, 2016
  • Numerical & scientific packages: numpy & scipy
    • Lecture notebook: pyf_math.ipynb
    • Vectorization
    • Matrix computation
    • Interpolation: spline
    • Optimization
2020.5.6 (no class due to personal excuse)
2020.5.9
2020.5.13
2020.5.16
  • (FYR) Kronos Research, Kronos Webinar Trilogy #1 - Quant Trading 101, 2020.5.16
  • Financial time series analysis (cont'd)
    • Generalized autoregressive conditional heteroskedasticity (GARCH) model
    • Vector autoregression (VAR) model
    • Cointegrated VAR using vector error correction (VEC) model
    • Granger causality
2020.5.20
  • Pricing theory
    • Lecture slides: pricing_theory.pdf
    • Lecture notebook: pyf_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
    • 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
2020.5.23
  • 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.5.27
  • Machine learning tutorial
    • Lecture notebook: pyf_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_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