fix(broker): dcy-013 KIS 외부 취소 감지 + 부분 체결 회계 + stale 워치독 (BAT-017)
KIS 계좌에서 직접 매도 주문을 취소하면 poll_fill 이 cncl_yn 을 파싱하지 않아 슬롯이 pending_sell 에 영구히 갇히고 죽은 주문을 무한 폴링하던 버그(issue #9) 정정. 거버넌스: 전부 change-req (신규 REQ 없음, dcy-013 OQ-3). - REQ-012: KIS poll_fill cncl_yn 파싱 → 외부 취소 감지. FillStatus.cancelled /is_partial_cancel 추가. 체결 0 취소→cancelled, 부분 체결 후 취소→partial+cancelled - REQ-013: 집행 _on_partial_cancel — 체결분 원장 1회 + qty 차감(매도 잔여/매수 체결분) + holding 복귀 (OQ-1 A안). 전량 취소는 기존 롤백 경로 재사용 - REQ-018: 부분 체결분 원장 1회 기록 (_record_ledger 재사용) - REQ-031: 잔여 포지션 정합 연계 (slot.qty ↔ 실 잔고, 과매도 방지) - REQ-014: pending stale 워치독 Alert-only (TREX_PENDING_STALE_THRESHOLD, WARN+카운터, 상태 미변경) — 취소 감지 누락 backstop - REQ-015: interface-contract/runtime-flows 정합 전량 취소는 holding 자동 복구(limit_price clear→재매도 시장가, dcy-012 연계). KIS cncl_yn 실 규약은 운영 검증(미지 값 보수 처리 + 워치독 backstop). 검증: 단위 294 passed/32 skipped, 인프라 게이트(PG+RabbitMQ) 326 passed, ruff clean. 신규 test_kis_cancel(httpx stub) + test_execution_cancel(programmable broker). BAT-017 release-candidate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -133,3 +133,41 @@
|
||||
- AC-1: tests/application/test_reconciliation.py::test_mismatch_raises_warning_and_masks_asset.
|
||||
- AC-2: ::test_subsequent_match_auto_clears_warning.
|
||||
- AC-3: ::test_paper_broker_returns_deterministic_balance.
|
||||
|
||||
### CHG-20260608-01
|
||||
|
||||
- Date: 2026-06-08
|
||||
- Author: Justin Ko
|
||||
|
||||
#### Change Summary
|
||||
|
||||
- (change-req, dcy-013/issue #9) 부분 체결 후 외부 취소 처리(REQ-013)가 슬롯 qty 를 체결분만큼 차감하고 잔여를 holding 으로 복귀시켜, 슬롯 잔여 수량이 실 브로커 잔고와 정합하도록 보장한다(과매도 방지). 포지션 정합 검증 로직 자체(`reconcile_positions`)는 코드 변경 없음 — 본 change-req 는 정합 불변식이 유지됨을 명시하는 연계 기록. BAT-017 검증 완료 → Implemented 유지.
|
||||
|
||||
#### Intent
|
||||
|
||||
- 부분 체결+취소에서 slot.qty ↔ 실제 held 수량 정합을 보장해 REQ-031 의 포지션 정합 불변식이 깨지지 않게 한다.
|
||||
|
||||
#### Acceptance Criteria Delta
|
||||
|
||||
- (변경 없음 — reconcile 로직 불변. 부분 취소 회계가 정합 입력을 정확히 유지)
|
||||
|
||||
#### Impacted Area Delta
|
||||
|
||||
- Modules: (없음 — REQ-013 `_on_partial_cancel` 이 잔여 qty 를 정확히 갱신)
|
||||
- Tests: tests/application/test_execution_cancel.py(잔여 qty=6 정합)
|
||||
|
||||
#### Delivery Trace Delta
|
||||
|
||||
- Batches: BAT-017
|
||||
- Releases: none
|
||||
|
||||
#### Revalidation Impact
|
||||
|
||||
- Reverification Needed: no (reconcile 코드 불변, 회계 정확성은 REQ-013 테스트로 커버)
|
||||
- Existing Implementation Invalidated: no
|
||||
- Status Recommendation: Implemented (연계 change-req)
|
||||
- Follow-up Action: confirm-req-implemented(BAT-017).
|
||||
|
||||
#### Validation Plan
|
||||
|
||||
- BAT-017: 부분 취소 후 slot.qty 가 잔여 held 와 일치(과매도 0).
|
||||
|
||||
Reference in New Issue
Block a user