Note: Download data if running for the first time
In [1]:
import bokeh
bokeh.sampledata.download()
In [2]:
import time
In [3]:
from numpy import cumprod, linspace, random
In [4]:
from bokeh.sampledata.stocks import AAPL, FB, GOOG, IBM, MSFT
from bokeh.plotting import figure, output_notebook, show
In [5]:
num_points = 300
now = time.time()
dt = 24*3600 # days in seconds
dates = linspace(now, now + num_points*dt, num_points) * 1000 # times in ms
acme = cumprod(random.lognormal(0.0, 0.04, size=num_points))
choam = cumprod(random.lognormal(0.0, 0.04, size=num_points))
In [6]:
output_notebook()
In [7]:
p1 = figure(x_axis_type = "datetime")
p1.line(dates, acme, color='#1F78B4', legend='ACME')
p1.line(dates, choam, color='#FB9A99', legend='CHOAM')
p1.title = "Stock Returns"
p1.grid.grid_line_alpha=0.3
show(p1)
Out[7]:
In [8]:
p2 = figure()
p2.scatter(acme, choam, color='#A6CEE3', legend='close')
p2.title = "ACME / CHOAM Correlations"
p2.grid.grid_line_alpha=0.3
show(p2)
Out[8]:
In [ ]: