Fix roll margin validation and SHFE close offset for night positions.
Use CTP account margin for roll cap checks and prefer close-today on SHFE when yesterday close is rejected. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1015,10 +1015,19 @@ class CtpBridge:
|
||||
return Offset.CLOSE
|
||||
vol = int(getattr(pos, "volume", 0) or 0)
|
||||
yd = int(getattr(pos, "yd_volume", 0) or 0)
|
||||
today = max(0, vol - yd)
|
||||
if today >= lots:
|
||||
td = max(0, vol - yd)
|
||||
if td >= lots:
|
||||
return Offset.CLOSETODAY
|
||||
return Offset.CLOSEYESTERDAY
|
||||
if yd >= lots:
|
||||
# 夜盘仓在 vnpy 常记在 yd,日盘平昨易报「平昨仓位不足」→ 上期所/能源优先平今
|
||||
if ex_u in ("SHFE", "INE"):
|
||||
return Offset.CLOSETODAY
|
||||
return Offset.CLOSEYESTERDAY
|
||||
if td + yd >= lots:
|
||||
return Offset.CLOSETODAY
|
||||
if ex_u in ("SHFE", "INE", "CZCE"):
|
||||
return Offset.CLOSETODAY
|
||||
return Offset.CLOSE
|
||||
|
||||
def _aggressive_limit_price(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user