本文介绍了Zipline的iPython魔术无法找到数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Python 2.7脚本,可以在命令提示符下运行Zipline,使用 - bundle = myBundle 来加载自定义数据包 myBundle 我使用 extension.py 注册。

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

问题:但是当我尝试使用%zipline IPython magic时要运行该算法,bundle参数 - bundle 似乎很难找到 myBundle

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

运行此将产生错误

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

我们是否使用IPython笔记本时必须以不同方式注册包吗?

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

推荐答案

这是zipline中已知(现已关闭)的错误,另见。

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

作为一种解决方法,您可以在单元格中加载以下内容zipline magic:

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,
)

这篇关于Zipline的iPython魔术无法找到数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-08 23:38