``````

In [1]:

%matplotlib inline

``````

# Visualizing the stock market structure

This example employs several unsupervised learning techniques to extract the stock market structure from variations in historical quotes.

The quantity that we use is the daily variation in quote price: quotes that are linked tend to cofluctuate during a day.

.. _stock_market:

## Learning a graph structure

We use sparse inverse covariance estimation to find which quotes are correlated conditionally on the others. Specifically, sparse inverse covariance gives us a graph, that is a list of connection. For each symbol, the symbols that it is connected too are those useful to explain its fluctuations.

## Clustering

We use clustering to group together quotes that behave similarly. Here, amongst the :ref:`various clustering techniques <clustering>` available in the scikit-learn, we use :ref:`affinity_propagation` as it does not enforce equal-size clusters, and it can choose automatically the number of clusters from the data.

Note that this gives us a different indication than the graph, as the graph reflects conditional relations between variables, while the clustering reflects marginal properties: variables clustered together can be considered as having a similar impact at the level of the full stock market.

## Embedding in 2D space

For visualization purposes, we need to lay out the different symbols on a 2D canvas. For this we use :ref:`manifold` techniques to retrieve 2D embedding.

## Visualization

The output of the 3 models are combined in a 2D graph where nodes represents the stocks and edges the:

• cluster labels are used to define the color of the nodes
• the sparse covariance model is used to display the strength of the edges
• the 2D embedding is used to position the nodes in the plan

This example has a fair amount of visualization-related code, as visualization is crucial here to display the graph. One of the challenge is to position the labels minimizing overlap. For this we use an heuristic based on the direction of the nearest neighbor along each axis.

``````

In [1]:

print(__doc__)

# Author: Gael Varoquaux gael.varoquaux@normalesup.org

import datetime

import numpy as np
import matplotlib.pyplot as plt
try:
from matplotlib.finance import quotes_historical_yahoo_ochl
except ImportError:
# quotes_historical_yahoo_ochl was named quotes_historical_yahoo before matplotlib 1.4
from matplotlib.finance import quotes_historical_yahoo as quotes_historical_yahoo_ochl
from matplotlib.collections import LineCollection
from sklearn import cluster, covariance, manifold

``````
``````

Automatically created module for IPython interactive environment

``````

Retrieve the data from Internet

``````

In [7]:

# Choose a time period reasonably calm (not too long ago so that we get
# high-tech firms, and before the 2008 crash)
d1 = datetime.datetime(2003, 1, 1)
d2 = datetime.datetime(2008, 1, 1)

# kraft symbol has now changed from KFT to MDLZ in yahoo
symbol_dict = {
'TOT': 'Total',
'XOM': 'Exxon',
'CVX': 'Chevron',
'COP': 'ConocoPhillips',
'VLO': 'Valero Energy',
'MSFT': 'Microsoft',
'IBM': 'IBM',
'TWX': 'Time Warner',
'CMCSA': 'Comcast',
'CVC': 'Cablevision',
'YHOO': 'Yahoo',
'DELL': 'Dell',
'HPQ': 'HP',
'AMZN': 'Amazon',
'TM': 'Toyota',
'CAJ': 'Canon',
'MTU': 'Mitsubishi',
'SNE': 'Sony',
'F': 'Ford',
'HMC': 'Honda',
'NAV': 'Navistar',
'NOC': 'Northrop Grumman',
'BA': 'Boeing',
'KO': 'Coca Cola',
'MMM': '3M',
'MCD': 'Mc Donalds',
'PEP': 'Pepsi',
'MDLZ': 'Kraft Foods',
'K': 'Kellogg',
'UN': 'Unilever',
'MAR': 'Marriott',
'PG': 'Procter Gamble',
'CL': 'Colgate-Palmolive',
'GE': 'General Electrics',
'WFC': 'Wells Fargo',
'JPM': 'JPMorgan Chase',
'AIG': 'AIG',
'AXP': 'American express',
'BAC': 'Bank of America',
'GS': 'Goldman Sachs',
'AAPL': 'Apple',
'SAP': 'SAP',
'CSCO': 'Cisco',
'TXN': 'Texas instruments',
'XRX': 'Xerox',
'LMT': 'Lookheed Martin',
'WMT': 'Wal-Mart',
'WBA': 'Walgreen',
'HD': 'Home Depot',
'GSK': 'GlaxoSmithKline',
'PFE': 'Pfizer',
'SNY': 'Sanofi-Aventis',
'NVS': 'Novartis',
'KMB': 'Kimberly-Clark',
'R': 'Ryder',
'GD': 'General Dynamics',
'RTN': 'Raytheon',
'CVS': 'CVS',
'CAT': 'Caterpillar',
'DD': 'DuPont de Nemours'}

symbols, names = np.array(list(symbol_dict.items())).T

quotes = [quotes_historical_yahoo_ochl(symbol, d1, d2, asobject=True)
for symbol in symbols]
print(quotes)
open = np.array([q.open for q in quotes]).astype(np.float)
close = np.array([q.close for q in quotes]).astype(np.float)

# The daily variations of the quotes are what carry most information
variation = close - open

``````
``````

[rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 31.36402804210637, 32.266053, 32.31455044991248, 31.360795611609678, 2986100.0, 32.266053),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 32.26928881147565, 32.136732, 32.26928881147565, 31.858688654743627, 2273800.0, 32.136732),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 32.178761028561354, 32.469737, 32.68635349076594, 32.15289641155142, 4102900.0, 32.469737),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 57.030112583135214, 56.41437100000001, 57.185815390754186, 56.22328244528521, 1098200.0, 56.414371),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 56.4780680368665, 56.145428, 56.93103008876618, 56.046345360002995, 874100.0, 56.145428),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 55.841098245385126, 55.657085, 56.336522767881505, 55.657085, 795200.0, 55.657085)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 24.957356020061376, 25.539398, 25.674621596327505, 24.786857009695513, 3072100.0, 25.539398),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 25.54527822760178, 25.668741, 25.709896825262245, 25.327747097188304, 2647700.0, 25.668741),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 25.515884047184016, 26.286061, 26.391887832685494, 25.515884047184016, 3124900.0, 26.286061),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 30.91865390546568, 30.780008, 31.140492484211865, 30.592830897620228, 4125000.0, 30.780008),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 30.918654018418646, 30.710681, 31.02264191411476, 30.578966141488316, 3306000.0, 30.710681),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 30.565101000000002, 30.565101000000002, 30.703749677704693, 30.440316496822383, 2994300.0, 30.565101)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 16.677393062726704, 17.452703, 17.683646964683508, 16.603161339191733, 1055800.0, 17.452703),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 18.137284521660646, 18.2775, 18.52493825462545, 18.12903655234657, 2128900.0, 18.2775),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 18.343483613685578, 19.044561, 19.16828053876137, 18.27749985967952, 1525500.0, 19.044561),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 44.8696683481114, 44.241941, 44.89546453785412, 44.06995980913586, 973000.0, 44.241941),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 44.585900302101116, 44.431118, 44.7148872736554, 44.31933336152089, 298200.0, 44.431118),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 44.19894716150647, 43.897979, 44.27633831111255, 43.64000936121467, 947400.0, 43.897979)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 13.408147354289987, 13.784872, 13.845633503880478, 13.31497868880545, 1927900.0, 13.784872),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 13.784872150626967, 13.886142, 13.955005092494263, 13.752465798827595, 1656300.0, 13.886142),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 13.655245742641265, 13.748414, 14.125139038471275, 13.57422946159777, 3049900.0, 13.748414),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 28.264587438747096, 28.247838, 28.515828182481524, 27.93797422065075, 3158700.0, 28.247838),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 28.65819819555075, 28.574451, 28.68332319168793, 28.222713616158817, 2582500.0, 28.574451),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 28.432081289840575, 28.624699, 28.808940315753297, 28.28971022151066, 2213900.0, 28.624699)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 21.765081906269796, 22.101006, 22.247973490848832, 21.681100882837242, 1977200.0, 22.101006),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 22.101006162658226, 22.115003, 22.240975235917816, 21.90504974003155, 1704200.0, 22.115003),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 22.184987561361087, 22.387941, 22.45792518568303, 22.094007420131295, 1912500.0, 22.387941),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 48.586611644287075, 47.808728, 48.62550504861779, 47.699825067683456, 1540700.0, 47.808728),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 48.27546034333511, 47.847622, 48.27546034333511, 47.6453738057348, 1158700.0, 47.847622),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 47.98431921656805, 47.414101, 48.08586584659366, 47.335986465169874, 1294900.0, 47.414101)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 11.218818103372433, 11.672363, 11.715150254398827, 11.201703201612903, 61335700.0, 11.672363),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 11.621018125089863, 11.903414, 11.946201253774262, 11.603903223580158, 50891700.0, 11.903414),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 11.988988436619719, 12.15158, 12.339843915492958, 11.963316084507042, 58936700.0, 12.15158),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 24.09778081548108, 23.781156, 24.28604387235697, 23.68702318794447, 46568900.0, 23.781156),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 23.918076299071487, 23.584334, 24.132012573162065, 23.301938973945532, 46861200.0, 23.584334),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 23.319053112301443, 23.165019, 23.532989379386777, 23.10511684521611, 60736600.0, 23.165019)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 6.8911413480885315, 7.21031, 7.217563832997988, 6.869379849094568, 10137600.0, 7.21031),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 7.166786652892562, 7.02171, 7.2320711466942145, 7.014456167355371, 8436000.0, 7.02171),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 7.036217209533267, 7.304609, 7.362639657398213, 7.021709545183714, 11028600.0, 7.304609),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 5.716810236842106, 5.691846, 5.775060122807018, 5.658560350877193, 24715700.0, 5.691846),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 5.700167179104477, 5.575346, 5.716810002985074, 5.558703176119402, 24070400.0, 5.575346),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 5.5503815304606245, 5.60031, 5.616952823179792, 5.533738707280833, 25845200.0, 5.60031)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 20.628315304395297, 20.818637, 20.824775151952995, 20.499388941925144, 4365400.0, 20.818637),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 20.818636357251176, 20.978259, 20.993608370005482, 20.751102567279666, 4958000.0, 20.978259),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 20.97825953411944, 21.457133, 21.610617494893148, 20.935284182518348, 7761200.0, 21.457133),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 68.78727093642789, 67.825058, 68.78727093642789, 67.75271271840123, 8155100.0, 67.825058),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 68.0131615256489, 68.628108, 68.6787499869413, 67.49950047211495, 7895000.0, 68.628108),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 68.27361070927238, 67.521204, 68.42553811755418, 67.28969446590614, 5086600.0, 67.521204)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 17.81051790789495, 17.81961, 17.910526829813602, 17.683235891734288, 1098500.0, 17.81961),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 17.728693098242683, 17.669597, 17.819609927687342, 17.5650431689078, 1362600.0, 17.669597),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 17.669597203258203, 17.510494, 17.669597203258203, 17.08318794239325, 2574000.0, 17.510494),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 17.417787351958697, 17.121425, 17.428186030974793, 17.09542882239371, 3660600.0, 17.121425),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 17.157820177304394, 17.131824, 17.313799840800492, 17.033034990692475, 4443200.0, 17.131824),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 17.048634430487603, 16.965445, 17.095428485136882, 16.939448822906563, 7418700.0, 16.965445)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 16.025528122582116, 16.653296, 16.653296, 15.96275095120419, 4539400.0, 16.653296),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 16.618420926278432, 16.541693, 16.635858584054247, 16.391726143790848, 3399800.0, 16.541693),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 16.583543843035564, 16.879991, 16.886964807563807, 16.583543843035564, 2354400.0, 16.879991),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 55.97947110227977, 55.86426, 56.73989940290227, 55.62614369026605, 3336500.0, 55.86426),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 56.07932775453498, 56.194545000000005, 56.57091478069206, 55.99483623441423, 3043600.0, 56.194545),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 56.07164461333089, 55.73367699999999, 56.61699819694486, 55.603099965580526, 2639600.0, 55.733677)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 25.65054466493887, 26.273897, 26.309719491475395, 25.328122179861374, 3656800.0, 26.273897),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 26.288227072759984, 26.367042, 26.603485348734417, 26.166422576021485, 2924000.0, 26.367042),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 26.309718846479132, 27.291318999999998, 27.434618276795174, 26.25956721634451, 4954800.0, 27.291319),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 44.8272094545243, 43.731773, 45.135301091079214, 43.663310093671626, 7884600.0, 43.731773),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 44.25381686940864, 43.509265, 44.373629095819624, 43.41512614968528, 6565800.0, 43.509265),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 43.51782124686205, 44.519118, 44.989812250288345, 43.320986325276465, 8380600.0, 44.519118)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 43.748193714871796, 44.964998, 44.964998, 43.652411351439795, 4358200.0, 44.964998),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 44.78762099558773, 44.794715, 44.96144946855879, 44.603150274361255, 2754400.0, 44.794715),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 44.59250560933814, 45.12109, 45.1920396225712, 44.528649991189795, 3824600.0, 45.12109),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 67.910346496052, 67.358233, 68.22584330267345, 67.26358206504219, 2278100.0, 67.358233),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 67.92612574269201, 67.11372, 67.92612574269201, 66.54583410417789, 2162700.0, 67.11372),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 66.76667914033193, 66.506394, 67.20837009290331, 66.47484368849155, 1740700.0, 66.506394)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 28.171810640714405, 27.977239999999995, 28.248458841240932, 27.74139276116363, 2085600.0, 27.97724),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 27.97723940983588, 27.853422, 27.97723940983588, 27.593984264524234, 2064100.0, 27.853422),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 27.835729559033165, 28.148225, 28.230772890131263, 27.629363666203492, 2110400.0, 28.148225),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 48.16969461711861, 48.031478, 48.37702196164779, 47.92089572200039, 1595900.0, 48.031478),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 48.32864961409227, 48.335562, 48.61890831428406, 48.16278759842559, 1536900.0, 48.335562),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 48.14204880857601, 47.920896, 48.59126197389729, 47.91398914293109, 1452000.0, 47.920896)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 16.620058565195656, 17.032747, 17.070263311882673, 16.319922067404313, 647700.0, 17.032747),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 16.867670864198264, 16.920194, 16.98772471075524, 16.792635990795652, 297200.0, 16.920194),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 16.95771248401012, 17.235338, 17.32537970158379, 16.95771248401012, 238000.0, 17.235338),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 39.09755819753239, 38.542519, 39.268966293171374, 38.371107639429354, 518600.0, 38.542519),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 38.92614774411851, 38.779225, 39.171020072626604, 38.62414237525331, 539000.0, 38.779225),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 38.58333019201575, 38.371108, 38.63230579976234, 38.15888907291593, 544300.0, 38.371108)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 10.945901203411925, 10.928697, 11.087832333282053, 10.752358323494688, 3832200.0, 10.928697),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 10.967405637983996, 11.135142, 11.268472105199463, 10.967405637983996, 4623600.0, 11.135142),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 11.135141607175699, 11.019017, 11.350188768961525, 10.963104307841363, 5273800.0, 11.019017),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 35.333207257438225, 35.235479, 35.43093640331515, 35.01336932400403, 5808300.0, 35.235479),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 35.235478842, 35.537548, 35.8307345478774, 35.217709179561304, 7186700.0, 35.537548),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 35.36874520994812, 35.315438, 35.564199945271994, 35.19105747158334, 6530700.0, 35.315438)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 17.151559084058214, 17.280621, 17.321376500732057, 16.845887054775627, 16739100.0, 17.280621),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 17.32137666455757, 17.620256, 17.65421880438632, 17.117596441891273, 12525700.0, 17.620256),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 17.661011079342387, 19.005965, 19.087477358827734, 17.633839613796816, 22932400.0, 19.005965),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 35.86348774244752, 35.091539, 35.943901565890016, 34.98700336145567, 16530000.0, 35.091539),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 35.53380193092068, 34.785975, 35.59813186422246, 34.432166397696086, 16852200.0, 34.785975),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 34.63319421474482, 35.099582, 35.49359549583567, 34.40804307132865, 16361200.0, 35.099582)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 18.57601231752531, 19.188002, 19.78144472353593, 18.421469780622687, 165700.0, 19.188002),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 18.7058287014876, 18.699647, 18.85418953719008, 18.582194053565388, 93400.0, 18.699647),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 18.600739073966427, 19.132366, 19.163273888101006, 18.56983118586542, 65700.0, 19.132366),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 31.74625165712511, 31.541965, 31.7802988658478, 31.48067879857513, 498400.0, 31.541965),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 31.589631758621504, 31.725824, 31.875635397420556, 31.528345556432193, 625800.0, 31.725824),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 31.88244424428826, 31.004008, 31.88244424428826, 31.004008, 498300.0, 31.004008)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 16.825239802856213, 17.279474, 17.288745031585034, 16.825239802856213, 257600.0, 17.279474),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 17.28874365763811, 17.325825, 17.38144469601687, 17.186773442431864, 134500.0, 17.325825),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 17.056991296891745, 17.298014, 17.353633696783817, 16.899399529474813, 212400.0, 17.298014),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 32.81465300909091, 32.636635, 32.87399432343242, 32.48828468111303, 333100.0, 32.636635),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 32.58718707641159, 32.775093, 33.091569465795914, 32.58718707641159, 257600.0, 32.775093),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 32.64652344678146, 32.775093, 33.121242101431136, 32.61685575609099, 271200.0, 32.775093)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 12.7328862169687, 12.794896, 12.83210331673783, 12.708081270242571, 1794600.0, 12.794896),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 12.646070629613053, 12.658473, 12.726685313668668, 12.604734218053549, 1559400.0, 12.658473),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 12.734957491891281, 12.718419, 12.747358828701337, 12.670875512461768, 2446500.0, 12.718419),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 26.951255303454996, 26.762685, 26.987518377026515, 26.675649706938092, 1186000.0, 26.762685),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 26.980267318858893, 26.929498, 26.980267318858893, 26.76993655831035, 1300400.0, 26.929498),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 27.060048045079814, 26.443562000000004, 27.060048045079814, 26.443562000000004, 1535600.0, 26.443562)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 47.985766716488264, 48.719135, 49.09034564818416, 47.985766716488264, 109900.0, 48.719135),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 48.800620203607735, 48.954535, 49.108453417959495, 48.800620203607735, 23400.0, 48.954535),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 49.43439077804888, 49.941412, 50.13154337379601, 48.71007823891567, 68200.0, 49.941412),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 104.10879991771708, 102.83673, 104.36704426349816, 102.59761929299357, 480300.0, 102.83673),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 102.57849475991547, 101.956805, 102.9801988404952, 101.89942129883347, 336100.0, 101.956805),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 101.86116204881156, 101.545534, 102.29155845574564, 101.04818755097902, 369100.0, 101.545534)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 5.137843397769517, 5.195789, 5.195789, 5.128185797397769, 137400.0, 5.195789),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 5.176473797421731, 5.244077, 5.273049801104972, 5.166816197053406, 75400.0, 5.244077),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 5.215103806104129, 5.379283, 5.379283, 5.186131007181328, 188500.0, 5.379283),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 9.3, 9.36, 9.57, 9.3, 2057100.0, 9.36),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 9.3, 9.27, 9.35, 9.09, 1803100.0, 9.27),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 9.19, 9.33, 9.42, 9.19, 2624000.0, 9.33)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 22.730926420576193, 23.209471, 23.350577593279187, 22.70638192886669, 216400.0, 23.209471),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 23.20947135287259, 23.405796, 23.454882530084248, 23.09290066024688, 179100.0, 23.405796),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 23.467150100031933, 24.007051, 24.14201932288905, 23.467150100031933, 197400.0, 24.007051),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 46.15767580357527, 45.443191, 46.15767580357527, 45.32574242199421, 430700.0, 45.443191),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 45.52148758093783, 45.25723, 45.74660314059805, 45.12020160564742, 460200.0, 45.25723),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 44.7091301004089, 44.855944, 45.26701548038335, 44.7091301004089, 278500.0, 44.855944)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 15.535669271978021, 16.058777, 16.134407032967033, 15.472643614255219, 21813600.0, 16.058777),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 15.976844486220475, 16.008357, 16.058777022047245, 15.762559392519687, 15025700.0, 16.008357),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 16.00835695233616, 16.418019, 16.51255780155765, 15.976844438650462, 18845000.0, 16.418019),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 27.030736020130412, 26.878957, 27.131919865309943, 26.821138692393, 23369600.0, 26.878957),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 26.994596023708084, 26.98737, 27.160830706340114, 26.785001585092925, 22747000.0, 26.98737),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 26.95845906684036, 26.792228000000005, 26.95845906684036, 26.712725117015705, 24131400.0, 26.792228)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 12.132421357080965, 12.719219, 12.774726810130437, 11.91039011655922, 11166900.0, 12.719219),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 12.48925669493222, 12.790584, 13.09191289100514, 12.433748887399187, 8440200.0, 12.790584),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 12.909530807667617, 13.512187, 13.55976432747862, 12.830233147286787, 11018800.0, 13.512187),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 27.705640994109423, 27.3319, 27.754391550368354, 27.25065340614011, 6684900.0, 27.3319),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 27.153152997122543, 27.21003, 27.42127374313086, 26.982532550758584, 7299300.0, 27.21003),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 27.11252909754598, 27.136906, 27.478146885140905, 26.958158298313876, 6175700.0, 27.136906)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 18.16402948734445, 18.630835, 18.660379024409167, 18.099030742788912, 13836700.0, 18.630835),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 18.619016487129755, 18.778558, 18.808102024288797, 18.536292155514975, 11596200.0, 18.778558),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 18.837646331607687, 18.908554, 18.961734308125, 18.73128689714231, 13712900.0, 18.908554),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 15.99598782722513, 15.768948, 16.0166284995178, 15.755188010471203, 36017800.0, 15.768948),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 15.858387233397906, 15.755188000000002, 15.892787895196511, 15.7001480419214, 24356600.0, 15.755188),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 15.775827894412668, 15.638227999999998, 15.775827894412668, 15.610708709116935, 30898200.0, 15.638228)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 0.9342703324324324, 0.9628970000000001, 0.970704207912365, 0.9336197263513514, 45357200.0, 0.962897),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 0.9628968749733642, 0.969403, 0.9713547529292113, 0.9492341490446881, 36863400.0, 0.969403),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 0.9778608128952475, 0.969403, 1.0006320227763743, 0.9681017229461932, 97633200.0, 0.969403),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 25.88762555975249, 25.83818, 26.40941156727986, 25.737986106402023, 198881900.0, 25.83818),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 26.101024683390303, 26.002132, 26.227241791876388, 25.61827413228605, 174911800.0, 26.002132),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 25.959191974228354, 25.774419, 26.089312716772014, 25.731479763928103, 134833300.0, 25.774419)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 17.755907743970443, 18.238, 18.24818469381637, 17.555602088726694, 67025200.0, 18.238),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 18.19386443867142, 18.261765, 18.265159332089155, 17.952818990685, 55546800.0, 18.261765),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 18.3398501646887, 18.594476, 18.750646512324263, 18.265159580162937, 59456200.0, 18.594476),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 28.9697217861141, 28.666877, 29.129115834139757, 28.642966418408577, 33311100.0, 28.666877),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 28.77047987811849, 28.78642, 28.874087084000195, 28.42778439244032, 33447200.0, 28.78642),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 28.61109006365658, 28.371997, 28.682817026394048, 28.308241293721427, 35229700.0, 28.371997)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 865.7881616017199, 898.571878, 898.571878, 860.4235832671982, 313800.0, 898.571878),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 894.8464588455868, 895.889592, 900.3600987973883, 887.2466270934052, 194700.0, 895.889592),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 895.8895955435028, 925.991023, 931.5045735634734, 895.5915468541419, 260800.0, 925.991023),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 911.6610469192525, 898.037915, 917.8533444263132, 894.7870052510244, 469900.0, 898.037915),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 901.9080985890064, 896.954338, 910.267746643961, 886.7370006977735, 424500.0, 896.954338),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 893.0841453587985, 902.527368, 913.2091120530531, 883.9504756668421, 578700.0, 902.527368)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 10.936653927290271, 11.193668, 11.22072286046664, 10.787855914674074, 8308500.0, 11.193668),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 11.159851075691622, 10.902837, 11.19366812986941, 10.841965085041682, 5714800.0, 10.902837),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 10.990762162162163, 11.261304, 11.274831091891894, 10.936653794594598, 7310900.0, 11.261304),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 44.768480350359695, 44.43069, 44.9786602621605, 44.408171393954575, 4189400.0, 44.43069),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 44.85855725770114, 44.663391, 44.881078866443545, 44.4156765738356, 5471700.0, 44.663391),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 44.82853338007995, 44.22051, 44.993673827524866, 44.16045988356849, 4346000.0, 44.22051)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 14.886181363807465, 15.122201, 15.169406545668119, 14.852463068734119, 9358800.0, 15.122201),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 15.125573402189678, 15.085113, 15.145802760352447, 14.909782792256314, 6184400.0, 15.085113),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 15.037907693326122, 15.145803, 15.223354100363185, 14.950243430999265, 7796000.0, 15.145803),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 23.94708621002241, 23.718655, 24.061300863241662, 23.684390489819187, 7729800.0, 23.718655),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 23.726268838284884, 23.707233, 23.893783453758374, 23.6044394732616, 8346400.0, 23.707233),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 23.627283335047604, 23.364588, 23.68058368331712, 23.307481245430495, 11729200.0, 23.364588)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 19.190001, 19.57, 19.68, 18.549999, 6484000.0, 19.57),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 19.59, 20.52, 20.530001, 19.41, 8757000.0, 20.52),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 20.4, 20.700001, 21.17, 20.299999, 7698100.0, 20.700001),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 92.669998, 94.25, 95.290001, 92.5, 7113700.0, 94.25),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 95.269997, 94.449997, 95.900002, 92.099998, 7587900.0, 94.449997),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 93.809998, 92.639999, 94.370003, 92.449997, 5755200.0, 92.639999)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 11.70468606253518, 11.831806, 11.848596000438516, 11.62313624225723, 5370700.0, 11.831806),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 11.879775579110952, 11.848596, 11.925347135397914, 11.81261797586233, 3661400.0, 11.848596),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 11.872579783247925, 12.071656, 12.112430068852149, 11.812617451697154, 6230400.0, 12.071656),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 48.10890278095504, 47.96282300000001, 48.31449654674363, 47.8492048515543, 10633100.0, 47.962823),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 48.15218845548231, 48.222521, 48.6337085275658, 47.96282253209653, 9596200.0, 48.222521),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 48.206293062442924, 47.773463, 48.22252144402569, 47.44884126472215, 8596000.0, 47.773463)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 13.353779766684667, 14.134602, 14.322684545051876, 13.34808090010818, 14491200.0, 14.134602),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 14.037712104583179, 13.96362, 14.106105342607945, 13.735642539917446, 11503900.0, 13.96362),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 14.083307981132076, 14.801437, 14.983818973045823, 13.997815861323183, 16651300.0, 14.801437),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 15.88433032772653, 15.756093, 16.09805920727075, 15.738994689636462, 17079600.0, 15.756093),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 15.978371346763314, 15.730445, 15.978371346763314, 15.68769922554348, 18993900.0, 15.730445),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 15.568010370166645, 15.610757, 15.738994324753557, 15.559462925014072, 19743300.0, 15.610757)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 6.6438354050767, 6.837554, 6.851902283251836, 6.6438354050767, 3274500.0, 6.837554),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 6.839351051019354, 6.738905, 6.853699333791358, 6.686888461564976, 3304700.0, 6.738905),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 6.703026461108528, 6.729934, 6.8698454176105, 6.6994392556163636, 3739700.0, 6.729934),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 52.933294079944574, 52.151581, 52.933294079944574, 52.151581, 3748800.0, 52.151581),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 52.30791797240658, 52.523827, 52.85140071120903, 51.69743925249971, 4529000.0, 52.523827),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 52.45682255070821, 52.136693, 52.50148827565283, 51.742111392331005, 4671700.0, 52.136693)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 29.63716553895048, 30.208475, 30.275687921700545, 29.63716553895048, 2627200.0, 30.208475),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 30.357837752894074, 30.320495, 30.54454031521067, 30.05911253297214, 1451600.0, 30.320495),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 30.376506924164417, 30.309294, 30.469858207726112, 30.264487250916062, 1946800.0, 30.309294),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 72.42560272582985, 71.758047, 72.90012592940852, 71.46046022162572, 966200.0, 71.758047),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 72.44168630145917, 71.621321, 72.46581315508048, 71.51676030911933, 836900.0, 71.621321),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 70.90551070573392, 71.57306, 72.00737312329123, 70.90551070573392, 825500.0, 71.57306)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 19.250887137748833, 19.720063, 19.731060417494174, 19.250887137748833, 2932600.0, 19.720063),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 19.518463953160275, 19.485475, 19.665082255849327, 19.434158850639584, 2150000.0, 19.485475),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 19.485475047128126, 19.910666, 19.958317076779565, 19.467148217427575, 2743800.0, 19.910666),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 31.814650475692563, 31.753981, 32.05327894718434, 31.68522075090606, 2143800.0, 31.753981),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 31.6245548373523, 31.847005, 31.98856441502551, 31.6245548373523, 1836800.0, 31.847005),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 31.72162356030816, 31.531528000000005, 32.00878817851797, 31.531528000000005, 2375000.0, 31.531528)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 24.450001, 25.219999, 25.26, 24.040001, 849400.0, 25.219999),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 25.190001, 25.48, 25.5, 24.85, 715100.0, 25.48),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 25.450001, 25.959999, 25.99, 25.4, 934800.0, 25.959999),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 55.849998, 54.799999, 55.849998, 54.349998, 196300.0, 54.799999),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 54.849998, 54.700001, 55.0, 54.5, 59800.0, 54.700001),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 54.700001, 54.200001, 54.700001, 53.5, 350900.0, 54.200001)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 26.215196246842293, 26.80528, 26.930068203536624, 25.924991122338504, 20805100.0, 26.80528),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 26.708546912558475, 26.88267, 26.929102823317745, 26.3409537279597, 16815900.0, 26.88267),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 26.814959111111108, 27.42439, 27.76296271604938, 26.795612098765428, 22526100.0, 27.42439),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 23.912906377858004, 24.11605, 24.37723465703971, 23.87421235459286, 18127600.0, 24.11605),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 24.251482084168337, 24.1354, 24.357890661322646, 24.009644408817636, 11244400.0, 24.1354),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 23.8645360750714, 23.70976, 23.96127112199102, 23.53563691554467, 16148000.0, 23.70976)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 29.566692921370844, 30.153905999999996, 30.184813325104642, 29.535788343461892, 6608800.0, 30.153906),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 30.098963946993827, 29.824243, 30.19511511088348, 29.74182815817961, 5519000.0, 29.824243),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 29.910093079598774, 30.164208, 30.229454929344396, 29.865452178802556, 5391600.0, 30.164208),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 55.99089346012193, 56.059172, 56.33988741613521, 55.854330310892486, 6901300.0, 56.059172),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 56.188147491924596, 56.332299, 56.51438168141955, 56.006064810505045, 6637900.0, 56.332299),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 56.332299375709596, 55.70259, 56.33988773474469, 55.55844380175235, 7996700.0, 55.70259)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 23.122467532034253, 23.520433, 23.533923354846298, 23.122467532034253, 907600.0, 23.520433),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 23.432748311065627, 23.142705, 23.432748311065627, 22.980820063222964, 898200.0, 23.142705),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 23.250627649650106, 23.58114, 23.74302560995897, 23.216899738404454, 1577900.0, 23.58114),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 40.799040664599275, 40.348264, 40.821959945049045, 40.32534166344242, 769800.0, 40.348264),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 40.47050763895162, 40.432304, 40.76083558308887, 40.348263328965054, 641400.0, 40.432304),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 40.22602045710216, 40.057933, 40.48578962017673, 39.99680931592855, 718700.0, 40.057933)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 17.70343360210802, 18.027246, 18.029718350397534, 17.666355267341917, 1956000.0, 18.027246),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 17.827026642222066, 17.864103, 17.943202146716402, 17.77264556172883, 800000.0, 17.864103),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 18.02724587190265, 18.514202, 18.56363813143284, 18.02724587190265, 1837000.0, 18.514202),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 50.09018067051819, 49.974502, 50.43722520598857, 49.93796788792103, 1949000.0, 49.974502),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 50.80254001978732, 50.966928, 51.07043147544676, 50.558998956467896, 1702000.0, 50.966928),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 50.44940612312246, 50.291103, 50.985193300341166, 49.97450284226648, 907000.0, 50.291103)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 6.65857463357843, 6.716189, 6.790264613970588, 6.502192781862745, 4526400.0, 6.716189),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 6.71618852173913, 6.814956, 6.814956, 6.691496652173913, 1546600.0, 6.814956),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 6.773802912322276, 6.946646, 6.971337869668248, 6.773802912322276, 3188200.0, 6.946646),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 13.475747156531986, 13.360218, 13.558268572064945, 13.35196503323255, 3326900.0, 13.360218),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 13.376721329008568, 13.484, 13.525259884700123, 13.285948592411263, 2806700.0, 13.484),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 13.467495014978692, 13.360218, 13.475747156531986, 13.285947900806185, 3127400.0, 13.360218)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 58.225560171532656, 59.550815, 60.53406689999011, 58.14006179066585, 4025400.0, 59.550815),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 59.55936732449488, 60.174962, 60.36306305682388, 59.525166432798876, 2342800.0, 60.174962),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 59.86716169992876, 62.415067, 62.79126911383746, 59.85006424657534, 4337600.0, 62.415067),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 191.9165607058648, 189.299672, 194.52450914400822, 189.299672, 5304600.0, 189.299672),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 191.53250697727069, 189.290746, 191.81831599483982, 189.17463505392678, 4209500.0, 189.290746),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 188.9781433530435, 192.068392, 193.6224356025759, 187.1114976176029, 5834300.0, 192.068392)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 39.54822109560649, 40.079434, 40.14754043627043, 39.20088937164338, 2066400.0, 40.079434),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 39.670808476763895, 39.984088, 40.09986682888698, 39.670808476763895, 1404100.0, 39.984088),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 39.68442889965812, 39.841069, 39.97046666271677, 39.568650072100205, 2046200.0, 39.841069),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 80.3758629100081, 79.213978, 80.47145870839717, 79.08161153223512, 1208500.0, 79.213978),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 79.09631628854521, 78.522729, 80.03758747243558, 78.20651948221634, 1488800.0, 78.522729),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 78.1771047837341, 77.40497, 78.86835336085213, 77.40497, 1329500.0, 77.40497)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 8.295, 8.8, 8.83, 8.25, 19640400.0, 8.8),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 8.75, 9.05, 9.175, 8.675, 15090600.0, 9.05),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 8.924999528775107, 9.47, 9.594999993400213, 8.89000003062302, 21209400.0, 9.47),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 23.6, 23.709999, 24.15, 23.57, 16041500.0, 23.709999),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 23.66, 23.450001, 23.709999, 23.209999, 13773000.0, 23.450001),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 23.219999, 23.26, 23.43, 23.110001, 14782600.0, 23.26)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 15.950346703961994, 16.430717, 16.474694962543072, 15.916516747360163, 9904200.0, 16.430717),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 16.254806307248405, 16.20068, 16.45101484760273, 16.20068, 7808000.0, 16.20068),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 16.170233670719593, 16.522055, 16.620159268469592, 16.170233670719593, 8097400.0, 16.522055),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 24.434093106075682, 24.068693, 24.537357334609382, 23.997201830313823, 18016800.0, 24.068693),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 24.243449920903952, 23.901881, 24.29111070056497, 23.75095519774011, 12907200.0, 23.901881),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 23.901880574300083, 23.981316, 24.283166804797393, 23.631802827697822, 12947700.0, 23.981316)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 24.43811102163224, 24.738167, 24.858191125019278, 24.43811102163224, 565700.0, 24.738167),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 25.33828544698545, 25.658348, 25.765034850874535, 25.304946264510086, 663500.0, 25.658348),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 25.658348619169654, 26.018419, 26.018419, 25.605006192640644, 322600.0, 26.018419),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 39.21593868380651, 39.065244, 39.302047266385884, 38.97195958260844, 1009600.0, 39.065244),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 39.54602565353003, 39.345103, 39.54602565353003, 39.18723391939878, 1052300.0, 39.345103),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 39.2876960175346, 38.97196, 39.409683775481426, 38.82844330221905, 844800.0, 38.97196)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 6.394037478465656, 6.600764, 6.727702508538737, 6.375903146760566, 23026300.0, 6.600764),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 6.655165812067205, 6.734956, 6.800237562201832, 6.62252503096629, 13645700.0, 6.734956),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 6.8727740648015265, 7.12665, 7.224573435114505, 6.858266889229007, 26119000.0, 7.12665),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 20.109076380705762, 19.900852, 20.294164333510178, 19.862291158297523, 17697900.0, 19.900852),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 19.87000334923379, 19.804452, 20.051235296601, 19.762035150869924, 15323000.0, 19.804452),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 19.777459573983222, 19.465123, 19.781315581069435, 19.43427417210888, 18880100.0, 19.465123)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 40.04883201390444, 40.996394, 41.073743749351706, 40.02949796070265, 169300.0, 40.996394),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 40.77400491490287, 40.744999, 40.90937326398605, 40.62897243970034, 149700.0, 40.744999),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 40.79334343545627, 41.373483, 41.57653020386702, 40.79334343545627, 209700.0, 41.373483),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 55.23883395123288, 54.267471, 55.23883395123288, 54.18817408283211, 472500.0, 54.267471),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 54.5945645877981, 53.821436, 54.5945645877981, 53.821436, 284300.0, 53.821436),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 53.92055764205211, 53.821436, 54.37650252592888, 53.603377902877526, 450400.0, 53.821436)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 29.628009049156823, 30.317358999999996, 30.387703013753246, 29.628009049156823, 3522600.0, 30.317359),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 30.451010204063746, 30.528387000000002, 30.59169471205955, 30.0922650955549, 3153400.0, 30.528387),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 30.422873223297792, 30.218881000000003, 30.72534340794561, 30.099301171047067, 4139400.0, 30.218881),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 59.160283917612155, 58.929787, 59.821035908903454, 58.84527154037375, 3429200.0, 58.929787),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 59.16028330728655, 59.183332, 59.40614422492722, 58.82990769920689, 2418600.0, 59.183332),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 59.10650129284582, 58.315138, 59.10650129284582, 58.199889158105684, 3707600.0, 58.315138)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 61.111172563628344, 62.483845, 62.483845, 60.63810308449412, 7864500.0, 62.483845),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 62.584660778523514, 63.32141099999999, 63.32141099999999, 62.20465632062799, 5962300.0, 63.321411),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 63.515291682174976, 64.82592, 65.76430761496579, 63.44549155796298, 7921300.0, 64.82592),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 90.28813667954218, 89.528451, 90.91712633868254, 89.43859580118877, 4513600.0, 89.528451),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 90.4760187519439, 89.928714, 90.4760187519439, 89.12818994442252, 5834500.0, 89.928714),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 89.45493654529305, 88.303153, 89.85519897974466, 87.61698929343463, 5732300.0, 88.303153)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 5.042597308873048, 5.533108, 5.59246860725358, 5.042597308873048, 4750700.0, 5.533108),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 5.5299837303843, 5.508114, 5.539356293446611, 5.383144201355194, 1901500.0, 5.508114),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 5.514362555842793, 5.779928, 5.873655197606526, 5.504989992296741, 6515900.0, 5.779928),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 11.845091975344008, 11.888711, 11.917790188216921, 11.791779726395307, 1106200.0, 11.888711),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 11.92263622731535, 11.723929, 11.93717606423768, 11.660924009325692, 2007300.0, 11.723929),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 11.791780557030567, 11.874172, 11.966255698622458, 11.636691865389716, 2134600.0, 11.874172)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 24.705632937535015, 25.037394999999997, 25.09386360639248, 24.684457386606642, 12798800.0, 25.037395),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 24.8821011971831, 25.05857, 25.15033448334, 24.846808142494933, 9221900.0, 25.05857),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 25.02327705075492, 25.679741, 25.835031429507602, 24.99504133631002, 11925100.0, 25.679741),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 74.5094137939768, 73.613509, 74.6430175610821, 73.613509, 14365600.0, 73.613509),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 73.91214802764419, 74.658733, 74.7373195682372, 73.49562617035579, 17368200.0, 74.658733),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 74.35224010272974, 73.62923, 74.62729702119944, 73.48777134788043, 13990900.0, 73.62923)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 24.056055707641196, 24.462408, 24.543679271176345, 23.722847640611562, 4933500.0, 24.462408),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 25.275112154850753, 26.136579, 26.136579, 25.210095789179107, 6986100.0, 26.136579),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 25.925275236080278, 25.559559, 26.234102153460693, 25.52705000518124, 4801400.0, 25.559559),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 32.0472035137404, 32.14772, 32.42413175164535, 31.96344354446473, 3578900.0, 32.14772),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 32.1644728964776, 32.348746, 32.66704108407667, 32.1644728964776, 3901800.0, 32.348746),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 32.189600081428566, 31.896436, 32.348746368856915, 31.829425008958772, 4065000.0, 31.896436)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 38.27980846424792, 38.997788, 39.005347978458985, 38.18155670781228, 7545500.0, 38.997788),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 39.0053472267711, 37.788555, 39.0053472267711, 37.675187823457804, 8389300.0, 37.788555),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 37.939709222392096, 37.93215, 38.204227590597284, 37.53914828003284, 7438400.0, 37.93215),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 38.76730924631587, 38.413491, 38.839681324817015, 38.292870065030534, 10758400.0, 38.413491),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 38.5984406573028, 38.662773, 38.97638452620641, 38.41348979581989, 8610900.0, 38.662773),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 38.46977940142604, 38.220497, 38.66277321404939, 38.059672575440075, 12176400.0, 38.220497)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 17.750211491510107, 18.24144, 18.26343603952717, 17.706221611986397, 12884400.0, 18.24144),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 16.511143378444498, 15.675320999999999, 16.606456373080277, 15.5800087385411, 65004600.0, 15.675321),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 15.829288323098075, 15.997919, 16.09323272446925, 15.689984720439961, 23925400.0, 15.997919),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 21.24092465819948, 21.075595, 21.24092465819948, 21.028357167516063, 13361100.0, 21.075595),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 21.051976044227885, 21.004739, 21.264542743253376, 20.74493525674663, 13743400.0, 21.004739),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 20.87090007272086, 21.209433, 21.39838038387601, 20.674079061095807, 16689900.0, 21.209433)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 19.462467816539483, 19.949417, 20.0323021437489, 19.452106655538724, 1033400.0, 19.949417),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 19.99603953586255, 20.115188999999997, 20.255055605447097, 19.892435180157293, 672000.0, 20.115189),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 19.830269523599227, 20.151451, 20.19807389194741, 19.76292690043826, 1130000.0, 20.151451),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 31.809542936385892, 31.624676, 31.84035357892923, 31.50143034870078, 1405700.0, 31.624676),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 31.291914139242795, 31.273428, 31.52608032472906, 31.17483197083744, 1041400.0, 31.273428),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 31.27342868671222, 31.051587, 31.692461819854373, 30.90985582119182, 934000.0, 31.051587)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 24.001995070779365, 24.642049, 24.671140145358965, 24.001995070779365, 2122500.0, 24.642049),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 24.8020608888093, 24.860249, 25.049354906370713, 24.649321642766267, 2303000.0, 24.860249),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 24.765693891310406, 24.823882, 25.13663526537494, 24.700233905534258, 2234100.0, 24.823882),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 71.13399152957726, 70.256574, 71.13399152957726, 69.82182191042544, 2890200.0, 70.256574),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 70.35143214730878, 69.758583, 70.43838414604626, 69.1499269134929, 2928100.0, 69.758583),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 69.67163156457256, 69.134115, 69.78229673963162, 68.96021179158451, 3184200.0, 69.134115)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 24.759697140062418, 25.032403, 25.092610391697704, 24.593238743418304, 12584000.0, 25.032403),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 24.82698585992075, 24.876568999999996, 24.9899018916097, 24.628654362099624, 7803400.0, 24.876569),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 24.667613242365668, 25.234277, 25.393650318556755, 24.440947455979703, 12500600.0, 25.234277),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 36.7432338818918, 36.27082, 36.769478174111384, 36.14834342856593, 19281700.0, 36.27082),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 36.48078296392805, 35.955877, 36.64700060506385, 35.72842063593288, 23522900.0, 35.955877),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 35.78965913691997, 36.095851, 36.39329622382187, 35.52720834368075, 24663300.0, 36.095851)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')]), rec.array([ (datetime.date(2003, 1, 2), 2003, 1, 2, 731217.0, 25.376376826198626, 25.685137, 26.0131951671138, 24.893938572184144, 6977600.0, 25.685137),
(datetime.date(2003, 1, 3), 2003, 1, 3, 731218.0, 25.685135867609233, 26.244768, 26.418448002355337, 25.472859880330653, 5426500.0, 26.244768),
(datetime.date(2003, 1, 6), 2003, 1, 6, 731221.0, 26.2447687119236, 27.190353, 27.364027217668742, 26.07108677505767, 4950100.0, 27.190353),
...,
(datetime.date(2007, 12, 27), 2007, 12, 27, 733037.0, 33.06074370825039, 33.14026, 33.71679237929851, 33.06074370825039, 5288600.0, 33.14026),
(datetime.date(2007, 12, 28), 2007, 12, 28, 733038.0, 33.100506, 33.100506, 33.418589070689585, 32.9414614825705, 3641600.0, 33.100506),
(datetime.date(2007, 12, 31), 2007, 12, 31, 733041.0, 32.88181870401253, 32.822179, 33.18002318824439, 32.74265873196449, 4855000.0, 32.822179)],
dtype=[('date', 'O'), ('year', '<i2'), ('month', 'i1'), ('day', 'i1'), ('d', '<f8'), ('open', '<f8'), ('close', '<f8'), ('high', '<f8'), ('low', '<f8'), ('volume', '<f8'), ('aclose', '<f8')])]

