quantopian / zipline

Zipline, a Pythonic Algorithmic Trading Library
https://www.zipline.io
Apache License 2.0
17.56k stars 4.71k forks source link

Example run error "sqlalchemy.exc.InvalidRequestError: .." #1316

Open guoweihw opened 8 years ago

guoweihw commented 8 years ago

Dear Zipline Maintainers,

Before I tell you about my issue, let me describe my environment:

Environment

Now that you know a little about me, let me tell you about the issue I am having:

Description of Issue

Here is how you can reproduce this issue on your machine:

Reproduction Steps

1. 2. 3. ...

What steps have you taken to resolve this already?

...

Anything else?

...

Sincerely, $ whoami Wei

guoweihw commented 8 years ago

if i use the following command: python run_algo.py -f ../examples/buyapple.py --start 2011-1-1 --end 2012-1-1 -o out.pickle The error information is as follows:

Traceback (most recent call last): File "run_algo.py", line 23, in from zipline.utils.calendars import default_nyse_schedule ImportError: No module named calendars

Thanks for any solutions or advices.

enriquedecote commented 8 years ago

having the exact same InvalidRequestError

rjmoggach commented 8 years ago

same issue here - probably related to assets-5.sqlite being 0 bytes?

rjmoggach commented 8 years ago

try using a release instead of master branch - master is not always stable

https://github.com/quantopian/zipline/releases

smujahed commented 8 years ago

Dear Devs, is there anything happening with this? Maybe @richafrank could help? I'm having the same issue...

EDIT: I have built a new data bundle, filled it with APPL info from Yahoo finance and used that to test buyapple.py . It works using my dataset, so I can only assume that the issue is with the quantopian-quandl bundled data.

To create data using Yahoo! look here http://www.zipline.io/bundles.html#yahoo-bundle-factories

richafrank commented 8 years ago

I've reproduced the InvalidRequestError. Agreed that the 0-byte assets db is the issue - looks to be the same as #1228, which is fixed now on master.

When I update to the latest build from master:

> conda install -c https://conda.anaconda.org/Quantopian/label/ci -c quantopian zipline

I'm able to run

> zipline run -f Miniconda2\envs\zp\Lib\site-packages\zipline\examples\buyapple.py  --start 2011-1-1 --end 2012-1-1
[2016-08-23 02:12:21.764000] INFO: Performance: Simulated 252 trading days out of 252.
[2016-08-23 02:12:21.764000] INFO: Performance: first open: 2011-01-03 14:31:00+00:00
[2016-08-23 02:12:21.764000] INFO: Performance: last close: 2011-12-30 21:00:00+00:00
...

successfully.

richafrank commented 8 years ago

Regarding the other error mentioned here (ImportError: No module named calendars), it's definitely confusing. run_algo.py is the pre-1.0 cli, but the default_nyse_schedule name was a short-lived piece of code that existed in some commits of master only after the latest release, i.e. post-1.0.1.

I'm not sure what commit was installed at the time, but I'd try the latest master @guoweihw , using the above command. Maybe zipline was installed some way other than conda or pip and didn't compile the c extensions?

If that doesn't solve the issue, let's make a new one in github, since it seems unrelated to the InvalidRequestError.

smujahed commented 8 years ago

Hey @richafrank I need advice on whether to open a new issue, since this is still happening on my system, although I am using a different operating system (OS X) and possibly different packages. What would you advise?

scarrick68 commented 8 years ago

I'm getting the same error on mac. I tried uninstalling zipline via pip and reinstalling, but that didn't solve it. I also tried clearing all the data via "zipline clean..." but that didn't do anything as seen by "zipline bundles". I'm using python 3.4.4 and pip3.

d3ld0t commented 8 years ago

I am having the same problem. I tried installing the master branch as suggested by @richafrank ,with pip: sudo -H pip3 install -e git+https://github.com/quantopian/zipline@master#egg=zipline_master and am having the same InvalidRequestError.

richafrank commented 8 years ago

I'm getting the same error on mac.

If this is more general than windows, then I'll just re-label this.

Also, https://github.com/quantopian/zipline/issues/1443 was spotted today, but using latest master should actually be a solution to that issue, so it's likely different from this one.

d3ld0t commented 8 years ago

If this is more general than windows, then I'll just re-label this.

Indeed, I was getting this error on Kubuntu 16.04.1

parrondo commented 8 years ago

Same error on Centos 7, solved with richafrank suggestion: conda install -c https://conda.anaconda.org/Quantopian/label/ci -c quantopian zipline

BlackForgeOne commented 8 years ago

Having the same issue. I tried richafrank's suggestion to conda install -c https://conda.anaconda.org/Quantopian/label/ci -c quantopian zipline, which downloaded and updated fine, but when I tried running my algo, I still get the same:

InvalidRequestError: Could not reflect: requested table(s) not available in sqlite:///C:\Users\JKLIMCAK/.zipline\data\quantopian-quandl\2016-08-31T11;05;48.373000\assets-5.sqlite: (asset_router, futures_root_symbols, version_info, equity_symbol_mappings, equities, futures_contracts, futures_exchanges)

Any ideas or anything else I can provide to help out? Do you think uploading my own data bundles would solve this issue?

richafrank commented 8 years ago

@CaballeroJoe Can you tell if the file at that path is empty?

BlackForgeOne commented 8 years ago

@richafrank Indeed looks like it. The conda install -c https://conda.anaconda.org/Quantopian/label/ci -c quantopian zipline went through fine however, what's the best way of getting that asset db file?

richafrank commented 8 years ago

Have you run zipline ingest after updating to that CI version zipline?

nicoCalvo commented 8 years ago

I had the same issue and was solved by re-running zipline ingest

ColeMurray commented 7 years ago

Also experiencing InvalidRequestError when running the buyApple.py. Running on OSX python2.7

Zipline1.0.2 was installed via pip. Have tried installing / reinstalling. Cleaning & re-ingesting. Asset-5 is not created until running the example. After running, it is an empty file.

Any update on this?

Update: Running sudo -H pip install -e git+https://github.com/quantopian/zipline@master#egg=zipline_master

worked for me. One thing I observed was that zipline master is using pandas 18.1, while pip's is using 17.1.

turboslon commented 7 years ago

Ubuntu 16.04 x64, python 2.7 zipline 1.0.2 (via pip). Confirm the same error (InvalidRequestError) and assets-5.sqlite is zero-length.

pbharrin commented 7 years ago

I had this issue as well, a bundle I ingested on 2016/11/29 worked but a new bundle ingested on 12/19/2016 did not work. The only thing that worked for me was clearing all installed packages and reinstalling Zipline via: sudo -H pip install -e git+https://github.com/quantopian/zipline@master#egg=zipline_master also I had to remove the original ~/.zipline/ folder for this work.

TimMurnaghan commented 7 years ago

Another me too. Fresh install on windows 7 from conda. Not even close to working "out-of-the-box"

First can't get the quandl data requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://s3.amazonaws.com/quantopian-public-zipline-data/quandl

Tried a yahoo bundle and now get: sqlalchemy.exc.InvalidRequestError: Could not reflect: requested table(s) not available in sqlite:///C:\Users\Tim/.zipline\data\quantopian-quandl\2017-04-01T17; 52;27.676000\assets-5.sqlite: (asset_router, futures_root_symbols, version_info, equity_symbol_mappings, equities, futures_contracts, futures_exchanges)

Just too hard to get going if the examples are this tough - bounced off and trying some alternatives.

freddiev4 commented 7 years ago

@TimMurnaghan that was an issue we had for about a day but was fixed (see https://github.com/quantopian/zipline/issues/1736)

Otherwise it looks like this works fine on master when I ran zipline ingest -b quantopian-quandl and then ran my example algorithm

acanacar commented 6 years ago

on my ubuntu 16.04 i got same error : SQLite file '/home/cem/.zipline/data/csvdir/2017-12-23T22;58;03.941248/assets-6.sqlite' doesn't exist. i tried with conda and zipline master version but still got same issue.

freddiev4 commented 6 years ago

@acanacar that looks like it's coming from the csvdir bundle and not quantopian-quandl. Did you run zipline ingest -b csvdir with your own set of equities?