Trading Strategies 101

Generating alpha is only one out of the three legs required for a complete trading strategy. The alphas generated need to be blended with the risk model and the transaction cost estimates in the optimizer in order to come up with the corresponding orders that need to be placed. An illustration of this process is presented below:


  • For transaction costs, typically investors perform the following calculation:

Transaction costs = Trade Fees + Bid-Ask Spread Cost = x bp + Bid-Ask Spread / 2

where x is the trade fees imposed by the broker

  • The risk model refers to the variance-covariance matrix of the stock returns
  • Alphas refer to the blend of a number of standardized alphas, e.g. momentum variations, mean reversion variations, pairs trading, etc.

The optimizer in then performing the following operations (multi-objective optimization):

  • Maximize alpha exposure
  • Minimize transaction costs
  • Minimize risk

Other objectives and constraints are typically included: neutralizing exposure to beta (for market neutral strategies) and setting caps for trade size, position size, industry exposure, country exposure, etc. We are planning to dig further into the optimization process in future posts.

Mean Reversion using Linear Regression Curves

We presented the concept of mean reversion in an earlier post, in this article we will present a tweaked version of mean reversion that utilizes Linear Regression Curves instead of moving averages.

Moving average is a lagging indicator so essentially the Linear Regression Curves can potentially provide a better fit of the available data. It is helpful to compare the results of both methods nonetheless – same applies to any tweaked versions tested, it would make sense to first compare to the base version.

Linear Regression Curve is essentially a bundle of numerous lines, but the extreme ends of the lines are hidden (upper and lower bounds), while the mid-point is only shown and is connected respectively to other mid-points across the time series.

Back-test implementation of mean reversion on S&P500 stocks using Linear Regression Curves:

  • Estimate the Linear Regression Curve per look-back window
  • In each day compare the closing price with the average value estimated;
  • If the closing price is greater than the average + n * deviation go short  and close when you cross the mean or at a pre-determined time
  • If the closing price is less than the average – n * deviation go long and  close when you cross the mean or at a pre-determined time

Adjusted Momentum Strategy

This is a slightly tweaked momentum strategy that involves the normilization of the stock returns using a risk metric. In this example, we will refer to the use of VIX levels for the risk adjustment of returns. Other risk metrics can be used as well such as Value at Risk (VaR). The concept is similar, we adjust the returns using a risk indicator before we sort the universe of stocks based on the returns.

VIX is the ticker of the CBOE Volatility Index, which is a popular measure of the implied volatility of S&P 500 stock options.

  • Calculate daily returns of S&P500 stocks
  • Calculate average returns per look-back window (e.g. 3-12 months)
  • Roll the average returns calculations one day at a time
  • Divide average returns by the VIX levels of each trading day
  • Sort stocks by adjusted returns – select top n and bottom n stocks
  • Track the returns of the n top and bottom performers for your holding period (e.g. 1-mo)
  • Estimate your historical returns and volatility and compare them to a benchmark – in this case S&P500 index.

Dividing returns by the VIX levels might not produce meaningful values on an absolute scale but on a relative scale and in order to order the stocks, it provides useful information. More specifically, it downgrades the impact of high returns on very volatile days and upgrades high returns on trading days with less volatility. The concept is similar if using any other risk indicators as mentioned earlier.


Momentum Strategy using PCA

Create a matrix that includes an index and the constituents: for example S&P500 and its constituents daily returns for the past 5 years.
A typical momentum strategy can be implemented using the following tweaks:
  • Estimate the principle components (in R use library stats and function princomp).
  • Regress each stock against the n most significant principal components.
  • Use the residuals to get a z-score or any other normalize metric for each stock.
  • Set a threshold for the z-score to select stocks to trade (trading trigger).
  • Select the weights based on z-score.
This is a relatively complex strategy since it involves the implementation of principal components analysis, so we are going to present a few frequent questions below:
1. Do you include SPX and 500 constituents and run a PCA or is SPX supposed to be excluded?
2. Is the PCA applied on returns or prices?
3. Then we regress the returns of each stock for our lookback period againsts the n principal components. How do we specify what is the cutpoint and how many principal components to include?
1) SPX should be included.
2) Returns are more meaningful since they’re closer to be stationary than levels.
3) Plotting the cumulative sum of eigenvalues can actually be very useful. The plot will provide a good indication of when most variation is explained.

Volatility Carry Trade

Volatility Carry Trade is a futures trading strategy – the first non-equities strategy presented in this blog so far.

  • Strategy on futures, key concepts: backwardation / contango
  • Vega neutral volatility carry trading strategy (i.e. hedge against volatility)
  • Two different futures contracts are traded: ST and LT; rolling futures on the S&P 500 VIX Index
  • ST is the short term future and LT is the long term future
  • If ST / LT > 1 then in backwardation so buy ST and sell LT
  • If ST / LT < 1 then do a carry trade: sell ST and buy LT

Key terms explained below:

Backwardation:  Futures contract is trading below the expected spot price.

Contango: Futures contract is trading above the expected spot price.

Vega neutral: Position that is not sensitive to volatility fluctuations.

Buy on GAP

Buy on GAP is a pretty straightforward strategy that requires the estimation of previous days lows and the comparison of the opening of each day over a time period to them. It relies on mean reversion and is an intraday strategy since the positions are expected to be closed within the day they were opened.

The strategy suggests the purchase of the 100 stocks out of the S&P500 that have the lowest previous days lows to the current opening price. Computations required:

  • Calculate the previous day close to current day open
  • Calculate the close to close returns and standard deviations
  • Calculate the open to close return for every day
  • Check that the above return is less than the 90-day standard deviation of  close

Building Systematic Trading Strategies – Part I

This series of posts is to give a broad overview about building quantitative strategies. This post is not about the intricate details on how to build an infrastructure to simulate such strategies or how to implement technically, but it should just serve as a primer for all those aspiring to build quantitative portfolios.

The Idea

Every strategy starts off with an idea. Unlike a qualitative assessment (say, Apple’s stock is going to increase in the next month) that involves an analyst’s research on primarily following a few stocks, a quantitative strategy is more involved and needs to subscribe to the following rules.

  1. It should be a general rule that can be applied to broad set of stocks (what we call, Universe)
  2. The strategy should not suffer from forward bias. In simple words, it means you cannot use future data to predict future data. The strategy can however use all data up to that time, to predict future directions.
  3. One should be able to express the rule in a mathematical form.
  4. The output of the rule should be a set of dollar amounts that can be assigned to each stock in the Universe

Say we have a simple idea that stocks that have gone up recently will come down and vice-versa. This behavior pattern is what is popularly called Mean reversion anomaly.  Let us how we “quantify” this idea.

Quantification of the idea

There are different ways on how we can “quantify” this idea. There is no such correct way in building an idea. Most of it involves trial and error,  and to see how different factors impact an idea.

Let us start with the mean reversion idea.  One way to state it mathematically is below

Amount Invested for Stock I and Day D  (weight[i,d] )=  – 5 day returns of Stock I on Day D ; for all Top 500 stocks by volume (returns5[i,d]).

In this expression we quantify “recent returns” as  the last 5 day returns. The universe is the top 500 stocks traded by volume in  US equity markets.

weight[i,d] = -returns5[i,d]

One immediate concern with this strategy is that we observe, the sum of dollar invested will not equal our notional value that we plan to invest. So to normalize to the notional we can do the following operation.

weight[i,d] = (weight[i,d]*notional value)/ (absolute sum of all weight[i,d])

That is it! This is the hello world version of a quantitative strategy. Lets see how it performs

Following up lets look at ways to improve the idea and make it more tradable!

Mean Reversion Strategy

Mean reversion in equities refers to the assumption that a stock tends to move over its historical price over time. As a result, one needs to estimate the historical average price of a stock over a period of time and then check how it diverges from it in different points in time.

