O'Reilly logo

NumPy 1.5 by Ivan Idris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – trading correlated pairs

For this tutorial, we will use two sample data sets, containing the bare minimum of 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, albeit not hundred percent. For trading correlated pairs, follow the ensuing steps:

  1. Load the data: 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, there are plenty of examples in the previous chapter.
  2. Covariance: Covariance tells us how two variables ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required