Let's play with some financial data today!

First, steal some code from stack overflow by googling for "api for market closes":

In [10]:
import csv
import urllib2
import StringIO

url = 'http://ichart.yahoo.com/table.csv?s=AAPL&d=11&e=6&f=2014&g=d&a=8&b=7&c=1984&ignore=.csv'
response = urllib2.urlopen(url)

Let's put this in a dataframe because that's cool.

In [11]:
import pandas as pd
#apple_stock = pd.read_csv(response)
apple_stock = pd.read_csv(response, index_col='Date', parse_dates=True)
In [12]:
apple_stock
Out[12]:
Open High Low Close Volume Adj Close
Date
2014-07-16 96.97 97.10 94.74 94.78 53396300 94.78
2014-07-15 96.80 96.85 95.03 95.32 45477900 95.32
2014-07-14 95.86 96.89 95.65 96.45 42731000 96.45
2014-07-11 95.36 95.89 94.86 95.22 33988800 95.22
2014-07-10 93.76 95.55 93.52 95.04 39662200 95.04
2014-07-09 95.44 95.95 94.76 95.39 36290200 95.39
2014-07-08 96.27 96.80 93.92 95.35 65130000 95.35
2014-07-07 94.14 95.99 94.10 95.97 56305400 95.97
2014-07-03 93.67 94.10 93.20 94.03 22891800 94.03
2014-07-02 93.87 94.06 93.09 93.48 28420900 93.48
2014-07-01 93.52 94.07 93.13 93.52 38170200 93.52
2014-06-30 92.10 93.73 92.09 92.93 49482300 92.93
2014-06-27 90.82 92.00 90.77 91.98 64006800 91.98
2014-06-26 90.37 91.05 89.80 90.90 32595800 90.90
2014-06-25 90.21 90.70 89.65 90.36 36852200 90.36
2014-06-24 90.75 91.74 90.19 90.28 38988300 90.28
2014-06-23 91.32 91.62 90.60 90.83 43618200 90.83
2014-06-20 91.85 92.55 90.90 90.91 100813200 90.91
2014-06-19 92.29 92.30 91.34 91.86 35486400 91.86
2014-06-18 92.27 92.29 91.35 92.18 33493800 92.18
2014-06-17 92.31 92.70 91.80 92.08 29689800 92.08
2014-06-16 91.51 92.75 91.45 92.20 35561000 92.20
2014-06-13 92.20 92.44 90.88 91.28 54525000 91.28
2014-06-12 94.04 94.12 91.90 92.29 54749000 92.29
2014-06-11 94.13 94.76 93.47 93.86 45681000 93.86
2014-06-10 94.73 95.05 93.57 94.25 62777000 94.25
2014-06-09 92.70 93.88 91.75 93.70 75415000 93.70
2014-06-06 649.90 651.26 644.47 645.57 87484600 92.22
2014-06-05 646.20 649.37 642.61 647.35 75951400 92.48
2014-06-04 637.44 647.89 636.11 644.82 83870500 92.12
... ... ... ... ... ... ...
1984-10-18 25.63 25.75 25.63 25.63 61790400 0.40
1984-10-17 24.88 25.00 24.88 24.88 39160800 0.39
1984-10-16 24.00 24.12 23.88 23.88 29506400 0.37
1984-10-15 24.00 24.25 24.00 24.00 60816000 0.37
1984-10-12 23.75 23.88 22.50 22.75 66449600 0.35
1984-10-11 23.88 24.50 23.75 23.75 45690400 0.37
1984-10-10 24.62 24.62 23.88 23.88 91212800 0.37
1984-10-09 24.88 25.00 24.62 24.62 31315200 0.38
1984-10-08 24.88 25.00 24.88 24.88 11743200 0.39
1984-10-05 25.37 25.37 24.75 24.88 24393600 0.39
1984-10-04 25.37 25.63 25.37 25.37 31371200 0.40
1984-10-03 25.12 25.50 25.12 25.12 30105600 0.39
1984-10-02 24.75 25.63 24.75 24.75 29562400 0.39
1984-10-01 25.00 25.00 24.50 24.50 24444000 0.38
1984-09-28 25.75 25.75 24.62 25.12 58352000 0.39
1984-09-27 25.75 25.87 25.75 25.75 26482400 0.40
1984-09-26 26.13 27.25 25.75 25.75 27742400 0.40
1984-09-25 26.50 26.50 26.13 26.13 41697600 0.41
1984-09-24 26.87 27.00 26.63 26.63 19751200 0.41
1984-09-21 27.13 27.88 26.50 26.87 24959200 0.42
1984-09-20 27.13 27.38 27.13 27.13 16542400 0.42
1984-09-19 27.62 27.88 27.00 27.00 26572000 0.42
1984-09-18 28.62 28.87 27.62 27.62 24326400 0.43
1984-09-17 28.62 29.00 28.62 28.62 48188000 0.45
1984-09-14 27.62 28.50 27.62 27.88 61717600 0.43
1984-09-13 27.50 27.62 27.50 27.50 51833600 0.43
1984-09-12 26.87 27.00 26.13 26.13 33280800 0.41
1984-09-11 26.63 27.38 26.63 26.87 38096800 0.42
1984-09-10 26.50 26.63 25.87 26.37 16156000 0.41
1984-09-07 26.50 26.87 26.25 26.50 20815200 0.41

7528 rows × 6 columns

Now steal a bunch of code from this handy ipython notebook

In [32]:
apple_stock
Out[32]:
Open High Low Close Volume Adj Close
Date
2014-07-11 95.36 95.89 94.86 95.22 33988800 95.22
2014-07-10 93.76 95.55 93.52 95.04 39662200 95.04
2014-07-09 95.44 95.95 94.76 95.39 36290200 95.39
2014-07-08 96.27 96.80 93.92 95.35 65130000 95.35
2014-07-07 94.14 95.99 94.10 95.97 56305400 95.97
2014-07-03 93.67 94.10 93.20 94.03 22891800 94.03
2014-07-02 93.87 94.06 93.09 93.48 28420900 93.48
2014-07-01 93.52 94.07 93.13 93.52 38170200 93.52
2014-06-30 92.10 93.73 92.09 92.93 49482300 92.93
2014-06-27 90.82 92.00 90.77 91.98 64006800 91.98
2014-06-26 90.37 91.05 89.80 90.90 32595800 90.90
2014-06-25 90.21 90.70 89.65 90.36 36852200 90.36
2014-06-24 90.75 91.74 90.19 90.28 38988300 90.28
2014-06-23 91.32 91.62 90.60 90.83 43618200 90.83
2014-06-20 91.85 92.55 90.90 90.91 100813200 90.91
2014-06-19 92.29 92.30 91.34 91.86 35486400 91.86
2014-06-18 92.27 92.29 91.35 92.18 33493800 92.18
2014-06-17 92.31 92.70 91.80 92.08 29689800 92.08
2014-06-16 91.51 92.75 91.45 92.20 35561000 92.20
2014-06-13 92.20 92.44 90.88 91.28 54525000 91.28
2014-06-12 94.04 94.12 91.90 92.29 54749000 92.29
2014-06-11 94.13 94.76 93.47 93.86 45681000 93.86
2014-06-10 94.73 95.05 93.57 94.25 62777000 94.25
2014-06-09 92.70 93.88 91.75 93.70 75415000 93.70
2014-06-06 649.90 651.26 644.47 645.57 87484600 92.22
2014-06-05 646.20 649.37 642.61 647.35 75951400 92.48
2014-06-04 637.44 647.89 636.11 644.82 83870500 92.12
2014-06-03 628.46 638.74 628.25 637.54 73177300 91.08
2014-06-02 633.96 634.83 622.50 628.65 92337700 89.81
2014-05-30 637.98 644.17 628.90 633.00 141005200 90.43
... ... ... ... ... ... ...
1984-10-18 25.63 25.75 25.63 25.63 61790400 0.40
1984-10-17 24.88 25.00 24.88 24.88 39160800 0.39
1984-10-16 24.00 24.12 23.88 23.88 29506400 0.37
1984-10-15 24.00 24.25 24.00 24.00 60816000 0.37
1984-10-12 23.75 23.88 22.50 22.75 66449600 0.35
1984-10-11 23.88 24.50 23.75 23.75 45690400 0.37
1984-10-10 24.62 24.62 23.88 23.88 91212800 0.37
1984-10-09 24.88 25.00 24.62 24.62 31315200 0.38
1984-10-08 24.88 25.00 24.88 24.88 11743200 0.39
1984-10-05 25.37 25.37 24.75 24.88 24393600 0.39
1984-10-04 25.37 25.63 25.37 25.37 31371200 0.40
1984-10-03 25.12 25.50 25.12 25.12 30105600 0.39
1984-10-02 24.75 25.63 24.75 24.75 29562400 0.39
1984-10-01 25.00 25.00 24.50 24.50 24444000 0.38
1984-09-28 25.75 25.75 24.62 25.12 58352000 0.39
1984-09-27 25.75 25.87 25.75 25.75 26482400 0.40
1984-09-26 26.13 27.25 25.75 25.75 27742400 0.40
1984-09-25 26.50 26.50 26.13 26.13 41697600 0.41
1984-09-24 26.87 27.00 26.63 26.63 19751200 0.41
1984-09-21 27.13 27.88 26.50 26.87 24959200 0.42
1984-09-20 27.13 27.38 27.13 27.13 16542400 0.42
1984-09-19 27.62 27.88 27.00 27.00 26572000 0.42
1984-09-18 28.62 28.87 27.62 27.62 24326400 0.43
1984-09-17 28.62 29.00 28.62 28.62 48188000 0.45
1984-09-14 27.62 28.50 27.62 27.88 61717600 0.43
1984-09-13 27.50 27.62 27.50 27.50 51833600 0.43
1984-09-12 26.87 27.00 26.13 26.13 33280800 0.41
1984-09-11 26.63 27.38 26.63 26.87 38096800 0.42
1984-09-10 26.50 26.63 25.87 26.37 16156000 0.41
1984-09-07 26.50 26.87 26.25 26.50 20815200 0.41

7525 rows × 6 columns

In [13]:
apple_stock = apple_stock.sort_index()
apple_stock
Out[13]:
Open High Low Close Volume Adj Close
Date
1984-09-07 26.50 26.87 26.25 26.50 20815200 0.41
1984-09-10 26.50 26.63 25.87 26.37 16156000 0.41
1984-09-11 26.63 27.38 26.63 26.87 38096800 0.42
1984-09-12 26.87 27.00 26.13 26.13 33280800 0.41
1984-09-13 27.50 27.62 27.50 27.50 51833600 0.43
1984-09-14 27.62 28.50 27.62 27.88 61717600 0.43
1984-09-17 28.62 29.00 28.62 28.62 48188000 0.45
1984-09-18 28.62 28.87 27.62 27.62 24326400 0.43
1984-09-19 27.62 27.88 27.00 27.00 26572000 0.42
1984-09-20 27.13 27.38 27.13 27.13 16542400 0.42
1984-09-21 27.13 27.88 26.50 26.87 24959200 0.42
1984-09-24 26.87 27.00 26.63 26.63 19751200 0.41
1984-09-25 26.50 26.50 26.13 26.13 41697600 0.41
1984-09-26 26.13 27.25 25.75 25.75 27742400 0.40
1984-09-27 25.75 25.87 25.75 25.75 26482400 0.40
1984-09-28 25.75 25.75 24.62 25.12 58352000 0.39
1984-10-01 25.00 25.00 24.50 24.50 24444000 0.38
1984-10-02 24.75 25.63 24.75 24.75 29562400 0.39
1984-10-03 25.12 25.50 25.12 25.12 30105600 0.39
1984-10-04 25.37 25.63 25.37 25.37 31371200 0.40
1984-10-05 25.37 25.37 24.75 24.88 24393600 0.39
1984-10-08 24.88 25.00 24.88 24.88 11743200 0.39
1984-10-09 24.88 25.00 24.62 24.62 31315200 0.38
1984-10-10 24.62 24.62 23.88 23.88 91212800 0.37
1984-10-11 23.88 24.50 23.75 23.75 45690400 0.37
1984-10-12 23.75 23.88 22.50 22.75 66449600 0.35
1984-10-15 24.00 24.25 24.00 24.00 60816000 0.37
1984-10-16 24.00 24.12 23.88 23.88 29506400 0.37
1984-10-17 24.88 25.00 24.88 24.88 39160800 0.39
1984-10-18 25.63 25.75 25.63 25.63 61790400 0.40
... ... ... ... ... ... ...
2014-06-04 637.44 647.89 636.11 644.82 83870500 92.12
2014-06-05 646.20 649.37 642.61 647.35 75951400 92.48
2014-06-06 649.90 651.26 644.47 645.57 87484600 92.22
2014-06-09 92.70 93.88 91.75 93.70 75415000 93.70
2014-06-10 94.73 95.05 93.57 94.25 62777000 94.25
2014-06-11 94.13 94.76 93.47 93.86 45681000 93.86
2014-06-12 94.04 94.12 91.90 92.29 54749000 92.29
2014-06-13 92.20 92.44 90.88 91.28 54525000 91.28
2014-06-16 91.51 92.75 91.45 92.20 35561000 92.20
2014-06-17 92.31 92.70 91.80 92.08 29689800 92.08
2014-06-18 92.27 92.29 91.35 92.18 33493800 92.18
2014-06-19 92.29 92.30 91.34 91.86 35486400 91.86
2014-06-20 91.85 92.55 90.90 90.91 100813200 90.91
2014-06-23 91.32 91.62 90.60 90.83 43618200 90.83
2014-06-24 90.75 91.74 90.19 90.28 38988300 90.28
2014-06-25 90.21 90.70 89.65 90.36 36852200 90.36
2014-06-26 90.37 91.05 89.80 90.90 32595800 90.90
2014-06-27 90.82 92.00 90.77 91.98 64006800 91.98
2014-06-30 92.10 93.73 92.09 92.93 49482300 92.93
2014-07-01 93.52 94.07 93.13 93.52 38170200 93.52
2014-07-02 93.87 94.06 93.09 93.48 28420900 93.48
2014-07-03 93.67 94.10 93.20 94.03 22891800 94.03
2014-07-07 94.14 95.99 94.10 95.97 56305400 95.97
2014-07-08 96.27 96.80 93.92 95.35 65130000 95.35
2014-07-09 95.44 95.95 94.76 95.39 36290200 95.39
2014-07-10 93.76 95.55 93.52 95.04 39662200 95.04
2014-07-11 95.36 95.89 94.86 95.22 33988800 95.22
2014-07-14 95.86 96.89 95.65 96.45 42731000 96.45
2014-07-15 96.80 96.85 95.03 95.32 45477900 95.32
2014-07-16 96.97 97.10 94.74 94.78 53396300 94.78

