Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Working With Local Data, Downloading the Database

Hi, I am trying to work locally, using zipline source code on Github, and trying to use data locally. Few questions: I downloaded, built, installed zipline, and ran

zipline/zipline/examples/buyapple.py  

I get

  File "/usr/local/lib/python2.7/dist-packages/pandas/io/parsers.py", line 957, in __init__  
    self._reader = _parser.TextReader(src, **kwds)  
  File "parser.pyx", line 480, in pandas.parser.TextReader.__cinit__ (pandas/parser.c:4517)  
ValueError: No columns to parse from file  

From Pandas. I coded up a simpler example (taken from README)

from zipline import TradingAlgorithm  
from zipline.transforms import MovingAverage  
from zipline.utils.factory import load_from_yahoo

from datetime import datetime  
import pytz  
import matplotlib.pyplot as plt

start = datetime(1990, 1, 1, 0, 0, 0, 0, pytz.utc)  
end = datetime(2002, 1, 1, 0, 0, 0, 0, pytz.utc)  
data = load_from_yahoo(stocks=['AAPL'], indexes={}, start=start,  
                   end=end, adjusted=False)  

This gives me

  File "/usr/local/lib/python2.7/dist-packages/pandas/core/internals.py", line 1935, in _find_block  
    self._check_have(item)  
  File "/usr/local/lib/python2.7/dist-packages/pandas/core/internals.py", line 1942, in _check_have  
    raise KeyError('no item named %s' % com.pprint_thing(item))  
KeyError: u'no item named Close'  

Any ideas what is going on? Also is there any link I can use to get all of Quantopian database?

4 responses

Hello KB,

I've just run buyapple.py in iPython on Windows 7 64-bit with Python 2.7 and it works. This is what I have installed:

C:\Users\pcawthron>pip list  
blist (1.3.4)  
Cython (0.19.1)  
Delorean (0.3.1)  
ipython (1.1.0)  
iso8601 (0.1.4)  
Logbook (0.6.0)  
matplotlib (1.3.1rc1)  
msgpack-python (0.3.0)  
numpy (1.7.1)  
pandas (0.12.0)  
pip (1.4.1)  
Pygments (1.6)  
pyparsing (2.0.1)  
pyreadline (2.0)  
python-dateutil (2.1)  
pytz (2013.7)  
pyzmq (13.1.0)  
requests (2.0.0)  
setuptools (0.9.8)  
six (1.4.1)  
TA-Lib (0.4.7)  
zipline (0.5.10)  

Your second example also works:

In [5]: from zipline import TradingAlgorithm  
from zipline.transforms import MovingAverage  
from zipline.utils.factory import load_from_yahoo

from datetime import datetime  
import pytz  
import matplotlib.pyplot as plt

start = datetime(1990, 1, 1, 0, 0, 0, 0, pytz.utc)  
end = datetime(2002, 1, 1, 0, 0, 0, 0, pytz.utc)  
data = load_from_yahoo(stocks=['AAPL'], indexes={}, start=start,  
                   end=end, adjusted=False)

AAPL

In [6]: data  
Out[6]:  
<class 'pandas.core.frame.DataFrame'>  
DatetimeIndex: 3028 entries, 1990-01-02 00:00:00+00:00 to 2001-12-31 00:00:00+00:00  
Data columns (total 1 columns):  
AAPL    3028  non-null values  
dtypes: float64(1)  

P.

Thanks for this response. I did "sudo pip install zipline --upgrade" which forced all the right dependencies (I assume) and now both code snippets work for me as well. Github zipline I had downloaded before was at 0.11.dev (not 0.10), and even though I had all the dependencies installed (with individual pip install commands), maybe some were not the right version. All good now.

Note:

I noticed I get another error when I typed ipython on the command line

    from . import unicode_helper, logger, clipboard, lineeditor, modes, console  
  File "pyreadline/modes/__init__.py", line 3, in <module>  
    from . import emacs, notemacs, vi  
  File "pyreadline/modes/emacs.py", line 11, in <module>  
    import pyreadline.logger as logger  
AttributeError: 'module' object has no attribute 'logger'  

Going back to readline 1.7 fixed this problem.

https://pypi.python.org/pypi/pyreadline/1.7.1#downloads

Koala:

Also, there is https://groups.google.com/forum/#!forum/zipline which is more dedicated to running Zipline locally.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Thanks for the link! I will take a look.