Numerical Method Inc. invents the BEST numerical library and financial analytics.

## Using Returns in Pairs Trading

This blog article is taken from our book [1].

In most entry-level materials on pairs trading such as in [2],  a mean reverting basket is usually constructed by this relationship:

$P_t - \gamma Q_t = Z_t, \textrm{(eq. 1)}$

, where $P_t$ is the price of asset $P$ at time t, $Q_t$ the price of asset $Q$ at time t, and $Z_t$ the price of the mean reverting asset to trade. One way to find $\gamma$ is to use cointegration. There are numerous problems in this approach as detailed in [1]. To mention a few: the identified portfolios are dense; executions involve considerable transaction costs; the resultant portfolios behave like insignificant and non-tradable noise; cointegration is too stringent and often unnecessary a requirement to satisfy.

This article highlights one important problem: it is much better to work in the space of (log) returns than in the space of prices. Therefore, we would like to build a mean reverting portfolio using a similar relationship to (eq. 1) but in returns rather than in prices.

The Benefits of Using Log Returns

When we compare the prices of two assets, [… TODO …]

A Model for a Mean Reverting Synthetic Asset

Let’s assume prices are log-normally distributed, which is a popular assumption in quantitative finance, esp. in options pricing. Then, prices are always positive, satisfying the condition of “limited liability” of stocks. The upside is unlimited and may go to infinity. [5] We have:

$P_t = P_0\exp(r_{P,t}) \\ Q_t = Q_0\exp(r_{Q,t}), \textrm{eq. 2}$

$r_{P,t}$ is the return for asset $P$ between times 0 and t; likewise for asset $Q$.

Instead of applying a relationship, e.g., cointegration (possible but not a very good way), to the pair on prices, we can do it on returns. This is possible because, just like prices, the returns at time t are simply random walks, hence $I(1)$ series. We have (dropping the time subscript):

$r_P - \gamma r_Q = Z, \textrm{(eq. 3)}$

Of course, the $\gamma$ is a different coefficient; the $Z$ a different white noise.

Remove the Common Risk Factors

Let’s consider this scenario. Suppose the oil price suddenly drops by half (as is developing in the current market). Exxon Mobile (XOM), being an oil company, follows suit. American Airlines (AAL), on the other hand, can save cost on fuel and may rise. The naive (eq. 3) will show a big disequilibrium and signal a trade on the pair. However, this disequilibrium is spurious. Both XOM and AAL are simply reacting to the new market/oil regime and adjust their “fair” prices accordingly. (Eq. 3) fails to account for the common oil factor to both companies. Mean reversion trading should trade only on idiosyncratic risk that are not affected by systematic risks.

To improve upon (eq. 3), we need to remove systematic risks or common risk factors from the equation. Let’s consider CAPM. It says:

$r = r_f + \beta (r_M - r_f) + \epsilon, \textrm{(eq. 4)}$

The asset return, $r$, and $\epsilon$, are normally distributed random variables. The average market return, $r_M$, and the risk free rate, $r_f$, are constants.

Substituting (eq. 4) into the L.H.S. of (eq. 3) and grouping some constants, we have:

$(r_P - \beta_P (r_M-r_f)) - \gamma (r_Q - \beta_Q (r_M-r_f)) = \epsilon + \mathrm{constant}$

To simply things:

$(r_P - \beta_P r_M) - \gamma (r_Q - \beta_Q r_M) = \epsilon + \gamma_0, \textrm{(eq. 5)}$

where $\gamma_0$ is a constant.
(Eq. 5) removes the market/oil effect from the pair. When the market simply reaches a new regime, our pair should not change its value. In general, for multiple n asset, we have:

$\gamma_0 + \sum_{i=1}^{n}\gamma_i (r_i - \beta_ir_M) = \epsilon, \textrm{(eq. 6)}$

For multiple n asset, multiple m common risk factors, we have:

$\gamma_0 + \sum_{i=1}^{n}\gamma_i (r_i - \sum_{j=i}^{m}\beta_jF_j) = \epsilon, \textrm{(eq. 7)}$

It is easy to see that if we use (eq. 1) to trade the pair, to long (short) $Z$, we buy (sell) 1 share of $P$ and sell (long) $\gamma$ share of $Q$. How do we trade using (eqs. 3, 5, 6, 7)? When we work in the log-return space, we trade for each stock, $i$, the number of shares worth of $\gamma_i$. That is, we trade for each stock $\gamma_i/P_i$ number of shares, where $P_i$ is the current price of stock $i$.

