This commit is contained in:
msincenselee 2018-01-30 21:39:26 +08:00
parent 37e31c34dd
commit 99f2de2161

View File

@ -796,7 +796,8 @@ class CtpTdApi(TdApi):
# 计算持仓均价
if pos.position and pos.symbol in self.symbolSizeDict:
size = self.symbolSizeDict[pos.symbol]
pos.price = (cost + data['PositionCost']) / (pos.position * size)
if size > 0 and pos.position > 0:
pos.price = (cost + data['PositionCost']) / abs(pos.position * size)
# 读取冻结
if pos.direction is DIRECTION_LONG: