target-weight pilot 날짜 헬퍼 모듈 분리 (모놀리스 1차 축소) - #387
Merged
Conversation
13,500줄 모놀리스(target_weight_rotation_pilot.py)에서 순수 KRX 거래일·날짜 로직을 tools/pilot_calendar.py로 분리했다. 동작 변화 0 — _접두어 이름을 re-import해 하위 호환을 유지하고, KST/TARGET_WEIGHT_PILOT_TARGET_DAYS 상수도 거기서 가져온다. 모놀리스 13521 → 13458줄. - pilot_calendar: split_symbols, date_range, load_kr_market_holidays, is_kr_market_business_day, pilot_valid_to, next_kr_market_business_day, coerce_kst_datetime, execution_day (+ _접두어 별칭). - 분리 전 전용 테스트가 없던 헬퍼에 test_pilot_calendar.py 18개 추가(거래일·휴장일· KST 변환 경계 검증). - 기존 테스트 2개가 twp._load_kr_market_holidays를 패치했는데, 의존성 조회 소스가 pilot_calendar로 옮겨졌으므로 pc.load_kr_market_holidays 패치로 정합화. 검증: 전체 1344 테스트 통과. pilot --help 및 헬퍼 접근성 스모크 정상.
easygap
added a commit
that referenced
this pull request
Jul 6, 2026
target-weight pilot 날짜 헬퍼 모듈 분리 (모놀리스 1차 축소)
easygap
added a commit
that referenced
this pull request
Jul 6, 2026
target_weight_rotation_pilot.py 모놀리스에서 외부 의존이 없는 stdlib 전용 헬퍼 4개를 tools/pilot_util.py로 추출했다. - stable_manifest_hash: dict 정렬·고정 직렬화 후 SHA-256 - numbers_match: 부동소수 오차 허용 비교(절대 허용오차 옵션) - coerce_float_or_none: float 변환, NaN/Inf는 None - coerce_int_or_zero: int 변환 실패 시 0 기존 호출부 호환을 위해 모놀리스에서 _접두어 별칭으로 re-import 하므로 동작은 100% 동일하다. 분리 전 전용 테스트가 없던 함수들이라 tests/test_pilot_util.py로 커버리지도 추가했다(15케이스). calendar 헬퍼 분리(#387)에 이은 2차 정리. 모놀리스 13458 -> 13425줄.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
개요
13,500줄 모놀리스
tools/target_weight_rotation_pilot.py를 점진적으로 분해하는 1차 작업입니다.순수 KRX 거래일·날짜 계산 로직만 떼어
tools/pilot_calendar.py로 분리했습니다.동작 변화 0 (behavior-preserving).
_접두어이름을 그대로 re-import해 모놀리스 내부·외부호출이 전부 그대로 동작하고,
KST/TARGET_WEIGHT_PILOT_TARGET_DAYS상수도 새 모듈에서 가져옵니다.변경 내용
tools/pilot_calendar.py(신규):split_symbols,date_range,load_kr_market_holidays,is_kr_market_business_day,pilot_valid_to,next_kr_market_business_day,coerce_kst_datetime,execution_day— 외부 상태 없이 stdlib만 쓰는 순수 함수(휴장일만
core.trading_hours에서 lazy load). 하위 호환용_접두어별칭 포함.tests/test_pilot_calendar.py(신규, 18개): 분리 전 전용 테스트가 없던 헬퍼에커버리지 추가 — 평일/휴장일 판정, pilot 윈도우 영업일 계산, 다음 영업일, KST 변환 경계.
twp._load_kr_market_holidays를 패치했는데, 의존성 조회 소스가pilot_calendar로 이동했으므로pc.load_kr_market_holidays패치로 정합화(올바른 패치 지점).왜
모놀리스가 너무 커서 유지보수·테스트가 어렵습니다. 가장 의존성이 적고 안전한 순수 날짜
로직부터 떼어내 (a) 단독 테스트 가능하게 하고 (b) 모놀리스를 점진적으로 줄입니다. 향후 추출
후보(독립성 순): authorization-snapshot 검증, db-persistence proof, evidence repair/finalize, CLI.
검증
target_weight_rotation_pilot.py --help정상, 추출된 헬퍼 7개가 모놀리스 네임스페이스에서여전히 접근·동작함을 스모크로 확인.