John Wiley, 2013. — 225 pp.
This book is a practical guide to algorithmic trading strategies that can be readily implemented by both retail and institutional traders. It is not an academic treatise on financial theory. Rather, I hope to make accessible to the reader some of the most useful financial research done in the past few decades, mixing them with insights I gained from actually exploiting some of those theories in live trading.
Because strategies take a central place in this book, we will cover a wide array of them, broadly divided into the mean-reverting and momentum camps, and we will lay out standard techniques for trading each category of strategies, and equally important, the fundamental reasons why a strategy should work. The emphasis throughout is on simple and linear strategies, as an antidote to the overfitting and data-snooping biases that often plague complex strategies.
In the mean-reverting camp, we will discuss the multiple statistical techniques (augmented Dickey-Fuller [ADF] test, Hurst exponent, Variance Ratio test, half-life) for detecting time series mean reversion or stationarity, and for detecting cointegration of a portfolio of instruments (cointegrated augmented Dickey Fuller [CADF] test, Johansen test). Beyond the mechanical application of these statistical tests to time series, we strive to convey an intuitive understanding of what they are really testing and the simple mathematical equations behind them.
We will explain the simplest techniques and strategies for trading meanreverting portfolios (linear, Bollinger band, Kalman filter), and whether using raw prices, log prices, or ratios make the most sense as inputs to these tests and strategies. In particular, we show that the Kalman filter is useful to traders in multiple ways and in multiple strategies. Distinction between time series versus cross-sectional mean reversion will be made. We will debate the pros and cons of scaling-in and highlight the danger of data errors in mean-reverting strategies, especially those that deal with spreads.
Examples of mean-reverting strategies will be drawn from interday and intraday stocks models, exchange-traded fund (ETF) pairs and triplets, ETFs versus their component stocks, currency pairs, and futures calendar and intermarket spreads. We will explain what makes trading some of these strategies quite challenging in recent years due to the rise of dark pools and high-frequency trading. We will also illustrate how certain fundamental considerations can explain the temporary unhinging of a hitherto very profi table ETF pair and how the same considerations can lead one to construct an improved version of the strategy. When discussing currency trading, we take care to explain why even the calculation of returns may seem foreign to an equity trader, and where such concepts as rollover interest may sometimes be important. Much emphasis will be devoted to the study of spot returns versus roll returns in futures, and several futures trading strategies can be derived or understood from a simple mathematical model of futures prices. The concepts of backwardation and contango will be illustrated graphically as well as mathematically. The chapter on mean reversion of currencies and futures cumulates in the study of a very special future: the volatility (VX) future, and how it can form the basis of some quite lucrative strategies.
In the momentum camp, we start by explaining a few statistical tests for times series momentum. The main theme, though, is to explore the four main drivers of momentum in stocks and futures and to propose strategies that can extract time series and cross-sectional momentum. Roll returns in futures is one of those drivers, but it turns out that forced asset sales and purchases is the main driver of stock and ETF momentum in many diverse circumstances. Some of the newer momentum strategies based on news events, news sentiment, leveraged ETFs, order flow, and high-frequency trading will be covered. Finally, we will look at the pros and cons of momentum versus mean-reverting strategies and discover their diametrically different risk-return characteristics under different market regimes in recent financial history.
I have always maintained that it is easy to find published, supposedly profi table, strategies in the many books, magazines, or blogs out there, but much harder to see why they may be flawed and perhaps ultimately doomed. So, despite the emphasis on suggesting prototype strategies, we will also discuss many common pitfalls of algorithmic trading strategies, which may be almost as valuable to the reader as the description of the strategies themselves. These pitfalls can cause live trading results to diverge significantly from their backtests. As veterans of algorithmic trading will also agree, the same theoretical strategy can result in spectacular profits and abysmal losses, depending on the details of implementation. Hence, in this book I have lavished attention on the nitty-gritties of backtesting and sometimes live implementation of these strategies, with discussions of concepts such as data-snooping bias, survivorship bias, primary versus consolidated quotes, the venue dependence of currency quotes, the nuances of short-sale constraints, the construction of futures continuous contracts, and the use of futures closing versus settlement prices in backtests. We also highlight some instances of regime shift historically when even the most correct backtest will fail to predict the future returns of a strategy.
I have also paid attention to choosing the right software platform for backtesting and automated execution, given that MatLAB, my favorite language, is no longer the only contender in this department. I will survey the state of the art in technology, for every level of programming skills, and for many different budgets. In particular, we draw attention to the integrated development environment for traders, ranging from the industrial strength platforms such as Deltix to the myriad open-source versions such as TradeLink. As we will explain, the ease of switching from backtesting to live trading mode is the most important virtue of such platforms. The fashionable concept of complex event processing will also be introduced in this context.
I covered risk and money management in my previous book, which was built on the Kelly formula—a formula that determines the optimal leverage and capital allocation while balancing returns versus risks. I once again cover risk and money management here, still based on the Kelly formula, but tempered with my practical experience in risk management involving black swans, constant proportion portfolio insurance, and stop losses. (U.S. Supreme Court Justice Robert H. Jackson could have been talking about the application of the Kelly formula when he said we should temper its doctrinaire logic with a little practical wisdom.) We especially focus on finding the optimal leverage in realistic situations when we can no longer assume Gaussian distribution of returns. Also, we consider whether risk indicators might be a useful component of a comprehensive risk management scheme. One general technique that I have overlooked previously is the use of Monte Carlo simulations. Here, we demonstrate using simulated, as opposed to historical, data to test the statistical significance of a backtest as well as to assess the tail risk of a strategy.
This book is meant as a follow-up to my previous book, Quantitative Trading. There, I focused on basic techniques for an algorithmic trader, such as how to find ideas for new strategies, how to backtest a strategy, basic considerations in automating your executions, and, finally, risk management via the Kelly formula. Yes, a few useful example strategies were sprinkled throughout, but those were not the emphasis. If you are completely new to trading algorithmically, that is a good book to read. Algorithmic Trading, however, is all about strategies.
All of the examples in this book are built around MatLAB codes, and they are all available for download from
www.wiley.com or my website at "www.epchan.com/book2". Readers will find the password embedded in the first example. Readers unfamiliar with MatLAB may want to study the tutorial in Quantitative Trading, or watch the free webinars on mathworks.com. Furthermore, the MatLAB Statistics Toolbox was occasionally used. (All MatLAB products are available as free trials from MathWorks.)
Software and mathematics are the twin languages of algorithmic trading. Readers will find this book involves somewhat more mathematics than my previous one. This is because of my desire to inject more precision in discussing the concepts involved in financial markets, and also because I believe using simple mathematical models for trading can be more advantageous than using the usual data-mining approach. That is to say, instead of throwing as many technical trading indicators or rules at a price series to see which indicator or rule is profitable—a practice that invites data-snooping bias—we try to distill the fundamental property of that price series using a simple mathematical model. We can then exploit that model to our financial benefit. Nevertheless, the level of mathematics needed in the trading of stocks, futures, and currencies is far lower than that needed in derivatives trading, and anyone familiar with freshman calculus, linear algebra, and statistics should be able to follow my discussions without problems. If you find the equations too confusing, you can just go straight to the examples and see their concrete implementations as software codes.
Backtesting and Automated Execution
The Basics of Mean Reversion
Implementing Mean Reversion Strategies
Mean Reversion of Stocks and ETFs
Mean Reversion of Currencies and Futures
Interday Momentum Strategies
Intraday Momentum Strategies
Risk Management