feat(v9-hardening): Complete P3~P6 specs, GAS functions, and MudBlazor UI

Phase 2 implementation complete:

P3 - 손절 체계 재정의 (Stop Loss Taxonomy):
  - spec/exit/stop_loss.yaml: P3 섹션 추가
  - calcAbsoluteRiskStopV1_: 절대 손실 금지선 (entry * 0.92 vs ATR * 1.5)
  - calcRelativeUnderperfAlertV1_: 상대 성과 추적 (WATCH/TRIM_30/TRIM_50/EXIT_100)
  - calcStopActionLadderV1_: 사다리식 액션 결정

P4 - 라우팅 단일화 (Unified Routing):
  - spec/xx_routing_contract.yaml: 4가지 스타일 가중치 정의
  - buildRoutePacket_: SCALP/SWING/MOMENTUM/POSITION 점수 + best_style 결정

P5 - 뒷북 차단 (Anti-Late Entry):
  - spec/exit/pre_distribution_gate.yaml: 배분 위험 조기 감지
  - calcAlphaLeadV1_: Alpha Lead Entry Gate (alpha_lead_score >= 75)
  - calcDistributionRiskV1_: Pre-Distribution Early Warning (risk >= 70)

P6 - 현금확보 (Cash Recovery):
  - spec/exit/cash_recovery.yaml: K2 50/50 분할 + value_damage <= 10%
  - calcCashRecoveryOptimizerV1_: 현금 최적화 (부족액 4,134만원)

UI/UX 개선 (MudBlazor 6.10.0):
  - Dashboard.razor: 단순 버전 (컴파일 에러 제거)
  - MainLayout.razor: Typo enum 수정 (H5→h5, H6→h6)
  - NavMenu.razor: Icons.Material.Filled.Portfolio → Inventory2

릴리스 빌드:
  - dotnet publish -c Release 성공
  - publish 폴더 24MB (배포 준비 완료)

실전 운영 계획:
  - spec/realtime/live_outcome_ledger_plan.yaml: 30건 신호 샘플링 계획
  - honest_proof_score: 56.57 → 95.0 개선 경로 정의
  - 예상 기간: 2026-06-25 ~ 2026-08-10 (약 6주)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-06-25 17:56:13 +09:00
parent 85568a338a
commit 0a51702a9a
11 changed files with 1136 additions and 264 deletions
+87
View File
@@ -0,0 +1,87 @@
---
schema_version: "cash_recovery_optimizer_v1"
generated: "2026-06-25"
description: "P6: 가치보존형 현금확보"
# Phase 6: 현금확보 (은퇴자산포트폴리오 목표 달성을 위한 현금 조성)
# 현재: 자산 3.94억, 현금 부족: 4,134만원 (목표: 5억)
# 제약: value_damage_raw_pct <= 10% (자산 가치 훼손 최소화)
problem:
current_asset_krw: 394191813 # 현재 자산
target_asset_krw: 500000000 # 목표
shortfall_krw: 41342219 # 부족액
current_cash_pct: 3.86 # 현금 비중
target_cash_pct: 15.0 # 목표 현금 비중
status: "BELOW_FLOOR"
market_regime: "BREAKDOWN"
objective: "현금 부족액 충족 AND 주식가치 훼손 최소 (raw <= 10%)"
# ─────────────────────────────────────────────────────────────────────────────
# 핵심 전략: K2 50/50 분할
# ─────────────────────────────────────────────────────────────────────────────
approach: "K2 50/50 분할: immediate_qty + rebound_wait_qty"
key_rules:
rule_1: |
K2 즉시 50% / 반등 대기 50% 분할
(rebound_trigger_price 도달 전까지 대기 주문 실행 금지)
rule_2: |
매도 순서: K3 regime_adjusted_sell_priority 사용
코어 주도주 마지막 (상승추세 종목 보호)
rule_3: |
value_damage_raw_pct <= 10% 상한 유지
(cap_pass=false 허용 안함)
rule_4: |
emergency_full_sell=true 조건:
(half_expected * 2) < shortfall_min 일 때만
# ─────────────────────────────────────────────────────────────────────────────
# 공식
# ─────────────────────────────────────────────────────────────────────────────
formulas:
rebound_trigger_price: |
prevClose + 0.5 * ATR20
(tick 정규화 후 지정가 사용)
value_damage_raw_pct: |
sum(target_sell_krw) / current_portfolio_value * 100
immediate_qty_pct: 50
rebound_wait_qty_pct: 50
# ─────────────────────────────────────────────────────────────────────────────
# 구현
# ─────────────────────────────────────────────────────────────────────────────
implementation:
- "spec/exit/cash_recovery.yaml (현재 파일)"
- "src/google_apps_script/gas_data_feed.gs: calcCashRecoveryOptimizerV1_()"
- "tools/validate_value_preservation_v1.py (raw <= 10% 검증)"
sample_case:
current_asset: 394191813
shortfall: 41342219
target_damage_pct: "10% max"
expected_recovery: 37108765
execution_checklist:
- "K3 regime_adjusted_sell_priority 실행"
- "매도 대상 종목 선정 (코어 제외)"
- "immediate 50% 주문 발생"
- "rebound_trigger_price 모니터링"
- "rebound_wait 50% 대기 주문 준비"
- "value_damage 모니터링 (10% 이내)"
- "emergency 조건 평가"
enforcement:
- "자동 매도 순서 적용, 수동 개입 금지"
- "value_damage > 10% 초과 시 ABORT"
- "모든 주문 로깅 의무"
+82
View File
@@ -0,0 +1,82 @@
---
schema_version: "pre_distribution_gate_v1"
generated: "2026-06-25"
description: "P5: 뒷북 매수·설거지 차단"
# Phase 5: 뒷북 차단 (배분 위험 조기 감지)
# late_chase_status=DEGRADE_BUY_PERMISSION 발동 중 → 차단
purpose: "배분 상황의 뒷북 매수 · 설거지 청산 차단"
# ─────────────────────────────────────────────────────────────────────────────
# Solution 1: ALPHA_LEAD_ENTRY_GATE_V1
# ─────────────────────────────────────────────────────────────────────────────
solution_1_alpha_lead_entry:
name: "ALPHA_LEAD_ENTRY_GATE_V1"
purpose: "선행 진입만 허용, 뒷북 진입 차단"
rules:
pilot_allowed: |
alpha_lead_score >= 75 AND lead_entry_state == PILOT_ALLOWED
add_on_allowed: |
pilot_pnl >= 0 AND flow_confirmed=true AND breakout_volume_confirmed=true
pullback_allowed: |
confirmed_add_on=true AND pullback_to_ma20_or_atr_band=true
tranche_order:
- "T1: 30% (파일럿 진입)"
- "T2: 30% (add_on 추가)"
- "T3: 40% (pullback 추가, 최후 진입)"
forbidden:
- "CONFIRMED_ADD_ON 없이 T3 진입 금지"
- "분위기로 PILOT 승격 금지"
- "상대 강세만으로 T3 진입 금지"
gas_function: "calcAlphaLeadV1_(alphaLeadScore, leadEntryState, pilotPnL, flowConfirmed)"
# ─────────────────────────────────────────────────────────────────────────────
# Solution 2: PRE_DISTRIBUTION_EARLY_WARNING_V1
# ─────────────────────────────────────────────────────────────────────────────
solution_2_pre_distribution_gate:
name: "PRE_DISTRIBUTION_EARLY_WARNING_V1"
purpose: "배분 위험 신호 4개 중 2개 이상 → BUY 차단"
block_buy_conditions:
- condition: "distribution_risk_score >= 70"
meaning: "배분 위험 점수 높음"
weight: "critical"
- condition: "price_up_volume_down == true"
meaning: "가격 상승 vs 거래량 하락 (약세 신호)"
weight: "high"
- condition: "foreign_inst_net_sell_5d == true"
meaning: "외국인 기관 순매도 (5일)"
weight: "high"
- condition: "candle_upper_tail_cluster == true"
meaning: "상부 꼬리 연속 형성 (배분 신호)"
weight: "medium"
trigger_logic: "2개 이상 신호 발생 → BLOCK_BUY"
action: "BLOCK_BUY (진입 금지)"
gas_function: "calcDistributionRiskV1_(score, priceUpVolDown, foreignInstNetSell5d, candleUpperTailCluster)"
# ─────────────────────────────────────────────────────────────────────────────
# 구현
# ─────────────────────────────────────────────────────────────────────────────
implementation:
- "spec/exit/pre_distribution_gate.yaml (현재 파일)"
- "src/google_apps_script/gas_data_feed.gs: calcAlphaLeadV1_(), calcDistributionRiskV1_()"
- "tools/validate_alpha_execution_harness.py (검증)"
enforcement:
- "Alpha Lead: 자동 실행, LLM 자유도 없음"
- "Distribution Gate: 자동 실행, LLM 자유도 없음"
- "차단 사항 로깅 의무"
+67
View File
@@ -99,6 +99,73 @@ timing_exit_score_formula:
v1_deprecated: "close × 0.998 (0.2% — 변동성 무시, 사실상 시가 매도)"
trailing_stop_breach: "trailingStop 가격 직접 사용. min(trailingStop, close×0.998) 적용 금지."
# ─────────────────────────────────────────────────────────────────────────────
# [P3: 손절 체계 재정의] ABSOLUTE_RISK_STOP_V1, RELATIVE_UNDERPERFORMANCE_ALERT_V1
# ─────────────────────────────────────────────────────────────────────────────
p3_absolute_risk_stop_v1:
name: "절대 손실 금지선 (P3)"
formula: "max(entry_price * 0.92, entry_price - ATR20 * 1.5)"
purpose: "진입가 대비 절대 손실 8% 또는 변동성 1.5배 중 높은쪽"
quantity_strategy:
immediate: "50% 즉시 매도"
rebound_wait: "50% 반등 대기"
rebound_trigger: "prevClose + 0.5 * ATR20"
order_method: "지정가 주문"
enforcement: "자동 실행, LLM 자유도 없음"
gas_function: "calcAbsoluteRiskStopV1_(entry_price, atr20) → stop_price"
p3_relative_underperformance_alert_v1:
name: "상대 성과 추적 (P3)"
condition: "excess_return_20d <= min(-10%, relative_threshold)"
action_ladder:
step_1: "WATCH: 모니터링 시작 (상대 underperformance -10%~-15%)"
step_2: "TRIM_30: 30% 감소 (상대 underperformance -15%~-20%)"
step_3: "TRIM_50: 추가 20% 감소 총 50% (상대 underperformance -20%~-25%)"
step_4: "EXIT_100: 완전 청산 (상대 underperformance < -25% AND 절대손실 >= 8%)"
forbidden:
- "상대 성과만으로 EXIT_100 금지 (절대손실 8% 미만)"
- "기술지표만으로 TRIM_50 금지"
gas_function: "calcRelativeUnderperfAlertV1_(ret_stock_20d, ret_market_20d) → alert_state"
action_ladder_function: "calcStopActionLadderV1_(alert_state, underperf_pct) → action"
p3_fundamental_thesis_break_v1:
name: "기본 이론 파괴 감지 (P3)"
description: "기업 기본가치 붕괴 신호 (절대/상대와 독립 평가)"
signals:
- "EPS cut ≥ 10%"
- "분기별 매출 성장률 역신장"
- "경쟁사 점유율 급락"
- "법적/규제 문제 발생"
action: "검증 후 EXIT_100 (다른 제약 불적용)"
override_absolute_stop: true
override_relative_alert: true
enforcement: "수동 검증 + 자동 실행"
p3_formula_registry:
- name: "calcAbsoluteRiskStopV1"
inputs: ["entry_price", "atr20"]
output: "stop_price"
formula: "max(entry * 0.92, entry - atr20 * 1.5)"
unit: "KRW"
- name: "calcRelativeUnderperfAlertV1"
inputs: ["return_stock_20d", "return_market_20d"]
output: "alert_state"
states: ["WATCH", "TRIM_30", "TRIM_50", "EXIT_100"]
logic: "ladder transition based on excess_return"
- name: "calcStopActionLadderV1"
inputs: ["alert_state", "underperf_pct", "absolute_loss_pct"]
output: "action"
logic: "WATCH → TRIM_30 → TRIM_50 → EXIT_100 with absolute_loss check"
p3_validation:
- "gap_down 프로토콜: 매도불가 상황에서 WAIT_FOR_OPEN"
- "TICK_NORMALIZER 통과 확인"
- "포지션 크기 조정 후 재진입 재평가"
- "지정가 주문이 체결되지 않으면 시장가 전환"
stop_loss:
principle: "손절가·손절수량·잔여수량·재진입 조건을 함께 제시"
priority_matrix: # [proposal_75 / 2026-05-15] 복수 손절 조건 동시 발동 시 최종 HTS 지정가 결정