7528 rows × 6 columns

In [15]:
from matplotlib.pyplot import *
In [20]:
close_px = apple_stock['Adj Close']
close_px.plot(label="AAPL")
wrong_px = apple_stock['Close']
wrong_px.plot(label="Oops")
plt.legend(loc=2)
Out[20]:
<matplotlib.legend.Legend at 0x1092dcc10>
In [22]:
apple_stock['Adj Close'].plot(label="Adj Close")
Out[22]:
<matplotlib.axes.AxesSubplot at 0x1094a9d90>
In [21]:
apple_stock['Close'][-30:-20]
Out[21]:
Date
2014-06-04    644.82
2014-06-05    647.35
2014-06-06    645.57
2014-06-09     93.70
2014-06-10     94.25
2014-06-11     93.86
2014-06-12     92.29
2014-06-13     91.28
2014-06-16     92.20
2014-06-17     92.08
Name: Close, dtype: float64
In [29]:
print close_px[:4]
print close_px.shift(1)[:4]
apple_stock['Shifted Close']=close_px.shift(1)
apple_stock
Date
1984-09-07    0.41
1984-09-10    0.41
1984-09-11    0.42
1984-09-12    0.41
Name: Adj Close, dtype: float64
Date
1984-09-07     NaN
1984-09-10    0.41
1984-09-11    0.41
1984-09-12    0.42
Name: Adj Close, dtype: float64
Out[29]:
Open High Low Close Volume Adj Close Shifted Close
Date
1984-09-07 26.50 26.87 26.25 26.50 20815200 0.41 NaN
1984-09-10 26.50 26.63 25.87 26.37 16156000 0.41 0.41
1984-09-11 26.63 27.38 26.63 26.87 38096800 0.42 0.41
1984-09-12 26.87 27.00 26.13 26.13 33280800 0.41 0.42
1984-09-13 27.50 27.62 27.50 27.50 51833600 0.43 0.41
1984-09-14 27.62 28.50 27.62 27.88 61717600 0.43 0.43
1984-09-17 28.62 29.00 28.62 28.62 48188000 0.45 0.43
1984-09-18 28.62 28.87 27.62 27.62 24326400 0.43 0.45
1984-09-19 27.62 27.88 27.00 27.00 26572000 0.42 0.43
1984-09-20 27.13 27.38 27.13 27.13 16542400 0.42 0.42
1984-09-21 27.13 27.88 26.50 26.87 24959200 0.42 0.42
1984-09-24 26.87 27.00 26.63 26.63 19751200 0.41 0.42
1984-09-25 26.50 26.50 26.13 26.13 41697600 0.41 0.41
1984-09-26 26.13 27.25 25.75 25.75 27742400 0.40 0.41
1984-09-27 25.75 25.87 25.75 25.75 26482400 0.40 0.40
1984-09-28 25.75 25.75 24.62 25.12 58352000 0.39 0.40
1984-10-01 25.00 25.00 24.50 24.50 24444000 0.38 0.39
1984-10-02 24.75 25.63 24.75 24.75 29562400 0.39 0.38
1984-10-03 25.12 25.50 25.12 25.12 30105600 0.39 0.39
1984-10-04 25.37 25.63 25.37 25.37 31371200 0.40 0.39
1984-10-05 25.37 25.37 24.75 24.88 24393600 0.39 0.40
1984-10-08 24.88 25.00 24.88 24.88 11743200 0.39 0.39
1984-10-09 24.88 25.00 24.62 24.62 31315200 0.38 0.39
1984-10-10 24.62 24.62 23.88 23.88 91212800 0.37 0.38
1984-10-11 23.88 24.50 23.75 23.75 45690400 0.37 0.37
1984-10-12 23.75 23.88 22.50 22.75 66449600 0.35 0.37
1984-10-15 24.00 24.25 24.00 24.00 60816000 0.37 0.35
1984-10-16 24.00 24.12 23.88 23.88 29506400 0.37 0.37
1984-10-17 24.88 25.00 24.88 24.88 39160800 0.39 0.37
1984-10-18 25.63 25.75 25.63 25.63 61790400 0.40 0.39
... ... ... ... ... ... ... ...
2014-06-04 637.44 647.89 636.11 644.82 83870500 92.12 91.08
2014-06-05 646.20 649.37 642.61 647.35 75951400 92.48 92.12
2014-06-06 649.90 651.26 644.47 645.57 87484600 92.22 92.48
2014-06-09 92.70 93.88 91.75 93.70 75415000 93.70 92.22
2014-06-10 94.73 95.05 93.57 94.25 62777000 94.25 93.70
2014-06-11 94.13 94.76 93.47 93.86 45681000 93.86 94.25
2014-06-12 94.04 94.12 91.90 92.29 54749000 92.29 93.86
2014-06-13 92.20 92.44 90.88 91.28 54525000 91.28 92.29
2014-06-16 91.51 92.75 91.45 92.20 35561000 92.20 91.28
2014-06-17 92.31 92.70 91.80 92.08 29689800 92.08 92.20
2014-06-18 92.27 92.29 91.35 92.18 33493800 92.18 92.08
2014-06-19 92.29 92.30 91.34 91.86 35486400 91.86 92.18
2014-06-20 91.85 92.55 90.90 90.91 100813200 90.91 91.86
2014-06-23 91.32 91.62 90.60 90.83 43618200 90.83 90.91
2014-06-24 90.75 91.74 90.19 90.28 38988300 90.28 90.83
2014-06-25 90.21 90.70 89.65 90.36 36852200 90.36 90.28
2014-06-26 90.37 91.05 89.80 90.90 32595800 90.90 90.36
2014-06-27 90.82 92.00 90.77 91.98 64006800 91.98 90.90
2014-06-30 92.10 93.73 92.09 92.93 49482300 92.93 91.98
2014-07-01 93.52 94.07 93.13 93.52 38170200 93.52 92.93
2014-07-02 93.87 94.06 93.09 93.48 28420900 93.48 93.52
2014-07-03 93.67 94.10 93.20 94.03 22891800 94.03 93.48
2014-07-07 94.14 95.99 94.10 95.97 56305400 95.97 94.03
2014-07-08 96.27 96.80 93.92 95.35 65130000 95.35 95.97
2014-07-09 95.44 95.95 94.76 95.39 36290200 95.39 95.35
2014-07-10 93.76 95.55 93.52 95.04 39662200 95.04 95.39
2014-07-11 95.36 95.89 94.86 95.22 33988800 95.22 95.04
2014-07-14 95.86 96.89 95.65 96.45 42731000 96.45 95.22
2014-07-15 96.80 96.85 95.03 95.32 45477900 95.32 96.45
2014-07-16 96.97 97.10 94.74 94.78 53396300 94.78 95.32

7528 rows × 7 columns

In [31]:
apple_stock['log returns'] = log(close_px/close_px.shift(1))
apple_stock['percent returns'] = close_px / close_px.shift(1) - 1
apple_stock
#apple_stock['return'] = 
Out[31]:
Open High Low Close Volume Adj Close Shifted Close log returns percent returns
Date
1984-09-07 26.50 26.87 26.25 26.50 20815200 0.41 NaN NaN NaN
1984-09-10 26.50 26.63 25.87 26.37 16156000 0.41 0.41 0.000000 0.000000
1984-09-11 26.63 27.38 26.63 26.87 38096800 0.42 0.41 0.024098 0.024390
1984-09-12 26.87 27.00 26.13 26.13 33280800 0.41 0.42 -0.024098 -0.023810
1984-09-13 27.50 27.62 27.50 27.50 51833600 0.43 0.41 0.047628 0.048780
1984-09-14 27.62 28.50 27.62 27.88 61717600 0.43 0.43 0.000000 0.000000
1984-09-17 28.62 29.00 28.62 28.62 48188000 0.45 0.43 0.045462 0.046512
1984-09-18 28.62 28.87 27.62 27.62 24326400 0.43 0.45 -0.045462 -0.044444
1984-09-19 27.62 27.88 27.00 27.00 26572000 0.42 0.43 -0.023530 -0.023256
1984-09-20 27.13 27.38 27.13 27.13 16542400 0.42 0.42 0.000000 0.000000
1984-09-21 27.13 27.88 26.50 26.87 24959200 0.42 0.42 0.000000 0.000000
1984-09-24 26.87 27.00 26.63 26.63 19751200 0.41 0.42 -0.024098 -0.023810
1984-09-25 26.50 26.50 26.13 26.13 41697600 0.41 0.41 0.000000 0.000000
1984-09-26 26.13 27.25 25.75 25.75 27742400 0.40 0.41 -0.024693 -0.024390
1984-09-27 25.75 25.87 25.75 25.75 26482400 0.40 0.40 0.000000 0.000000
1984-09-28 25.75 25.75 24.62 25.12 58352000 0.39 0.40 -0.025318 -0.025000
1984-10-01 25.00 25.00 24.50 24.50 24444000 0.38 0.39 -0.025975 -0.025641
1984-10-02 24.75 25.63 24.75 24.75 29562400 0.39 0.38 0.025975 0.026316
1984-10-03 25.12 25.50 25.12 25.12 30105600 0.39 0.39 0.000000 0.000000
1984-10-04 25.37 25.63 25.37 25.37 31371200 0.40 0.39 0.025318 0.025641
1984-10-05 25.37 25.37 24.75 24.88 24393600 0.39 0.40 -0.025318 -0.025000
1984-10-08 24.88 25.00 24.88 24.88 11743200 0.39 0.39 0.000000 0.000000
1984-10-09 24.88 25.00 24.62 24.62 31315200 0.38 0.39 -0.025975 -0.025641
1984-10-10 24.62 24.62 23.88 23.88 91212800 0.37 0.38 -0.026668 -0.026316
1984-10-11 23.88 24.50 23.75 23.75 45690400 0.37 0.37 0.000000 0.000000
1984-10-12 23.75 23.88 22.50 22.75 66449600 0.35 0.37 -0.055570 -0.054054
1984-10-15 24.00 24.25 24.00 24.00 60816000 0.37 0.35 0.055570 0.057143
1984-10-16 24.00 24.12 23.88 23.88 29506400 0.37 0.37 0.000000 0.000000
1984-10-17 24.88 25.00 24.88 24.88 39160800 0.39 0.37 0.052644 0.054054
1984-10-18 25.63 25.75 25.63 25.63 61790400 0.40 0.39 0.025318 0.025641
... ... ... ... ... ... ... ... ... ...
2014-06-04 637.44 647.89 636.11 644.82 83870500 92.12 91.08 0.011354 0.011419
2014-06-05 646.20 649.37 642.61 647.35 75951400 92.48 92.12 0.003900 0.003908
2014-06-06 649.90 651.26 644.47 645.57 87484600 92.22 92.48 -0.002815 -0.002811
2014-06-09 92.70 93.88 91.75 93.70 75415000 93.70 92.22 0.015921 0.016049
2014-06-10 94.73 95.05 93.57 94.25 62777000 94.25 93.70 0.005853 0.005870
2014-06-11 94.13 94.76 93.47 93.86 45681000 93.86 94.25 -0.004147 -0.004138
2014-06-12 94.04 94.12 91.90 92.29 54749000 92.29 93.86 -0.016869 -0.016727
2014-06-13 92.20 92.44 90.88 91.28 54525000 91.28 92.29 -0.011004 -0.010944
2014-06-16 91.51 92.75 91.45 92.20 35561000 92.20 91.28 0.010028 0.010079
2014-06-17 92.31 92.70 91.80 92.08 29689800 92.08 92.20 -0.001302 -0.001302
2014-06-18 92.27 92.29 91.35 92.18 33493800 92.18 92.08 0.001085 0.001086
2014-06-19 92.29 92.30 91.34 91.86 35486400 91.86 92.18 -0.003478 -0.003471
2014-06-20 91.85 92.55 90.90 90.91 100813200 90.91 91.86 -0.010396 -0.010342
2014-06-23 91.32 91.62 90.60 90.83 43618200 90.83 90.91 -0.000880 -0.000880
2014-06-24 90.75 91.74 90.19 90.28 38988300 90.28 90.83 -0.006074 -0.006055
2014-06-25 90.21 90.70 89.65 90.36 36852200 90.36 90.28 0.000886 0.000886
2014-06-26 90.37 91.05 89.80 90.90 32595800 90.90 90.36 0.005958 0.005976
2014-06-27 90.82 92.00 90.77 91.98 64006800 91.98 90.90 0.011811 0.011881
2014-06-30 92.10 93.73 92.09 92.93 49482300 92.93 91.98 0.010275 0.010328
2014-07-01 93.52 94.07 93.13 93.52 38170200 93.52 92.93 0.006329 0.006349
2014-07-02 93.87 94.06 93.09 93.48 28420900 93.48 93.52 -0.000428 -0.000428
2014-07-03 93.67 94.10 93.20 94.03 22891800 94.03 93.48 0.005866 0.005884
2014-07-07 94.14 95.99 94.10 95.97 56305400 95.97 94.03 0.020422 0.020632
2014-07-08 96.27 96.80 93.92 95.35 65130000 95.35 95.97 -0.006481 -0.006460
2014-07-09 95.44 95.95 94.76 95.39 36290200 95.39 95.35 0.000419 0.000420
2014-07-10 93.76 95.55 93.52 95.04 39662200 95.04 95.39 -0.003676 -0.003669
2014-07-11 95.36 95.89 94.86 95.22 33988800 95.22 95.04 0.001892 0.001894
2014-07-14 95.86 96.89 95.65 96.45 42731000 96.45 95.22 0.012835 0.012917
2014-07-15 96.80 96.85 95.03 95.32 45477900 95.32 96.45 -0.011785 -0.011716
2014-07-16 96.97 97.10 94.74 94.78 53396300 94.78 95.32 -0.005681 -0.005665

