feat: 집계 배치율 감시 — 설계 대비 미달을 헬스로 표면화#431
Merged
Merged
Conversation
한 달 운영 리뷰(docs/PAPER_MONTH1_REVIEW_AND_PLAN.md P1-5) 처방. 종목별 드리프트 트리거는 집계 배치율 이탈을 못 본다 — 이번 달 하이닉스 슬롯 공백+정수 절사로 실효 주식비중이 설계 80% 대신 59%로 굳었는데 아무 알림이 없었다. core/operator_health.py: - summarize_deployment(순수): 실제 주식비중이 설계보다 tolerance(기본 5%p) 초과 미달이면 ATTENTION(초과 배치는 리밸런서가 자연 교정하므로 미달만 감시) - summarize_basket_operation이 미달 시 verdict ATTENTION 승격(staleness와 공존) main.py --mode health: - 최신 스냅샷(total_value, cash)으로 배치율 계산 — 네트워크 불필요 - 설계 비중은 BasketRebalancer._stock_fraction과 동일 규칙으로 계산 - 복수 바스켓이면 가장 미달인 바스켓을 대표 보고 실CLI 스모크로 59%<80% ATTENTION 확인. 스모크가 내가 넣은 config 미정의 NameError(바스켓 헬스 섹션을 통째로 삼킴)를 적발해 수정. 적대적 리뷰 반영: - 배치율 계산을 자체 try로 격리 — bad config(float 불가 target_stock_weight 오타 등)가 결측/staleness 감지를 삼키지 않게(medium) - 경계(shortfall==tolerance) 엄격 '>' 고정 테스트 추가 전체 스위트 1574 통과.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
무엇
한 달 운영 리뷰(docs/PAPER_MONTH1_REVIEW_AND_PLAN.md P1-5)의 집계 배치율 감시를 구현합니다.
왜
종목별 드리프트 트리거(8%p)는 집계 배치율 이탈을 영영 못 봅니다. 이번 달 하이닉스 슬롯 공백 + 정수 절사로 실효 주식비중이 설계 80% 대신 59%로 굳었는데, 어떤 알림도 없었습니다. 이 이탈을 운영자 헬스로 표면화합니다.
무엇을 했나
core/operator_health.pysummarize_deployment(deployment_ratio, design_fraction, tolerance=0.05)— 실제가 설계보다 5%p 초과로 낮으면 ATTENTION(초과 배치는 리밸런서가 자연 교정하므로 미달만 감시).summarize_basket_operation이 배치율 미달 시 verdict를 ATTENTION으로 승격 + 노트 추가(스냅샷 staleness 판정과 공존).main.py run_health_checkPortfolioSnapshot(total_value, cash)으로 배치율 계산 → 네트워크 불필요.BasketRebalancer._stock_fraction과 동일 규칙으로 계산(min_cash_ratio / target_stock_weight).실CLI 스모크 + 적대적 리뷰
--mode health:주식 배치율 59% < 설계 80% (-21.1%p)ATTENTION 정상 출력.config미정의(NameError)가 바스켓 헬스 섹션을 통째로 조용히 죽이던 것을 실행으로 잡아 수정(모의 테스트로는 안 잡혔을 이슈).target_stock_weight오타 하나로 핵심 결측 신호까지 삼켜지던 문제 → 배치율 계산을 자체 try로 격리(실패해도 결측/staleness 감지는 생존).>고정 테스트 추가.테스트
tests/test_operator_health.py에summarize_deployment분기 +summarize_basket_operation배치율 승격 + 경계 테스트.