Back-test implementation of mean reversion on S&P500 stocks:

  • Calculate a rolling average and rolling deviation over the historical stock prices
  • In each day compare the closing price with the historical average;
  • If the closing price is greater than the average + n * deviation go short  and close when you cross the mean or at a pre-determined time
  • If the closing price is less than the average – n * deviation go long and  close when you cross the mean or at a pre-determined time

By default and if no pre-determined time is used, all returns yielded should be positive if at any point in time the stock crossed its historical average (especially if using a large data set of historical prices, most likely that happened at some point). It also might make sense to set a closing trigger based on timing as well (e.g. 12-mo period or longer based on personal assessment if the stock has not reverted in the meantime). As always, it might also be a good idea to set a threshold based on losses – i.e. do not allow losses to exceed n % which could again be determined based on a personal assessment. The restrictions could be modeled in the back-testing to see what the impact would be on the generated alpha.

Momentum Trading

Momentum in equities refers to the purchase of stocks that have had high returns in the past (typically over the past 3-12 months) and the sale of those who had poor returns over the same time period. It is an empirically observed tendency for rising prices to rise further and falling prices to fall more. Signals based on a 52-week high have been used by analysts in buy and sell recommendations.

Back-test implementation of momentum on S&P500 stocks:

  • Calculate daily returns of S&P500 stocks
  • Calculate average returns per look-back window (e.g. 3-12 months)
  • Roll the average returns calculations one day at a time
  • Sort stocks by  returns – select top n and bottom n stocks
  • Track the returns of the n top and bottom performers for your holding period (e.g. 1-mo)
  • Estimate your historical returns and volatility and compare them to a benchmark – in this case S&P500 index. Is there persistence in the returns?



Pairs Trading

Pairs Trading Overview

The concept of equity pairs trading is relatively straight-forward:

  • Identify pairs whose spread historically fluctuates around the same level
  • Estimate this average historical spread
  • Investigate how the spread deviates from this average value at any point in time
  • Take a long position on the stock that trades below the average and a short position on the one that trades above

The underlying assumption is that the spread follows a mean reverting process- which means that eventually it will move back towards its historical average.

Key Concepts

The following items are crucial in our analysis:

  • Co-Integration:   The metric that shows if the spread historically fluctuates around   the same levels.
  • Correlation:   A measure of co-movement, and dependency. It is essentially a   statistical technique that can show whether and how pairs of   variables are related.
  • Back-testing:   The process of applying a strategy to historical data in order to   see how good it performs and extract meaningful statistics.


  • If two or more series are individually integrated but some linear combination of them has a lower order of integration, then the series are said to be co-integrated.
  • In time series, the order of integration reflects the minimum number of differences required to obtain a covariance stationary series.
  • A stochastic process is strictly stationary when its joint probability distribution does not change when shifted in time. Consequently, parameters such as the mean and variance, also do not change over time.
  • Hence, if the spread of a pair of stocks is co-integrated it means that it does not change over time.
  • Since, it is impossible to identify strictly stationary spreads, we are seeking for weak stationarity. Practically, their spread is expected to fluctuate around a tight range over time rather than remain unchanged.
  • The mathematics essentially show that if you go long stock A and short stock B with some appropriate hedging factor to cancel out the drift/growth terms in the Brownian motion then you are left with a stationary signal which is the spread between the two stocks.
  • The math also show that in expectation the daily change in the spread is zero and hence any deviation from this presents the opportunity for a trade.
  • It is assumed that the stock growth terms are constant (or drifting slowly over time both at the same rate) or in other words the hedge ratio is constant.

Pairs Trading Trigger:

spread < historical average + n * historical st. deviation

OR   spread > historical average – n * historical st. deviation



  • The implementation of the Dickey Fuller test required for the co-integration test requires a regression analysis of the log price returns of each pair.
  • When investigating a large number of stocks you end up with an extremely large number of combinations.
  • The model is significantly slow.


  • Introduce another filter before testing for co-integration.
  • We only test pairs that are strongly correlated: their correlation is above a certain threshold.
  • As a result, the number of pairs investigated is decreased significantly whereas the filtered pairs are more likely to be co-integrated.