Merge pull request #1112 from nanoric/fix_ctpGateway_onRspQryInvestorPosition_KeyError_before_qryInstrument

[Fix] ctpGateway: 修正一个在查询持仓时,若未查询过该合约大小则出错的BUG
This commit is contained in:
vn.py 2018-09-14 17:11:06 +08:00 committed by GitHub
commit 3790777475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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