[Last update Dec 2022]
This is a compound course on time series analysis, financial engineering and algorithmic trading featuring Python programming. Originally it was for night training sessions for new-hire in my previous institution (hedge fund), all quantitative analysts and macro analysts are supposed to have more than working knowlege of time series modelling, so this training session will discuss and demonstrate the underlying mathematical foundations, modelling and Python-related skills.
The tutorial splits in several parts, the Part I discusses various topics in time series analysis, the Part II will cover the classic financial engineering, the Part III discusses portfolio optimization and management, the Part IV discusses systematic trading. Also there are some supplementary tutorials about algorithms and data structures as a starter reference for more complicated quant developing topics.
All learners are required to have solid knowledge of linear algebra, probability theory, statistics and basic econometrics. All analysts are researchers too, with these knowledge, you can freely read institutional or academic researches and internalize them into your own analystical framework.
The learners must have working knowledge of linear algrebra, statistics and probability theory, and ideally advanced econometrics skills too.
And also the learners are assumed to have constant exposure of
- Python
- NumPy
- Matplotlib
- Statsmodels
- Pandas
I use poetry to management environment, if you happen to use VS code like me, please follow the steps below:
- In Windows powershell and install poetry
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -p
- Navigate to
cd $env:APPDATA\Python\Scripts
, check if poetry being installed. - Open a notepad
notepad $profile
and set alias for poetrySet-Alias poetry "C:\Users\user\AppData\Roaming\Python\Scripts\poetry.exe"
in notepad, I prefered this way, because sometimes setting env path not working in windows. - Reload profile by
. $profile
. - If you are on your personal computer
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
to unstrict your execution policy and choose Y. - Resume the default restricted policy for security
Set-ExecutionPolicy Restricted -Scope CurrentUser
. - Now check
poetry --version
, if you see the version printed, then means we succeed in setting alias. - You choose to use
poetry update
, or just manage version at your own convenience. - Download python 3.12 or anything version higher
Invoke-WebRequest -Uri "https://www.python.org/ftp/python/3.12.0/python-3.12.0-amd64.exe" -OutFile "python-3.12.0-amd64.exe"
. - This command will install python
Start-Process -FilePath ".\python-3.12.0-amd64.exe" -ArgumentList "InstallAllUsers=1 PrependPath=1" -Wait
. - According to my installed directory, we will let poetry to use the newly installed Python
poetry env use "C:\Program Files\Python312\python.exe"
. - Enter
poetry shell
, checkpython --version
. - Do
poetry install
, this should create poetry.lock accoring to poetry toml. poetry run python -m ipykernel install --user --name=poetry-env --display-name "Python (Poetry)"
will register and create Jupyter kernel.poetry env info -p
will print out the path of this kernel.- Give this path to "Select Python Interpretor" menu.
It is advised that you download all material and browse in your own computer, since nbviewer has persistent LaTeX rendering errors.
Chapter 0 - Dates and Time in Python
Chapter 1 - Time Series Manipulation
Chapter 2 - Lag Operator and Difference Equation
Chapter 3 - Simple and Log Returns
Chapter 4 - Stationary Processes and Trend Removal
Chapter 5 - ARMA Models
Chapter 6 - ARCH and GARCH Models
Chapter 16 - Implementing Technical Indicators
Chapter 0 - Wiener Process and Random Walk
Chapter 1 - Bond Valuation and Modern Portfolio Theory
Chapter 2 - Capital Assets Pricing Model (CAPM)
Chapter 3 - Options Pricing
Chapter 4 - Rates Modeling
Chapter 5 - Value at Risk (VaR)