In [1]:
import seaborn as sns
import datetime
import pandas as pd
import numpy as np
import sweet_charts as sc

In [2]:
import matplotlib.pyplot as plt
%matplotlib inline

In [3]:
# run the broad function to get the rolling betas for a list of stock tickers
df = sc.get_chart_data(['BRK-B', 'AMZN', 'GOOG'])


/home/jpuser/anaconda3/envs/py27/lib/python2.7/site-packages/pandas/core/indexing.py:284: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[key] = _infer_fill_value(value)
/home/jpuser/anaconda3/envs/py27/lib/python2.7/site-packages/pandas/core/indexing.py:545: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  self.obj[item_labels[indexer[info_axis]]] = value

In [4]:
# look at the last few rows to understand how the data is structured
df.tail(15)


Out[4]:
AMZN BRK-B GOOG
2016-12-16 1.206290 0.933485 1.088248
2016-12-19 1.205595 0.934477 1.087660
2016-12-20 1.206183 0.933964 1.086916
2016-12-21 1.206742 0.933961 1.087208
2016-12-22 1.206884 0.933880 1.087294
2016-12-23 1.206145 0.933761 1.087251
2016-12-27 1.206290 0.933600 1.087186
2016-12-28 1.203998 0.933506 1.086674
2016-12-29 1.204083 0.933545 1.086697
2016-12-30 1.206866 0.933061 1.088009
2017-01-03 1.205773 0.932187 1.089995
2017-01-04 1.205148 0.932495 1.088145
2017-01-05 1.204658 0.932513 1.087981
2017-01-06 1.205562 0.932347 1.088673
2017-01-09 1.205650 0.932935 1.088465

In [5]:
# create a simple plot of the stock rolling betas
df.plot(kind='line', figsize=(12,9))


Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f3355602ed0>