{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from numpy import cumprod, linspace, random"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from bokeh.sampledata.stocks import AAPL, FB, GOOG, IBM, MSFT\n",
    "from bokeh.plotting import figure, show, output_notebook\n",
    "from bokeh.models import GridPlot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "num_points = 300\n",
    "\n",
    "now = time.time()\n",
    "dt = 24*3600 # days in seconds\n",
    "dates = linspace(now, now + num_points*dt, num_points) * 1000 # times in ms\n",
    "acme = cumprod(random.lognormal(0.0, 0.04, size=num_points))\n",
    "choam = cumprod(random.lognormal(0.0, 0.04, size=num_points))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "output_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p1 = figure(x_axis_type = \"datetime\")\n",
    "\n",
    "p1.line(dates, acme, color='#1F78B4', legend='ACME')\n",
    "p1.line(dates, choam, color='#FB9A99', legend='CHOAM')\n",
    "\n",
    "p1.title = \"Stock Returns\"\n",
    "p1.grid.grid_line_alpha=0.3\n",
    "\n",
    "show(p1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "p2 = figure()\n",
    "\n",
    "p2.scatter(acme, choam, color='#A6CEE3', legend='close')\n",
    "\n",
    "p2.title = \"ACME / CHOAM Correlations\"\n",
    "p2.grid.grid_line_alpha=0.3\n",
    "\n",
    "show(p2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
