Time for action – trading correlated pairs
For this section, we will use two sample datasets, containing end-of-day price data. The first company is BHP Billiton (BHP), which is active in mining of petroleum, metals, and diamonds. The second is Vale (VALE), which is also a metals and mining company. So, there is some overlap of activity, albeit not 100 percent. For evaluating correlated pairs, follow these steps:
- First, load the data, specifically the close price of the two securities, from the CSV files in the example code directory of this chapter and calculate the returns. If you don't remember how to do it, look at the examples in Chapter 3, Getting Familiar with Commonly Used Functions.
- Covariance tells us how two variables vary together; which is nothing more than unnormalized correlation (see https://www.khanacademy.org/math/probability/regression/regression-correlation/v/covariance-and-the-regression-line):
Compute the covariance matrix from the returns with the
cov()
function...