The market efficiency theory has been tested by different types of research. Such a concept postulates, on its weak form, that the past trading information of a stock is reflected in its value, meaning that historical trading data have no potential for predicting future behaviour of an asset's prices. The main theoretical consequence of this concept is that no logical rules of trading based on historical data should have a significant positive excessive return over some benchmark portfolio.

In opposition to the market efficiency theory, several papers have shown that past information is able, to some extent, to explain future stock market returns. Such predictability can appear in different ways, including time anomalies (day of the weak effect1) and correlation between the asset's returns and other variables.2 A more substantial review of the market efficiency subject can easily be found in the literature.3, 4

A respectable amount of papers have tried to use quantitative tools in order to model the market and build trading rules. The basic idea of this type of research is to look for some kind of pattern in the historical stock price behaviour, and, using only historical information, take such a pattern into account for the creation of long and short trading positions.

One of the most popular approaches to model the market and infer logical rules is technical analysis.5 Such a technique is based on quantitative indicators (moving averages, among others) and also visual patterns (head and shoulders, triple top, and so on) in order to identify entry and exit points on the short-term behaviour of stock prices. The popularisation of technical analysis lead to a number of tests, the objective of which was to verify whether such tools were profitable or not. It is worth stating that even though the majority of papers has shown that technical analysis is profitable, several problems can be addressed with such studies, including data-snooping problems, transaction costs and liquidity. All this incompleteness of the research makes technical analysis a subject to be studied further.6

With the advent of computer power in the late 1990s, more sophisticated mathematical methods could be employed in the case of trading rules. One example is the use of the nearest neighbour (NN) algorithm in trading strategies.7, 8, 9, 10 The NN algorithm is a non-parametric method of modelling time series in which the main principle is that the series copies its own behaviour in a fractal way, that is, we find similar pieces of data from the past and use them as a benchmark to forecast the future observations. The main conclusion drawn from the results presented on the predictability potential of this method is that it is able to predict correct market direction for most of the forecasted financial observations. But it is important to state that the evidence was not strong in all studies.

For the case of trading strategies based on parametric models,11, 12 these referenced papers based the forecasts on the regime-switching model, where the results indicated that the method can predict the financial time series researched in each case. Others types of strategies using quantitative formulations include timing the market with fundamentals or statistical models13, 14and momentum strategies.15, 16 The results from these papers are also positive.

A popular strategy that gained a reputation in the early 1980s is the so-called pairs-trading. This methodology was designed by a team of scientists from different areas (mathematics, computer sciences, physics, and so on), which were brought together by the Wall Street quant Nunzio Tartaglia. The main objective of this team was to use statistical methods to develop computer-based trading platforms, where the human subjectivity had no influence whatsoever in the decision-making process of buying or selling a particular stock. Such systems were quite successful for a period of time, but the performance was not consistent after a while, and the team was dismantled after a couple of periods of bad performance. More details about the origins of pairs-trading can be found at Vidyamurthy17 and Gatev.18

Basically, the central idea of pairs-trading is to take advantage of market inefficiencies. The first step is to identify two stocks that move together and trade them every time the absolute distance between the price paths is above a particular threshold value. If the stocks, after the divergence, return to the historical behaviour of symmetry, then it is expected that the one with highest price will have a decrease in value and the one with the lowest price will have an increase. All long and short positions are taken according to this logic. The specific details about choosing pairs and defining the threshold value in pairs-trading are given in the scope of this paper.

