BlackArbs LLC Brian Christopher, CFA April 25, 2017
Brian ChristopherQuantitative researcher, Python developer, CFA charterholder, and founder of Blackarbs LLC, a quantitative research firm.
Six years ago he learned to code using Python for the purpose of creatingalgorithmic trading strategies. Four years ago he decided to self publish hisresearch with a focus on practical, reproducible application.
Now he continues his open research initiatives for a growing community oftraders, researchers, developers, engineers, architects and practitionersacross various industries.
He attained a BSc in Economics from Northeastern University in Boston,MA and received the Chartered Financial Analyst (CFA) designation in 2016.
About the Speaker
2
Return prediction is difficult.
In Time Series Analysis (TSA) we observe multiple phenomenathat violate the rules of stationarity (non-linear processes,volatility clustering, autocorrelation, etc.)
Traditional TSA techniques don’t generalize well for assetreturn prediction but may be useful in volatility prediction(ARIMA, ARCH, GARCH)
The Problem with Traditional Time Series Analysis(Defining the Problem)
3
Traditional Issues with Asset Return Prediction
4
Blackarbs credit: SeanAbu.com
What Can We Do?
5
We need a model that doesn’t require stationary data.
We need a model that can approximate non-linear distributions.
Are mixture models a solution?
6
Mixture models build on several established concepts.
Markov models - Sequences where future statedepends only upon current state aka memorylessprocesses.
Hidden Markov models – The true state is unobserved(hidden) but there are observable factors that give usinformation about the true state.
Expectation-Maximization (E-M) – Class of algorithmsthat iterates between computing class parameters andevaluating the likelihood of the data given thoseparameters.
What are mixture models and how do they work?
7
We know that time series exhibit temporary periods wherethe expected means and variances are stable through time.These periods or regimes can be likened to hidden states.
If we can better estimate an asset's most likely regime orhidden state, including the associated means and variances,then our predictive models become more adaptable and willlikely improve.
If that's the case, then all we need are observable variableswhose behavior allows us to infer the true hidden state(s).
What are mixture models and how do they work?Summary
8
Think of an asset’s returns as a sequence of states or“regimes”.
Each regime has its own descriptive statistics including meanand volatility.
Examples include “low-vol” vs “high-vol” regimes.
The model assumes that over time, the asset’s returns willtransition between regimes based on probability.
Mixture models try to estimate the sequence of regimes,each regime’s descriptive attributes, and the transitionprobabilities between regimes.
The most well known is the Gaussian Mixture Model (GMM).
What are mixture models and how do they work?
9
GMM assumes each regime (aka component, class, state) isgenerated by a Gaussian process with discoverableparameters.
GMM uses E-M under the hood alternating betweenestimating the regime parameters (mean, variance) andlikelihood that those parameters could generate the data,until convergence or another stopping criteria is met.
Can GMMs model non-stationary data sets?
10
Using SPY return data from Yahoo Finance I fit the GMM with3 components representing low-volatility, neutral, and high-volatility regimes.
Can GMMs model non-stationary data sets?
11
Notice the 2th hidden state or “regime” has a negative meanreturn, and the largest variance, which represents our high-vol regime. The 1th hidden state looks like our low-volregime, and the 0th hidden state is somewhere in between.
The GMM accounts for non-stationarity by design. It chopsthe data into regimes and provides us with an estimate of themean and variance for each one.
Can GMMs approximate nonlinear data distributions?
12
Short answer: Yes
The top image shows theGMM trying to fit 2Gaussians to the data withpredictably bad results.
The bottom image showsthe GMM trying to fit 16Gaussians to the data withmore success.
You can approx. manycomplex shapes withenough Gaussiancomponents but you riskoverfitting.
Strategy Design
13
Now that we have determined that GMMs can overcome the weaknesses of the TSA models, we can design a trading strategy to test its application:
The strategy uses a total of 4 factors to estimate thesequence of regimes and their parameters.
• The asset’s returns (Yahoo Finance)
• TEDRATE (FRED)
• T10Y2Y (FRED)
• T10Y3M (FRED)
Strategy Design
14
The strategy works like so.
Feed market data to the GMM.
Call predict method to extract model estimate of last regime“label”.
Once we have the “label” we can get the model estimate ofthe mean and variance for that regime.
We feed the parameter estimates to the JohnsonSUdistribution and draw N samples to construct our 99%confidence intervals (CIs).
Any returns that fall outside the estimated CIs are defined asoutliers and assumed to mean revert. This strategy assumesa “buy” of the etf for M number of steps (days) after theoutlier event of a return falling below the lower CI.
Evaluate the Strategy
15
For a single ETF with a set of parameters, for the walk-forward period, we can plot the model accuracy as well as an“equity” plot.
Below is an example output for SPY:
Evaluate the Strategy
16
To really dive in we have to analyze the aggregated results. Byorganizing the data properly...
We can evaluate each ETF individually across lookbacks, stepsor ks
We can evaluate the ETFs collectively across lookbacks, stepsor ks
We’ll look at a few examples in the following slides...
Evaluate the Strategy
17
We can see that across lookbacks SPY, QQQ, TLT have positivemedian returns per event. EFA and EEM have more symmetricdistributions.
Evaluate the Strategy
18
We can see a similar distribution pattern here using thesum_ratio statistic. The sum_ratio statistic is the sum of returns> 0 divided by the sum of returns < 0. Values greater than 1 areconsidered a “success”.
Evaluate the Strategy
19
In this example we evaluate the median return for each ETF bylookback and across steps. Again we see SPY, QQQ, and TLTdominating. EFA is also mostly > 0 across steps.
Evaluate the Strategy
20
In this plot we see the sum_ratio metric is > 1 across multipledimensions for SPY, QQQ, TLT, and EEM. GLD’s sum_ratiodepends on lookback. EFA is weak, and EEM suffers fromexposure at 21 steps.
Evaluate the Strategy
21
Here we can evaluate the median returns across k (# ofcomponents). Again we see broad success across k for SPY,QQQ, TLT, and surprisingly EFA. GLD and EEM are more variedand dependent on lookback.
Evaluate the Strategy
22
Here we can evaluate the median returns across k (# ofcomponents). Again we see broad success across k for SPY,QQQ, TLT, and surprisingly EFA. GLD and EEM are more variedand dependent on lookback.
Evaluate the Strategy
23
Here we see a similar pattern among the ETFs with thesum_ratio for SPY, QQQ, TLT are > 1 across multipledimensions. EEM and GLD show similar variability based onlookback but with passable performance overall.
Conclusions
24
The secret sauce for GMM accuracy when predicting the return distribution is choosing the proper sampling distribution (JohnsonSU vs. Normal)
US based ETFs showed consistently positive results across many parameter combinations.
There was more variability with GLD, EFA, and EEM depending on metric evaluated, steps (exposure), and k which warrants an expanded study.
Must note that there is a risk that these results are simply the result of being long the US market post 2009!
Further Areas to Explore
25
GMM with large cross section of single-issuer stocks.
GMM testing with multiple time frames (intraday, weekly, monthly).
GMM as basis for volatility strategy (testing volatility trends post outlier event.
Are the outlier events themselves randomly distributed? Or are they clustered?
GMM as a basis for multi-asset class strategy (combinations of equity, options, futures)
Resources
26
* Introduction to Hidden Markov Models with Python, Networkxand Sklearn - http://blkarb.se/2l6Lndw
* Intro to Expectation-Maximization, K-Means, Gaussian Mixture Models with Python, Sklearn - http://blkarb.se/2n1A7kn
* Python Data Science Handbook by Jake Vanderplas -https://github.com/jakevdp/PythonDataScienceHandbook
* Blackarbs blog – Blackarbs.com/blog
* Blackarbs Github -https://github.com/BlackArbsCEO/Mixture_Models
Contact
27
* Website: Blackarbs.com
* Twitter: @blackarbsCEO
* Linkedin: www.linkedin.com/in/bcrblackarbs/
* Email: [email protected]
SINGAPORE
30 Cecil Street, #19-08,
Prudential Tower,
Singapore – 049712
Phone: +65-9057-8301
INDIA
A-309, Boomerang,
Chandivali Farm Road, Powai,
Mumbai - 400 072
Phone: +91-22-61691400
Learn Automated Trading
Join EPAT™The Executive Programme in
Algorithmic Trading
Enquire Now!