failed on beginner code

262 views
Skip to first unread message

jerry...@gmail.com

unread,
Dec 15, 2017, 12:02:28 PM12/15/17
to Zipline Python Opensource Backtester
Hi Zipliners,

I got zipline installed and imported, but when I run this in notebooks:

%%zipline --start 2000-1-1 --end 2014-1-1


from zipline.api import symbol, order, record


def initialize(context):
   
pass


def handle_data(context, data):
    order
(symbol('AAPL'), 10)
    record
(AAPL=data[symbol('AAPL')].price)

It gives me:



Does anyone has any clue? Is it the problem with pandas datareader or zipline.
I got Zipline == 1.1.1 and pandas datareader == 0.5.0
Thanks.





Islam El-Ashi

unread,
Dec 17, 2017, 7:37:34 AM12/17/17
to Zipline Python Opensource Backtester

I'm having the same issue as well. Did Google Finance drop support for their API?

Ed Bartosh

unread,
Dec 17, 2017, 8:20:32 AM12/17/17
to Islam El-Ashi, Zipline Python Opensource Backtester
Hi,

Did Google Finance drop support for their API?
No, it didn't. It changed it.

To fix this you can either try to install fixed pandas-datareader:

Or use this zipline fix (changing data provider from google finance to IEX):

Regards,
Ed


--
You received this message because you are subscribed to the Google Groups "Zipline Python Opensource Backtester" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zipline+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
BR,
Ed

Matthew Cochrane

unread,
Dec 27, 2017, 9:55:48 PM12/27/17
to Zipline Python Opensource Backtester
I was having the same issue and updated to master (pull 2031 was merged into master 9 hours ago as I write this, it is literally the last commit to master).
Now there's more problems when I run zipline ingest.  I just get a 400 error from quandl... Any ideas?
Log below

zipline ingest
[2017-12-28 02:42:06.470343] INFO: zipline.data.bundles.quandl: Downloading WIKI metadata.
[2017-12-28 02:42:22.463420] ERROR: zipline.data.bundles.quandl: Exception raised reading Quandl data. Retrying.
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/zipline/data/bundles/quandl.py", line 89, in fetch_data_table
    format_metadata_url(api_key)
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py", line 562, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py", line 301, in _read
    compression=kwds.get('compression', None))
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/common.py", line 308, in get_filepath_or_buffer
    req = _urlopen(str(filepath_or_buffer))
  File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.5/urllib/request.py", line 510, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
[2017-12-28 02:42:22.467313] INFO: zipline.data.bundles.quandl: Downloading WIKI metadata.
[2017-12-28 02:42:27.793521] ERROR: zipline.data.bundles.quandl: Exception raised reading Quandl data. Retrying.
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/zipline/data/bundles/quandl.py", line 89, in fetch_data_table
    format_metadata_url(api_key)
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py", line 562, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py", line 301, in _read
    compression=kwds.get('compression', None))
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/common.py", line 308, in get_filepath_or_buffer
    req = _urlopen(str(filepath_or_buffer))
  File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.5/urllib/request.py", line 510, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
[2017-12-28 02:42:27.794024] INFO: zipline.data.bundles.quandl: Downloading WIKI metadata.
[2017-12-28 02:42:31.955397] ERROR: zipline.data.bundles.quandl: Exception raised reading Quandl data. Retrying.
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/zipline/data/bundles/quandl.py", line 89, in fetch_data_table
    format_metadata_url(api_key)
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py", line 562, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py", line 301, in _read
    compression=kwds.get('compression', None))
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/common.py", line 308, in get_filepath_or_buffer
    req = _urlopen(str(filepath_or_buffer))
  File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.5/urllib/request.py", line 510, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
[2017-12-28 02:42:31.956024] INFO: zipline.data.bundles.quandl: Downloading WIKI metadata.
[2017-12-28 02:42:36.227856] ERROR: zipline.data.bundles.quandl: Exception raised reading Quandl data. Retrying.
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/zipline/data/bundles/quandl.py", line 89, in fetch_data_table
    format_metadata_url(api_key)
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py", line 562, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py", line 301, in _read
    compression=kwds.get('compression', None))
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/common.py", line 308, in get_filepath_or_buffer
    req = _urlopen(str(filepath_or_buffer))
  File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.5/urllib/request.py", line 510, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
[2017-12-28 02:42:36.228230] INFO: zipline.data.bundles.quandl: Downloading WIKI metadata.
[2017-12-28 02:42:41.528279] ERROR: zipline.data.bundles.quandl: Exception raised reading Quandl data. Retrying.
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/zipline/data/bundles/quandl.py", line 89, in fetch_data_table
    format_metadata_url(api_key)
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py", line 562, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py", line 301, in _read
    compression=kwds.get('compression', None))
  File "/usr/local/lib/python3.5/dist-packages/pandas/io/common.py", line 308, in get_filepath_or_buffer
    req = _urlopen(str(filepath_or_buffer))
  File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/usr/lib/python3.5/urllib/request.py", line 582, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.5/urllib/request.py", line 510, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 590, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
Traceback (most recent call last):
  File "/usr/local/bin/zipline", line 11, in <module>
    load_entry_point('zipline==1.1.1+210.g7c6920c', 'console_scripts', 'zipline')()
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/zipline/__main__.py", line 323, in ingest
    show_progress,
  File "/usr/local/lib/python3.5/dist-packages/zipline/data/bundles/core.py", line 451, in ingest
    pth.data_path([name, timestr], environ=environ),
  File "/usr/local/lib/python3.5/dist-packages/zipline/data/bundles/quandl.py", line 203, in quandl_bundle
    environ.get('QUANDL_DOWNLOAD_ATTEMPTS', 5)
  File "/usr/local/lib/python3.5/dist-packages/zipline/data/bundles/quandl.py", line 113, in fetch_data_table
    "Failed to download Quandl data after %d attempts." % (retries)
ValueError: Failed to download Quandl data after 5 attempts.

To unsubscribe from this group and stop receiving emails from it, send an email to zipline+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
BR,
Ed

fva...@quantopian.com

unread,
Jan 8, 2018, 1:44:22 AM1/8/18
to Zipline Python Opensource Backtester
Hi Matthew,

The reason for that error is that you need a Quandl API key and need to run:

QUANDL_API_KEY=<yourkey> zipline ingest -b quandl

You can find more info about that and bundles in general here.

Tik Ho Hui

unread,
Jan 10, 2018, 3:49:52 AM1/10/18
to Zipline Python Opensource Backtester
It seems that the correct URL should be http://finance.google.com/finance, but the format is still wrong for zipline !
Reply all
Reply to author
Forward
0 new messages