iPython magic for Zipline cannot find data bundle

2019-07-05 00:30发布

I have a Python 2.7 script that runs Zipline fine on the command prompt, using --bundle=myBundle to load the custom data bundle myBundle which I have registered using extension.py.

zipline run -f myAlgo.py --bundle=myBundle --start 2016-6-1 --end 2016-7-1 --data-frequency=minute

Problem: However when I try to use the %zipline IPython magic to run the algorithm, the bundle argument --bundle seems to have difficulty finding myBundle.

%zipline --bundle=myBundle--start 2016-6-1 --end 2016-7-1 --data-frequency=minute

Running this will give the error

UnknownBundle: No bundle registered with the name u'myBundle'

Do we have to register the bundle differently when using IPython notebook?

1条回答
一纸荒年 Trace。
2楼-- · 2019-07-05 01:29

It is a known (now closed) bug in zipline, see also https://github.com/quantopian/zipline/issues/1542.

As a workaround you can load the following in the cell before the zipline magic:

import os

from zipline.utils.run_algo import load_extensions

load_extensions(
    default=True,
    extensions=[],
    strict=True,
    environ=os.environ,
)
查看更多
登录 后发表回答