Arxiv:2006.08307V1 [Q-Fin.TR] 15 Jun 2020
Total Page:16
File Type:pdf, Size:1020Kb
Hidden Markov Models Applied To Intraday Momentum Trading With Side Information Hugh Christensena,∗, Richard Turnerb, Simon Godsilla aSignal Processing and Communications Laboratory, Engineering Department, Cambridge University, CB2 1PZ, UK bMachine Learning Group, Engineering Department, Cambridge University, CB2 1PZ, UK Abstract A Hidden Markov Model for intraday momentum trading is presented which specifies a latent momentum state re- sponsible for generating the observed securities’ noisy returns. Existing momentum trading models suffer from time- lagging caused by the delayed frequency response of digital filters. Time-lagging results in a momentum signal of the wrong sign, when the market changes trend direction. A key feature of this state space formulation, is no such lagging occurs, allowing for accurate shifts in signal sign at market change points. The number of latent states in the model is estimated using three techniques, cross validation, penalized likelihood criteria and simulation based model selection for the marginal likelihood. All three techniques suggest either 2 or 3 hidden states. Model parameters are then found using Baum-Welch and Markov Chain Monte Carlo, whilst assuming a single (discretized) univariate Gaussian distribution for the emission matrix. Often a momentum trader will want to condition their trading signals on additional information. To reflect this, learning is also carried out in the presence of side information. Two sets of side information are considered, namely a ratio of realized volatilities and intraday seasonality. It is shown that splines can be used to capture statistically significant relationships from this information, allowing returns to be predicted. An Input Output Hidden Markov Model is used to incorporate these univariate predictive signals into the transition matrix, presenting a possible solution for dealing with the signal combination problem. Bayesian inference is then carried out to predict the securities t + 1 return using the forward algorithm. The model is simulated on one year’s worth of e-mini S&P500 futures data at one minute sampling frequency, and it is shown that pre-cost the models have a Sharpe ratio in excess of 2.0. Simple modifications to the current framework allow for a fully non-parametric model with asynchronous prediction. Keywords: Bayesian inference, trend following, high frequency futures trading, quantitative finance. 1. Introduction Quantitative trading, namely the application of the scientific method, is now well established in the finan- An intraday momentum trading strategy is presented, cial markets. A sub-section of this field is termed al- consisting of a Hidden Markov Model (HMM) frame- gorithmic trading, where algorithms are responsible for work that has the ability to use side information from the full trade cycle, including the decision of when to external predictors. The proposed framework is quite buy and sell. When this process is dependent on the general and allows any predictors to be used in conjunc- prior behavior of the security, it historically was termed tion with the momentum model. An appealing aspect technical analysis (Lo et al., 2000). Momentum trad- arXiv:2006.08307v1 [q-fin.TR] 15 Jun 2020 of this model is that all the computationally demand- ing (or trend following) falls into this category and is ing learning is done off-line, allowing for a fast infer- the most popular hedge fund style trading strategy cur- ence phase meaning the model can be applied to high- rently used. For example, the largest quantitative hedge frequency financial data. funds by assets under management famously trade mo- mentum strategies (Anon, 2011). It can be inferred from this that momentum is the most significant exploitable ∗ Corresponding author. effect in the financial markets, and as a result of this Email addresses: [email protected] (Hugh Christensen), [email protected] (Richard Turner), [email protected] (Simon there is a large body of literature published on the ef- Godsill) fect (Hong and Stein, 1999). Momentum (or trend) can Preprint submitted to arXiv June 22, 2020 be defined as the rate of change of price. As a strat- ten want to incorporate other information into their mo- egy, momentum trading aims to forecast future security mentum based forecast, the signal combination prob- returns by exploiting the positive autocorrelation struc- lem, and an IOHMM framework is established to al- ture of the data. Once a trend is detected by careful es- low this. For both innovations, realistic experiments are timation of the mean return (in the presence of noise), it conducted (including transaction costs and slippage), can be predicted. The most well known trend-following results presented and conclusions drawn. system is that introduced by Gerald Appel in the 1970’s, This paper is structured as follows. In Section 2 the moving-average convergence-divergence (MACD) HMM’s in finance and economics are reviewed and the (Gerald, 1999), made famous by the success of a group HMM framework is introduced. In Section 3 the three of traders named the “turtles” (Faith, 2007). The MACD learning methodologies are presented. In Section 4 two strategy uses the difference between a pair of cascaded extrinsic predictors are developed and tested, and then low pass filters in parallel to remove noise while es- in Section 5 learning is carried out using this side in- timating the true mean of the rate of change of price formation. In Section 6 our inference algorithm is pre- (Satchell and Acar, 2002). The reasons for the mo- sented. In Section 7 we present the historical futures mentum effect existing are less than clear despite ex- data and then simulate the performance of the models tensive academic research on the subject. Financial data with data and present results. Finally in Section 8 con- consists of deterministic and stochastic components and clusions are presented, along with suggestions for fur- both of these components can exhibit trends. Signifi- ther work. cant trends commonly occur even in data which is gen- erated by a random process, such as geometric Brow- nian motion (Wilmott, 2006) and can be explained by 2. Hidden Markov Models the effect of summing random disturbances (Lo and An HMM is a Bayesian state space model that as- MacKinlay, 2001). Attempting to model such stochas- sumes discrete time unobserved (hidden or latent) states tic trends can lead to spurious results. Deterministic (Gales and Young, 2008). The basic assumptions of a reasons for trends existing are thought to include herd- Markov state space model are firstly that states are con- ing behaviour (Shiller, 2005), supply-and-demand argu- ditionally independent of all other states given the pre- ments (Johnson, 2002) and delayed over-reactions that vious state, and secondly that observations are condi- are eventually reversed (Jegadeesh and Titman, 1999). tionally independent of all other observations given the While there is debate in the academic literature between state that generated it. those that believe the momentum effect is still viable post-transaction costs, for example (Jegadeesh and Tit- man, 1999), and those that believe the effect has been 2.1. Literature Review of HMM in Finance and Eco- arbitraged away, for example (Lesmond et al., 2004), nomics the continued profitability of large momentum trading In the 1970’s Leonard Baum was one of the first re- hedge funds is testament to the enduring nature of the searchers to work with what is now known as an HMM. momentum effect. He applied the methodology to securities’ trading for The motivation for this paper is to apply HMM’s to the hedge fund Renaissance Technologies (Baum et al., produce a trading algorithm that exploits the momentum 1970; Teitelbaum, 2008). Since then HMMs have been effect, and that can be applied to the financial markets in used extensively in finance and economics (Bhar and real-time by industry practitioners. The core aim of the Hamori, 2004; Mamon and Elliott, 2007). The first paper is to give the algorithm the best predictive perfor- widely attributed public application of HMM’s to fi- mance possible, irrespective of methodology. Applica- nance and economics was by James Hamilton in 1989 tion of such work to the financial markets has obvious (Hamilton, 1989). In his seminal paper, Hamilton views economic benefits. the parameters of an autoregression as the outcome of The two main innovations presented in this paper are a discrete Markov process, where the observed variable both new and novel applications of existing statistical is GNP and the latent variable is the business cycle. By techniques to an applied problem. No new methodolo- observing GNP, the position in the business cycle can gies are introduced in the paper. Firstly, the price dis- be estimated and future activity predicted. covery process of a security is described by a trend term Following Hamilton’s paper there has been much in the presence of noise. This process is fitted into an Bayesian work discussing estimation of these mod- HMM framework and various means of parameter esti- els and providing financial and economic applications, mation are inspected. Secondly, momentum traders of- most of which focus on Markov chain Monte Carlo 2 (MCMC). MCMC is a means of providing a numerical process as in an HMM (Bishop, 2006). Liesenfeld et approximation to the posterior distribution using a set of al apply a bivariate mixture model to stock price and samples, allowing approximate posterior probabilities trading volume (Liesenfeld, 2001). In their model, the