In [ ]:
import numpy as np
from bokeh.sampledata.stocks import AAPL, FB, GOOG, IBM, MSFT
from bokeh.plotting import figure, show, output_notebook

In [ ]:
output_notebook()

In [ ]:
p1 = figure(x_axis_type = "datetime")

p1.line(np.array(AAPL['date'], dtype=np.datetime64), AAPL['adj_close'], color='#A6CEE3', legend='AAPL')
p1.line(np.array(FB['date'], dtype=np.datetime64), FB['adj_close'], color='#1F78B4', legend='FB')
p1.line(np.array(GOOG['date'], dtype=np.datetime64), GOOG['adj_close'], color='#B2DF8A', legend='GOOG')
p1.line(np.array(IBM['date'], dtype=np.datetime64), IBM['adj_close'], color='#33A02C', legend='IBM')
p1.line(np.array(MSFT['date'], dtype=np.datetime64), MSFT['adj_close'], color='#FB9A99', legend='MSFT')

p1.title = "Stock Closing Prices"
p1.grid.grid_line_alpha=0.3

show(p1)

In [ ]:
aapl = np.array(AAPL['adj_close'])
aapl_dates = np.array(AAPL['date'], dtype=np.datetime64)

window_size = 30
window = np.ones(window_size)/float(window_size)
aapl_avg = np.convolve(aapl, window, 'same')

In [ ]:
p2 = figure(x_axis_type="datetime")

p2.circle(aapl_dates, aapl, size=4, color='darkgrey', alpha=0.2, legend='close')
p2.line(aapl_dates, aapl_avg, color='navy', legend='avg')

p2.title = "AAPL One-Month Average"
p2.grid.grid_line_alpha=0
p2.ygrid.band_fill_color="olive"
p2.ygrid.band_fill_alpha = 0.1

show(p2)

In [ ]: