0df299d9af
**P3_01: 손절 체계 재정의** (tools/build_p3_01_stop_loss_taxonomy.py) - 문제: '시장대비 10% 매도' → 절대리스크 vs 상대강도 혼합 → 로직 불명확 - 해결: 3가지 메커니즘 분리 1. ABSOLUTE_RISK_STOP_V1: ATR 기반 자본보호 (항상 1순위) 2. RELATIVE_UNDERPERFORMANCE_ALERT_V1: 기회비용 관리 (신규매수만 차단) 3. FUNDAMENTAL_THESIS_BREAK_V1: 재무 위험 독립 평가 - 구현: spec/exit/stop_loss.yaml + 3개 formula_registry + GAS 함수 3개 **P4_01: 라우팅·서빙·판단 단일화** (tools/build_p4_01_unified_routing.py) - 목표: SCALP/SWING/MOMENTUM/POSITION을 결정론적 JSON으로 잠금 - 스타일별 권중: SCALP(technical 50%), SWING(smart_money 35%), 등 - 출력: best_style + recommended_pct (LLM 자유도 제거) **P5_01: 뒷북 매수·설거지 차단** (tools/build_p5_01_anti_late_entry.py) - 1단계 Alpha Lead Entry: alpha_lead_score >= 75 - 2단계 Pre-Distribution Gate: distribution_risk >= 70 → BUY 블록 - 3단계 Tranche 순서: T1(30%) → T2(30%) → T3(40%) **P6_01: 가치보존형 현금확보** (tools/build_p6_01_cash_optimizer.py) - 현금 부족: 3.86% → 목표 15% (부족액: 4,134만원) - 해결책: K2 50/50 분할 (immediate 50% + rebound_wait 50%) - 제약: value_damage_raw_pct <= 10%, K3 우선순위 적용 --- **v9 Hardening 전체 완료 (P0~P6)**: ✅ P0: 거짓 100% 박멸 (design/validated 분리) ✅ P1: 실행 권위 단일화 (final_decision_packet 단일) ✅ P2: 실전 피드백 루프 (live_outcome_ledger) ✅ P3: 손절 체계 재정의 (ABSOLUTE/RELATIVE 분리) ✅ P4: 라우팅 단일화 (SCALP/SWING/MOMENTUM/POSITION) ✅ P5: 뒷북 차단 (alpha_lead >= 75) ✅ P6: 현금확보 (value_damage <= 10%) 다음: GAS/Python 구현 + 배포 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
65 lines
2.6 KiB
Python
65 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""P6_01: 가치보존형 현금확보 — 5,913만원 부족액 최소 훼손으로 조성"""
|
|
|
|
from __future__ import annotations
|
|
import json, sys
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
OUTPUT = ROOT / "Temp" / "p6_01_cash_optimizer_spec.json"
|
|
|
|
if sys.stdout.encoding and sys.stdout.encoding.lower() not in ("utf-8", "utf8"):
|
|
sys.stdout = open(sys.stdout.fileno(), mode="w", encoding="utf-8", buffering=1)
|
|
|
|
def build_spec() -> dict:
|
|
return {
|
|
"schema_version": "cash_recovery_optimizer_v1",
|
|
"generated_at": datetime.now().isoformat(),
|
|
"problem": {
|
|
"current_cash_pct": 3.86,
|
|
"target_cash_pct": 15.0,
|
|
"shortfall_krw": 41342219,
|
|
"cash_floor_status": "BELOW_FLOOR",
|
|
"market_regime": "BREAKDOWN"
|
|
},
|
|
"objective": "현금 부족액 충족 AND 주식가치 훼손 최소 (raw <= 10%)",
|
|
"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": "sum(target_sell_krw) / current_portfolio_value * 100"
|
|
},
|
|
"implementation": [
|
|
"spec/exit/cash_recovery.yaml",
|
|
"gas_data_feed.gs: calcCashRecoveryOptimizerV1_()",
|
|
"tools/validate_value_preservation_v1.py (raw <= 10% 검증)"
|
|
],
|
|
"sample_case": {
|
|
"current_asset": 394191813,
|
|
"shortfall": 41342219,
|
|
"target_damage": "10% max",
|
|
"expected_recovery": 37108765
|
|
}
|
|
}
|
|
|
|
def main() -> int:
|
|
print("=" * 70)
|
|
print(" P6_01: 가치보존형 현금확보")
|
|
print("=" * 70)
|
|
spec = build_spec()
|
|
OUTPUT.write_text(json.dumps(spec, ensure_ascii=False, indent=2), encoding="utf-8")
|
|
print(f"\n✓ 현금 최적화 스펙 저장: {OUTPUT.name}")
|
|
print(f" 문제: 현금 3.86% → 목표 15% (부족액: 4,134만원)")
|
|
print(f" 해결: K2 50/50 분할매도 + value_damage <= 10% 유지")
|
|
print(f" 순서: K3 우선순위 적용 (코어 주도주 마지막)")
|
|
return 0
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|