fix: preserve SOR execution venue separately

This commit is contained in:
Hermes Agent
2026-08-19 12:48:05 +09:00
parent 15aeae6930
commit 7366cadf03
15 changed files with 126 additions and 17 deletions
+4 -1
View File
@@ -104,7 +104,10 @@ class FillStatus:
execution_id: Optional[str] = None
fee: float = 0.0
tax: float = 0.0
# dcy-013 / REQ-012 (issue #9): an external cancel was detected. When the
# Broker-authoritative execution exchange. For SOR orders this is KRX or
# NXT; None means the polling surface did not establish it.
execution_venue: Optional[str] = None
# dcy-013 / REQ-012: an external cancel was detected.
# order had a partial fill before the cancel, state stays "partially_filled"
# and this flag is set so execution records the filled portion and returns
# the remainder to holding (is_partial_cancel). A zero-fill external cancel
+16 -1
View File
@@ -773,6 +773,20 @@ class ExecutionService:
if resolved_price is not None
else (float(fs.avg_price) if fs.avg_price is not None else 0.0)
)
execution_venue = fs.execution_venue
if execution_venue is None and slot.venue in {"KRX", "NXT"}:
execution_venue = slot.venue
if execution_venue not in {"KRX", "NXT"}:
r.ledger_skipped += 1
_log.warning(
"ledger skip: slot=%s portfolio_id=%s side=%s "
"reason=missing_execution_venue order_venue=%s",
slot.slot_id,
slot.portfolio_id,
side,
slot.venue,
)
return
trade = LedgerTrade(
asset_id=str(slot.portfolio_id),
order_id=str(broker_order_id),
@@ -783,7 +797,8 @@ class ExecutionService:
fee=float(fs.fee),
tax=float(fs.tax),
executed_at=datetime.now(tz=timezone.utc),
venue=slot.venue,
venue=execution_venue,
order_venue=slot.venue,
)
self._ledger_outbox.enqueue(trade)
r.ledger_enqueued += 1
+3 -2
View File
@@ -57,9 +57,10 @@ class LedgerTrade:
fee: float = 0.0
tax: float = 0.0
executed_at: Optional[datetime] = None
# Actual order venue persisted in the Core outbox. Portfolio Hub remains
# unchanged until its API contract explicitly accepts this additive field.
# Broker-authoritative execution exchange (KRX/NXT).
venue: str = "KRX"
# Original submission/routing venue (KRX/NXT/SOR), retained for audit.
order_venue: str = "KRX"
@property
def correlation_id(self) -> str: