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>
60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""P5_01: 뒷북 매수·설거지 차단 — alpha_lead + pre_distribution 게이트"""
|
|
|
|
from __future__ import annotations
|
|
import json, sys
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
OUTPUT = ROOT / "Temp" / "p5_01_anti_chase_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": "anti_late_entry_v1",
|
|
"generated_at": datetime.now().isoformat(),
|
|
"problem": "late_chase_status=DEGRADE_BUY_PERMISSION 발동중. 뒷북+설거지 차단 필요",
|
|
"solution_1_alpha_lead_entry": {
|
|
"name": "ALPHA_LEAD_ENTRY_GATE_V1",
|
|
"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%)", "T3(40%)"],
|
|
"forbidden": ["CONFIRMED_ADD_ON 없이 T3 진입", "분위기로 PILOT 승격"]
|
|
},
|
|
"solution_2_pre_distribution_gate": {
|
|
"name": "PRE_DISTRIBUTION_EARLY_WARNING_V1",
|
|
"block_buy_if": [
|
|
"distribution_risk_score >= 70",
|
|
"price_up_volume_down == true",
|
|
"foreign_inst_net_sell_5d == true",
|
|
"candle_upper_tail_cluster == true"
|
|
]
|
|
},
|
|
"implementation": [
|
|
"spec/exit/pre_distribution_gate.yaml",
|
|
"gas_data_feed.gs: calcAlphaLeadV1_(), calcDistributionRiskV1_()",
|
|
"tools/validate_alpha_execution_harness.py"
|
|
]
|
|
}
|
|
|
|
def main() -> int:
|
|
print("=" * 70)
|
|
print(" P5_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" 1. Alpha Lead Entry: alpha_lead_score >= 75")
|
|
print(f" 2. Pre-Distribution: distribution_risk >= 70 → BUY 블록")
|
|
print(f" 3. Tranche 순서: T1(30%) → T2(30%) → T3(40%)")
|
|
return 0
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|