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

今天实盘交易中,出现如下错误提示。我是中午更新VNPY2.0.4到2.0.5。更新之前,早上运行一切正常,更新后触发成交后,就出错了。我检查是在self.put_event()时,事件处理程序中save_json()时出错的。
Traceback (most recent call last):
File "D:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\ui\widget.py", line
246, in stop_strategy
self.cta_engine.stop_strategy(self.strategy_name)
File "D:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 688
, in stop_strategy
self.sync_strategy_data(strategy)
File "D:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 785
, in sync_strategy_data
save_json(self.data_filename, self.strategy_data)
File "D:\vnstudio\lib\site-packages\vnpy\trader\utility.py", line 105, in save
_json
ensure_ascii=False
File "D:\vnstudio\lib\json__init.py", line 179, in dump
for chunk in iterable:
File "D:\vnstudio\lib\json\encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "D:\vnstudio\lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "D:\vnstudio\lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "D:\vnstudio\lib\json\encoder.py", line 438, in _iterencode
o = _default(o)
File "D:\vnstudio\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.
class.name__} '
TypeError: Object of type int64 is not JSON serializable
为什么更新后就出现这个问题?请问应该如何解决?

Member
avatar
加入于:
帖子: 10
声望: 1

发现新版本中,在process_trade_event(self, event: Event)里,新增调用了sync_strategy_data(strategy),之前没有,这个函数中保存json文件时出错了。

Administrator
avatar
加入于:
帖子: 1690
声望: 80

请在Github上开个issue吧,我们来尝试重现下

Member
avatar
加入于:
帖子: 10
声望: 1

已经开issue,请尽快处理。
目前我临时处理方式是注释掉sync_strategy_data调用。

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