VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 5
声望: 0

报错内容:
Traceback (most recent call last):
File "C:\veighna_studio\lib\site-packages\vnpy\trader\ui\mainwindow.py", line 276, in open_widget
widget = widget_class(self.main_engine, self.event_engine)
File "C:\veighna_studio\lib\site-packages\vnpy_ctastrategy\ui\widget.py", line 41, in init
self.cta_engine.init_engine()
File "C:\veighna_studio\lib\site-packages\vnpy_ctastrategy\engine.py", line 118, in init_engine
self.load_strategy_data()
File "C:\veighna_studio\lib\site-packages\vnpy_ctastrategy\engine.py", line 835, in load_strategy_data
self.strategy_data = load_json(self.data_filename)
File "C:\veighna_studio\lib\site-packages\vnpy\trader\utility.py", line 105, in load_json
data: dict = json.load(f)
File "C:\veighna_studio\lib\json__init.py", line 293, in load
return loads(fp.read(),
File "C:\veighna_studio\lib\json\
init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\veighna_studio\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\veighna_studio\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 17 (char 121)

可以复现,每次停止策略的时候就会报错,强制关闭之后模块就启动不了了,恢复方法是删除user目录下的配置缓存文件(不知道删哪个能解决反正全删了)

Member
avatar
加入于:
帖子: 4883
声望: 293

需要删除cta_strategy_data.json,json文件保存不了str\bool\int\float这四种基础数据以外的类型,就会出错

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

xiaohe wrote:

需要删除cta_strategy_data.json,json文件保存不了str\bool\int\float这四种基础数据以外的类型,就会出错
每次停止策略都会报这个错,请问这个文件记录的是啥,有可能是哪里写的不对

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

晚上观察了一下,每次策略自动下单json就会报错

Traceback (most recent call last):
File "C:\veighna_studio\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "C:\veighna_studio\lib\threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "C:\veighna_studio\lib\site-packages\vnpy\event\engine.py", line 60, in _run
self._process(event)
File "C:\veighna_studio\lib\site-packages\vnpy\event\engine.py", line 73, in _process
[handler(event) for handler in self._handlers[event.type]]
File "C:\veighna_studio\lib\site-packages\vnpy\event\engine.py", line 73, in <listcomp>
[handler(event) for handler in self._handlers[event.type]]
File "C:\veighna_studio\lib\site-packages\vnpy_ctastrategy\engine.py", line 229, in process_trade_event
self.sync_strategy_data(strategy)
File "C:\veighna_studio\lib\site-packages\vnpy_ctastrategy\engine.py", line 846, in sync_strategy_data
save_json(self.data_filename, self.strategy_data)
File "C:\veighna_studio\lib\site-packages\vnpy\trader\utility.py", line 118, in save_json
json.dump(
File "C:\veighna_studio\lib\json__init.py", line 179, in dump
for chunk in iterable:
File "C:\veighna_studio\lib\json\encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "C:\veighna_studio\lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "C:\veighna_studio\lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "C:\veighna_studio\lib\json\encoder.py", line 438, in _iterencode
o = _default(o)
File "C:\veighna_studio\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.
class.name__} '
TypeError: Object of type int32 is not JSON serializable

Member
avatar
加入于:
帖子: 125
声望: 4

显示数据类型报错了

Member
avatar
加入于:
帖子: 4883
声望: 293

HPF wrote:

xiaohe wrote:

需要删除cta_strategy_data.json,json文件保存不了str\bool\int\float这四种基础数据以外的类型,就会出错
每次停止策略都会报这个错,请问这个文件记录的是啥,有可能是哪里写的不对
检查你的策略的变量的类型,是str\bool\int\float这四种基础数据以外的类型

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

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】