Skip to content

weijie-chen/Time-Series-and-Financial-Engineering-With-Python

Repository files navigation

[Last update Dec 2022]

Time Series Analysis and Financial Engineering With Python

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.

Prerequisites

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

Environment Setup

I use poetry to management environment, if you happen to use VS code like me, please follow the steps below:

  1. In Windows powershell and install poetry (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -p
  2. Navigate to cd $env:APPDATA\Python\Scripts, check if poetry being installed.
  3. Open a notepad notepad $profile and set alias for poetry Set-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.
  4. Reload profile by . $profile.
  5. If you are on your personal computer Set-ExecutionPolicy RemoteSigned -Scope CurrentUser to unstrict your execution policy and choose Y.
  6. Resume the default restricted policy for security Set-ExecutionPolicy Restricted -Scope CurrentUser.
  7. Now check poetry --version, if you see the version printed, then means we succeed in setting alias.
  8. You choose to use poetry update, or just manage version at your own convenience.
  9. 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".
  10. This command will install python Start-Process -FilePath ".\python-3.12.0-amd64.exe" -ArgumentList "InstallAllUsers=1 PrependPath=1" -Wait.
  11. According to my installed directory, we will let poetry to use the newly installed Python poetry env use "C:\Program Files\Python312\python.exe".
  12. Enter poetry shell, check python --version.
  13. Do poetry install, this should create poetry.lock accoring to poetry toml.
  14. poetry run python -m ipykernel install --user --name=poetry-env --display-name "Python (Poetry)" will register and create Jupyter kernel.
  15. poetry env info -p will print out the path of this kernel.
  16. Give this path to "Select Python Interpretor" menu.

Contents

It is advised that you download all material and browse in your own computer, since nbviewer has persistent LaTeX rendering errors.

Part I

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

Part II

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)

Screen Captures

opt capm simu ou mpt rolling_mean AR IRF log_division fx_dist sp500 diag

About

A series of lessons on time series analysis with Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published