Composition of portfolios by pairs trading with volatility criteria in the Brazilian market*,**

The objective of this study was to understand how the shares’ volatility affects the portfolios’ dynamics formed using the model of pairs trading in the Brazilian stock market. This article distinguished itself by bringing new evidence about the effects of volatility in the pairs trading model not covered by previous studies, expanding the sample size analyzed in the Brazilian stock market. The chosen theme’s relevance is that investors can use pairs trading or long-short models to build their portfolios. The use of cointegration concepts probabilistically contributes to portfolios’ formation weakly correlated to the market indexes with superior performance. This article impacts the area by contributing new evidence for better use of the model in the analysis of investments. From January 2016 to December 2018, the 90 most liquid assets of Bolsa, Brasil, Balcão (B3) were analyzed, totaling 5,927,400 possible pairs. The Augmented Dickey-Fuller test and subsequent backtesting of the pairs in the proposed period were used to evaluate the cointegration criteria. Statistical analysis was performed by parametric and non-parametric tests and Pearson and Spearman correlation analyses. The results found indicated that the formation of portfolios by pairs trading with dependent assets with the criterion of higher levels of volatility (20 periods) presented a superior performance. These findings can be justified by a better risk and return ratio for the portfolio, measured by the Sharpe Index of the returns obtained concerning the portfolio’s volatility, compared to a portfolio formation based on a random selection of the pairs. In addition, the results also showed a low correlation of returns concerning the market index. Therefore, the application of the statistical cointegration analysis methodology alone does not guarantee results that are different from the market average.


INTRODUCTION
The hypothesis of market efficiency (or efficient markets) is based on the statement that the price of a share reflects the information available about the issuing company, i.e., that new information in the capital market is quickly incorporated and adjusted to the affecting cash flow and investors' future expectations (Fama, 1970).
Thousands discuss this issue, but without a consensus on the matter (Fama, 1998), since only the possibility of capturing inefficiencies in the pricing of assets would allow systematic profits to be obtained through some asset trading method (Pontuschka & Perlin, 2015). One of the strategies applied would start from the opening of a long position and, at the same time, a short position, starting from the search to obtain profits from the convergence of the prices of the traded assets. These operations, also known as pairs trading or long-short strategies, expect the observed divergence to return to long-term equilibrium, selling the overvalued asset and buying the other undervalued one, ending the transaction when the divergence between the assets ceases (Santos & Pessoa, 2017).
The development of the statistical arbitrage model in pairs trading is attributed to Nunzio Tartaglia and his working group composed of mathematicians, physicists, and programmers at Morgan Stanley bank, who applied this strategy in mid-1987 to allow automated entries and exits in the market by investors, benefiting from the inefficiencies of that market. Since then, it continues to spread among hedge funds and institutional investors in the view of Vidyamurthy (2004), Figueiredo (2017), and Yoshikawa (2017).
In this context, this article seeks to answer the following question: How do asset volatility levels affect the composition of share portfolios by pairs trading in the Brazilian stock market?
For the modeling and the study of the patterns between the assets, econometric techniques applied to time series are used with statistical analysis tools. These tools validate whether their behavior is stationary and, therefore, that do not propagate any harmful shocks to the modeling of future behavior caused, for example, due to changes in the trading conditions of the asset or a substantial reduction in operating liquidity, especially in the postopening moment of positions, breaking the condition of historical stationarity in the period under analysis. Thus, an option is the cointegration model, which analyzes the joint movements of asset prices in the long term, aiming to obtain the residuals' stationary distribution from its regression, seeking financial returns when the residual returns to the long-term average (Gujarati, 2011).
The model's main advantage is the analysis' objectivity and generality between the pairs of shares studied. This analysis can be used for most assets, regardless of other economic and financial factors, such as assets analyzed from the same sector, whether there are good prospects for the sectors in which the assets are inserted, or, even if the indebtedness level is high. Cointegration does not refer to the joint movements of returns but the joint movements of asset prices (or exchange rates). If spreads are reversed to the average, then asset prices are linked, in the long run, by a common stochastic trend, and, in this case, prices can be considered cointegrated (Alexander, 2005).
Thus, this work is divided into four more sections, in addition to this introduction. The next topic deals with the theoretical framework, addressing a survey on pairs trading by cointegration and studies related to the theme. In the third topic, the methodological procedures, followed by the results, final considerations and references.

Cointegration-Based Pairs Trading
Market agents are continually looking for an optimal structure for minimizing uncertainties and allocating their resources, balancing their risk relationships with return and, consequently, an expected utility (Copeland et al., 2005). Therefore, these agents seek to detect opportunities using historical series of assets that can reflect the random movements of their values according to the market feeling and exogenous variables, such as political-economic events (Cutler et al., 1990) or fundamental indicators of companies such as price per share, share profit, assetmarket risk, among others, in order to margin their volatility (Fortuna, 2008).
In this context, the quantitative approach by pairs trading with cointegration aims to explore the logic in financial markets out of balance, culminating in a trading or investment strategy arising from long-short operations. This strategy deals with the purchase of undervalued assets and, simultaneously, selling overvalued assets; more specifically, of pairs of financial assets with historical series and similar movements in order to verify short-term deviations and the influence on the long-term equilibrium of their prices (Pucciarelli, 2014;Yoshikawa, 2017). Granger (1981), Granger and Weiss (1983), Granger and Engle (1985), and Engle and Granger (1987) started applying the concept of cointegrated vectors, proposing the connection between error correction models and cointegrated systems. The concept also considered the studies by Johansen (1988) and additions by other authors, with the properties of the least-squares method in cointegration (Stock, 1987) and aspects of trends of variables in time series (Davidson & Hall, 1991;Stock, 1987).
This last correction of errors allowed us to observe that the short-term time series behaves dynamically and flexibly; in another perspective, long-term series obey some restrictions so that the model under analysis reaches a satisfactory regressive balance. According to Murray (1994), the concept is probabilistic, and the regressions that involve changes in the cointegrated variables must present these lag levels and the restrictions of their relationships, supporting the work of Engle e Granger (1987). However, Philips (1989) makes comparisons to the Engle-Granger model, proposing a new error correction mechanism and signaling that his analysis dealt with linear cointegration parameters, diverging, in some aspects, from the Engle-Granger model that deals with non-linear aspects parameters, and that, based on a single model, may involve bias and lose the optimization of its applicability.
On the other hand, advances in its application bring pairs trading strategies and the cointegration technique. This strategy goes back to Lucas' (1997) effort to observe the generation of scenarios from the behavior of multivariate time series-based models. The author sought to show the correlation of the scenarios with past results of the analyzed time series, with the notion of the correction of its errors and describing its effects on short and long-term financial decision making.
Another contribution to the cointegrated model is based on Alexander (1999), who highlights the importance of differentiating results from correlation and cointegrated models. By highlighting that, when managing portfolio risk, the analysis of the correlation of its expected returns is related; when it involves the precept of cointegration, it is based on raw data on the price of assets and their yields, the latter having expanded its performance as a predominant approach in time series econometrics, mainly based on studies by Murray (1994), Hamilton (1994), and Hendry (1986Hendry ( , 1995. Given its evolution in worldwide research, this study combines pairs trading with cointegration in the Brazilian stock market. Thus, this article's evidence focuses on observing the behavior of assets given the long-short strategy signed with assets traded in Brasil, Bolsa, Balcão (B3), which justifies the econometric model adopted in terms of estimation and validation.

Related Studies
It is then possible to identify recent works that explore the scientific production on pairs trading by cointegration in the Brazilian market, in different segments, groups, and periods. It is worth mentioning that there are still gaps in the academic literature that deals with the relationship between asset volatility and the composition of stock portfolios based on pairs trading since national studies analyze the behavior of one of these attributes isolatedly.
Statistical arbitrage strategies by pairs trading and their generalizations depend on the construction of stationary spreads with a certain degree of predictability. The work of Caldeira and Moura (2013) applied cointegration tests to identify assets to be used in pairs trading strategies with daily data on the 50 most liquid assets of Bovespa, between January 2005 and October 2012. The authors' idea was to estimate the long-term balance and model the resulting residues, with the selected pairs of shares were based on a profitability indicator to compose a portfolio of pairs. The empirical analysis showed that the proposed strategy obtained excess returns of around 16.38% per year, a Sharpe index of 1.34, and a low correlation with Ibovespa. The authors also applied cointegration with maximum stationarity and minimum variance tracking error for the pair strategy, noting deviations and adherences concerning the benchmark, the latter with a higher incidence resulting in a low volatility level.
Pontuschka e Perlin (2015) sought to analyze the performance of the pair strategy at different data frequencies in the Brazilian stock market, extending the range of frequencies and entering the intraday universe with sampling frequencies in 1, 5, 15, 30, 60 minutes and daily one, between 2008 and 2011. The database composition used the 20 assets with the highest number of contracts traded in the period, applying the training and negotiation techniques, comparing the information indexes of pairs strategy in the different data frequencies.
The survey results confirmed the primary hypothesis that the higher the sampling frequency, the greater the evidence of market inefficiency. Sampaio (2016) focused his research on a simple method centered on two main phases: the first is the choice of pairs over the 12-month horizon; and the second, the strategy of investing in pairs in a monthly cycle, with successive repetitions later, until the use in its entirety of the study data, collected in Economática ® -closing prices and daily volume of all assets traded in Ibovespa (50 stocks with a higher volume, excluding the sector classification criterion in the analysis) between 2006 (test period) and 2015. The results with the returns between the years 2007 and 2015 showed a total of 108 studied monthly windows, of which, of a total of 1,225 pairs, 130 of them showed cointegration, outlining an accumulated net profit of 46.3% in the analyzed period. The author highlights the results found concerning the market, noting, however, that the expected returns become uninteresting in the face of other factors, such as inflationary movements and interest in the period.
Oliveira (2017) sought to verify the distance method's performance of the strategy of pairs trading in the Brazilian market between 2004 and 2017, identifying whether these strategies brought consistent returns, despite the various economic and political crises in Brazil. Unlike the vast literature that seeks more complex models that can act in pairs trading strategies, this study focused only on the distance method, without the incidence of transaction costs, in this more recent horizon not yet studied, becoming necessary, then, understand its behavior in crises. The methodology used was extracted from the articles by Gatev et al. (2006), and Rad et al. (2016), with only one change in closing positions' criteria. As a result, the studied strategy did not present statistically significant losses in crisis periods. Santos and Pessoa (2017) investigated pairs trading performance using the cointegration tests for shares traded on Bovespa from 2003 to 2014. Different opening, closing, and stop bands were tested. From these results, three different strategies for performance analysis were separated. Strategies 1, 2, and 3 obtained an average net return of 5.24%, 5.1%, 8.29% per year, and an average annualized Sharpe Index (IS) of 0.33, 0.31, and 0.54, respectively. Therefore, the portfolio's performance composed by strategy 1 was superior to the others, confirming the hypothesis of the optimal deviation of Vidyamurthy (2004) and reinforcing the importance of using cointegration in pairs trading strategies.

Research Sample
This article consists, briefly, in obtaining the closing prices of the initially proposed quantity of the assets in the period from January 2015 to December 2018, performing the analysis of the pairs between January 2016 and December 2018, according to the cointegration criteria for each day of the proposed interval, selecting the cointegrated pairs and observing their behavior after the day of analysis, as a historical simulation (backtesting), performing the data acquisition for later demonstration of the results of each proposed model variation. Table 1 Analyzed assets The daily historical quotations of the assets' closing prices will be used, obtained through files made available on the B3 website, with adjustments for the earnings, groupings, and developments in the past. All calculations were performed with Python language algorithms for data collection and treatment, the study of statistical criteria, and evaluation of entry and exit of positions, for each pair of assets evaluated and storage of regression parameters, cointegration tests, volatilities, and operational results of portfolios in Microsoft Excel with the help of SPSS Statistics to carry out the final statistical tests.
The choice of assets will be defined based on the average daily liquidity presented at the end of the interval, proposing the choice of the 90 most liquid assets, which have sufficient historical data for the proposed assessment. Daily liquidity is essential for a pairs trading strategy, as the shortage represents a high risk for operations (Pontuschka & Perlin, 2015;Santos & Pessoa, 2017).

Pair Analysis
The assets will then be evaluated in pairs, without restrictions related to the same sector's assets. According to Equation, all possible pairs will be evaluated with samples of the previous 252 days' closing prices, including the day studied, to estimate multiple linear regression parameters by Ordinary Least Squares (OLS) for time series 1.
where dep_asset t are the prices of the dependent asset at time t; ind_asset t , the prices of the independent asset at time t; β 0 , the linear coefficient between prices; β 1 , the hedge coefficient; β 2 , the time coefficient; t, the time, and ε t , the residual that will be analyzed from the regression. The composition of the equations for each daily closing price for the period of 252 trading sessions forms matrices of the values of Y, X, β and from ε it residuals, according to Equation 2.
After the next matrix multiplication, we can estimate the values of the β matrix that result in the coefficients, β 0 , β 1 , and β 2 , using them to estimate the residuals and perform the stationarity tests, where The number of pairs will be given by the simple arrangement of the number of assets, considering that, due to the coefficients changing when the order of tssets is changed, they will be considered distinct operations. For example, the ITUB4 (Itaú Unibanco S/A) and VALE3 (Vale S/A) pair will have different coefficients from VALE3 and ITUB4. Therefore, for the 90 assets, 8,010 pairs were analyzed. Once the pairs are identified, and their performance is calculated, parametric or nonparametric statistics will evaluate them to identify the possible relationships between their returns and the volatility calculated on the standard deviations of daily returns for 20, 60, 120, and 252 periods in an annualized format, for dependent and independent assets.

Time Series Modeling and Criteria for Opening and Closing Positions
A stationary series has a temporary effect, but it gradually disappears without affecting a series over a long time. However, when this shock is not quickly dissipated, some tests and transformations can be applied to verify these components' presence, such as the presence of unit roots or stochastic tendencies (Gujarati, 2011). Therefore, the finding of stationarity in time series is similar to testing a unit root's existence. If the series is stationary at level, it is integrated with order zero or I (0). If it is necessary to transform the series to park it in the first order, the series becomes integrated with order one or I (1).
Thus, the Augmented Dickey-Fuller (ADF) (Dickey & Fuller, 1979), Phillips-Perron (Phillips & Perron, 1988), and KPSS (Kwiatkowski et al., 1992) statistical tests were applied in this research, conventionally indicated to check stationarity in time series, highlighted during this analysis. The ADF test's null hypothesis is that the time series has a unit root, therefore, not stationary. Thus, at a level of 5% of significance, the p-value must reject the null hypothesis of the ADF test, accepting the alternative hypothesis of stationarity of the analyzed series.
The Phillips-Perron test is also used to verify the existence of a unit root in time series. The PP test is similar to the ADF test, but this test deals with the serial correlation in the error terms without adding the lagged difference terms (Gujarati, 2011). The test's null hypothesis is that the series has a unit root, therefore, not stationary, as in the ADF test. Finally, the third proposed test, the KPSS, is an alternative to the ADF and PP tests since its null hypothesis is stationarity. Therefore, there is no unit root in the time series.
Then, as a criterion for carrying out the operations, the value of the observed residual on the studied day will be checked whether it exceeds the value calculated as a deviation band (σ) to ±2σ (more or less twice the standard deviation), added and subtracted from the average residuals. If the residue exceeds the upper or lower limit of the standard deviations studied, this will be considered an entry signal in the pair operation. If the upper limit of the average band is exceeded, the dependent asset (Y) will be sold and, consequently, the independent asset (X) will be purchased, in the proportion indicated by the parameter of the linear beta coefficient (β 1 ) of the regression of period 252. It is worth noting that pairs with negative values of the linear coefficient β 1 will not be considered. Pairs that show stationarity in at least 2 of the 3 tests indicated above will be considered.
The operating margin will be calculated based on current market parameters with a factor of 60% for the purchased asset's financial volume and 140% for the financial volume of the sold asset. All operations that require margin, or not, will be considered for the formation of portfolios. Considering that the β 1 of the regressions will be considered to determine the proportion of purchase and, respective, sale of the pair's assets, they may be considered pairs in which the financial relationship will not necessarily be cash neutral. In proportion to the residuals' standard deviation, the exit criteria will initially be 0%σ (or equal to the average of the residuals). The exit point will be given when, during the days following the operation's entry signal, the residual value exceeds or equals the proportion of the standard deviation defined for the exit.

Formation of Portfolios and Evaluation of Results
Then, the statistical relationship between the returns of the pairs and the volatility level will be evaluated, proposing the formation of portfolios with a criterion of choice based on volatility, evaluated, and adjusted daily. The maximum exposure restriction on a single asset of the pair is proposed, limited to a maximum of 80% of the two assets' total financial value, and cannot exceed this proportion, avoiding too much concentration on a single asset of the pair maintaining hedge balance.
Other restrictions can be assessed, aiming at greater diversification of the portfolio, and exposure to a single asset may be limited as a proportion to the total portfolio. Its gross result will evaluate the portfolio's performance, risk, IS, correlation, and Ibovespa performance. The IS, or return per risk, will be calculated according to Equation 4.
where R c will be the portfolio's daily return; R f will be the daily CDI return for the period, divided by the standard deviation or risk.
The results will be organized in tables and diagrams, noting the behavior of each operation performed individually. Each pair's gross return will be considered as the sum of the results of the long and short parts of the position. Also, the period elapsed from the operation, portfolio results, profitability compared to the market portfolio, risks, and correlation of returns with those observed in the market will be demonstrated. Finally, the criteriat make it possible to obtain superior results, for the proposed period of study, of the model of pairs trading by statistical cointegration in the Brazilian stock market will be evaluated analytically, individually, and in a combined manner.

RESULTS
In total, 5,927,400 pairs were analyzed in backtesting throughout the proposed period -from January 2016 to December 2018 -or, still, 8,010 pairs daily during 740 trading sessions. The necessary condition of cointegration was obtained by the ADF test, identifying 126,350 pairs cointegrated throughout the analysis. The daily average of the number of cointegrated pairs was 139 signals, varying to a maximum of 410 and at least one pair over the period.
To achieve a better hedge balance of the total number of cointegrated signals, the pairs that had a financial relationship between the assets greater than five times were disregarded for statistical analysis and portfolio formation -calculated by the ratio between the gross financial value of the dependent asset position, on the gross financial value of the independent asset position for each pair and, respectively, of the independent on the dependent. Pairs with a β 1 coefficient below 0.05 were also disregarded. The relationship between the elapsed operational periods and the observed returns of the 126,350 pairs cointegrated individually was analyzed, measured by Spearman's correlation test with ρ = -0.46, p < 0.001, α = 0.01. The pairs' returns showed a slight significant negative correlation, i.e., the longer the operational term, the lower the observed returns. While Pearson's correlation shows a slightly higher degree, ρ = -0.375, p < 0.001, α = 0.01, due to the change in behavior observed in the data, in particular, in the operational terms over 23 trading sessions that remained strongly negative, we consider the Spearman coefficient to be more robust for measuring the observed non-linear relationship, between the individual returns of the pairs and the operational deadlines.
The performance of pairs in backtesting was also measured with the definition of a stop criterion for the operational time elapsed since the beginning of each operation, defined by the observed value of the third quartile of the terms initially obtained without stopping criteria of 69 days.
A stop criterion was also adopted due to variations in the spread of the regression residues, defined in four standard deviations (4σ) from the mean, in order to minimize movements contrary to the operational signal of the model, which, possibly, due to adverse price shocks, changed the relationship statistic observed historically in the adopted regression period of 252 days before the evaluated day. The percentage returns from operations showed a non-normal, leptokurtic distribution with kurtosis > 15.64 (high), according to Table 2.

Mean
-0. Mann-Whitney U non-parametric tests showed significant differences between the observed returns from operations with annualized volatility (20 periods) of the dependent asset higher than the median daily volatilities (Z = -18.509, p < 0.001). In the remaining periods suggested for assessing annualized volatilities for 60, 120, and 252 periods, no significant differences in returns were identified.
In the comparison of the elapsed operating terms between the pairs of the highest volatility of the dependent asset, with a significantly more significant difference of the operating terms for the dependent assets with volatility more significant than the median of the assets on the same day (Z = 5.435, p < 0.001).
Thus, verifying whether the returns remain when operationalized systematically through the formation of long-term portfolios, the performance was evaluated between a portfolio randomly composed by any of the unrestricted pairs and another portfolio composed of pairs that presented annualized volatility (20 periods) of the dependent asset, higher than the median volatility of the other pairs for the day of the operation. The proposed portfolio with a volatility criterion higher than the daily medians presented, at the end of the period, a performance superior to that of the random portfolio of the asset pairs, obtaining a Sharpe Index of 0.50 against 0.19 of the random portfolio. Also, with a greater number of transactions, 154, against 107 in the random portfolio. However, the average returns observed between the portfolios did not show statistically significant differences (Mann-Whitney U: Z = -0.522, p > 0.60 and Kolmogorov-Smirnov: Z = 0.764, p > 0.60). Figure 1 shows the performance of the proposed portfolios and the Ibovespa. The proposed portfolios showed lower results than the Ibovespa in the period studied. However, the portfolios showed a low Pearson correlation with the Ibovespa returns for 100 days, which is characteristic of pairs trading operations, as shown in Figure 2. During the formation of the portfolio with the highest volatilities, pairs with volatilities higher than the medians of 20 periods were considered, as they presented the fastest response to market variations. Figure 3 shows the daily medians of dependent assets, measured according to the volatilities of 20, 60, 120, and 252 periods.   Through the individualized analysis of the cointegrated pairs throughout the proposed period, some pairs showed more frequent signs of cointegration and fit the operational criteria than others -in some cases, with an assertiveness index above 90% of the signs with positive returns between each period of operation. In contrast, a total of 1,804 pairs, or 22.52% of the total, showed no operational sign according to entry criteria in the period. In Table 4, it is possible to observe that, of the total number of cointegrated pairs, operations with positive returns had lower average operating terms compared to operations that resulted in financial losses. This way of observing corroborates the weakly observed degree of correlation between the pairs' returns concerning the operational deadlines, with decreasing results due to the delay of the pair returning to the long-term average of the residuals.
However, the pairs did not present a statistically relevant relationship concerning the operational terms when analyzing in a grouped way. Regarding the volatility levels, no other causal factors were identified when crossed with the operational terms.

FINAL CONSIDERATIONS
This article aimed to evaluate the effects of asset volatility on the performance of statistical arbitrage operations by pairs trading, proposing the composition of a portfolio using volatility as a decision criterion. It performed wide backtesting of the 5,927,400 pair combinations over the study period, identifying the cointegration relations of the price series, according to the assumptions of the statistical model of arbitrage by pairs trading with shares.
The results indicated that the portfolio made up of assets with the highest volatility obtained a result of 85.2% in the period, or 22.8% annualized, thus surpassing the portfolio made up of random pairs without defining criteria for volatility. However, it did not exceed the Ibovespa's accumulated return of 108.56% in this period, something considered atypical in the Brazilian market. Thus, the analysis of the statistical significance of this relationship corroborated, showing that the greater the volatility, the shorter the operational terms, and the greater the observed returns. The adoption of stop criteria based on the operating term and the spread of residuals increased the average returns from the sample of pairs used to form portfolios.
The pair trading arbitrage model provides a variety of strategies to obtain neutral returns concerning market returns, with an objective proposal for the analysis of decision criteria for choosing assets and forming portfolios, which can be replicated at any time. We found results highlighting the low correlation characteristic of portfolio returns and the market index for most of the proposed period.
However, we found limitations in the data processing capacity due to many pairs identified daily and the portfolios' subsequent possible combinations. The observed results' dispersion and consistency and the possibility of replication in other periods aside from the sample were also limitations.
The ad hoc arbitrage model's application without complementary analyses of the long-term equilibrium relationships of the assets evaluated does not guarantee results that are different from the market average. As a suggestion for future work, it is essential to analyze the aspects that affect the model's statistical balance to mitigate the market risks of the strategy, especially those related to operating deadlines. Regarding the factors that interfere with the stationarity of the pairs' statistical relationship, we recommend using, as a criterion, different periods for analyzing the stationarity of the pairs, in addition to considering a more extended period of analysis and a more significant amount of liquid assets. Studies performing a variation of the entry and exit criteria of the operations, such as deviation bands due to the paper's volatility, or even limiting the operational term to shorter horizons, can contribute to the assertiveness of the model and the improvement of the adjusted returns to market risks.