13.08.2022 Views

advanced-algorithmic-trading

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

171

Figure 12.11: Residuals of the first linear combination of RDS-A and RDS-B

In adf.test(comb1$residuals, k = 1) : p-value smaller than printed p-value

And for the second:

> adf.test(comb2$residuals, k=1)

Augmented Dickey-Fuller Test

data: comb2$residuals

Dickey-Fuller = -3.9846, Lag order = 1, p-value = 0.01

alternative hypothesis: stationary

Warning message:

In adf.test(comb2$residuals, k = 1) : p-value smaller than printed p-value

Since the first linear combination has the smallest Dickey-Fuller statistic, we conclude that

this is the optimal linear regression. In any subsequent trading strategy we would utilise these

regression coefficients for our relative long-short positioning.

12.8 Full Code

library("quantmod")

library("tseries")

## Set the random seed to 123

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!