feat: 리밸런싱 엔진 V1 + GAS 버그 수정 (2026-06-13)

주요 변경:
- tools/build_rebalance_engine_v1.py: REBALANCE_ENGINE_V1 신규
  * account_snapshot 직접 합산(_build_snap_position_map) → 소수주 분리 행 병합
  * 레짐 소스 macro.REGIME_PRELIM 최우선 (GAS 와 동일)
- src/gas_adapter_parts/gdf_06_rebalance.gs: runRebalanceSheet_() 신규
  * Logger.log / getSpreadsheet_() 로 run_all 연동 수정
- src/gas_adapter_parts/gdc_01_fetch_fundamentals.gs
  * _mergePositionRecord_(): 소수주 중복 행 합산 신규
  * parseInt → parseFloat (qty, availQty)
- src/gas_adapter_parts/gdf_01_price_metrics.gs
  * 미보유 종목 SELL_READY → WATCH_EXIT_SIGNAL
- spec/41_release_dag.yaml: build_rebalance_sheet 노드 추가 (step_count 63)
- spec/51_formula_lifecycle_registry.yaml: REBALANCE_ENGINE_V1 등록

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 13:20:14 +09:00
commit ee3e799de1
1474 changed files with 176087 additions and 0 deletions
@@ -0,0 +1,53 @@
schema_version: 2026-06-03-value-preserving-cash-raise-optimizer-v9
formula_id: VALUE_PRESERVING_CASH_RAISE_V9
supersedes: VALUE_PRESERVING_CASH_RAISE_OPTIMIZER_V7
purpose: 현금확보와 가치보전 동시 관리 — BREACH_FULL_LIQUIDATION 금지, K2 50/50 강제.
required_fields:
- value_damage_pct_avg_raw
- value_damage_pct_avg
- execution_damage_for_gate
# ── 청산 정책 (liquidation_policy) ──────────────────────────────────────────
liquidation_policy:
formula_id: VALUE_PRESERVING_CASH_RAISE_V9
rationale: >
현재 현금확보가 한 종목을 통째로 던져 15.7% 가치를 깎고 반등 포착 확률 0%.
가치훼손 캡(10%)과 반등 포착(>=50%)을 게이트로 두고,
과매도 구간은 K2 50/50 분할로 강제한다.
rules:
- id: LP001_SINGLE_STOCK_CONCENTRATION
rule: "단일 종목 비중이 청산금액의 60%를 넘지 못하게 분산"
enforcement: HARD_BLOCK
- id: LP002_BREACH_FULL_LIQUIDATION_BAN
rule: "후보가 oversold(rsi14<30) 이거나 brt_verdict!=BROKEN 이면 BREACH_FULL_LIQUIDATION 금지"
exception: "emergency_full_sell=true 일 때만 전량 즉시 허용"
enforcement: HARD_BLOCK
- id: LP003_K2_50_50_SPLIT
rule: "LP002 조건 충족 시 K2 50/50: immediate=floor(qty/2), rebound_wait=나머지"
rebound_trigger: "prevClose + rebound_factor×ATR20"
rebound_factors:
EVENT_SHOCK: 0.7
RISK_OFF: 0.6
NEUTRAL: 0.5
RISK_ON: 0.3
enforcement: MANDATORY
- id: LP004_VALUE_DAMAGE_CAP
rule: "raw_value_damage_pct_avg <= 10.0"
cap_violated_action: "조합 재탐색. 캡 위반 시 HTS 주문 차단"
enforcement: HARD_BLOCK
- id: LP005_REBOUND_CAPTURE
rule: "rebound_capture_probability >= 0.50"
enforcement: GATE
emergency_override:
condition: "half_expected_krw × 2 < cash_shortfall_min_krw"
emergency_full_sell: true
note: "이 조건만이 전량 즉시 허용. 다른 이유로 전량 즉시 금지."
acceptance_criteria:
raw_value_damage_pct_avg: {op: "<=", target: 10.0, current: 15.7, blocking: true}
rebound_capture_probability: {op: ">=", target: 0.50, current: 0.0, blocking: true}
breach_full_liquidation_count: {op: "==", target: 0, note: "emergency_full_sell=true 제외"}
single_stock_concentration_pct: {op: "<=", target: 60.0}
output: Temp/smart_cash_recovery_v9.json
python_tool: "tools/build_value_preserving_cash_raise_optimizer_v7.py (v9로 출력)"
gs_coverage: "gas_apex_runtime_core.gs:calcValuePreservingCashRaiseV9_()"
validator: "tools/validate_value_preserving_cash_raise_optimizer_v7.py + validate_cash_raise_pareto_executor_v2.py"