prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  latest tutorial.ipynb has non working examples 
  Dear Zipline Maintainers,
  
  Before I tell you about my issue, let me describe my environment:
  # Environment
  - Operating System: (MAC OS X El Capitan`)
  - Python Version: `$ python --3.4`
  - Python Bitness: `$ python -c 'import math, sys;print(int(math.log(sys.maxsize + 1, 2) + 1))'`
  - How did you install Zipline: (`pip`)
  - Python packages: `$ pip freeze` or `$ conda list`
  
  Now that you know a little about me, let me tell you about the issue I am
  having
  # Description of Issue
  
  While going through the latest tutorial.ipynb it throws an error:
  TypeError: a float is required
  - What did you expect to happen?
    I ran the notebook and expected to see the same results as in your notebook
  - What happened instead?
    An error:
    TypeError: a float is required
  
  Here is how you can reproduce this issue on your machine:
  ## Reproduction Steps
  
  1.Run the last cell in the tutorial
  
  ...
  ## What steps have you taken to resolve this already?
  
  I was trying to identify where the errors belongs to by commenting the lines of code. I'm a beginner , so I don't know how to solve it yet. It seems like the error is thrown when accessing the line:
  short_mavg = history(100, '1d', 'price').mean()
  ...
  # Anything else?
  
  ...
  
  Sincerely,
  `$ whoami`
  
  
  </issue>
  <code>
  [start of zipline/examples/buyapple.py]
  1 #!/usr/bin/env python
  2 #
  3 # Copyright 2014 Quantopian, Inc.
  4 #
  5 # Licensed under the Apache License, Version 2.0 (the "License");
  6 # you may not use this file except in compliance with the License.
  7 # You may obtain a copy of the License at
  8 #
  9 #     http://www.apache.org/licenses/LICENSE-2.0
  10 #
  11 # Unless required by applicable law or agreed to in writing, software
  12 # distributed under the License is distributed on an "AS IS" BASIS,
  13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 # See the License for the specific language governing permissions and
  15 # limitations under the License.
  16 
  17 from zipline.api import order, record, symbol
  18 
  19 
  20 def initialize(context):
  21     pass
  22 
  23 
  24 def handle_data(context, data):
  25     order(symbol('AAPL'), 10)
  26     record(AAPL=data.current(symbol('AAPL'), 'price'))
  27 
  28 
  29 # Note: this function can be removed if running
  30 # this algorithm on quantopian.com
  31 def analyze(context=None, results=None):
  32     import matplotlib.pyplot as plt
  33     # Plot the portfolio and asset data.
  34     ax1 = plt.subplot(211)
  35     results.portfolio_value.plot(ax=ax1)
  36     ax1.set_ylabel('Portfolio value (USD)')
  37     ax2 = plt.subplot(212, sharex=ax1)
  38     results.AAPL.plot(ax=ax2)
  39     ax2.set_ylabel('AAPL price (USD)')
  40 
  41     # Show the plot.
  42     plt.gcf().set_size_inches(18, 8)
  43     plt.show()
  44 
  45 
  46 def _test_args():
  47     """Extra arguments to use when zipline's automated tests run this example.
  48     """
  49     import pandas as pd
  50 
  51     return {
  52         'start': pd.Timestamp('2014-01-01', tz='utc'),
  53         'end': pd.Timestamp('2014-11-01', tz='utc'),
  54     }
  55
  [end of zipline/examples/buyapple.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/zipline/examples/buyapple.py b/zipline/examples/buyapple.py
  --- a/zipline/examples/buyapple.py
  +++ b/zipline/examples/buyapple.py
  @@ -18,12 +18,12 @@
   
   
   def initialize(context):
  -    pass
  +    context.asset = symbol('AAPL')
   
   
   def handle_data(context, data):
  -    order(symbol('AAPL'), 10)
  -    record(AAPL=data.current(symbol('AAPL'), 'price'))
  +    order(context.asset, 10)
  +    record(AAPL=data.current(context.asset, 'price'))
   
   
   # Note: this function can be removed if running
  
verification_info: {"golden_diff": "diff --git a/zipline/examples/buyapple.py b/zipline/examples/buyapple.py\n--- a/zipline/examples/buyapple.py\n+++ b/zipline/examples/buyapple.py\n@@ -18,12 +18,12 @@\n \n \n def initialize(context):\n-    pass\n+    context.asset = symbol('AAPL')\n \n \n def handle_data(context, data):\n-    order(symbol('AAPL'), 10)\n-    record(AAPL=data.current(symbol('AAPL'), 'price'))\n+    order(context.asset, 10)\n+    record(AAPL=data.current(context.asset, 'price'))\n \n \n # Note: this function can be removed if running\n", "issue": "latest tutorial.ipynb has non working examples \nDear Zipline Maintainers,\n\nBefore I tell you about my issue, let me describe my environment:\n# Environment\n- Operating System: (MAC OS X El Capitan`)\n- Python Version: `$ python --3.4`\n- Python Bitness: `$ python -c 'import math, sys;print(int(math.log(sys.maxsize + 1, 2) + 1))'`\n- How did you install Zipline: (`pip`)\n- Python packages: `$ pip freeze` or `$ conda list`\n\nNow that you know a little about me, let me tell you about the issue I am\nhaving\n# Description of Issue\n\nWhile going through the latest tutorial.ipynb it throws an error:\nTypeError: a float is required\n- What did you expect to happen?\n  I ran the notebook and expected to see the same results as in your notebook\n- What happened instead?\n  An error:\n  TypeError: a float is required\n\nHere is how you can reproduce this issue on your machine:\n## Reproduction Steps\n\n1.Run the last cell in the tutorial\n\n...\n## What steps have you taken to resolve this already?\n\nI was trying to identify where the errors belongs to by commenting the lines of code. I'm a beginner , so I don't know how to solve it yet. It seems like the error is thrown when accessing the line:\nshort_mavg = history(100, '1d', 'price').mean()\n...\n# Anything else?\n\n...\n\nSincerely,\n`$ whoami`\n\n", "before_files": [{"content": "#!/usr/bin/env python\n#\n# Copyright 2014 Quantopian, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom zipline.api import order, record, symbol\n\n\ndef initialize(context):\n    pass\n\n\ndef handle_data(context, data):\n    order(symbol('AAPL'), 10)\n    record(AAPL=data.current(symbol('AAPL'), 'price'))\n\n\n# Note: this function can be removed if running\n# this algorithm on quantopian.com\ndef analyze(context=None, results=None):\n    import matplotlib.pyplot as plt\n    # Plot the portfolio and asset data.\n    ax1 = plt.subplot(211)\n    results.portfolio_value.plot(ax=ax1)\n    ax1.set_ylabel('Portfolio value (USD)')\n    ax2 = plt.subplot(212, sharex=ax1)\n    results.AAPL.plot(ax=ax2)\n    ax2.set_ylabel('AAPL price (USD)')\n\n    # Show the plot.\n    plt.gcf().set_size_inches(18, 8)\n    plt.show()\n\n\ndef _test_args():\n    \"\"\"Extra arguments to use when zipline's automated tests run this example.\n    \"\"\"\n    import pandas as pd\n\n    return {\n        'start': pd.Timestamp('2014-01-01', tz='utc'),\n        'end': pd.Timestamp('2014-11-01', tz='utc'),\n    }\n", "path": "zipline/examples/buyapple.py"}]}