1.8 KiB
1.8 KiB
id, status
| id | status |
|---|---|
| ac-0013 | active |
장마감 자동취소와 체결 경합의 슬롯·원장 정합성
Criterion
KIS 주문조회가 장마감 자동취소의 terminal evidence를 제공하면 무체결 초기 매수는 PENDING_BUY → INACTIVE, 무체결 증액 매수는 broker 기존 보유량 기준 PENDING_BUY → HOLDING으로 전환해야 한다. 매수 부분체결 후 잔량취소는 체결분을 deterministic execution identity로 ledger에 exactly-once 기록하고 broker 잔고 기준으로 HOLDING을 확정해야 한다. 매도 무체결 또는 부분체결 후 잔량취소는 broker 잔고에 따라 HOLDING 또는 기존 terminal sell 경계를 적용해야 하며, 취소 flag와 전량체결이 경합하면 전량체결 경로를 우선해야 한다. 반복 polling·outbox 재처리·daemon 재시작은 슬롯수량이나 ledger 체결을 중복시키지 않아야 한다.
Verification
- 성공 조건: 초기/증액 매수 무체결, 매수·매도 부분체결, 전량체결 race가 각각 정해진 슬롯 상태·broker-authoritative 수량·ledger 결과를 만들고 동일 execution의 반복 처리에도 ledger item은 하나다.
- 실패·경계 조건: 부분체결을 전량취소로 소실하거나, 전량체결을 취소로 rollback하거나, 로컬 추정수량을 broker 잔고보다 우선하거나, 동일 체결을 중복 ledger 기록하거나, terminal evidence 없이 상태를 확정하면 FAIL이다.
- 검사 방법:
tests/application/test_execution_cancel.py,tests/application/test_execution_ledger.py,tests/adapters/broker/test_kis_cancel.py와tests/application/test_order_timeout_reconciliation.py를 실행하여 zero/partial/full race, broker balance authority와 deterministic ledger idempotency를 검증한다.