Let’s rewrite (eq. 3) in the price space.

$\log(P/P_0) - \gamma \log(Q/Q_0) = Z$

The R.H.S. is

$\log(P/P_0) - \gamma \log(Q/Q_0) = \log(1 + \frac{P-P_0}{P_0}) - \gamma \log(1 + \frac{Q-Q_0}{Q_0})$

Using the relationship $\log(1+r) \approx r, r \ll 1$, we have

$\log(1 + \frac{P-P_0}{P_0}) - \gamma \log(1 + \frac{Q-Q_0}{Q_0}) \approx \frac{P-P_0}{P_0} - \gamma \frac{Q-Q_0}{Q_0} \\ = (\frac{P}{P_0} -1) - \gamma (\frac{Q}{Q_0} -1) \\ = \frac{1}{P_0}P - \gamma \frac{1}{Q_0}Q + \mathrm{constant} \\= Z$

Dropping the constant, we have:

$\frac{1}{P_0}P - \gamma \frac{1}{Q_0}Q = Z, \textrm{(eq. 8)}$

That is, we buy $\frac{1}{P_0}$ shares of $P$ at price $P_0$ and $\frac{1}{Q_0}$ shares of $Q$ at price $Q_0$. We can easily extend (eq. 8) to account for the general cases: we trade for each stock $i$ $\gamma_i/P_i$ number of shares.

References:

1. Numerical Methods in Quantitative Trading, Dr. Haksun Li, Dr. Ken W. Yiu, Dr. Kevin H. Sun
2. Pairs Trading: Quantitative Methods and Analysis, by Ganapathy Vidyamurthy
3. Identifying Small Mean Reverting Portfolios, Alexandre d’Aspremont
4. Developing high-frequency equities trading models, Infantino
5. The Econometrics of Financial Markets, John Y. Campbell, Andrew W. Lo, & A. Craig MacKinlay

This course introduces students to quantitative trading. A “quant” portfolio manager or a trader usually starts with an intuition or a vague trading idea. Using mathematics, s/he turns the intuition into a mathematical trading model for analysis, back testing and refinement. When the quantitative investment model proves to be likely profitable after passing rigorous statistical tests, the portfolio manager implements the model on a computer system for automatic execution. In short, quantitative trading is the process where ideas are turned into mathematical models and then coded into computer programs for systematic trading. It is a science where mathematics and computer science meet. In this course, students study investment strategies from the popular academic literature and learn the fundamental mathematics and IT aspects of this emerging field. After satisfactorily completing this course, the students will have an overview of the necessary quantitative, computing, and programming skills in quantitative trading.

More…

Markowitz’s celebrated mean-variance portfolio optimization theory assumes that the means and covariances of the underlying asset returns are known. In practice, they are unknown and have to be estimated from historical data. Plugging the estimates into the efficient frontier that assumes known parameters has led to portfolios that may perform poorly and have counter-intuitive asset allocation weights; this has been referred to as the “Markowitz optimization enigma.” [Lai, Xing and Chen, 2010] explains the root cause of the enigma and propose a new approach to resolve it. Specificially, it assumes that the mean and the covariances are unknown. The classical quadratic optimization problem therefore becomes a stochastic optimization problem. Not only is the new approach shown to provide substantial improvements over previous methods, but it also allows flexible modeling to incorporate dynamic features and fundamental analysis of the training sample of historical data, as illustrated in simulation and empirical studies.

More…

AlgoQuant greatly streamlines our modeling and backtesting process. Our family office builds our research IT infrastructure leveraging the AlgoQuant API. Stella Xing

Owner, Chorys Limited

I am impressed with NM’s innovative mathematical approach to quantitative/algorithmic trading and their trading research technologies. Glad to work with them. Allen Yan

Deputy CEO, Rongtong Fund Management

As a head quant trader in a prop trading house, I found in the libraries proposed by Numerical Method Inc. an impressive set of algorithms and tools that I can use as a foundation to my in-house framework. These libraries enabled me to quickly implement research ideas by using standard tools, but also having access to more sophisticated up-to-date algorithms, as companions to our in-house algorithms.

The fact that these libraries are reliable, robust and efficiently implemented turned out to be an important gain of time for us, so we could really focus on the elaboration of our intellectual property, and the implementation of our own tool and strategies.

Finally, the support and developing teams are really prompt at responding to questions, which is a real plus.

lfhf