7528 rows × 9 columns

In [32]:
apple_stock['log returns'].plot(label="log returns")
apple_stock['percent returns'].plot(label = "percent returns")
legend(loc=2)
Out[32]:
<matplotlib.legend.Legend at 0x1094f33d0>
In [33]:
apple_stock['Mean Close 10'] = pd.rolling_mean(apple_stock['Adj Close'], 10)
apple_stock['Mean Close 40'] = pd.rolling_mean(apple_stock['Adj Close'], 40)
In [34]:
apple_stock
Out[34]:
Open High Low Close Volume Adj Close Shifted Close log returns percent returns Mean Close 10 Mean Close 40
Date
1984-09-07 26.50 26.87 26.25 26.50 20815200 0.41 NaN NaN NaN NaN NaN
1984-09-10 26.50 26.63 25.87 26.37 16156000 0.41 0.41 0.000000 0.000000 NaN NaN
1984-09-11 26.63 27.38 26.63 26.87 38096800 0.42 0.41 0.024098 0.024390 NaN NaN
1984-09-12 26.87 27.00 26.13 26.13 33280800 0.41 0.42 -0.024098 -0.023810 NaN NaN
1984-09-13 27.50 27.62 27.50 27.50 51833600 0.43 0.41 0.047628 0.048780 NaN NaN
1984-09-14 27.62 28.50 27.62 27.88 61717600 0.43 0.43 0.000000 0.000000 NaN NaN
1984-09-17 28.62 29.00 28.62 28.62 48188000 0.45 0.43 0.045462 0.046512 NaN NaN
1984-09-18 28.62 28.87 27.62 27.62 24326400 0.43 0.45 -0.045462 -0.044444 NaN NaN
1984-09-19 27.62 27.88 27.00 27.00 26572000 0.42 0.43 -0.023530 -0.023256 NaN NaN
1984-09-20 27.13 27.38 27.13 27.13 16542400 0.42 0.42 0.000000 0.000000 0.423 NaN
1984-09-21 27.13 27.88 26.50 26.87 24959200 0.42 0.42 0.000000 0.000000 0.424 NaN
1984-09-24 26.87 27.00 26.63 26.63 19751200 0.41 0.42 -0.024098 -0.023810 0.424 NaN
1984-09-25 26.50 26.50 26.13 26.13 41697600 0.41 0.41 0.000000 0.000000 0.423 NaN
1984-09-26 26.13 27.25 25.75 25.75 27742400 0.40 0.41 -0.024693 -0.024390 0.422 NaN
1984-09-27 25.75 25.87 25.75 25.75 26482400 0.40 0.40 0.000000 0.000000 0.419 NaN
1984-09-28 25.75 25.75 24.62 25.12 58352000 0.39 0.40 -0.025318 -0.025000 0.415 NaN
1984-10-01 25.00 25.00 24.50 24.50 24444000 0.38 0.39 -0.025975 -0.025641 0.408 NaN
1984-10-02 24.75 25.63 24.75 24.75 29562400 0.39 0.38 0.025975 0.026316 0.404 NaN
1984-10-03 25.12 25.50 25.12 25.12 30105600 0.39 0.39 0.000000 0.000000 0.401 NaN
1984-10-04 25.37 25.63 25.37 25.37 31371200 0.40 0.39 0.025318 0.025641 0.399 NaN
1984-10-05 25.37 25.37 24.75 24.88 24393600 0.39 0.40 -0.025318 -0.025000 0.396 NaN
1984-10-08 24.88 25.00 24.88 24.88 11743200 0.39 0.39 0.000000 0.000000 0.394 NaN
1984-10-09 24.88 25.00 24.62 24.62 31315200 0.38 0.39 -0.025975 -0.025641 0.391 NaN
1984-10-10 24.62 24.62 23.88 23.88 91212800 0.37 0.38 -0.026668 -0.026316 0.388 NaN
1984-10-11 23.88 24.50 23.75 23.75 45690400 0.37 0.37 0.000000 0.000000 0.385 NaN
1984-10-12 23.75 23.88 22.50 22.75 66449600 0.35 0.37 -0.055570 -0.054054 0.381 NaN
1984-10-15 24.00 24.25 24.00 24.00 60816000 0.37 0.35 0.055570 0.057143 0.380 NaN
1984-10-16 24.00 24.12 23.88 23.88 29506400 0.37 0.37 0.000000 0.000000 0.378 NaN
1984-10-17 24.88 25.00 24.88 24.88 39160800 0.39 0.37 0.052644 0.054054 0.378 NaN
1984-10-18 25.63 25.75 25.63 25.63 61790400 0.40 0.39 0.025318 0.025641 0.378 NaN
... ... ... ... ... ... ... ... ... ... ... ...
2014-06-04 637.44 647.89 636.11 644.82 83870500 92.12 91.08 0.011354 0.011419 89.383 82.84900
2014-06-05 646.20 649.37 642.61 647.35 75951400 92.48 92.12 0.003900 0.003908 89.969 83.30200
2014-06-06 649.90 651.26 644.47 645.57 87484600 92.22 92.48 -0.002815 -0.002811 90.516 83.72400
2014-06-09 92.70 93.88 91.75 93.70 75415000 93.70 92.22 0.015921 0.016049 91.113 84.20725
2014-06-10 94.73 95.05 93.57 94.25 62777000 94.25 93.70 0.005853 0.005870 91.600 84.71800
2014-06-11 94.13 94.76 93.47 93.86 45681000 93.86 94.25 -0.004147 -0.004138 92.072 85.21175
2014-06-12 94.04 94.12 91.90 92.29 54749000 92.29 93.86 -0.016869 -0.016727 92.224 85.67950
2014-06-13 92.20 92.44 90.88 91.28 54525000 91.28 92.29 -0.011004 -0.010944 92.309 86.11825
2014-06-16 91.51 92.75 91.45 92.20 35561000 92.20 91.28 0.010028 0.010079 92.548 86.55900
2014-06-17 92.31 92.70 91.80 92.08 29689800 92.08 92.20 -0.001302 -0.001302 92.648 86.97450
2014-06-18 92.27 92.29 91.35 92.18 33493800 92.18 92.08 0.001085 0.001086 92.654 87.39050
2014-06-19 92.29 92.30 91.34 91.86 35486400 91.86 92.18 -0.003478 -0.003471 92.592 87.82325
2014-06-20 91.85 92.55 90.90 90.91 100813200 90.91 91.86 -0.010396 -0.010342 92.461 88.07950
2014-06-23 91.32 91.62 90.60 90.83 43618200 90.83 90.91 -0.000880 -0.000880 92.174 88.31900
2014-06-24 90.75 91.74 90.19 90.28 38988300 90.28 90.83 -0.006074 -0.006055 91.777 88.46600
2014-06-25 90.21 90.70 89.65 90.36 36852200 90.36 90.28 0.000886 0.000886 91.427 88.62125
2014-06-26 90.37 91.05 89.80 90.90 32595800 90.90 90.36 0.005958 0.005976 91.288 88.79800
2014-06-27 90.82 92.00 90.77 91.98 64006800 91.98 90.90 0.011811 0.011881 91.358 88.99675
2014-06-30 92.10 93.73 92.09 92.93 49482300 92.93 91.98 0.010275 0.010328 91.431 89.21550
2014-07-01 93.52 94.07 93.13 93.52 38170200 93.52 92.93 0.006329 0.006349 91.575 89.41925
2014-07-02 93.87 94.06 93.09 93.48 28420900 93.48 93.52 -0.000428 -0.000428 91.705 89.64525
2014-07-03 93.67 94.10 93.20 94.03 22891800 94.03 93.48 0.005866 0.005884 91.922 89.89225
2014-07-07 94.14 95.99 94.10 95.97 56305400 95.97 94.03 0.020422 0.020632 92.428 90.19150
2014-07-08 96.27 96.80 93.92 95.35 65130000 95.35 95.97 -0.006481 -0.006460 92.880 90.48400
2014-07-09 95.44 95.95 94.76 95.39 36290200 95.39 95.35 0.000419 0.000420 93.391 90.75150
2014-07-10 93.76 95.55 93.52 95.04 39662200 95.04 95.39 -0.003676 -0.003669 93.859 91.00700
2014-07-11 95.36 95.89 94.86 95.22 33988800 95.22 95.04 0.001892 0.001894 94.291 91.26650
2014-07-14 95.86 96.89 95.65 96.45 42731000 96.45 95.22 0.012835 0.012917 94.738 91.57475
2014-07-15 96.80 96.85 95.03 95.32 45477900 95.32 96.45 -0.011785 -0.011716 94.977 91.82375
2014-07-16 96.97 97.10 94.74 94.78 53396300 94.78 95.32 -0.005681 -0.005665 95.103 92.03400

