模拟交易报错
由caltair创建,最终由caltair 被浏览 40 用户
问题
开始几天运行的还好,23号开始运行就出现了个这个错误提示:
<TypeError: '<' not supported between instances of 'int' and 'NaTType'>,请问这个NaT类型是什么?只记得有个NaN类型呀…
请大佬指教!!
这是报错信息链接,劳烦大佬过目!!
下面是一些细节:
[2022-05-23 19:40:14.528182] INFO forward_test: c_initialize() positions len:7, value:669907.0 [2022-05-23 19:40:14.530271] INFO forward_test: c_initialize() orders len:4 [2022-05-23 19:40:14.532581] INFO Blotter: place order [sid:924, oid:522a4d, symbol:000585.SZA, amount:5800, position_effect:None, is_stored_order:True], dt:2022-05-23 00:00:00+00:00 [2022-05-23 19:40:14.534439] INFO Blotter: place order [sid:2619, oid:48de95, symbol:600695.SHA, amount:64400, position_effect:None, is_stored_order:True], dt:2022-05-23 00:00:00+00:00 [2022-05-23 19:40:14.537893] INFO Blotter: place order [sid:186, oid:d3f1ac, symbol:830839.BJA, amount:4800, position_effect:None, is_stored_order:True], dt:2022-05-23 00:00:00+00:00 [2022-05-23 19:40:14.541694] INFO Blotter: place order [sid:3632, oid:6985a7, symbol:832000.BJA, amount:4800, position_effect:None, is_stored_order:True], dt:2022-05-23 00:00:00+00:00 [2022-05-23 19:40:14.874456] ERROR forward_test: run hit Exception, e '<' not supported between instances of 'int' and 'NaTType' Traceback (most recent call last): File "/var/app/enabled/bigline/zipline/data/data_portal.py", line 498, in get_spot_value session_label = self.dt_to_session_dict[dt] KeyError: NaT
KeyError Traceback (most recent call last) /var/app/enabled/bigline/zipline/data/data_portal.py in get_spot_value(self, asset, field, dt, data_frequency) 497 try: --> 498 session_label = self.dt_to_session_dict[dt] 499 except KeyError:
KeyError: NaT
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last) /usr/local/python3/lib/python3.8/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds) 57 try: ---> 58 return bound(*args, **kwds) 59 except TypeError:
TypeError: '<' not supported between instances of 'int' and 'NaTType'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last) <ipython-input-1-ed1b83ca5bcc> in <module> 196 ) 197 --> 198 m15 = M.trade.v4( 199 instruments=m8.data, 200 options_data=m7.predictions,
\
解答
NaTType是日期为NA的意思
- 光看这个报错信息有限,可以把notebook或者完整的报错截图发出来;
- 或者在开发环境中把开始和结束日期均设置为该日期,看下是否会报错 以及报错的内容。
看了下,建议不要使用stockranker.v2模块(这个模块很久没有维护了),尝试将这个模块换成「stockranker训练.v6」和「stockranker预测.v5」这两个模块进行训练和预测。