This code accompanies the the paper Slow Momentum with Fast Reversion: A Trading Strategy Using Deep Learning and Changepoint Detection and preprint.
⚠️ This work has now been improved upon with the paper Trading with the Momentum Transformer: An Intelligent and Interpretable Architecture. Please refer to the this repo for the implementation of both the Slow Momentum with Fast Reversion and Trading with the Momentum Transformer papers.
Momentum strategies are an important part of alternative investments and are at the heart of commodity trading advisors (CTAs). These strategies have however been found to have difficulties adjusting to rapid changes in market conditions, such as during the 2020 market crash. In particular, immediately after momentum turning points, where a trend reverses from an uptrend (downtrend) to a downtrend (uptrend), time-series momentum (TSMOM) strategies are prone to making bad bets. To improve the response to regime change, we introduce a novel approach, where we insert an online change-point detection (CPD) module into a Deep Momentum Network (DMN) pipeline, which uses an LSTM deep-learning architecture to simultaneously learn both trend estimation and position sizing. Furthermore, our model is able to optimise the way in which it balances 1) a slow momentum strategy which exploits persisting trends, but does not overreact to localised price moves, and 2) a fast mean-reversion strategy regime by quickly flipping its position, then swapping it back again to exploit localised price moves. Our CPD module outputs a changepoint location and severity score, allowing our model to learn to respond to varying degrees of disequilibrium, or smaller and more localised changepoints, in a data driven manner. Using a portfolio of 50, liquid, continuous futures contracts over the period 1990-2020, the addition of the CPD module leads to an improvement in Sharpe ratio of one-third. Even more notably, this module is especially beneficial in periods of significant nonstationarity, and in particular, over the most recent years tested (2015-2020) the performance boost is approximately two-thirds. This is especially interesting as traditional momentum strategies have been underperforming in this period.
- Create a Nasdaq Data Link account to access the free Quandl dataset. This dataset provides continuous contracts for 600+ futures, built on top of raw data from CME, ICE, LIFFE etc.
- Download the Quandl data with:
python -m data.download_quandl_data <<API_KEY>>
- Create Momentum Transformer input features with:
python -m examples.create_features_quandl
. In this example we use the 100 futures tickers which have i) the longest history ii) more than 90% of trading days have data iii) data up until at least Dec 2021. - Run the changepoint detection module:
python -m examples.concurent_cpd_quandl
- CPD Module
- Deep Momentum Network - see Momementum Transformer repo
Please cite our paper with:
@article {Wood111,
author = {Wood, Kieran and Roberts, Stephen and Zohren, Stefan},
title = {Slow Momentum with Fast Reversion: A Trading Strategy Using Deep Learning and Changepoint Detection},
volume = {4},
number = {1},
pages = {111--129},
year = {2022},
doi = {10.3905/jfds.2021.1.081},
publisher = {Institutional Investor Journals Umbrella},
issn = {2640-3943},
URL = {https://jfds.pm-research.com/content/4/1/111},
eprint = {https://jfds.pm-research.com/content/4/1/111.full.pdf},
journal = {The Journal of Financial Data Science}
}