Skip to content

日期报错 #27

Description

@jingmouren

使用tdx数据bundle
回测示例的buy hold策略
买入 000001
起始日为2012-1-1

报如下错误

AttributeError: 'NoneType' object has no attribute 'index'

Debug跟了下,好像是1-16日的交易日历时间为 1-16 0.0 Nat NaT
这是数据导入出了问题,还是这个版本的交易日历有问题,还是那天停牌而系统处理失当,还是其他问题?
buy1.zip
附件为完整代码

跟踪时 到 tradesimulation.py 这个文件时
查看 [dt for dt,action in self.clock] 的结果为
[Timestamp('2012-01-04 00:00:00+0000', tz='UTC'), Timestamp('2012-01-04 13:45:00+0000', tz='UTC'), Timestamp('2012-01-04 21:00:00+0000', tz='UTC'), Timestamp('2012-01-04 21:00:00+0000', tz='UTC'), Timestamp('2012-01-05 00:00:00+0000', tz='UTC')。。。Timestamp('2012-01-16 00:00:00+0000', tz='UTC'), NaT, Timestamp('2012-01-16 13:45:00+0000', tz='UTC'), NaT, Timestamp('2012-01-17 00:00:00+0000', tz='UTC'), Timestamp('2012-01-17 13:45:00+0000', tz='UTC'), Timestamp('2012-01-17 21:00:00+0000', tz='UTC'), Timestamp('2012-01-17 21:00:00+0000', tz='UTC'),

又跟踪了下
在 zipline/algorithm.py(531)_create_clock()
529 """
530 trading_o_and_c = self.trading_calendar.schedule.ix[
531 self.sim_params.sessions]
--> 532 market_closes = trading_o_and_c['market_close']

这传出的close时间就已经有NAT值了,这个值是何用意?
2012-01-13 00:00:00+00:00 2012-01-13 21:00:00
2012-01-16 00:00:00+00:00 NaT
2012-01-17 00:00:00+00:00 2012-01-17 21:00:00

2012-02-17 00:00:00+00:00 2012-02-17 21:00:00
2012-02-20 00:00:00+00:00 NaT
2012-02-21 00:00:00+00:00 2012-02-21 21:00:00

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions