매도(sell) 주문이 현재가가 아닌 매수가(entry_price) 지정가로 나가던 버그(issue #10) 정정. 슬롯의 매수 전용 entry_price 를 side 무관 "현재 pending 주문 지정가" limit_price 로 내부 rename 하고, pending 이탈(→holding/→closed) 시 clear 해 매수 지정가가 매도로 누수되는 경로를 구조적으로 제거. 거버넌스: 전부 change-req (신규 REQ 없음, dcy-012 OQ-3). - REQ-002: Slot entry_price→limit_price rename + clear-on-exit 생애주기 - REQ-006: daily_slot 컬럼 rename 마이그레이션 006 (idempotent) + persistence 매핑 - REQ-013: _dispatch 가 slot.limit_price 단일 필드로 가격/주문유형 결정 - REQ-007: SellIntent/sell payload optional limit_price + _admit_sell 운반 - REQ-036: SlotService.sell optional 가격 → 자율 매도(safety-sell/kill-switch) 시장가 - REQ-003: 컬럼 계약/드리프트 가드 limit_price 반영 - REQ-015: runtime-flows/interface-contract/data-model 정합 매도 정책(OQ-1 하이브리드): 가격 지정→지정가("00"), 미지정→시장가("01"). 자율 매도는 가격 미전달 → 항상 시장가 (손절 미체결 pending_sell 갇힘 방지, issue #9 연계). 검증: 단위 286 passed/32 skipped, 인프라 게이트(PG+RabbitMQ) 318 passed, ruff clean. 신규 test_sell_pricing(recording broker)로 지정가 매수 슬롯의 매도가 매수가 재사용 안 함을 직접 검증. BAT-016 release-candidate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4.4 KiB
4.4 KiB
BAT-016 Planning
- Status: confirmed
- Batch: BAT-016
- Profile: standard
Included REQ
- REQ-002 (Interface, change-req): Slot
entry_price→limit_pricerename + clear-on-exit(→HOLDING/→CLOSED) 생애주기. - REQ-006 (Data, change-req): daily_slot 컬럼 rename 마이그레이션 006(idempotent) + persistence 매핑.
- REQ-013 (Integration, change-req):
_dispatch가slot.limit_price단일 필드로 가격/주문유형 결정(매수가 재사용 제거). - REQ-007 (Interface, change-req):
SellIntent/sell payload optionallimit_price+_admit_sell운반; buy entry_price→limit_price 매핑. - REQ-036 (Interface, change-req):
SlotService.selloptionallimit_price(default None → 자율 매도 시장가). - REQ-003 (Testing, change-req): 컬럼 계약/드리프트 가드 limit_price 반영.
- REQ-015 (Documentation, change-req): runtime-flows/interface-contract/data-model 정합.
Delivery Plan
- REQ-002:
models.pySlot 필드 + EXPECTED_SLOT_FIELDS rename;service.pytransit_slot/_apply_transition_fields 파라미터 rename + clear-on-exit(→HOLDING/→CLOSED),SlotService.selloptional limit_price. - REQ-013:
execution.py::_dispatch가slot.limit_price단일 필드 사용. - REQ-007:
intents.pySellIntent.limit_price + _admit_sell 운반 + _admit_buy limit_price 매핑;messaging_handlers.pysell payload limit_price, slot read 외부 entry_price→limit_price 매핑. - REQ-006:
006_*.sqlrename 마이그레이션(idempotent) +postgresql.py매핑. - REQ-003: 컬럼 계약/드리프트 가드 확인(상수 참조 자동 + DB 게이트).
- REQ-015: baseline 3문서 정합.
- 신규 테스트(test_sell_pricing) + 전체 회귀 + ruff + 인프라 게이트(PG 마이그레이션/컬럼 계약).
Dependencies
- Internal:
- dcy-003/BAT-004 broker execution(
_dispatch) — 버그 지점. - dcy-001/BAT-001 slot 도메인(REQ-002/003) — rename 대상.
- dcy-002/BAT-002 persistence(REQ-006) — 컬럼/마이그레이션.
- dcy-007/BAT-010 safety-sell(REQ-036 SlotService.sell) — 자율 매도 시장가 경로.
- dcy-011/BAT-015 — slot.symbol 서버 resolve(가정 A-1) 충족.
- dcy-003/BAT-004 broker execution(
- External:
- PostgreSQL(rename 마이그레이션). KIS ORD_DVSN 00/01 매핑(OrderRequest 경유).
Design Gate
- Design Required Before Implementation: yes
- Reason: (a)
entry_price→limit_pricerename 은 도메인 모델·서비스 전이·persistence·마이그레이션·컬럼 계약 가드까지 교차 절단(cross-cutting) — 전이별 set/clear 매트릭스를 설계에서 못박지 않으면 매수 지정가 누수/복원 회귀(R-4) 위험. (b) 매도 가격 하이브리드(가격 유무 분기)의 단일 메커니즘 경계(자율=None=시장가, 재량=optional 지정가)를 설계에서 고정해야 reason 별 분기 혼입을 막는다(OQ-2). (c) released 집행 경로(R-1)·컬럼 rename 마이그레이션 idempotency 를 설계에서 명시. → design.md 동일 턴 scaffold.
Milestones
- M1 — REQ-002 도메인 rename + clear-on-exit, 단위 green
- M2 — REQ-013 _dispatch limit_price 단일 필드 + REQ-007/036 sell 가격 경로, test_sell_pricing green
- M3 — REQ-006 마이그레이션 006 + persistence 매핑, PG 게이트 컬럼 계약 green
- M4 — REQ-003 가드 + REQ-015 문서 정합
- M5 — 전체 회귀 + ruff + 인프라 게이트
Risks
- R-1 (High): released 집행 경로 매도 동작 변경. 대응: paper recording broker 로 손절/지정가/현재가>매수가 시나리오 검증 + change-req 이력. 실거래 배포는 release 단계 검증.
- R-2 (Medium): 재량 지정가 미체결 시 pending_sell 잔류. 대응: 본 주기는 가격 결정 분기에 한정, 미체결 처리는 issue #9/기존 롤백 범위.
- R-3 (Low, OQ-2): reason 별 차등 없이 가격 유무로 분기 → 자율 매도는 default None 으로 항상 시장가(체결성 보장).
- R-4 (Medium): rename/clear-on-exit 가 도메인/persistence/마이그레이션 교차. 대응: 전이별 set/clear 단위 + 컬럼 계약 가드 + idempotent 마이그레이션 + 외부 필드명 유지(경계 매핑).
Notes
- 1차 게이트: 전체 회귀 green(rename 호출부 누락 부재 확인).
- 버그 검증은 반드시 지정가 매수 슬롯(entry_price 채워짐) 매도 케이스 포함(S-1 측정 조건).
- 마이그레이션은 PG 게이트(실 PostgreSQL) 컬럼 계약/드리프트 테스트로 검증.