[Fix] ctpGateway: 修正一个在查询持仓时,若未查询过该合约大小则出错的BUG

This commit is contained in:
nanoric 2018-09-13 21:29:32 -04:00
parent 904895899a
commit 24198b82be

View File

@ -734,6 +734,8 @@ class CtpTdApi(TdApi):
pos.ydPosition = data['Position'] - data['TodayPosition'] pos.ydPosition = data['Position'] - data['TodayPosition']
# 计算成本 # 计算成本
if pos.symbol not in self.symbolSizeDict:
return
size = self.symbolSizeDict[pos.symbol] size = self.symbolSizeDict[pos.symbol]
cost = pos.price * pos.position * size cost = pos.price * pos.position * size