I can't replicate the code from book "Mastering pandas for Finance" - Zipline - KeyError: 'Cost'
<p>I'm reading the book "Mastering pandas for Finance". Up until where the Zipline module is involved all was very smooth and interesting, but now when I need to recreate the books code in the Jupyter Notebook, I'm getting and error from Zipline library.</p>

<p>The book's code is:</p>

<pre><code>import zipline as zp
import zipline.utils.factory as zpf
import pandas as pd
import pandas_datareader.data as web
import numpy as np

# dates
from datetime import datetime
# zipline has its own method to load data from Yahoo! Finance
data = zpf.load_from_yahoo(stocks=['AAPL'], 
                           indexes={}, 
                           start=datetime(1990, 1, 1),
                           end=datetime(2014, 1, 1), 
                           adjusted=False)

class BuyApple(zp.TradingAlgorithm):
    """ Simple trading algorithm that does nothing
    but buy one share of AAPL every trading period.
    """

    trace=False

    def __init__(self, trace=False):
        BuyApple.trace = trace
        super(BuyApple, self).__init__()

    def initialize(context):
        if BuyApple.trace: print("---&gt; initialize")
        if BuyApple.trace: print(context)
        if BuyApple.trace: print("&lt;--- initialize")

    def handle_data(self, context):
        if BuyApple.trace: print("---&gt; handle_data")
        if BuyApple.trace: print(context)
        self.order("AAPL", 1)
        if BuyApple.trace: print("&lt;-- handle_data")  


result = BuyApple(trace=True).run(data['2000-01-03':'2000-01-07'])
</code></pre>

<p>After running it, I get long list of errors, but the last line in the Jupyter Notebook cell is:</p>

<pre><code>/Users/***/anaconda/lib/python3.4/site-packages/zipline/finance/commission.py in __repr__(self)
     83             .format(class_name=self.__class__.__name__,
     84                     cost_per_share=self.cost_per_share,
---&gt; 85                     min_trade_cost=self.min_trade_cost)
     86 
     87     def calculate(self, order, transaction):

KeyError: 'cost'
</code></pre>

<p>This code is supposed to run a very simple strategy, just buying AAPL every day, but it doesn't work. I think something is amiss within the Zipline and something changes since the book was written. 
I managed to make it run, but with no transactions being made at all. It just shows some data not related to the orders because no order are made and they are not made since I don't instantiate the class BuyApple.</p>

<p>I'm new to Python and to pandas and to Zipline as well, so if someone could shed some light as to why this is not working, it's great.
I'm on Python 3.4 and Zipline 1.0.1</p>

<p>I am using Python 2.7 and Zipline 0.7.0 Since I have 32 bit OS and Zipline future releases are focused on 64 bit I cannot upgrade Zipline on my system. The code ran perfectly well on my system. Perhaps the code is compatible with older Zipline version. Are you using windows? Why is there Python3.4 between lib and sitepackages? I am using Anaconda as well but my path is Anaconda/lib/sitepackages/zipline</p>

python pandas algorithmic-trading zipline