fix: reconcile KIS exchange rejections

This commit is contained in:
jordan
2026-07-28 13:29:43 +09:00
parent 24c42d1c92
commit d6c2e2d28a
5 changed files with 89 additions and 7 deletions
+7
View File
@@ -496,6 +496,7 @@ class KISBroker:
) -> FillStatus:
ord_qty = _safe_int(row.get("ord_qty")) or 0
ccld_qty = _safe_int(row.get("tot_ccld_qty")) or 0
rejected_qty = _safe_int(row.get("rjct_qty")) or 0
avg = _safe_int(row.get("avg_prvs")) or _safe_int(row.get("ccld_prvs"))
# dcy-013 / REQ-012 (issue #9): external cancel detection. KIS
# inquire-daily-ccld marks a cancelled order with cncl_yn="Y". Without
@@ -504,6 +505,12 @@ class KISBroker:
# cancelled (conservative — the stale watchdog is the backstop, R-1).
cancelled = str(row.get("cncl_yn") or "").strip().upper() == "Y"
if ccld_qty <= 0:
# KIS can acknowledge an order submission and later report the
# whole quantity as exchange-rejected without setting cncl_yn.
# Treating that row as accepted leaves the slot pending forever
# and suppresses the strategy's next valid signal.
if rejected_qty > 0 and (ord_qty <= 0 or rejected_qty >= ord_qty):
return FillStatus(state="rejected", raw=row)
if cancelled:
return FillStatus(state="cancelled", raw=row) # full external cancel
return FillStatus(state="accepted", raw=row)