We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN 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`


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `zipline/examples/buyapple.py`
Content:
```
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 FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

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

{"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"}], "after_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    context.asset = symbol('AAPL')\n\n\ndef handle_data(context, data):\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# 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"}]}