7528 rows × 11 columns

In [36]:
apple_stock['Adj Close'].plot(label="AAPL")
apple_stock['Mean Close 10'].plot(label="10 day avg close")
apple_stock['Mean Close 40'].plot(label="40 day avg close")
#legend()
legend(loc=2)
Out[36]:
<matplotlib.legend.Legend at 0x10a425150>
In [37]:
apple_stock['Adj Close'][-200:].plot(label="AAPL")
apple_stock['Mean Close 10'][-200:].plot(label="10 day avg close")
apple_stock['Mean Close 40'][-200:].plot(label="40 day avg close")
legend(loc=2)
Out[37]:
<matplotlib.legend.Legend at 0x10b005d10>
In [70]:
 
In [38]:
apple_stock["percent returns"].plot(figsize=(10, 6))
Out[38]:
<matplotlib.axes.AxesSubplot at 0x10b13ded0>
In [40]:
import pandas.io.data
df = pd.io.data.get_data_yahoo(['AAPL', 'GE', 'IBM', 'KO', 'MSFT', 'PEP'], 
                               start=datetime.datetime(2010, 1, 1), 
                               end=datetime.datetime(2013, 1, 1))['Adj Close']
In [41]:
df
Out[41]:
AAPL GE IBM KO MSFT PEP
Date
2010-01-04 29.22 13.33 121.91 25.02 27.48 53.54
2010-01-05 29.27 13.40 120.44 24.72 27.49 54.19
2010-01-06 28.81 13.33 119.66 24.71 27.32 53.64
2010-01-07 28.75 14.02 119.24 24.65 27.03 53.30
2010-01-08 28.94 14.32 120.44 24.19 27.22 53.13
2010-01-11 28.69 14.46 119.18 24.68 26.87 53.07
2010-01-12 28.36 14.47 120.13 24.95 26.70 53.81
2010-01-13 28.76 14.52 119.87 25.02 26.94 54.25
2010-01-14 28.60 14.41 121.78 25.06 27.49 54.90
2010-01-15 28.12 14.18 121.29 24.69 27.40 54.46
2010-01-19 29.36 14.27 123.47 24.75 27.61 54.49
2010-01-20 28.91 14.24 119.89 24.34 27.16 54.16
2010-01-21 28.41 13.82 118.74 23.85 26.64 53.28
2010-01-22 27.00 13.90 115.51 23.79 25.71 52.80
2010-01-25 27.73 14.12 116.09 23.84 26.03 52.66
2010-01-26 28.12 14.11 115.74 23.75 26.19 52.67
2010-01-27 28.39 14.06 116.28 23.91 26.34 52.71
2010-01-28 27.21 13.94 113.90 23.77 25.89 52.23
2010-01-29 26.22 13.87 112.65 23.80 25.02 52.12
2010-02-01 26.59 14.02 114.75 23.85 25.22 53.07
2010-02-02 26.74 14.54 115.54 24.15 25.27 53.46
2010-02-03 27.20 14.39 115.66 24.07 25.42 53.58
2010-02-04 26.22 13.84 113.21 23.44 24.72 52.14
2010-02-05 26.69 13.62 113.69 23.29 24.88 52.03
2010-02-08 26.51 13.46 112.68 23.09 24.61 51.55
2010-02-09 26.79 13.46 113.91 23.69 24.87 52.50
2010-02-10 26.64 13.54 113.54 23.59 24.85 52.79
2010-02-11 27.13 13.61 114.39 23.78 24.96 53.50
2010-02-12 27.36 13.42 114.64 23.68 24.80 53.26
2010-02-16 27.77 13.84 115.78 24.05 25.29 53.60
... ... ... ... ... ... ...
2012-11-16 72.69 19.02 181.33 34.76 25.37 64.96
2012-11-19 77.93 19.50 184.63 35.40 25.57 65.41
2012-11-20 77.27 19.46 183.52 35.41 25.55 65.53
2012-11-21 77.38 19.52 184.58 35.55 25.78 65.91
2012-11-23 78.73 19.86 187.68 36.06 26.50 66.75
2012-11-26 81.21 19.88 187.09 35.52 26.20 66.57
2012-11-27 80.56 19.70 185.49 35.58 25.91 66.67
2012-11-28 80.30 19.95 186.21 35.95 26.17 66.90
2012-11-29 81.19 19.94 185.78 36.35 25.78 66.87
2012-11-30 80.63 19.94 184.36 36.30 25.47 66.77
2012-12-03 80.75 19.65 183.79 35.78 25.28 66.45
2012-12-04 79.33 19.69 183.67 35.56 25.23 66.44
2012-12-05 74.22 20.04 182.98 35.71 25.51 66.81
2012-12-06 75.39 20.17 184.00 35.78 25.57 67.11
2012-12-07 73.46 20.25 186.19 36.10 25.31 67.34
2012-12-10 72.99 20.19 186.84 36.03 25.77 67.29
2012-12-11 74.58 20.30 188.37 36.24 26.14 67.49
2012-12-12 74.25 20.56 187.16 36.03 26.06 67.32
2012-12-13 72.97 20.41 186.22 35.99 25.93 67.29
2012-12-14 70.23 20.41 186.00 36.05 25.65 67.24
2012-12-17 71.47 20.70 187.81 35.90 25.93 67.44
2012-12-18 73.55 20.47 189.81 35.69 26.37 67.59
2012-12-19 72.50 19.83 189.22 35.21 26.13 66.97
2012-12-20 71.87 20.05 188.92 35.47 26.48 67.19
2012-12-21 71.54 19.89 187.61 35.31 26.26 66.73
2012-12-24 71.66 19.83 186.62 35.16 25.89 66.54
2012-12-26 70.67 19.78 186.19 34.86 25.70 65.97
2012-12-27 70.95 19.71 186.92 34.86 25.79 65.81
2012-12-28 70.20 19.47 184.13 34.43 25.40 65.19
2012-12-31 73.31 19.99 185.80 34.70 25.55 65.58

754 rows × 6 columns

In [42]:
rets = df.pct_change()
In [43]:
rets
Out[43]:
AAPL GE IBM KO MSFT PEP
Date
2010-01-04 NaN NaN NaN NaN NaN NaN
2010-01-05 0.001711 0.005251 -0.012058 -0.011990 0.000364 0.012140
2010-01-06 -0.015716 -0.005224 -0.006476 -0.000405 -0.006184 -0.010149
2010-01-07 -0.002083 0.051763 -0.003510 -0.002428 -0.010615 -0.006339
2010-01-08 0.006609 0.021398 0.010064 -0.018661 0.007029 -0.003189
2010-01-11 -0.008639 0.009777 -0.010462 0.020256 -0.012858 -0.001129
2010-01-12 -0.011502 0.000692 0.007971 0.010940 -0.006327 0.013944
2010-01-13 0.014104 0.003455 -0.002164 0.002806 0.008989 0.008177
2010-01-14 -0.005563 -0.007576 0.015934 0.001599 0.020416 0.011982
2010-01-15 -0.016783 -0.015961 -0.004024 -0.014765 -0.003274 -0.008015
2010-01-19 0.044097 0.006347 0.017973 0.002430 0.007664 0.000551
2010-01-20 -0.015327 -0.002102 -0.028995 -0.016566 -0.016298 -0.006056
2010-01-21 -0.017295 -0.029494 -0.009592 -0.020131 -0.019146 -0.016248
2010-01-22 -0.049630 0.005789 -0.027202 -0.002516 -0.034910 -0.009009
2010-01-25 0.027037 0.015827 0.005021 0.002102 0.012447 -0.002652
2010-01-26 0.014064 -0.000708 -0.003015 -0.003775 0.006147 0.000190
2010-01-27 0.009602 -0.003544 0.004666 0.006737 0.005727 0.000759
2010-01-28 -0.041564 -0.008535 -0.020468 -0.005855 -0.017084 -0.009106
2010-01-29 -0.036384 -0.005022 -0.010975 0.001262 -0.033604 -0.002106
2010-02-01 0.014111 0.010815 0.018642 0.002101 0.007994 0.018227
2010-02-02 0.005641 0.037090 0.006885 0.012579 0.001983 0.007349
2010-02-03 0.017203 -0.010316 0.001039 -0.003313 0.005936 0.002245
2010-02-04 -0.036029 -0.038221 -0.021183 -0.026174 -0.027537 -0.026876
2010-02-05 0.017925 -0.015896 0.004240 -0.006399 0.006472 -0.002110
2010-02-08 -0.006744 -0.011747 -0.008884 -0.008587 -0.010852 -0.009225
2010-02-09 0.010562 0.000000 0.010916 0.025985 0.010565 0.018429
2010-02-10 -0.005599 0.005944 -0.003248 -0.004221 -0.000804 0.005524
2010-02-11 0.018393 0.005170 0.007486 0.008054 0.004427 0.013450
2010-02-12 0.008478 -0.013960 0.002186 -0.004205 -0.006410 -0.004486
2010-02-16 0.014985 0.031297 0.009944 0.015625 0.019758 0.006384
... ... ... ... ... ... ...
2012-11-16 0.003867 0.004754 0.005880 0.003754 -0.005098 0.001696
2012-11-19 0.072087 0.025237 0.018199 0.018412 0.007883 0.006927
2012-11-20 -0.008469 -0.002051 -0.006012 0.000282 -0.000782 0.001835
2012-11-21 0.001424 0.003083 0.005776 0.003954 0.009002 0.005799
2012-11-23 0.017446 0.017418 0.016795 0.014346 0.027929 0.012745
2012-11-26 0.031500 0.001007 -0.003144 -0.014975 -0.011321 -0.002697
2012-11-27 -0.008004 -0.009054 -0.008552 0.001689 -0.011069 0.001502
2012-11-28 -0.003227 0.012690 0.003882 0.010399 0.010035 0.003450
2012-11-29 0.011083 -0.000501 -0.002309 0.011127 -0.014903 -0.000448
2012-11-30 -0.006897 0.000000 -0.007643 -0.001376 -0.012025 -0.001495
2012-12-03 0.001488 -0.014544 -0.003092 -0.014325 -0.007460 -0.004793
2012-12-04 -0.017585 0.002036 -0.000653 -0.006149 -0.001978 -0.000150
2012-12-05 -0.064414 0.017776 -0.003757 0.004218 0.011098 0.005569
2012-12-06 0.015764 0.006487 0.005574 0.001960 0.002352 0.004490
2012-12-07 -0.025600 0.003966 0.011902 0.008944 -0.010168 0.003427
2012-12-10 -0.006398 -0.002963 0.003491 -0.001939 0.018175 -0.000743
2012-12-11 0.021784 0.005448 0.008189 0.005828 0.014358 0.002972
2012-12-12 -0.004425 0.012808 -0.006424 -0.005795 -0.003060 -0.002519
2012-12-13 -0.017239 -0.007296 -0.005022 -0.001110 -0.004988 -0.000446
2012-12-14 -0.037550 0.000000 -0.001181 0.001667 -0.010798 -0.000743
2012-12-17 0.017656 0.014209 0.009731 -0.004161 0.010916 0.002974
2012-12-18 0.029103 -0.011111 0.010649 -0.005850 0.016969 0.002224
2012-12-19 -0.014276 -0.031265 -0.003108 -0.013449 -0.009101 -0.009173
2012-12-20 -0.008690 0.011094 -0.001585 0.007384 0.013395 0.003285
2012-12-21 -0.004592 -0.007980 -0.006934 -0.004511 -0.008308 -0.006846
2012-12-24 0.001677 -0.003017 -0.005277 -0.004248 -0.014090 -0.002847
2012-12-26 -0.013815 -0.002521 -0.002304 -0.008532 -0.007339 -0.008566
2012-12-27 0.003962 -0.003539 0.003921 0.000000 0.003502 -0.002425
2012-12-28 -0.010571 -0.012177 -0.014926 -0.012335 -0.015122 -0.009421
2012-12-31 0.044302 0.026708 0.009070 0.007842 0.005906 0.005983