``````

Learn a graphical structure from the correlations

``````

In [3]:

edge_model = covariance.GraphLassoCV()

# standardize the time series: using correlations rather than covariance
# is more efficient for structure recovery
X = variation.copy().T
X /= X.std(axis=0)
edge_model.fit(X)

``````
``````

Out[3]:

GraphLassoCV(alphas=4, assume_centered=False, cv=None, enet_tol=0.0001,
max_iter=100, mode='cd', n_jobs=1, n_refinements=4, tol=0.0001,
verbose=False)

``````

Quote More precisely if one uses `assume_centered=False`, then the test set is supposed to have the same mean vector as the training set. If not so, both should be centered by the user, and `assume_centered=True` should be used.

Jethro: It means that here the test case should habe same mean vector as the training set.

Cluster using affinity propagation

``````

In [4]:

_, labels = cluster.affinity_propagation(edge_model.covariance_)
n_labels = labels.max()

for i in range(n_labels + 1):
print('Cluster %i: %s' % ((i + 1), ', '.join(names[labels == i])))

``````
``````

Cluster 1: Northrop Grumman, Raytheon, General Dynamics, Lookheed Martin, Boeing
Cluster 2: SAP, Cisco, 3M, Texas instruments, Microsoft, Dell, HP, IBM
Cluster 3: Chevron, ConocoPhillips, Valero Energy, Total, Exxon
Cluster 4: Kraft Foods
Cluster 5: DuPont de Nemours, Ford, American express, Ryder, JPMorgan Chase, General Electrics, Pfizer, AIG, Mc Donalds, Goldman Sachs, Wells Fargo, Wal-Mart, Home Depot, Bank of America
Cluster 6: Marriott, Caterpillar, Honda, Unilever, Toyota, Mitsubishi, Canon, Navistar, Xerox, Sony
Cluster 7: Apple, Amazon, Yahoo
Cluster 8: Comcast, Cablevision, Time Warner
Cluster 9: Kimberly-Clark, Colgate-Palmolive, Procter Gamble
Cluster 10: Sanofi-Aventis, Novartis, GlaxoSmithKline
Cluster 11: Coca Cola, Kellogg, Pepsi
Cluster 12: CVS, Walgreen

