{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Using DirectView and LoadBalancedView together"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We mentioned that you can use any number of views of any sort simultaneously.\n",
    "\n",
    "The most common model for doing this is to use a DirectView to initialise the engine namespaces\n",
    "(either defining functions and variables, or loading datasets) with a DirectView,\n",
    "and then submitting work as tasks via the LoadBalancedView.\n",
    "\n",
    "For this example, we are going to define a few functions for fetching data and getting a simple summary on some stocks,\n",
    "then we are going to run those functions on a series of stocks in a load-balanced way."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The usual boilerplate:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].\n",
      "For more information, type 'help(pylab)'.\n"
     ]
    }
   ],
   "source": [
    "%pylab inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from IPython import parallel\n",
    "\n",
    "rc = parallel.Client()\n",
    "dv = rc[:]\n",
    "lbv = rc.load_balanced_view()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Use matplotlib to fetch data from Yahoo\n",
    "\n",
    "Note that we are defining these functions on the engines"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%%px\n",
    "\n",
    "import urllib2\n",
    "from io import BytesIO\n",
    "\n",
    "from matplotlib import finance\n",
    "\n",
    "def get_yahoo_data(name=None, start=None, end=None):\n",
    "    \"\"\"return historical stock data from yahoo as a recarray.\"\"\"\n",
    "    fp = finance.fetch_historical_yahoo(name, start, end)\n",
    "    return finance.parse_yahoo_historical(fp, asobject=True)\n",
    "\n",
    "def relative_close(records):\n",
    "    \"\"\"return the reative change in closing price over the interval\"\"\"\n",
    "    \n",
    "    close = records['aclose']\n",
    "    return (close[-1] - close[0]) / close[0]\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Setup the timestamps.  We want the past year"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "%%px\n",
    "import datetime\n",
    "end = datetime.datetime.now()\n",
    "start = end - datetime.timedelta(days=365)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Our ticker of stocks to check"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "ticker = ['AAPL', 'GOOG', 'MSFT', 'RIMM', 'NOK', 'ORCL', 'AMZN', 'INTC', 'ATVI', 'EA', 'NFLX']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And map a simple function (that depends on the code we have defined on the engines)\n",
    "onto our ticker."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AsyncMapResult: year_over_year>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def year_over_year(name):\n",
    "    \"\"\"fetch data, and return year-over-year change (relative to first close)\n",
    " \n",
    "    in percent\n",
    "    \"\"\"\n",
    "    stock = get_yahoo_data(name, start, end)\n",
    "    return relative_close(stock) * 100\n",
    "\n",
    "amr = lbv.map(year_over_year, ticker)\n",
    "amr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.lines.Line2D at 0x110db1590>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
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644\nje9tdW3v58+fV6tWrSRVbw+HDx/WZ599psjISFVWVlrFry4NPYRa3z6l5r3Wp08fPf/88+rVq5dC\nQ0Ot9amxbNkyTZgwodahkuuvv149e/ZUdnZ2g67HpYKCgjR58mQtWbLka+/X17ZtW4+zO02hvteg\nLrfeequ2bdumkJCQRj+DWZeafc6lTNatMdS2X6nvOHn5+7CqqkorVqxQenq6VqxYoWeeeabJh1Z9\nlc+dkdq9e7d++tOfavr06Zo+fbqefPJJdezYUceOHdOmTZs0depUa97TTz+tyspKFRUVSWrcoSRJ\nuuWWW3TgwAEdOnTImlZcXKyLFy9q1KhRWrFihc6dO2fN+/TTT7V582bddtttiomJkdPp9Bimq7lG\nasyYMZKqL2RcsmSJx4WuBQUFDXbgGThwoF588cUrri377LPPrINhq1atVF5ebs3zhbtn3HfffXrj\njTfqnB8REaHi4mJ98MEH6tevX62Zu3Xrpn//+986duyYYmNjG3W9bDabkpOTtWTJElVVVUnS124/\nNeLj4zV+/HjNnTvXeh80lNq296KiIr3yyisaP368pOrtIS4uTqdOndKJEycUGBiofv366S9/+Ytc\nLpckqaKiQllZWdb/G/p3Xd8+pea9ZLPZ1K1bN7300ku64447PJ6/adMmRUVFWV9/dama7MOGDdPh\nw4d17NixBl2XS3Xu3FldunTR+vXra81UIzY2VkVFRfrXv/5lTSssLLTOQDeG+l6DuvTu3Vv79+/X\n7t27fXpYyWTdGkNt+xW3213n++3y6e+++67i4+MVExOjxMRErVy5ssEz+yufq5cbN27UU0895TFt\n4MCBevfdd3X+/Pkr/opqwIABev/996/4lHypN9980/qE2b9/f699urHZbPrVr36llStXavny5QoO\nDlZgYKCGDx+u8PBwPfjgg3r11VfldDrlcrkUFRWlxx57zDrDlJKSonfffVfZ2dmy2+2y2WwaN26c\nevToIUnq27evbDabnn32WbndbtntdnXo0OGKYQdviYuL0/vvv+9x0blUfV3UK6+8oqqqKgUFBSkp\nKcmaV1+pa+gzDTXCw8PVs2dPbdiw4YqDYI3BgwcrLy9PdrtdAQEBHtlq/n3zzTdbr01jZa8RGRmp\nAQMGaN26dZL0jbafGj169FBISIgWLlyoX/7yl7r22msbJOPl27vNZlNwcLDuuece6y/ean5vkydP\nVmZmpmbOnKkRI0Zo8+bNmjlzpgIDA2Wz2TRs2DDrDGJmZqb1SffOO++s971soq59SlZWliZOnGhN\nS0xM1MGDB69YlzfeeEMxMTE6cOCA9dhHH33U4zGS9NBDD+mJJ55okG2nrmWOHj1aaWlptW7Pl5o2\nbZpWr16tv/71rwoODlZQUJDuu+8+r+esS32vwbRp02p9js1mU9euXVVRUeEzZ0JqhvZqDBw4UDt2\n7PjW69ZYLt+v1LdtXvo+7Ny5s06dOqUJEyZIqv7AtmfPHuXm5jb6tXX+gBtyAgAAGPK5oT0AAAB/\nQZECAAAwRJECAAAwRJECAAAwRJECAAAwRJECAAAwRJECAAAw9H8sFaV+onMxRgAAAABJRU5ErkJg\ngg==\n"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, ax = subplots()\n",
    "fig.set_figwidth(10)\n",
    "ax.bar(range(len(amr)), amr)\n",
    "ax.set_xticks(np.arange(len(amr))+0.4)\n",
    "ax.set_xticklabels(ticker);\n",
    "ax.axhline(0, c='k')"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 0
}