• Ei tuloksia

Modelling cointegration

The cointegration strategy was implemented as presented in D. Chen et al. (2017). This is consistent with Figuerola-Ferretti et al. (2018) and roughly follows the method defined in Vidyamurthy (2004, pp. 82–84).

1. Identify pairs that could be cointegrated. This can be based on the stock fundamentals or statistical approach from historical data. Vidyamurthy suggests using fundamental information for pair selection. This thesis uses fundamental selection criterion as described in Gatev et al. (1999).

2. Verify the proposed hypotheses of cointegration by applying statistical tests to historical data. Determine the cointegrating coefficient and examine the spread series to ensure it is stationary and mean-reverting.

3. Examine cointegrated pairs to determine suitable level for delta and start trading.

A cointegrated pair 𝐴, 𝐵 satisfies the condition 𝐴𝑡 − 𝛽 𝐵𝑡 = 𝑢𝑡 where 𝑢𝑡 is stationary. This can be rearranged to say that the fair price of𝐴at time𝑡is𝛽 𝐵𝑡+𝑢𝑡. The following example if purely fictional, uses nominal prices for the ease of understanding and is intended for illustrational purposes only.

Suppose that we have estimated from historic data that Cointegration Ratio𝛽 = 1.5

Premium𝑢𝑡 on asset A = 0e Trading threshold ±0.8e And we know that

Price of A at time𝑡 = 20.30e Price of B at time𝑡 = 14.10e

The computed fair price for 𝐴 at time 𝑡 is 1.5×14.10e+0e = 21.15e. Because this is higher than the actual market price of𝐴at time𝑡, it can be said that𝐴isundervaluedrelative to𝐵, or𝐵isovervaluedrelative to𝐴. The magnitude of this deviation 20.30−21.15=−0.85 is compared to the trading threshold, which is set at two times the standard deviation of past deviations. Since|−0.85| > 0.80, trader buys 𝐴and shorts 𝐵 in cointegrating ratio of 1 to 1.5.

Now suppose that prices develop so that at time𝑡+1 Price of A at time𝑡+1 = 20.79e (+2.4%) Price of B at time𝑡+1 = 13.86e (-1.7%)

The positions are then closed, because the prices have converged to the equilibrium level where 1.5×13.86e=20.79e.

The total profit from the trade is the profit on 𝐴plus𝛽times the profit on𝐵:

=(20.79e−20.30e) +1.5× (14.10e−13.86e)

≈0.85e

And the return, ignoring all costs and margin requirements, is

=ln(20.79e

20.30e) +1.5×ln(14.10e

13.86e)

≈0.0239+1.5×0.0172

≈4.1%

For cointegration tests, Engle-Granger Augmented Dickey-Fuller test was implemented in Python using statsmodelspackage. To obtain the optimal hedge ratios and residual series, simple OLS regression was fitted first. Becausestatsmodels does not include constant by default, a user must remember to add a vector of ones to the matrix of exogenous variables.

If one does not remember to do so, the residuals of the OLS regression will be biased and therefore ADF test might yield incorrect results. OLS regression was followed by ADF test on residual series, using AIC for determining the optimum number of lags. Tests were run for each of the qualifying pairs present during the fitting period.

After running the cointegration tests, several cointegrated pairs emerged with a negative cointegrating coefficient. Such pairs are diverging and violate dollar-neutrality, as those would imply long-long or short-short portfolios. The test were run again this time considering only pairs with positive cointegrating relationship.

The best 10 pairs for each period were selected by approximating MacKinnon’s p-values for t-values from ADF regressions. This procedure is discussed in details in MacKinnon (1994).

MacKinnon aims to solve the problem of nonstandard asymptomatic distributions in ADF tests for which only few critical values have been tabulated, mainly by Fuller in his book Introduction to Statistical Time Series (1976). MacKinnon’s p-values are drawn from his approximations of the asymptotic distribution functions for these tests.

After ranking each pair, trades were performed on the best 10 pairs of each time frame. In this phase, the cointegrating parameter of the model was used to calculate the fair value of the first asset based on the current value of the second asset by assuming a long-run equilibrium to exist between the assets. The current value of the first asset was then compared to the computed fair value for the asset to obtain the relative value of the first asset. Positions were opened when the current value differed enough from the computed value and closed when the relative value changed from overpriced to underpriced or vice versa. For opening threshold, two standard deviations were used based on recommendations in D. Chen et al.

(2017). Trades were closed at convergence.

Cointegration strategy is illustrated here with the most cointegrated pair from an arbitrarily chosen trading period, in this case period 56 where the fitting range was from from August 2016 to August 2017 and the trading period from August 2017 to February 2018. The most cointegrated pair for that range based on MacKinnon’s statistic was Oriola Oyj A - Oriola Oyj B. Log-prices for that pair are presented in Figure 10.

The price of both share classes shows significant decline during the fitting period, and this decline steepens during the trading period. Cointegrating linear relationship between the two

Oct Jan

2017 Apr Jul Oct Jan

2018 1.0

1.1 1.2 1.3 1.4

1.5 OKDAV fitting

OKDAV trading OKDBV fitting OKDBV trading

Figure 10. The most cointegrated pair for trading period 56

share classes is displayed in Figure 11. Class A shares trade at a small premium, which is most likely explained by higher voting power at general meetings (Oriola 2020).

Figure 12 illustrates cointegration based trading strategy on that pair. Positions are opened at vertical solid green lines, and closed at the red lines following these green lines. Dotted line represents computed equilibrium price of Class A shares. The direction of opening trade is illustrated with a green triangle pointing to desired direction of price movement i.e. down for short position and up for long position. Red×marks the price at which positions are closed at convergence. Profit is made when either both prices move in desired direction or one of the prices moves to desired direction more than the other does in undesired direction.

Detailed description of each trade in Figure 12 is presented in Table 7. Asset prices are represented as natural logarithms, and can be converted to real prices by raising 𝑒 to the power of log-price if desired. For most though, log-representation in Table 7 is likely more understandable as(𝑒1.31−𝑒1.28)/𝑒1.31 =1.31−1.28≈3%.

On November 6thspread changed sign and caused the open positions to be closed due to the convergence and the reverse position to be simultaneously opened due to significant change in opposite direction. Because of declining trend during the trading period, practically all of the profits were made through selling short the overvalued asset.

1.0 1.1 1.2 1.3 1.4 1.5

OKDBV

1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45

OKDAV

fit

training data trading data

Figure 11. Fit of pair in Figure 10

Sep Oct Nov Dec Jan

2018 Feb

0.95 1.00 1.05 1.10 1.15 1.20 1.25 1.30

OKDAV fair OKDAV true OKDBV true close buy short

Figure 12. Trades on trading period 56 for pair in Figure 10

Table7.CointegrationtradeswithOriolasharesbetweenAugust2017andFebruary2018,cointegratingcoefficient=0.69 DATEOKDAVOKDBVOKDAV_fairvaluationspreadactionlongprofitshortprofittotalprofit 2017-09-211.311.221.28over-0.03open 2017-09-251.281.231.28under0.01close0.000.030.03 2017-09-281.301.211.28over-0.03open 2017-10-061.281.231.28under0.00close0.010.020.03 2017-10-261.271.161.24over-0.03open 2017-11-061.201.151.23under0.03close+open-0.010.070.06 2018-01-051.211.121.21over-0.00close0.010.020.03 2018-01-221.171.101.19under0.02open 2018-02-121.120.991.12over-0.00close-0.040.070.03 2018-02-161.090.981.11under0.03open 2018-02-191.120.971.11over-0.01close0.030.010.04 2018-02-201.160.991.12over-0.04open 2018-02-231.120.971.11over-0.01close-0.010.040.04 TOTAL-0.010.260.26