``````

Find a low-dimension embedding for visualization: find the best position of the nodes (the stocks) on a 2D plane

``````

In [5]:

# We use a dense eigen_solver to achieve reproducibility (arpack is
# initiated with random vectors that we don't control). In addition, we
# use a large number of neighbors to capture the large-scale structure.
node_position_model = manifold.LocallyLinearEmbedding(
n_components=2, eigen_solver='dense', n_neighbors=6)

embedding = node_position_model.fit_transform(X.T).T

``````

Visualization

``````

In [6]:

plt.figure(1, facecolor='w', figsize=(10, 8))
plt.clf()
ax = plt.axes([0., 0., 1., 1.])
plt.axis('off')

# Display a graph of the partial correlations
partial_correlations = edge_model.precision_.copy()
d = 1 / np.sqrt(np.diag(partial_correlations))
partial_correlations *= d
partial_correlations *= d[:, np.newaxis]
non_zero = (np.abs(np.triu(partial_correlations, k=1)) > 0.02)

# Plot the nodes using the coordinates of our embedding
plt.scatter(embedding[0], embedding[1], s=100 * d ** 2, c=labels,
cmap=plt.cm.spectral)

# Plot the edges
start_idx, end_idx = np.where(non_zero)
#a sequence of (*line0*, *line1*, *line2*), where::
#            linen = (x0, y0), (x1, y1), ... (xm, ym)
segments = [[embedding[:, start], embedding[:, stop]]
for start, stop in zip(start_idx, end_idx)]
values = np.abs(partial_correlations[non_zero])
lc = LineCollection(segments,
zorder=0, cmap=plt.cm.hot_r,
norm=plt.Normalize(0, .7 * values.max()))
lc.set_array(values)
lc.set_linewidths(15 * values)

# Add a label to each node. The challenge here is that we want to
# position the labels to avoid overlap with other labels
for index, (name, label, (x, y)) in enumerate(
zip(names, labels, embedding.T)):

dx = x - embedding[0]
dx[index] = 1
dy = y - embedding[1]
dy[index] = 1
this_dx = dx[np.argmin(np.abs(dy))]
this_dy = dy[np.argmin(np.abs(dx))]
if this_dx > 0:
horizontalalignment = 'left'
x = x + .002
else:
horizontalalignment = 'right'
x = x - .002
if this_dy > 0:
verticalalignment = 'bottom'
y = y + .002
else:
verticalalignment = 'top'
y = y - .002
plt.text(x, y, name, size=10,
horizontalalignment=horizontalalignment,
verticalalignment=verticalalignment,
bbox=dict(facecolor='w',
edgecolor=plt.cm.spectral(label / float(n_labels)),
alpha=.6))

plt.xlim(embedding[0].min() - .15 * embedding[0].ptp(),
embedding[0].max() + .10 * embedding[0].ptp(),)
plt.ylim(embedding[1].min() - .03 * embedding[1].ptp(),
embedding[1].max() + .03 * embedding[1].ptp())

plt.show()

``````
``````

``````