% matplotlib inline
import matplotlib.pyplot as plt
import datetime
import pandas as pd
yhoo = DataReader("yhoo", "yahoo", datetime.datetime(2007, 1, 1),
datetime.datetime(2012,1,1))
top = plt.subplot2grid((4,4), (0, 0), rowspan=3, colspan=4)
top.plot(yhoo.index, yhoo["Close"])
plt.title('Yahoo Price from 2007 - 2012')
bottom = plt.subplot2grid((4,4), (3,0), rowspan=1, colspan=4)
bottom.bar(yhoo.index, yhoo['Volume'])
plt.title('Yahoo Trading Volume')
plt.gcf().set_size_inches(15,8)
mavg = yhoo['30_MA_Open'] = pd.stats.moments.rolling_mean(yhoo['Open'], 30)
yhoo['30_MA_Open'].tail()
yhoo[160:165]
yhoo.ix['2010-01-04']
yhoo.Volume.plot()
yhoo.plot(subplots = True, figsize = (8, 8));
plt.legend(loc = 'best')
plt.show()
close_px = yhoo['Adj Close']
mavg = pd.rolling_mean(close_px, 30)
yhoo.Close.plot(label='Yahoo')
mavg.plot(label='mavg')
plt.legend()
plt.gcf().set_size_inches(15,8)
yhoo.Close.plot(kind='kde')