fix(execution): fail closed on unresolved orders
This commit is contained in:
@@ -270,6 +270,14 @@ class ExecutionService:
|
||||
for slot in self._repo.list_dispatched_pending(self._instance_key):
|
||||
side = "buy" if slot.status is SlotState.PENDING_BUY else "sell"
|
||||
set_correlation_id(str(slot.slot_id)) # REQ-084: same key as submit
|
||||
if not str(slot.broker_order_id or "").startswith("submission-unknown:") and (
|
||||
slot.order_submitted_at is None or slot.order_date is None
|
||||
):
|
||||
# Legacy rows cannot be tied safely to an authoritative KIS
|
||||
# inquiry date. Do not poll: a reused ODNO on today's date
|
||||
# could otherwise drive a false terminal transition.
|
||||
self._emit_order_metadata_unknown_alarm(slot)
|
||||
continue
|
||||
fs = self._poll_fill(slot, side)
|
||||
resolved_order_id = (
|
||||
fs.raw.get("resolved_broker_order_id") if isinstance(fs.raw, dict) else None
|
||||
@@ -589,6 +597,11 @@ class ExecutionService:
|
||||
CancelState.REJECTED.value,
|
||||
CancelState.UNKNOWN.value,
|
||||
}
|
||||
if slot.cancel_state == CancelState.REQUESTED.value:
|
||||
reason = fs.raw.get("reason") if isinstance(fs.raw, dict) else None
|
||||
if fs.state == "unknown" or reason == "order_not_visible_unresolved":
|
||||
self._emit_unresolved_cancel_alarm(slot)
|
||||
return
|
||||
if slot.cancel_state is not None and not is_retry:
|
||||
return
|
||||
if is_retry:
|
||||
|
||||
Reference in New Issue
Block a user