[Mod]添加对OFFSET_CLOSE在不同交易所的区别判断
This commit is contained in:
parent
f3eea4a1c0
commit
711265c70a
@ -654,14 +654,18 @@ class PositionDetail(object):
|
|||||||
# 平昨
|
# 平昨
|
||||||
elif trade.offset is OFFSET_CLOSEYESTERDAY:
|
elif trade.offset is OFFSET_CLOSEYESTERDAY:
|
||||||
self.shortYd -= trade.volume
|
self.shortYd -= trade.volume
|
||||||
# 平仓(非上期所,优先平今)
|
# 平仓
|
||||||
elif trade.offset is OFFSET_CLOSE:
|
elif trade.offset is OFFSET_CLOSE:
|
||||||
self.shortTd -= trade.volume
|
# 上期所等同于平昨
|
||||||
|
if self.exchange is EXCHANGE_SHFE:
|
||||||
if self.shortTd < 0:
|
self.shortYd -= trade.volume
|
||||||
self.shortYd += self.shortTd
|
# 非上期所,优先平今
|
||||||
self.shortTd = 0
|
else:
|
||||||
|
self.shortTd -= trade.volume
|
||||||
|
|
||||||
|
if self.shortTd < 0:
|
||||||
|
self.shortYd += self.shortTd
|
||||||
|
self.shortTd = 0
|
||||||
# 空头
|
# 空头
|
||||||
elif trade.direction is DIRECTION_SHORT:
|
elif trade.direction is DIRECTION_SHORT:
|
||||||
# 开仓
|
# 开仓
|
||||||
@ -675,11 +679,16 @@ class PositionDetail(object):
|
|||||||
self.longYd -= trade.volume
|
self.longYd -= trade.volume
|
||||||
# 平仓
|
# 平仓
|
||||||
elif trade.offset is OFFSET_CLOSE:
|
elif trade.offset is OFFSET_CLOSE:
|
||||||
self.longTd -= trade.volume
|
# 上期所等同于平昨
|
||||||
|
if self.exchange is EXCHANGE_SHFE:
|
||||||
if self.longTd < 0:
|
self.longYd -= trade.volume
|
||||||
self.longYd += self.longTd
|
# 非上期所,优先平今
|
||||||
self.longTd = 0
|
else:
|
||||||
|
self.longTd -= trade.volume
|
||||||
|
|
||||||
|
if self.longTd < 0:
|
||||||
|
self.longYd += self.longTd
|
||||||
|
self.longTd = 0
|
||||||
|
|
||||||
# 汇总今昨
|
# 汇总今昨
|
||||||
self.calculatePosition()
|
self.calculatePosition()
|
||||||
|
Loading…
Reference in New Issue
Block a user