quantopian / zipline

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

Can't Get Zipline to work (run a backtest) neither in The Cmd or in Jupyter #2287

Open BMuss opened 6 years ago

BMuss commented 6 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

Zipline seems to have been properly installed, to verify i tried to import Zipline and it works fine. see below: ""C:\Python35>python Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import zipline quit() ''''''

  1. First attempt BUT when i tried to run zipline from Jupyter Notebook , the kernel dies Whenever i try to run a backtest, find below the command and Code i used: --> %load_ext zipline --> from zipline.api import order, record, symbol def initialize(context): pass def handle_data(context, data): order(symbol('AAPL'), 10) record(AAPL=data.current(symbol('AAPL'), 'price')) -->%zipline --bundle quantopian-quandl --start 2012-1-1 --end 2012-2-1 -o buyAppl.pickle (that is where the Kernel dies with no answer)
  1. Second attempt I therefore tried to run Zipline from the cmd prompt to check if the problem was due to jupyter but there also i received no answer, Nothing Happens , no error shown, Nothing, the prompt just go to the next line waiting for an another instruction. see below: -->C:\Python35>zipline run --bundle quantopian-quandl -f C:\Python35\testa.py --start 2016-1-1 --end 2017-1-1 --output buyapple_out.pickle -->C:\Python35> It is important to note that i properly ingested the quantopian-quandl Bundles ( At least i believe) because i retrieve the file in .Zipline folder with sqlite lite file, bcolz folder inside. Also find below the code written in "testa.py"

from zipline.api import order, record, symbol def initialize(context): pass

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

3.Attempt I therefore tried to run one of the algo(buyapple.py) in the Example File, but same response ,

  1. I tried then to run the buyapple.py in the Exemple with default quandl bundle, i ingested first quandl bundle and i got the this below. -->C:\Users\TOSHIBA>zipline ingest -b quandl [2018-09-04 14:29:33.596495] INFO: zipline.data.bundles.quandl: Downloading WIKI metadata. Downloading WIKI Prices table from Quandl [####################################] 100% [2018-09-04 14:50:21.773229] INFO: zipline.data.bundles.quandl: Parsing raw data. [2018-09-04 14:53:12.803871] INFO: zipline.data.bundles.quandl: Generating asset metadata. Merging daily equity files: [----------------------------------#-] 4

I was wondered if everything was right because the process seems to have broken on the line "Merging Daily equity file". But as no error have been shown i continued but i went first to check in the file in .zipline , i saw no sqlite file , the folder was created for the Bundle but nothing inside.

I tried however to lanch the backtest and i got the following results, -->C:\Users\TOSHIBA>zipline run -f C:\Python35\Lib\site-packages\zipline\examples\buyapple.py --start 2016-1-1 --end 2017-1-1 --output buyapple_out.pickle Traceback (most recent call last): File "c:\python35\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "c:\python35\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Python35\Scripts\zipline.exe__main.py", line 9, in File "c:\python35\lib\site-packages\click\core.py", line 722, in call return self.main(args, kwargs) File "c:\python35\lib\site-packages\click\core.py", line 697, in main rv = self.invoke(ctx) File "c:\python35\lib\site-packages\click\core.py", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "c:\python35\lib\site-packages\click\core.py", line 895, in invoke return ctx.invoke(self.callback, ctx.params) File "c:\python35\lib\site-packages\click\core.py", line 535, in invoke return callback(args, kwargs) File "c:\python35\lib\site-packages\zipline__main_.py", line 107, in return f(*args, *kwargs) File "c:\python35\lib\site-packages\click\decorators.py", line 17, in new_func return f(get_current_context(), args, kwargs) File "c:\python35\lib\site-packages\zipline__main__.py", line 276, in run blotter=blotter, File "c:\python35\lib\site-packages\zipline\utils\run_algo.py", line 141, in _run bundle_timestamp, File "c:\python35\lib\site-packages\zipline\data\bundles\core.py", line 524, in load asset_db_path(name, timestr, environ=environ), File "c:\python35\lib\site-packages\zipline\assets\assets.py", line 267, in init__ self.engine = engine File "c:\python35\lib\site-packages\zipline\utils\input_validation.py", line 792, in preprocessor return to(arg, **to_kwargs) File "c:\python35\lib\site-packages\zipline\utils\sqlite_utils.py", line 46, in check_and_create_engine verify_sqlite_path_exists(path) File "c:\python35\lib\site-packages\zipline\utils\sqlite_utils.py", line 35, in verify_sqlite_path_exists raise ValueError("SQLite file {!r} doesn't exist.".format(path)) ValueError: SQLite file 'C:\Users\TOSHIBA/.zipline\data\quandl\2018-09-04T14;29;26.475560\assets-6.sqlite' doesn't exist.

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

Reproduction Steps

What steps have you taken to resolve this already?

-Tried jupyter run -tried cmd run with my algo -tried with Example provided by zipline algo -tried different bundles

Anything else?

I'am wondering what is the issue, all the dependencies seem to be correctly installed, even the pandas requirement. Also if the failor that cause the quandl Bundle to be empty is related to te first of receiving no answer when running Zipline backtest i believ the solution you will provide will help resolve both of them at the same time, But if it is not please help with both issues

Sincerely, Moussa

BMuss commented 6 years ago

Hello! Someone Help me? or Point me to the right direction?