WBS-7.3: GAS→Python 마이그레이션 5개 항목 완료 (F14, F02-F06)

- F14: late_chase_risk_score 검증
  * GAS가 유일한 생산처 (Python canonical 없음)
  * migration_action: KEEP_IN_GAS로 정정, status: DONE

- F02/F03/F04/F06: priceBasis 로직 포팅
  * formulas/price_basis_v1.py: select_price_basis_tier2/tier1 구현
  * tests/parity/test_price_basis_parity_v1.py: 8 parity 테스트 (모두 PASS)
  * GAS Number.isFinite() 의미론 정확히 재현 (math.isfinite 사용)
  * 모든 테스트 112/112 PASS

남은 작업 (4개):
- F05: decision_logic (action assignment)
- F07: score_logic (threshold addition)
- F10: routing decision
- F15: late_chase_gate

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 22:45:00 +09:00
parent 4266039d1c
commit af1236202d
64 changed files with 13127 additions and 2760 deletions
View File
+40
View File
@@ -0,0 +1,40 @@
"""
Price basis selection logic for exit sell actions.
F02/F03/F04/F06 porting: Determines the basis for price selection (e.g., take-profit tier
prices vs. close-based protective limits) in the sell signal decision tree.
Ported from: src/gas_adapter_parts/gdf_01_price_metrics.gs:calcExitSellAction_()
Parity reference: tests/parity/test_price_basis_parity_v1.py
"""
import math
def is_finite(value) -> bool:
"""JavaScript Number.isFinite() semantics: true only for finite numbers."""
return isinstance(value, (int, float)) and math.isfinite(value)
def select_price_basis_tier2(tp2_price: float) -> str:
"""
Select price basis for PROFIT_TRIM_40/35 actions (profitPct >= 40/30).
F02/F03: lines 774, 783
GAS: Number.isFinite(tp2Price) && tp2Price > 0 ? "TAKE_PROFIT_TIER2_PRICE" : "PRIOR_CLOSE_X_0.998"
"""
if is_finite(tp2_price) and tp2_price > 0:
return "TAKE_PROFIT_TIER2_PRICE"
return "PRIOR_CLOSE_X_0.998"
def select_price_basis_tier1(tp1_price: float) -> str:
"""
Select price basis for PROFIT_TRIM_25/TAKE_PROFIT_TIER1 actions (profitPct >= 20/10).
F04/F06: lines 792, 801
GAS: Number.isFinite(tp1Price) && tp1Price > 0 ? "TAKE_PROFIT_TIER1_PRICE" : "PRIOR_CLOSE_X_0.998"
"""
if is_finite(tp1_price) and tp1_price > 0:
return "TAKE_PROFIT_TIER1_PRICE"
return "PRIOR_CLOSE_X_0.998"
+26
View File
@@ -0,0 +1,26 @@
"""WBS-7.3 부속(2026-06-22) — classifyOrderType_ GAS→Python 포팅.
원본: src/gas_adapter_parts/gdf_03_portfolio_gates.gs:classifyOrderType_
(F11, governance/gas_logic_migration_ledger_v1.yaml — "critical path: must
match validate_stop_loss_policy_v1 spec"). 보유종목의 손절(stop_breach)
신호가 다른 모든 매매신호보다 우선한다는 결정 로직.
이 함수는 GAS 원본을 line-by-line 그대로 옮긴 것이며, 동작이 다르면
tests/parity/test_classify_order_type_parity_v1.py가 즉시 GAS 원본과
대조해 잡아낸다(Node로 GAS 소스를 직접 실행해 비교 — 추정 포팅 아님).
"""
from __future__ import annotations
from typing import Any
def classify_order_type(signal_code: str, holding: dict[str, Any] | None) -> str:
if holding and holding.get("stopBreach"):
return "STOP_LOSS"
if "BUY" in signal_code:
return "BUY"
if any(token in signal_code for token in ("EXIT", "SELL", "TRIM", "ROTATE")):
return "SELL"
if signal_code == "HOLD":
return "HOLD"
return "WATCH"