我正在通过在$ ZIPLINE_ROOT目录中的extenstion.py中添加以下内容来创建自定义基本yahoo软件包:
equities = {
'AAPL',
'QQQ',
}
register(
'test-bundle', # name this whatever you like
yahoo_equities(equities),
)
当我运行捆绑包时,一切都很好。
zipline ingest -b test-bundle
zipline bundles
产生输出(我刚刚运行它)
test-bundle 2016-12-10 20:13:11.014192
很好,一切都按预期工作。
当我使用一些基本策略运行zipline 2周时:
zipline run -f ./test_algo.py --start 2016-12-01 --end 2016-12-9 -o output.pickle --bundle test-bundle
它运行,直到它到达星期四(2016年8月12日)日期:
Traceback (most recent call last):
File "/usr/local/lib64/python3.5/site-packages/pandas/core/indexing.py", line 1325, in _has_valid_type error()
File "/usr/local/lib64/python3.5/site-packages/pandas/core/indexing.py", line 1320, in error (key, self.obj._get_axis_name(axis)))
KeyError: 'the label [2016-12-08 00:00:00+00:00] is not in the [index]'
During handling of the above exception, another exception occurred:
.... zipline stack trace
但如果我运行它:
zipline run -f ./test_algo.py --start 2016-12-01 --end 2016-12-7 -o output.pickle --bundle test-bundle
然后我得到了预期的成功输出:
[2016-12-10 20:17:11.519059] INFO: Performance: Simulated 5 trading days out of 5.
[2016-12-10 20:17:11.519495] INFO: Performance: first open: 2016-12-01 14:31:00+00:00
[2016-12-10 20:17:11.519770] INFO: Performance: last close: 2016-12-07 21:00:00+00:00
知道我的捆绑包下载到T-2数据的原因。我希望看到12/8和12/9的数据,市场是开放的,这是正常的日子,我看到雅虎金融的数据当天。
谢谢 -
答案 0 :(得分:0)
这是因为基准回报不可用,并且只能从T-2基础上获得,包括交易日。 (IE:如果你在星期一早上运行它,那么星期四的数据将可用,你可以运行模拟直到星期五)如果你在星期六/星期日运行它,基准的最后一天是星期三,并且最新的模拟日是星期四。
可能的解决方案:
目前的解决方法:
修改:./ zipline /gens / transimimulation.py
并设置:
def handle_benchmark(date, benchmark_source=self.benchmark_source):
algo.perf_tracker.all_benchmark_returns[date] = 1
这样它就不会检查是否有数据,只是总是为基准返回1