Repository: quantopian/zipline

Issue #2603: Quandl datasource for default bundle broken
Created: 2019-12-31T16:17:10Z
The default bundle is based on: https://www.quandl.com/databases/WIKIP/documentation
The bundle implementation no longer works with Quandl's WIKIP, so the default bundle fails.
The bundle failure is the root cause of many reported issues. This new issue will be the canonical reference issue for the quandl bundle. Other issues will be closed as a dupe to this issue.

Duplicate issue #2226: Execute zipline shell commands as ipython magic to keep all scripting in a notebook
Created: 2018-06-29T17:47:34Z
Environment
zipline in a docker container
Description of Issue
Given I am a modern developer with multiple computers running different OS, I want to run all my software in docker containers so that my development environment is portable and consistent.
Given I am using zipline in a docker container with Jupyter lab, I want to script everything within a notebook for portability.
Currently, I have to use the command line in the docker container for ingest or in a cell with %%script magic. This gets pretty cumbersome. It would be much easier to run %zipline ingest but that fails.
%zipline ingest
UsageErrorTraceback (most recent call last)
<ipython-input-112-984b05ef838d> in <module>()
----> 1 get_ipython().run_line_magic('zipline', 'ingest')

/opt/conda/envs/zipline/lib/python3.5/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2129                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2130             with self.builtin_trap:
-> 2131                 result = fn(*args,**kwargs)
   2132             return result
   2133 

/opt/conda/envs/zipline/lib/python3.5/site-packages/zipline/__main__.py in zipline_magic(line, cell)
    292             '%s%%zipline' % ((cell or '') and '%'),
    293             # don't use system exit and propogate errors to the caller
--> 294             standalone_mode=False,
    295         )
    296     except SystemExit as e:

/opt/conda/envs/zipline/lib/python3.5/site-packages/click/core.py in main(self, args, prog_name, complete_var, standalone_mode, **extra)
    694         try:
    695             try:
--> 696                 with self.make_context(prog_name, args, **extra) as ctx:
    697                     rv = self.invoke(ctx)
    698                     if not standalone_mode:

/opt/conda/envs/zipline/lib/python3.5/site-packages/click/core.py in make_context(self, info_name, args, parent, **extra)
    619         ctx = Context(self, info_name=info_name, parent=parent, **extra)
    620         with ctx.scope(cleanup=False):
--> 621             self.parse_args(ctx, args)
    622         return ctx
    623 

/opt/conda/envs/zipline/lib/python3.5/site-packages/click/core.py in parse_args(self, ctx, args)
    883             ctx.fail('Got unexpected extra argument%s (%s)'
    884                      % (len(args) != 1 and 's' or '',
--> 885                         ' '.join(map(make_str, args))))
    886 
    887         ctx.args = args

/opt/conda/envs/zipline/lib/python3.5/site-packages/click/core.py in fail(self, message)
    474         :param message: the error message to fail with.
    475         """
--> 476         raise UsageError(message, self)
    477 
    478     def abort(self):

UsageError: Got unexpected extra argument (ingest)

Here's my hack to get this working as is:
import os

# TODO - deal with setting the key in docker
%set_env QUANDL_API_KEY=<my_key>
# Set Zipline data directory to within the project's scope so that I don't pollute my multi-purpose conda container.
os.environ['ZIPLINE_ROOT']=os.path.join(os.getcwd(),'zipline')
# Activate zipline
%load_ext zipline

%%script bash
/opt/conda/envs/zipline/bin/zipline ingest

This works but with the length of time waiting on ingest with no feedback, one starts to wonder if the notebook is hung.
The samples do run...
EG:
%%zipline --start 2016-1-1 --end 2018-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)

Closing comment (2019-12-31T16:18:15Z): Closing as a duplicate of #2603