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

在策略运行的过程中,点击全部停止会触发下列错误,看了半天也每天看懂是什么原因,有大神能帮忙看一下吗?

Traceback (most recent call last):
File "C:\Users\puir\Anaconda3\lib\site-packages\vnpy\trader\ui\mainwindow.py", line 253, in closeEvent
self.main_engine.close()
File "C:\Users\puir\Anaconda3\lib\site-packages\vnpy\trader\engine.py", line 220, in close
engine.close()
File "C:\Users\puir\Anaconda3\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 116, in close
self.stop_all_strategies()
File "C:\Users\puir\Anaconda3\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 846, in stop_all_strategies
self.stop_strategy(strategy_name)
File "C:\Users\puir\Anaconda3\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 702, in stop_strategy
self.sync_strategy_data(strategy)
File "C:\Users\puir\Anaconda3\lib\site-packages\vnpy\app\cta_strategy\engine.py", line 803, in sync_strategy_data
save_json(self.data_filename, self.strategy_data)
File "C:\Users\puir\Anaconda3\lib\site-packages\vnpy\trader\utility.py", line 109, in save_json
ensure_ascii=False
File "C:\Users\puir\Anaconda3\lib\json__init.py", line 179, in dump
for chunk in iterable:
File "C:\Users\puir\Anaconda3\lib\json\encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "C:\Users\puir\Anaconda3\lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "C:\Users\puir\Anaconda3\lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "C:\Users\puir\Anaconda3\lib\json\encoder.py", line 438, in _iterencode
o = _default(o)
File "C:\Users\puir\Anaconda3\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.
class.name__} '
TypeError: Object of type time is not JSON serializable

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

这个报错应该是你某个策略的variables参数里,有不是int/float/str/bool类型的数据,请检查下吧。

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

用Python的交易员 wrote:

这个报错应该是你某个策略的variables参数里,有不是int/float/str/bool类型的数据,请检查下吧。

谢谢!删掉了配置文件,重新生成策略的时候,问题就解决了。

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