Systematic Quant funds are a rapidly rising part of the hedge fund and smart beta world. Although there is a large focus on high-frequency by academics, medium-to-low frequency algo trading accounts for over $350bn AUM and is the highest growth segment of the HF world.
This algorithmic trading course covers the underlying principles behind algorithmic trading, including analyses of trend-following, carry, value, mean-reversion, and relative value strategies. We will discuss the rationale for the strategy, standard strategy designs, the pros and cons of various design choices, and the gains from diversification in portfolio strategies. Finally, since the industry is plagued by overfitting and resulting poor performance, we will discuss p-hacking (or 'financial charlatanism') and various strategies to avoid it.
What am I going to get from this course?
Professionals - Understand the mechanics of standard implementations of the single asset and portfolio based risk-premia trading strategies. Recognize pros and cons of various approaches to designing strategies and the common pitfalls encountered by algorithmic traders. Be able to devise new and improved algorithmic
Algorithmic Traders - Recognize the reasons commonly-used strategies work and when they don't. Understand the statistical properties of strategies and discern the mathematically proven from the empirical. Acquire an understanding of methods to prevent overfitting.
Academics/students - Gain familiarity with the broad area of algorithmic trading strategies. Master the underlying theory and mechanics behind the most common strategies. Acquire the understanding of principals and context necessary for new academic research into the large number of open questions in the area.
Prerequisites and Target Audience
What will students need to know or do before starting this course?
Course work to include (or familiarity with the following topics):
- Undergrad ODE and PDE (math physics or engineering/Fourier expansion based)
- Some Stochastic Differential Equations (SDEs), although some will be covered in the course
- Basic undergrad Analysis
- Numerical linear algebra.
- Statistics (taught in a statistics, econometrics, machine learning or signal processing course)
- Familiarity with some time-series and difference equations
- Python or Matlab or R
- Finance: Familiarity with financial products: Futures, Equities, Bonds, Commodities
- Helpful but not necessary: Black-Scholes Option Pricing
Who should take this course? Who should not?
Bachelors or Masters degree
- in Physical Sciences and Engineering
- in Computer Science with a firm understanding of mathematics
- in Economics or Finance with a firm knowledge of econometrics
Module 1: Course Overview
We discuss algo trading strategies and their recent context in the world of alternative investment management
Context and Background
Introduction to the area, Algo as opposed to High-Frequency/Low Latency Trading, and areas of growth.
The goals of the course, for students/academics, professionals, and algo traders, and general background to the course.
What the course is Not and the Role of Data Science
What the course is not.
The Role of Data science and ML - do data scientists need to know about 'canonical' strategies? Can they just start fresh? We argue that some of the most commonly used strategies give good guidance for data scientists whose techniques rarely work "out of the box" and are especially prone to problems in the area of algo trading strategies.
Prerequisites and Syllabus
We describe the basics of the syllabus. Some of these materials are covered very thoroughly, while others are covered quite quickly as methods in use / approaches to consider in devising and refining strategies. We cover Background, Momentum, Mean Reversion, Carry, Value, Basic Portfolio Strategies, and the important concept of Overfitting, focusing on the mathematical and statistical justification, formulation and properties of each strategy.
Slides on Introduction, Background Material, Goals and Prerequisites and Syllabus
Module 2: Industry Overview and Math Review
Alternatives, Hedge Funds, CTAs and Quant Funds. What size and what numbers? How much are they growing? Where are the opportunities? From the top down look at the overall prospects of the industry where Algo Trading Strategies are employed.
Algo Trading Strategy Infrastructure
Intro Quiz on Background
Quiz on background and introduction
Review 2 ARMA Processes
We review basic Box-Jenkins method for ARMA models, look at characteristic polynomials, describe stationary vs nonstationary processes
Review 1 - White noise and Brownian motion
We review some of the basic mathematics for timeseries including white noise and brownian motion
Review 3 - Autocovariance, autocorrelation and criteria
We review the ACF and its relation to ARMA models, and start on criteria (AIC, BIC) as a means of doing model choice.
Review 4 - Cross Validation, Bootstrap and solving SDEs
We touch on more computer intensive methods for doing model selection - cross validation, and finding standard errors-bootstrap. Finally, we discuss two most common method for solving SDEs in closed-form, muitipying constants and integration by parts/Ito's lemma
We go through some basic ARMA models and their ACFs
Module 3: Momentum / Trend Following
Momentum - a first glance
We introduce the very basic intution behind momentum and how we would construct the most simplistic of strategies
Momentum Related Factoids 1
We discuss some of the properties and tradeoffs of momentum, many of which can be changed by strategy design.
Momentum Factoids 2
Further factoids including examples of returns in practice
Proving results about momentum 1
We look at discrete time versions of momentum and seek to prove that skewness changes by horizon
Proving results about momentum 2
This is a whiteboard section on the basics of the skewness over horizon results (Martin-Zou), going through the proof, showing that the concepts are relatively easy (even if the algebra is a little tedious).
Skewness - why is it so strange?
Having proved results about the skewness of momentum returns over different horizons, we apply it to an exponentially weighted moving average (EWMA) rule, showing how the peak skewness is related to the effective lookback (in our case, the "span") of the EWMA.
Practical Momentum - Different methods for similar results
We describe the most commonly used methods in the industry, from Kalman Filters to Moving Averages to ARIMA models. Used properly, most of these models can attain almost the same performance.
Coding Momentum 1
We introduce an ipython notebook. It takes data from Quandl (and some from Yahoo finance) including SPX, SPTR, and Effective Fed Funds. We use these to construct S&P 500 excess returns, and compare to SPX. We then devise a strategy for momentum.
Coding Momentum 2
Computing relevant stats (Sharpes and Skewness) over different horizons
Momentum variants, and fads and fancies in models
Cross sectional vs Timeseries momentum. Which is better? Where are each of them used? Why should we know them both?
Fads and fancies in momentum modelling. Models vs Method.
Momentum - capped, floored and otherwise altered signals
We look at Winsorising or capping and flooring the signals (sometimes needed to prevent too large capacity utilisation), using thresholds, etc. These typically detract from the skewness, but they could help the overall performance. We look at various methods and discuss their pros and cons and how to measure them.
Readings for further study
We give links to and summarize the handful of most important papers on statistical aspects of momentum trading for further study. Being well-known, these are also the most cited papers, and so any new academic research can be found (using google scholar) just by searching preprints and papers which cite these important studies.
Momentum - Summary
Summarizing the main points we made in section 2 on Momentum
Module 4: Mean Reversion / Change-points
Mean Reversion Overview and Time-scales of trades
Overview of MR, and the timescales/horizons associated with MR, Momentum and Value
Putting timescales all together and where to search for history
A continuation of the previous lecture, putting the timescales all together, and looking to ancient history (if need be)
Mean Reversion in action
The typical features of an MR trading strategy, what to expect and what to be careful with
Rationales for Mean Reversion
Various competing (or not so competing) rationales for mean reversion: Liquidity Provision and Overreaction
Vol and Mean Reversion
Volatility and Mean Reversion, the theory and empirics behind their relationship
Liquidity - References
A few of the most important academic papers on liquidity
Mean Reversion and Unit Root Tests, Intro
An analysis of the types of behaviour we want to discern between, focusing on mean reverting vs unit root processes.
Augmented Dickey Fuller Tests
ADF Tests are the most commonly used unit root tests out there. We introduce their use and limitations
KPSS tests turn H0 and H1 on their heads, testing for mean-reversion. They also have their limitations
Variance Ratio Tests
We introduce variance ratio tests, explore their use and misuses
Cointegration and Johansen Test
Cointegration and Engle Granger testing, and the more thorough Johansen test
Harvey Nyblom Tests and Shortcomings
Harvey Nyblom is to Johansen as KPSS is to ADF and we explore H-N Tests and then the shortcomings for all testing methods
Power, Type I and Type II errors
power of tests, confidence intervals, type 1 and type 2 errors
Changepoints - Overview
Overview and more classical approaches to changepoint detection. These are useful for piecewise linear fits to data to establish trending means and mean reversion to these trending means.
Changepoints - Lasso based tools
Using the lasso regression to detect trends, we can identify breakpoints and extract trends at the same time. While not always the easiest method, regularisation methods like lasso are helpful in many circumstances and also are a decent framework to think of the underlying problems.
Changepoints - sequential binary segmentation, switching kalman filters and summary
We follow up with a very practical and implementable tool - sequential binary segmentation (and Wild binary segmentation)
Module 5: Carry, Value, and Portfolio Strategies
Carry - First definitions
We define carry and give a rationale in terms of P vs Q measures
P vs Q measure
We continue the discussion of the differences between P measure (physical world) vs Q measure (for pricing and hedging derivatives). While Q (where spot rates will always drift towards forwards or - 'forwards are realised') is an interesting construct, it is merely that. We have to use it to price and hedge (or 'risk manage') derivatives. Realistically, in incomplete markets, Q is not actually unique and is merely a useful construct. Realistically speaking, spot rates tend to stay put, and random walks are much more likely than having realised forwards. If spot rates are martingales/random walks, this is a perfectly decent rationale for studying carry.
Defining carry-- what is it? Why do we care about it? What is a positive carry position and what is a negative carry position? What about commodities?
Carry for Swaps (and a little for bonds)
We define carry for swaps, something not as easily available, and also a little bit for bonds. Bonds, however, are altogether more difficult, since you need to know bond-specific funding rates (term repo rates), so we mostly pursue carry for swaps.
Carry for Futures, FX, Equities and Derivatives
We briefly describe carry for Futures (including commodity and equity) and FX and for the less well covered area of Derivatives.
Carry - Summary
We summarize the exploration of carry
We define value, its use and how it differs from Equities (where it is well defined and followed regularly) to fixed income, fx and commodities. Value, with its longer-term mean-reversion properties, is naturally orthogonal to momentum, and mean-reversion.
Portfolio Strategies 1 - MVO
Mean variance optimisation as a guide to basics of portfolio strategy
Portfolios - Testing weights
We present portfolio optimisation as a regression and describe F-tests for statistical significance of changes in portfolio weights.
Portfolio Optimisation - Conditional Portfolios and other performance measures
We introduce conditional portfolios and optimisation to include dynamic reallocation. Using augmented portfolios allows us to consider dynamic signals in portfolio optimisation.
Finally, we talk about the shortcomings of most MVO style portfolio optimisation, and introduce a number of the standard performance measures used in measurement and allocation problems.
Module 6: Overfitting
Intro to Overfitting and the major issues
We introduce the problem and related issues of p-hacking, lack of reproducibility, and holdout overfitting in Kaggle competitions.
Overfitting in Finance
Overfitting in finance is perhaps more problematic than any other field. While Amazon or Google could miss a few keyclicks by relying on spurious results, in finance, we could easily risk insolvency. Meanwhile, overfitting is altogether too common and recent studies have shown its prevalence.
Dealing with overfitting - increasing backtest length
Bailey et al have proposed increasing backtest lengths to avoid overfitting. The method is illustrative but provides more of a rule of thumb. We describe the results of their paper on "Financial Charlatanism and Pseudo-Mathematics" and the concept of minimum backtest length
Adjusted Sharpe Ratios and Multiple Hypothesis Tests
Harvey and Liu discuss the statistics of Sharpe ratios, converting to p-values (if Sharpe = E[Ret]/Std[Ret], the test is H0: E[Ret]=0). They then discuss multiple hypothesis testing and how one deals with it.
Multiple Hypothesis Testing - Holm and Bonferroni
Ways of dealing with Multiple Hypothesis Testing - Holm and Bonferroni methods, somewhat more extreme than optimal but giving some good insight into means of adjusting p-values.
Multiple Hypothesis Testing - BHY adjustments and Practical Methods to prevent overfitting
We describe the best method for controlling the rate of false discovery (FDR), the BHY adjustment and we talk about its impact on Sharpe Ratios based on number of strategies run and size of history available for backtest.
Finally, we summarize the practical approaches to backtest overfitting.
Module 7: Course Summary