The main objective of this research is to investigate the profitability and risk of the pairs-trading strategy for Brazilian stock market. This trading rule presented a positive performance in past studies,18, 19 and this is one of the motivations of this study, along with the fact that this type of research has not yet been applied to the Brazilian market. In order to reach the objective, data from three different frequencies (daily, weekly and monthly) are used, and all returns from the logical rules are compared against a naïve strategy of buy-and-hold and also against a bootstrap method of random trading. The systematic risk and the filtered constant return (Jensen's Alpha) of such strategies are also part of the analysis.

This paper is organised as follows: the first part is related to the main guidelines of the methodology, including the way the pairs are formed, the logical rules of trading and performance assessment. Second, the results are presented and discussed, followed by some concluding remarks.


The methodology of this research involves two points: (1) How to trigger a long/short position based on pairs-trading strategy in each stock and (2) How to evaluate the performance of the trading signals. All the calculations for this paper were conducted at Matlab. All the functions used for execution and evaluation of the strategy are available at (keywords: ‘pairs trading’). The steps of each algorithm are covered as follows.

Pairs selection

In the pairs-formation phase, the basic idea is to bring all assets' prices to a particular unit, and then search two stocks that move together. Quantitatively speaking, this can be carried out in many different ways. The approach used in this paper is the minimum squared distance rule, meaning that, for each stock, there will be a search for a corresponding pair that offers the minimum squared distance between the normalised price series.

The reason for the unit transformation is straightforward. The use of original prices (without normalisation) would be a problem for the case of minimum squared distance rule, as two stocks can move together yet have a high-squared distance between them. After the normalisation, all stocks are brought to the same standard unit and this permits a quantitatively fair formation of pairs.

The transformation employed is the normalisation of the price series based on its mean and standard deviation, equations (1).

The value of P it * is the normalised price of asset i at time t, E(P it ) is just the expectation of P it , in this case the average, and σ i is the standard deviation of the respective stock price. Both indexes were calculated within a particular moving window of the time series. With the use of equation (1), all prices are transformed to the same normalised unit, which will permit the use of the minimum squared distance rule.

The next step is to choose, for each stock, a pair that has minimum squared distance between the normalised prices. This is a simple search on the database, using only past information up to time t. The normalised price for the pair of asset i is now addressed as p it *. After the pair of each stock is identified, the trading rule will create a trading signal every time the absolute distance between P it * and p it * is higher than d. The value of d is arbitrary, and it represents the filter for the creation of a trading signal. The value can neither be very high, otherwise only a few trading signal will be created, nor can it be too low, or the rule will be too flexible, and this will result in too many trades and, consequently, high value of transaction costs.

After a trading sign is created, the next step is to define the positions taken on the stocks. According to the pairs-trading strategy, if the value of P it *is higher (lower) than p it *, then a short (long) position is kept for asset i and a long (short) position is made for the pair of asset i. Such a position is kept until the absolute difference between the normalised price is lower than d. This may sound counter-intuitive, as, using continuous price behaviour, if one buys when the distance is d and sells it when the distance is again d, there is no profit. But remember that the prices were in discrete time, meaning that the buying price occurs when the distance is higher than d, and therefore the expected profit is positive. For the case of pairs-trading at approximate continuous time (for example, 5 min quotes), this can be easily adapted by setting a gap between the threshold for the buying operation and for the selling operation.

The main logic behind the expected profits of pairs-trading strategy is if the correlated movement between the pairs continues in the future, then, when the distance between an asset and its pair is higher than a particular threshold value (d), there is a good possibility that such prices will converge in the future, and this can be explored for profit purposes. If the distance is positive, then the value of P it *, according to the logic expressed earlier, probably will reduce in the future (short position for asset i), and the value of p it * will probably increase (long position for the pair of i). The same logic is true for the cases where the distance is negative. The situations where pairs-trading fails to achieve profit are an increase in the distance between P it * and p it *, where the market goes the opposite way of the expectation, and also a decrease (increase) on the price of the long (short) position.

As an example, Figure 1 shows the pairs-trading strategy for weekly prices of asset TNLP4 and its pair, TNLP3.

Figure 1
figure 1

Example of pairs-trading with TNLP4 and TNLP3 with d=1.

In Figure 1, TNLP3 is the found pair of TNLP4 based on the minimum squared distance criteria. It is possible to see that both normalised prices have a similar behaviour. On the points that have a blue circle or red triangle the absolute difference in the normalised prices has crossed the value of d, meaning that a trade has taken place. The blue circles (red triangles) are the short (long) positions created. This happens every time the absolute distance is higher than 1 and the value of the analysed asset is higher (lower) than its pair. Every time the absolute difference uncrosses the value of d, the positions are closed. If the assets, after the opening of a position, move back to the historical relationship, then the one with the higher price should have a decrease in the prices and the one with the lower price should have an increase. As a short position was made for the first asset and a long position for the second, then, if both prices behave historically, a profit will arise from this trading case; this is the whole idea behind pairs-trading – making profits out of market corrections.

Assessing performance of the strategy

One of the aims of this study is to evaluate the performance of pairs-trading strategy against a naïve approach. For this purpose, two methods are employed here. The first is the computation of the excessive return of the strategy over a properly weighted portfolio, and the second is the use of bootstrap methods for evaluating the performance of the trading rule against the use of random pairs for each stock.

Calculation of strategy's returns

The calculation of the strategy total return is executed according to the following formula, equation (2):


R it :

Real return of asset i on time t, calculated by ln(P it /Pit−1).

I it L&S :

Dummy variable that takes value 1 if a long position is created for asset i, value −1 if a short position is created and 0 otherwise. When a long position is made at time t, this variable is addressed as I it L and as I it S for short positions.

W it :

Weighting variable that controls for portfolio construction at time t. In this particular paper, the simulated portfolio is equal weight, meaning that each trading position will have the same weight at time t, that is, W it =1/(∑I=1nI it L&S∣). Naturally, the sum of W it for all assets is equal to 1 or zero (no trading position at time t).

Tc it :

Dummy variable that takes value 1 if a transaction is made for asset i on time t and zero otherwise. It is important to distinguish the values of I it L&S (long and short positions) from Tc it (transaction dummy). The values of Tc it are derived from the vector I it L&S, but they are not equal. For example, suppose a long position is created for asset i on time t−1 and also on time t, only. The vector of I it L will have values of 1 to time t−1 and t, but the vector of Tc it has only value 1 for time t−1, as for t, the asset was already in the portfolio, and thus there is no need to buy it again. The same is true for short positions.

C :

Transaction cost per operation (in percentage).

T :

Number of observations on the whole trading period.

For equation (2), the basic idea is to calculate the returns from the strategy accounting for transaction costs. The first part of (1), ∑t=1Ti=1nR it I it L&SW it calculates the total raw return of the strategy. Every time a long and short position is created for asset i, the raw return of the simulated portfolio on time t is ∑i=1nR it I it L&SW it , that is, the prospected returns multiplied by their corresponding weight in the portfolio. As t goes from 1 to T, it is necessary to sum such returns, which gives the final result for the first part of (1), ∑t=1Ti=1nR it I it L&SW it .

The second part of equation (2) has the objective of accounting for transaction costs. For example, suppose that the trading cost of buying and selling stock is C, which is expressed as a percentage of the transaction price. If a stock is purchased at price P B and sold at price P S , then the real buying and selling prices, including transaction costs, are P B (1+C) and P S (1−C). Taking the logarithm return of the operation results in the formula R=ln(P S (1−C)/P B (1+C)). Using logarithm properties, the previous equation becomes R=ln(P S /P B )+ln((1−C)/(1+C)). It is possible to see from this result that the return for this operation has two separate components: the logarithm return from the difference between the selling and buying prices, and the term ln((1−C)/(1+C)), which accounts for the transaction cost on the whole operation. This exemplified result basically states that the transaction cost for one operation (buy and sell) is ln((1−C)/(1+C)).

Returning to the analysis of the second part of equation (1), as ln((1−C)/(1+C)) is the transaction cost of one operation, logically the term (∑t=1Ti=1nTc it ) is just the number of operations made by the trading strategy. Is important to note that as (1−C)/(1+C) is always less than one because C is always positive and higher than zero, then the value of ln((1−C)/(1+C)) is always negative, meaning that the transaction costs are subtracted from the strategy's returns, which is an intuitive result.

Evaluation of strategy's returns

In order to evaluate the performance of the strategy, it is necessary to compare it to a naïve approach. If the strategy performs significantly better than an out-of-skill investor, then such a trading rule has value. This is the main idea that will develop both methods used in this research in order to evaluate the performance of pairs-trading strategy for the Brazilian financial market. The approaches described here are computation of excessive return over a naïve buy-and-hold rule and the more sophisticated bootstrap method of random trading.

Computation of excessive return of a naïve portfolio:

The calculation of excessive return is the simplest approach to evaluating a trading strategy. The idea is quite simple: verify how much of the returns from the strategy tested exceeds a naïve rule. In this case, the naïve rule is the buy-and-hold of a properly weighted portfolio for comparison with the long positions and a ‘sell-and-unhold’ for the short positions.

The return of the naïve approach, over the whole number of assets, is based on the following formula, equation (3):

For equation (3), the value of P i L and P i S is only the proportion of days, related to the whole trading period, that the strategy created long and short positions for asset i. Formally, P i L=((∑t=1TI it L)/T) and P i S=((∑t=1TI it S)/T). Note that, in the calculation of P t S, the sum of the short positions is always negative or equal to zero, as I it S takes values −1 and 0, only.

As pairs-trading strategy uses two different types of position in the stock market, long for the hope of a price increase and short for the hope of a price decrease, it is necessary to construct a naïve portfolios that also makes use of such positions. This is the function of the terms ∑i=1nP i Lt=1TR it and ∑i=1nP i St=1TR it where the first simulates a buy-and-hold (long positions) of a properly weighted portfolio and the second simulates a ‘sell-and-unhold’ (short positions) scheme for another properly weighted portfolio. The weights in both terms are derived from the number of long and short positions taken on each asset, as shown before. The higher the number of long and short signals a strategy makes for asset i, the higher the weight that such a stock will have on the simulated portfolio. It is clear from equation (3) that, if P i S=P i L, which is a perfectly hedged position for asset i in the benchmark portfolio, the terms ∑i=1nP i Lt=1TR it i=1nP i St=1TR it null each other and the contribution of accumulated return for this respective asset in the benchmark portfolio is only the transaction cost for setting up the portfolios.

It should be noted that the calculation of return in equation (3) does not include the W it variable as in equation (2). This occurs because the refereed equation is calculating the sum of expected returns of a naïve long and short position for all assets, and not the return of the simulated portfolio over time (equation (2)).

As can be seen from equation (3), one of the premises of the research is that the transaction cost per operation is the same for long and short positions. The last term of (3) is the transaction costs for opening positions (making the portfolio) and trading them at the end of the period. In this case, the number of trades required to form and close the two portfolios is 2n where n is the number of researched assets.

The excessive return for the strategy is given by the difference between (2) and (3), which forms the final formula for computing excessive return: equation (4).

Analysing equation (4), the maximisation of R E *, which is the objective of any trading strategy, is given by the maximisation of ∑i=1nt=1TR it I it L&S, minimisation of ∑i=1nP i Lt=1TR it and ∑i=1nP i St=1TR it and minimisation of (∑i=1nt=1TTc it −2n), as [ln((1−C)/(1+C))] is a constant. The conclusion about this analysis is intuitive because the strategy will only be successful if it efficiently creates long and short positions on the stocks, keeping the transaction costs and the benchmark returns at low values. In short, make more money with fewer trades.

Bootstrap method for assessing pairs-trading performance:

The bootstrap method represents a way to compare the trading signals of the strategy against pure chance. The basic idea is to simulate random entries in the market, save the total returns for each simulation and count the number of times that those random entries were less than the return obtained in the tested strategy. Such an approach is similar to the ideas of Patrick Burns.20, 21 It should be noted that each trading strategy takes a different number of long and short positions and for a different number of days. Such information is also taken into account in the random simulations.

The steps are as follows:

  1. 1

    Separately, for long and short position, calculate the median number of days (nDays_Long and nDays_Short) that the strategy has been trading in the market, and also the median number of assets (nAssets_Long and nDays_Short).

  2. 2

    With the values of the nDays and nAssets for long and short, define nDays random entries in the market for nAssets number of assets. Again, making it clear, this procedure should be repeated for each type of trading position (long and short).

  3. 3

    Repeat Steps 1 and 2 m number of times, saving the accumulated raw return (total return minus transaction costs) for each time.

After a considerable number of simulations, for example m=5000, the result for the bootstrap method will be a distribution of returns. The test here is to verify the percentage of returns that the tested strategy has beaten compared with the use of random trading.

As an example, next is the histogram of the accumulated returns from the use of the bootstrap algorithm for the daily database with options m=5000, nDays_Long=400, nDays_Long=250, nAssets_Long=5, nAssets_Short=3, and with zero transaction cost.

Figure 2 shows that, considering the options given to the algorithm, an out-of-skill investor would earn, on average, a total raw return of approximately 10 per cent. The best case for the naïve investors is approximately 74 per cent and the worst is −70 per cent.

Figure 2
figure 2

Histogram of the accumulated returns from random trading.

The next step in using this bootstrap approach is to count the number of times that the accumulated return from pairs-trading is higher than the accumulated return from the random trading signal, and divide that by the number of simulations. The result is a percentage showing how many random signals the tested strategy has beaten. If such a strategy has value, it would produce something close to 90 per cent. If it is just a case of chance, it would give a percentage close to 50 per cent, and if the strategy does not present any value, it would result in a percentage close to 10 per cent, meaning that, in this case, it is possible to obtain higher returns by using only a random seed to select assets and days to trade.

One way of analysing the result of the bootstrap algorithm is to compare the selections made by the trading strategy, that is, the days and assets to trade, against an expected return for the same days and number of trades over the entire researched data.

Database for the research

The database for this research is based on the 100 most liquid stocks from the Brazilian financial market between 2000 and 2006.

The study aims to assess the performance and risk of pairs-trading for different frequencies of the data: daily, weekly and monthly prices. As there are some liquidity problems for a few cases, the database had to be reconfigured for each frequency. The rule here is to select the stocks that have at least 98 per cent of valid closing prices. The resulting number of stocks after the application of the filter is shown in Table 1.

Table 1 Database according to time series frequency

For Table 1, the major decrease in the researched database is for daily frequency, where only 57 stocks were selected after filtering for stocks with less than 98 per cent of closing prices. For weekly and monthly prices, such filtering was not a problem, and most of the stocks from the original database were kept. For the cases of missing prices, they were simply replaced by the past price, which sets the logarithm return in that date to zero.

Every test of trading strategy has two phases in the research data: the training period and the trading period. For this study, the training period is a moving window composed of approximately 2 years of data for all frequencies. For daily prices, such a moving window has a length of 494, for weekly prices of 105 and for annual frequency of 24.

Another issue in executing the pairs-trading strategy over data is that each stock may change its pairs over time. In order to assess such a possibility, the pair of each stock is updated at each month for all tested frequencies. For instance, for daily data, at each 25 observations the pairs are recalculated.

It is important to note that the algorithm does not use future observation to build the trading rules. All aspects of the strategy are calculated using only past information, which is a necessary assumption for a realistic assessment of a quantitative trading strategy performance.


Table 2 presents the returns obtained from the pairs-trading strategy at the different researched frequencies, with C=0.1 per cent. This value of transaction cost is realistic for the Brazilian equity market, and can be easily achieved with a moderate amount of invested capital.

Table 2 Evaluation of pairs trading returns for different values of d

Before the analysis of Table 2, an important observation is that the total return is not only the sum of the returns from the long and short positions. For the excessive and raw returns, if the column ‘Long Positions’ was summed with the column ‘Short Positions’, it will not equal the column ‘Total’. This occurs because one asset can be having a buy sign and also a sell sign for the same time t, as such stock can be the pair of other stock. If only short or long positions are analysed, the respective trading positions are valid, but when analysing the total return from both, a buy and sell sign, for the same asset at the same time, null each other. As can be seen, the difference is quite high, meaning that such an event has occurred very often.

For the case of raw return, Table 2, which is simply the clean return of the strategy minus the transaction costs, it can be seen that the long positions were far more profitable than the short positions in all tested frequencies. This was expected, as the period of the study was clearly an upward-trending market, meaning that a short position would not make much money, as can be seen in the raw returns for the short signals, at different frequencies.

Analysing the excessive returns of Table 2, it can be seen that the pairs-trading strategy was able to beat a properly weighted naïve portfolio in most of the cases. Such a result is more consistent for the daily frequency in the interval of d between 1.5 and 2, and also for the monthly frequency in the whole tested interval of d.

Verifying the relationship between d and number of trades, it is very clear that they are negatively correlated, as in the execution of the trading rules high (low) values of d presented a low (high) number of transactions. This can be easily explained by the fact that d is the threshold variable that controls when a price divergence is not considered normal. As d grows, fewer and fewer abnormal divergences are found, which consequently reduces the number of transactions made by the strategy.

The bootstrap method presented at Table 2 shows that pairs trading is superior to the use of random trading signals (percentages of beaten random portfolios higher than 90%) in just a few cases, more precisely for the data with daily frequency and with threshold value ranging from 1.5 to 2. There are also indications of positive performance of the bootstrap method over the monthly data with 2.6⩾d⩾3. But, given that only a few trades were made for this particular interval (4.08 per cent – 3 observations), the result cannot be taken seriously regarding the performance of the pairs-trading strategy. A much clearer picture of positive performance is given in Panel A.

Another piece of information provided in Table 2 is that the bootstrap method is much more restrictive for positive performance than the benchmark portfolio approach. Whereas the last presented positive excess return for almost all values over the different panels, the last only resulted in positive performance for a couple of cases. It could be argued that the benchmark method is a static way of assessing performance, and the bootstrap method is superior in the sense that the way to assess naïve performances is much more dynamic, and therefore superior.

The best case in Table 2, when comparing returns and bootstrap methods, is for daily frequency, where the total raw returns presented a high percentage of beaten random portfolios, and also a positive and consistent excessive return at a particular domain of d. The performance of pairs-trading for weekly prices was not very consistent for different values of d and, for monthly prices, positive values of excessive returns were found, but the simulation of random portfolios showed that most of the raw returns obtained at this frequency were simply a case of chance, and not skill.

The result of the superiority of higher frequencies in the pairs-trading framework is logically consistent, as the objective of pairs-trading is to take advantage of market corrections, and such inefficiency would, as expected, occur more often at high frequencies. The next step in this type of research could be to study the performance of pairs-trading at high-frequency data (intraday quotes), and check whether, again, the performance is higher at higher frequencies of the data.

The next analysis pursued in the paper is the evaluation of the risk in the tested strategies (Table 3).

Table 3 Beta and jensen's alpha for pairs trading

Regarding the Jensen's Alphas in Table 3, which should be positive and statistically significant if the strategy has good performance independently of market conditions, it can be seen that, for Panel A, most of them are positive but not statistically significant. This particular result shows that pairs-trading strategy has a positive constant return after filtering for market conditions, but such a coefficient is not statistically significant.

Another aim of this study relates to the risk of pairs-trading strategy. The values of systematic risk (beta) in Table 3 are very close to zero, and only one of them is statistically significant at 10 per cent. Such a result corroborates with the fact that pairs-trading is often called a market-neutral rule, meaning that the returns from such a strategy usually does not follow the market behaviour. This is intuitive because, in the pairs-trading framework, the number of long positions is equal to the number of short positions when there is no overlapping (short and long at the same time), which creates a natural hedge against the market movements.

After the analysis of the information shown in Tables 2 and 3, it is possible to state that, for the Brazilian financial market, the positions created by the pairs-trading were a moderately profitable strategy in the past and, at the same time, neutral to the market-systematic movements. The best results were found at the database with daily frequency. For this particular database, the excessive returns obtained were consistent over a particular region of d, and the raw returns cannot be considered a simple case of chance. The conclusion about the profitability of pairs-trading corroborates with the previous research on the topic (Gatev18 and Nath19).


The main objective of this research was to verify the performance (return) and also the risk of classical pairs-trading in the Brazilian financial market at different time frequencies (daily, weekly and monthly). Such analysis was also carried out considering different values for the threshold parameter d.

In order to achieve this objective, the returns from the strategies were compared against a properly weighted portfolio made with long and short positions at the beginning of the trading period, and also against a variant of the bootstrap method for assessing performance. The risk of the trading signals was obtained with the analysis of the systematic risk (beta) of the strategies.

The main conclusion of this paper is that pairs-trading had a good performance when applied to the Brazilian financial market, especially for the daily frequency. The tests performed showed that the market rules presented betas very close to zero and not statistically significant at 10 per cent, which means that pairs-trading may be called a market-neutral rule. Regarding profitability, the best case was for daily frequency, where the interval of d between 1.5 and 2 presented consistent values of excessive return over a benchmark portfolio. The bootstrap approach also showed that the raw returns for this particular set of parameter were not given by chance, but by skill.

However, it is also important to address a weakness of the research. The framework used in the study did not allow for liquidity risk of the strategy, which may be a negative factor affecting the realisable (and not measurable) returns. Given this fact, the results of positive performance can only be assessed given the constraints of the research.