6d4ee39e04
GAS calcDistributionRiskRow_의 "THIN_ADAPTER: delegated to Python" 주석이 틀린 주석이었음을 발견 — GAS(DISTRIBUTION_RISK_SCORE_V1, 점수식 BUY 차단 게이트)와 Python calc_distribution_detector_per_ticker(DISTRIBUTION_SELL_DETECTOR_V1, 6신호 카운트, PRE_DISTRIBUTION_EARLY_WARNING 정밀도 보완)는 이미 spec에 서로 다른 고유 formula_id로 등록된 독립 공식이었다. "GAS가 Python의 중복" 이라는 ledger 전제가 거짓이었을 뿐, 코드는 원래부터 올바르게 분리돼 있었다. 사용자 결정(둘 다 유지, 역할 분리)에 따라: - GAS 소스의 잘못된 주석 정정(gdf_03_portfolio_gates.gs) + 번들 재생성 - 양쪽 formula_registry에 상호 related_formula 참조 추가(향후 혼동 방지) - governance/gas_logic_migration_ledger_v1.yaml: migration_action을 DELETE_DISTRIBUTION_RISK_GAS → KEEP_BOTH_SEPARATE_ROLES로 변경, DONE
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""macro 인덱스 파생 계산(ret_pct/avg) 단위 테스트 — 네트워크 미사용."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
if str(ROOT) not in sys.path:
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from src.quant_engine.macro_index_collection_v1 import MACRO_SYMBOLS, _avg, _ret_pct
|
|
|
|
|
|
def test_macro_symbols_cover_thirteen_raw_instruments():
|
|
assert len(MACRO_SYMBOLS) == 13
|
|
symbols = {s for s, _, _ in MACRO_SYMBOLS}
|
|
assert "^KS11" in symbols # KOSPI
|
|
assert "HYG" in symbols
|
|
# "Computed" 카테고리(MRS_COMPUTED 등)는 의도적으로 포함하지 않는다.
|
|
assert "MRS_COMPUTED" not in symbols
|
|
|
|
|
|
def test_ret_pct_against_n_days_ago():
|
|
closes = [110.0, 108, 107, 106, 105, 100.0]
|
|
assert _ret_pct(closes, 5) == 10.0
|
|
|
|
|
|
def test_ret_pct_none_when_window_exceeds_length():
|
|
assert _ret_pct([100.0, 99.0], 20) is None
|
|
|
|
|
|
def test_avg_returns_none_for_empty_list():
|
|
assert _avg([]) is None
|
|
|
|
|
|
def test_avg_computes_mean():
|
|
assert _avg([10.0, 20.0, 30.0]) == 20.0
|