754 rows × 6 columns

In [44]:
plt.scatter(rets.PEP, rets.KO)
plt.xlabel('Returns PEP')
plt.ylabel('Returns KO')
Out[44]:
<matplotlib.text.Text at 0x10b19bc90>
In [45]:
pd.scatter_matrix(rets, diagonal='kde', figsize=(10, 10))
Out[45]:
array([[<matplotlib.axes.AxesSubplot object at 0x10b591c10>,
        <matplotlib.axes.AxesSubplot object at 0x10b688550>,
        <matplotlib.axes.AxesSubplot object at 0x10b709410>,
        <matplotlib.axes.AxesSubplot object at 0x10b76d110>,
        <matplotlib.axes.AxesSubplot object at 0x10b7e1e90>,
        <matplotlib.axes.AxesSubplot object at 0x10c166b90>],
       [<matplotlib.axes.AxesSubplot object at 0x10c1e4a50>,
        <matplotlib.axes.AxesSubplot object at 0x10c1f2cd0>,
        <matplotlib.axes.AxesSubplot object at 0x10c3d5590>,
        <matplotlib.axes.AxesSubplot object at 0x10c456350>,
        <matplotlib.axes.AxesSubplot object at 0x10c4b9650>,
        <matplotlib.axes.AxesSubplot object at 0x10c644510>],
       [<matplotlib.axes.AxesSubplot object at 0x10c6a9050>,
        <matplotlib.axes.AxesSubplot object at 0x10c729310>,
        <matplotlib.axes.AxesSubplot object at 0x10c761490>,
        <matplotlib.axes.AxesSubplot object at 0x10c90bcd0>,
        <matplotlib.axes.AxesSubplot object at 0x10c98ca90>,
        <matplotlib.axes.AxesSubplot object at 0x10c9f1b10>],
       [<matplotlib.axes.AxesSubplot object at 0x10ca7ca90>,
        <matplotlib.axes.AxesSubplot object at 0x10cad3510>,
        <matplotlib.axes.AxesSubplot object at 0x10cc607d0>,
        <matplotlib.axes.AxesSubplot object at 0x10cc99950>,
        <matplotlib.axes.AxesSubplot object at 0x10cd4f1d0>,
        <matplotlib.axes.AxesSubplot object at 0x10cdc5f50>],
       [<matplotlib.axes.AxesSubplot object at 0x10cf27fd0>,
        <matplotlib.axes.AxesSubplot object at 0x10cfb2f50>,
        <matplotlib.axes.AxesSubplot object at 0x10c9b1e10>,
        <matplotlib.axes.AxesSubplot object at 0x10d084a10>,
        <matplotlib.axes.AxesSubplot object at 0x10d2037d0>,
        <matplotlib.axes.AxesSubplot object at 0x10d265dd0>],
       [<matplotlib.axes.AxesSubplot object at 0x10d2f3450>,
        <matplotlib.axes.AxesSubplot object at 0x10d355b50>,
        <matplotlib.axes.AxesSubplot object at 0x10d3d5e10>,
        <matplotlib.axes.AxesSubplot object at 0x10d378250>,
        <matplotlib.axes.AxesSubplot object at 0x10d4c5590>,
        <matplotlib.axes.AxesSubplot object at 0x10d648350>]], dtype=object)
In [ ]: