vn.py官网
开源量化社区
Member
avatar
加入于:
帖子: 15
声望: 0

Traceback (most recent call last):
File "C:\vnstudio\lib\site-packages\vnpy\trader\ui\mainwindow.py", line 269, in closeEvent
self.main_engine.close()
File "C:\vnstudio\lib\site-packages\vnpy\trader\engine.py", line 229, in close
engine.close()
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 118, in close
self.stop_all_strategies()
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 882, in stop_all_strategies
self.stop_strategy(strategy_name)
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 742, in stop_strategy
self.sync_strategy_data(strategy)
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 839, in sync_strategy_data
save_json(self.data_filename, self.strategy_data)
File "C:\vnstudio\lib\site-packages\vnpy\trader\utility.py", line 116, in save_json
ensure_ascii=False
File "C:\vnstudio\lib\json__init.py", line 179, in dump
for chunk in iterable:
File "C:\vnstudio\lib\json\encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "C:\vnstudio\lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "C:\vnstudio\lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "C:\vnstudio\lib\json\encoder.py", line 438, in _iterencode
o = _default(o)
File "C:\vnstudio\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.
class.name_} '
TypeError: Object of type bool
is not JSON serializable

Member
avatar
加入于:
帖子: 15
声望: 0

下一次打开vn启动策略就会报错

Traceback (most recent call last):
File "C:\vnstudio\lib\site-packages\vnpy\trader\ui\mainwindow.py", line 281, in open_widget
widget = widget_class(self.main_engine, self.event_engine)
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\ui\widget.py", line 38, in init
self.cta_engine.init_engine()
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 112, in init_engine
self.load_strategy_data()
File "C:\vnstudio\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 828, in load_strategy_data
self.strategy_data = load_json(self.data_filename)
File "C:\vnstudio\lib\site-packages\vnpy\trader\utility.py", line 99, in load_json
data = json.load(f)
File "C:\vnstudio\lib\json__init.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "C:\vnstudio\lib\json\
init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\vnstudio\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\vnstudio\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 6 column 21 (char 98)

Member
avatar
加入于:
帖子: 3150
声望: 184

请先删除.vntrader文件夹下对应的json文件,再重启。你这个应该是删除cta_strategy_data.json。如果还报同样的错,建议检查策略代码中,是否有把str、bool、int、float类型以外的变量名称写到了parameters列表中,这四种类型以外的变量由于无法通过json序列化会导致保存策略状态出错(损坏json文件)

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

沪公网安备 31011502017034号