vnpy / vnpy_ib

VeighNa框架的InteractiveBrokers交易接口
https://www.vnpy.com
MIT License
34 stars 31 forks source link

IB外汇成交后保存状态报错 #55

Open Mjzs12138 opened 1 month ago

Mjzs12138 commented 1 month ago

错误信息如下。委托成交后同步数据时json保存出错。

Traceback (most recent call last): File "C:\Softwares\veighna_studio\lib\threading.py", line 1016, in _bootstrap_inner self.run() File "C:\Softwares\veighna_studio\lib\threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "C:\Softwares\veighna_studio\lib\site-packages\vnpy\event\engine.py", line 60, in _run self._process(event) File "C:\Softwares\veighna_studio\lib\site-packages\vnpy\event\engine.py", line 73, in _process [handler(event) for handler in self._handlers[event.type]] File "C:\Softwares\veighna_studio\lib\site-packages\vnpy\event\engine.py", line 73, in [handler(event) for handler in self._handlers[event.type]] File "C:\Softwares\veighna_studio\lib\site-packages\vnpy_ctastrategy\engine.py", line 211, in process_trade_event self.sync_strategy_data(strategy) File "C:\Softwares\veighna_studio\lib\site-packages\vnpy_ctastrategy\engine.py", line 842, in sync_strategy_data save_json(self.data_filename, self.strategy_data) File "C:\Softwares\veighna_studio\lib\site-packages\vnpy\trader\utility.py", line 119, in save_json json.dump( File "C:\Softwares\veighna_studio\lib\json__init__.py", line 179, in dump for chunk in iterable: File "C:\Softwares\veighna_studio\lib\json\encoder.py", line 431, in _iterencode yield from _iterencode_dict(o, _current_indent_level) File "C:\Softwares\veighna_studio\lib\json\encoder.py", line 405, in _iterencode_dict yield from chunks File "C:\Softwares\veighna_studio\lib\json\encoder.py", line 405, in _iterencode_dict yield from chunks File "C:\Softwares\veighna_studio\lib\json\encoder.py", line 438, in _iterencode o = _default(o) File "C:\Softwares\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

Mjzs12138 commented 1 month ago

vnpy_ib, vnpy, vnpy_ctastrategy都是最新版本

vnpy commented 1 month ago

策略变量上,定义了非str/float/int/bool这四种基础类型的其他类型吧

Mjzs12138 commented 1 month ago

没有哦,variables只有这四种基础类型。而且,只有通过IB委托成交才会报此错误,ctp则没有出现过。

vnpy commented 1 month ago

IB的价格数据,有Decimal这个高精度浮点数类型噢