vn.py量化社区
By Traders, For Traders.
Member
avatar
加入于:
帖子: 22
声望: 0

启动vntrader 交易窗口输入合约代码回车,报以下错误:
File "D:\ProgramData\Anaconda2\lib\json\encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: datetime.datetime(2019, 2, 12, 11, 3, 5) is not JSON serializable

这个时期序列化错误,在什么位置怎么解决呢?

2019-02-12 11:03:11,881 INFO: MAIN_ENGINE MongoDB连接成功
2019-02-12 11:03:13,061 INFO: CTP 行情服务器连接成功
2019-02-12 11:03:13,095 INFO: CTP 行情服务器登录完成
2019-02-12 11:03:13,292 INFO: CTP 交易服务器连接成功
2019-02-12 11:03:13,357 INFO: CTP 交易服务器登录完成
2019-02-12 11:03:13,388 INFO: CTP 结算信息确认完成
2019-02-12 11:03:13,526 INFO: CTP 交易合约信息获取完成
Exception in thread Thread-1:
Traceback (most recent call last):
File "D:\ProgramData\Anaconda2\lib\threading.py", line 801, in bootstrap_inner
self.run()
File "D:\ProgramData\Anaconda2\lib\threading.py", line 754, in run
self.
target(*self.args, **self.kwargs)
File "D:\python ITEM\vnpy-1.9.2\vnpy-1.9.2\vnpy\event\eventEngine.py", line 83, in run
self.
process(event)
File "D:\python ITEM\vnpy-1.9.2\vnpy-1.9.2\vnpy\event\eventEngine.py", line 93, in process
[handler(event) for handler in self.
handlers[event.type]]
File "D:\python ITEM\vnpy-1.9.2\vnpy-1.9.2\vnpy\trader\app\rtdService\rtdEngine.py", line 76, in processDataEvent
self.server.publish(event.type
, d)
File "D:\python ITEM\vnpy-1.9.2\vnpy-1.9.2\vnpy\rpc\vnrpc.py", line 187, in publish
datab = self.pack(data)
File "D:\python ITEM\vnpy-1.9.2\vnpy-1.9.2\vnpy\rpc\vnrpc.py", line 57, in jsonPack
return dumps(data)
File "D:\ProgramData\Anaconda2\lib\json\
init__.py", line 244, in dumps
return _default_encoder.encode(obj)
File "D:\ProgramData\Anaconda2\lib\json\encoder.py", line 207, in encode
chunks = self.iterencode(o, _one_shot=True)
File "D:\ProgramData\Anaconda2\lib\json\encoder.py", line 270, in iterencode
return _iterencode(o, 0)
File "D:\ProgramData\Anaconda2\lib\json\encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: datetime.datetime(2019, 2, 12, 11, 3, 5) is not JSON serializable

Administrator
avatar
加入于:
帖子: 2105
声望: 96

这个报错是因为VtTickData的datetime字段无法序列化导致的,最简单的处理方式是把run.py里的rtdService模块去掉就行(如果你不用EXCEL RTD功能的话)

© 2015-2019 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号-3