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:
@@ -0,0 +1,95 @@
|
||||
# 은퇴자산포트폴리오 투자 에이전트 운영 지침
|
||||
|
||||
## 0. 최우선 원칙
|
||||
- 이 파일은 운영 인덱스다. 상세 규칙은 `governance/rules/*.yaml`와 `spec/*.yaml`를 우선한다.
|
||||
- 가격, 수량, TP/SL, 점수는 오직 `spec/13_formula_registry.yaml`와 하네스 산출값만 사용한다.
|
||||
- 임의 계산, 임의 가격, 임의 수량, 미등록 공식은 금지한다.
|
||||
- 하네스 결측은 `DATA_MISSING — 하네스 업데이트 필요`로만 표시한다.
|
||||
- 차단된 종목의 산출값은 숨기지 말고 shadow ledger로 투명하게 남긴다.
|
||||
|
||||
## 1. 읽는 순서
|
||||
1. `runtime/active_artifact_manifest.yaml`
|
||||
2. `Temp/final_decision_packet_active.json` (manifest alias)
|
||||
|
||||
## 1b. Critical Authority Files
|
||||
- `spec/00_execution_contract.yaml`
|
||||
- `spec/risk/aggregate_risk.yaml`
|
||||
- `spec/risk/portfolio_exposure.yaml`
|
||||
- `spec/14_raw_workbook_mapping.yaml`
|
||||
- `spec/15_account_snapshot_contract.yaml`
|
||||
- `spec/02_data_contract.yaml`
|
||||
- `spec/09_decision_flow.yaml`
|
||||
- `spec/12_field_dictionary.yaml`
|
||||
- `spec/13_formula_registry.yaml`
|
||||
|
||||
## 2. 문서 역할
|
||||
- `AGENTS.md`: 운영 헌법과 링크 인덱스.
|
||||
- `governance/agents_index.yaml`: rule file 목록과 hash migration index.
|
||||
- `governance/rules/*.yaml`: 장문의 세부 규칙.
|
||||
- `spec/*.yaml`: 계약, 공식, 게이트, 출력 계약의 원본 권위.
|
||||
- `src/quant_engine`: canonical Python package. schema/model parity와 reporting helper를 담는다.
|
||||
- `tools/*.py`: 검증/생성 CLI. 가능한 한 얇게 유지한다.
|
||||
- `Temp/*.json`: 런타임 산출물. 읽기 전용 취급이며 직접 편집하지 않는다.
|
||||
- `schemas/*.schema.json`: shape validation.
|
||||
|
||||
## 2b. Directory Routing / Serving
|
||||
- `spec/`: source of truth. 공식, 계약, 게이트, 출력 스키마의 최우선 읽기 경로.
|
||||
- `governance/`: 운영 규칙, 인덱스, 해시 마이그레이션, ADR, 템플릿.
|
||||
- `src/`: Python canonical implementation. 새 로직은 여기부터 반영한다.
|
||||
- `tools/`: build, validate, convert, audit CLI. 상태는 유지하되 핵심 로직은 두지 않는다.
|
||||
- `gas_event_calendar.gs`: 이벤트 캘린더 배포 호환 스텁. `seedEventCalendar_()` / `runEventRisk()` 진입점을 유지한다.
|
||||
- `Temp/`: 실행 결과와 캐시. 라우팅 대상은 아니며 runtime consumer만 읽는다.
|
||||
- `dist/`, `artifacts/`, `docs/`, `examples/`, `prompts/`, `schemas/`, `tests/`: 패키징/문서/검증/산출물 보조 경로.
|
||||
- `run_all`: 외부 스케줄러가 호출하는 진입점으로 유지한다. 실행 시 `run_all_invocation_mode=external_scheduler`를 기준으로 해석한다.
|
||||
|
||||
## 3. 하드 룰
|
||||
- 가격 임의 창작 금지.
|
||||
- 다중 조건 접속사 기반 주문문 금지 (모든 매도는 단일 sell priority table 및 waterfall 방식으로 선형 처리).
|
||||
- tick normalization 의무.
|
||||
- TP stale 값은 제거.
|
||||
- sell candidate가 2개 이상이면 sell priority table을 먼저 출력.
|
||||
- LLM은 하네스 판정을 번복하지 않으며, 임의로 사칙연산, 평균, 순위(rank) 등을 재계산하지 않고 context key를 그대로 copy-only하여 렌더링한다.
|
||||
- 외부 시장 데이터는 참고용이며 JSON harness가 우선한다.
|
||||
- provenance 없는 숫자는 보고서에 쓰지 않는다.
|
||||
- 추격 매수 방지를 위해 모든 매수 진입은 anti-late entry gate 검증을 필수로 통과한다.
|
||||
- 데이터 흐름은 단방향(Data -> Feature -> Decision -> Execution -> Report) 아키텍처 경계를 유지하며, renderer가 core 계산을 호출하는 역참조를 금지한다.
|
||||
- D+2 영업일 기준 현금을 즉시방어 자산으로 간주하고, 목표 예산 5억 원을 기준으로 포지션 사이징 및 리스크 버킷을 제어한다.
|
||||
- 매주 주말 리밸런싱(rebalance_required=true) 및 매월 1일/11일/21일 중간점검(mid_check_required=true) 운영 cadence를 준수한다.
|
||||
|
||||
## 4. 보고 규칙
|
||||
- 모든 숫자에는 반드시 provenance(출처)를 남기며, 출처가 유효하지 않거나 없는 숫자는 보고서 표기를 전면 배제(DATA_MISSING 처리)한다.
|
||||
- 보고서 첫 부분에는 portfolio health와 주요 차단 사유를 먼저 쓴다.
|
||||
- blocked/limited 상태라도 산출된 기준가, 손절가, 익절가, 수량은 숨기지 않는다.
|
||||
- narrative는 숫자와 게이트를 완화하는 표현을 쓰지 않는다.
|
||||
|
||||
## 5. 개발 규칙
|
||||
- 새 기능은 contract, schema, golden case, owner ledger를 먼저 만든다.
|
||||
- 구현은 Python canonical first, GAS adapter second다.
|
||||
- `tools/*.py`는 CLI wrapper에 가깝게 유지한다.
|
||||
- `gas_*.gs`는 thin adapter 방향으로 유지한다.
|
||||
- `src/quant_engine`는 canonical package로 유지한다.
|
||||
- `schemas/generated`와 `src/quant_engine/models/generated`는 schema/model parity를 유지한다.
|
||||
- 경로가 새로 생기면 `AGENTS.md`의 Directory Routing / Serving 섹션과 zip 화이트리스트를 함께 갱신한다.
|
||||
|
||||
## 6. 검증 규칙
|
||||
- `python tools/validate_specs.py`
|
||||
- `python tools/validate_golden_coverage_100.py`
|
||||
- `python tools/validate_calibration_registry_v1.py`
|
||||
- `python tools/validate_schema_model_generation_v1.py`
|
||||
- `python tools/validate_gas_thin_adapter_v1.py`
|
||||
- `python tools/validate_agents_shrink_v1.py`
|
||||
|
||||
## 7. Rule Index
|
||||
- [governance/agents_index.yaml](/C:/Temp/data_feed/governance/agents_index.yaml)
|
||||
- [governance/rules/00_core_locks.yaml](/C:/Temp/data_feed/governance/rules/00_core_locks.yaml)
|
||||
- [governance/rules/01_harness_contract.yaml](/C:/Temp/data_feed/governance/rules/01_harness_contract.yaml)
|
||||
- [governance/rules/02_portfolio_policy.yaml](/C:/Temp/data_feed/governance/rules/02_portfolio_policy.yaml)
|
||||
- [governance/rules/03_order_grammar.yaml](/C:/Temp/data_feed/governance/rules/03_order_grammar.yaml)
|
||||
- [governance/rules/04_reporting_contract.yaml](/C:/Temp/data_feed/governance/rules/04_reporting_contract.yaml)
|
||||
- [governance/rules/05_migration_hashes.yaml](/C:/Temp/data_feed/governance/rules/05_migration_hashes.yaml)
|
||||
|
||||
- 모든 수치 provenance 및 아키텍처 경계는 `spec/49_refactor_methodology_contract.yaml` 및 `ADR-0011`을 준수한다.
|
||||
- 가격/수량/공식을 LLM이 즉석 정의하지 않는다.
|
||||
- replay 표본을 live 운영성과로 혼입하지 않는다.
|
||||
- validation 실패를 무시하지 않는다.
|
||||
- deprecated artifact를 runtime source로 읽지 않는다.
|
||||
Reference in New Issue
Block a user