问题
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:
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,
)
来源:https://stackoverflow.com/questions/40076616/ipython-magic-for-zipline-cannot-find-data-bundle