Obtaining historical stock and index data
The examples will use two sets of data obtained from Yahoo! Finance. The first one is a series of stock values for several stocks over the calendar years 2012–2014. The second set of data is the S&P 500 average over the same period. Note that although we are using data from a fixed period in time, the adjusted close values tend to change slightly over time, so there may be slight differences in output when you run the code as compared to what is in the text.
Fetching historical stock data from Yahoo!
The examples in this chapter will use historical quotes for Apple (AAPL), Microsoft (MSFT), General Electric (GE), IBM (IBM), American Airlines (AA), Delta Airlines (DAL), United Airlines (UAL), Pepsi (PEP), and Coca-Cola (KO).
These stocks were chosen deliberately to have a sample of multiple stocks in each of three different sectors: technology, airlines, and soft drinks. The purpose of this is to demonstrate deriving correlations in various...