fix: SHFE止盈止损平仓改平今并限制重复报单

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-24 14:30:41 +08:00
parent f6ee13765d
commit 397e9cd9d8
3 changed files with 41 additions and 15 deletions
+7 -2
View File
@@ -298,10 +298,15 @@ class CtpBridge:
def _resolve_close_offset(self, sym: str, ex_name: str, hold_direction: str, lots: int) -> Any:
from vnpy.trader.constant import Offset
if ex_name not in ("CZCE", "CFFEX"):
ex_u = (ex_name or "").upper()
# 上期所/能源中心/郑商所/中金所须区分平今/平昨;大商所等可用通用 CLOSE
if ex_u not in ("CZCE", "CFFEX", "SHFE", "INE"):
return Offset.CLOSE
pos = self._find_position(sym, ex_name, hold_direction)
pos = self._find_position(sym, ex_u, hold_direction)
if not pos:
# 找不到持仓明细时,日盘新开仓优先平今(避免 SHFE「平昨仓位不足」)
if ex_u in ("SHFE", "INE", "CZCE"):
return Offset.CLOSETODAY
return Offset.CLOSE
vol = int(getattr(pos, "volume", 0) or 0)
yd = int(getattr(pos, "yd_volume", 0) or 0)