self.main_engine.connect(setting_ctp, "CTP")
sleep(10)
self.pos_symbol = self.main_engine.get_symbol_position(symbol=self.vt_symbol.split('.')[0])
if self.possymbol:
self.price_cost = self.main_engine.get_position(vt_positionid=f"{self.vt_symbol}.{Direction.LONG.value}").price_
self.pnl = self.main_engine.get_position(vt_positionid=f"{self.vt_symbol}.{Direction.LONG.value}").pnl
self.vol = self.main_engine.get_position(vt_positionid=f"{self.vt_symbol}.{Direction.LONG.value}").volume
elif self.pos_symbol==-1:
self.price_cost = self.main_engine.get_position(vt_positionid=f"{self.vt_symbol}.{Direction.SHORT.value}").price
self.pnl = self.main_engine.get_position(vt_positionid=f"{self.vt_symbol}.{Direction.SHORT.value}").pnl
self.vol = self.main_engine.get_position(vt_positionid=f"{self.vt_symbol}.{Direction.SHORT.value}").volume
请问 程序经常会报 “NoneType” object has no attribute "price"
这种问题 有时出现有时不出现
是跟 我上句 get_symbol_position 读取持仓后 紧接着又读取一次 相关么