Files
QuantEngineByItz/spec/formulas/domains/reporting.yaml
kjh2064 ee3e799de1 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>
2026-06-13 13:20:14 +09:00

673 lines
21 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
schema_version: formula_domain.v1
source: C:\Temp\data_feed\spec\13_formula_registry.yaml
domain: reporting
formulas:
FLOW_CREDIT_V1:
purpose: 가격·거래량·5D 수급 품질을 0~1 점수로 계산
inputs:
- field: close_price
unit: KRW_per_share
- field: open_price
unit: KRW_per_share
optional: true
- field: previous_close_price
unit: KRW_per_share
optional: true
- field: volume
unit: shares
- field: avg_volume_5d
unit: shares
- field: frg_5d_sh
unit: shares
- field: inst_5d_sh
unit: shares
- field: flow_ok
unit: none
components:
C1_price_action:
expression: 1 if close_price >= open_price OR close_price > previous_close_price
else 0
weight: 0.3
missing_action: 0
C2_volume_action:
expression: 1 if volume >= avg_volume_5d * 1.20 else 0
weight: 0.3
missing_action: 0
C3_flow_action:
expression: 1 if flow_ok == true AND (frg_5d_sh + inst_5d_sh) > 0 else 0
weight: 0.4
missing_action: 0
expression: C1_price_action*0.30 + C2_volume_action*0.30 + C3_flow_action*0.40
output:
field: flow_credit
unit: ratio_0_1
hard_override:
- condition: C1_price_action == 0 AND C2_volume_action == 0
result: 0
reason: C3 단독 충족은 물량 받기로 간주
canonical_ref: spec/02_data_contract.yaml:quant_feed_contract.investor_flow_rules.active_quality_gate
owner: quant_team
lifecycle_state: active
input_fields:
- close_price
- open_price
- previous_close_price
- volume
- avg_volume_5d
- frg_5d_sh
- inst_5d_sh
- flow_ok
output_fields:
- flow_credit
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
TRADE_QUALITY_SCORER_V1:
purpose: '실행된 매수·매도를 T+1/T+5/T+20 기준으로 자동 채점해 뒷박/설거지/저점 투매를 데이터로 증명. O4(WIN_LOSS_STREAK_GUARD_V1)
개선 피드백 루프.
'
applicable: monthly_history 업데이트 배치. 진입 후 T+5, T+20 경과 시 자동 평가.
inputs:
- field: velocity_1d_at_entry
unit: percent
note: buy quality — 진입 당일 속도
- field: entry_price
unit: KRW_per_share
note: buy quality
- field: ma20_at_entry
unit: KRW_per_share
note: buy quality
- field: volume_ratio_at_entry
unit: ratio
note: buy quality
- field: t5_return_pct
unit: percent
optional: true
note: buy quality T+5
- field: t20_vs_core_pctp
unit: percent
optional: true
note: buy quality T+20 alpha
- field: sell_price
unit: KRW_per_share
note: sell quality
- field: ma20_at_sell
unit: KRW_per_share
note: sell quality
- field: average_cost
unit: KRW_per_share
note: sell quality — 평단
- field: price_t5_after_sell
unit: KRW_per_share
optional: true
note: sell quality T+5 사후
- field: cash_recovered_krw
unit: KRW
note: sell quality — 실제 회수액
- field: cash_shortfall_min_krw
unit: KRW
note: sell quality — 목표 현금 부족분
scoring:
buy_score:
velocity_ok:
condition: velocity_1d_at_entry < 1
points: 20
ma20_proximity:
condition: entry_price <= ma20_at_entry * 1.01
points: 20
volume_confirm:
condition: volume_ratio_at_entry >= 1.2
points: 20
t5_positive:
condition: t5_return_pct > 0
points: 20
t20_alpha:
condition: t20_vs_core_pctp > 0
points: 20
sell_score:
above_ma20:
condition: sell_price >= ma20_at_sell * 0.99
points: 25
above_cost:
condition: sell_price >= average_cost
points: 25
not_too_early:
condition: price_t5_after_sell is null OR price_t5_after_sell < sell_price
points: 25
cash_goal_met:
condition: cash_recovered_krw >= cash_shortfall_min_krw
points: 25
grade_table:
90100:
grade: EXCELLENT
tag: GOOD_EXECUTION
7589:
grade: GOOD
tag: GOOD_EXECUTION
6074:
grade: ACCEPTABLE
tag: REVIEW_NEEDED
4059:
grade: POOR
tag: CHASE_ENTRY_OR_PANIC_EXIT
0_39:
grade: CRITICAL
tag: PATTERN_ALERT
feedback_tags:
- CHASE_ENTRY
- PANIC_EXIT
- DISTRIBUTION_ENTRY
- OVERSOLD_PANIC
- GOOD_EXECUTION
output:
field: trade_quality_json
schema:
- ticker: 종목코드
action: BUY|SELL
score: 0~100
grade: enum
feedback_tag: enum
ground_truth: harness
llm_allowed: cite_only
prohibition:
- LLM이 trade_quality_score를 즉석 계산 금지
- POOR/CRITICAL 종목에 '이번엔 괜찮다' 임의 판단 금지
canonical_ref: AGENTS.md:Direction F1, O4(WIN_LOSS_STREAK)
version: 2026-05-22_3RD_HARNESS
owner: quant_team
lifecycle_state: active
input_fields:
- velocity_1d_at_entry
- entry_price
- ma20_at_entry
- volume_ratio_at_entry
- t5_return_pct
- t20_vs_core_pctp
- sell_price
- ma20_at_sell
- average_cost
- price_t5_after_sell
- cash_recovered_krw
- cash_shortfall_min_krw
output_fields:
- trade_quality_json
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
PATTERN_BLACKLIST_AUTO_V1:
purpose: '같은 종목에서 3회 이상 POOR/CRITICAL grade가 누적되면 자동으로 강화 제한 적용. "같은 실수를 4번째는
시스템이 막는다."
'
applicable: TRADE_QUALITY_SCORER_V1 이후. monthly_history 배치.
inputs:
- field: trade_quality_json
unit: array
- field: monthly_history
unit: array
trigger:
condition: 동일 ticker, grade IN [POOR, CRITICAL] 누적 횟수 >= 3
action: PATTERN_BLACKLIST_TRIGGERED
restrictions_applied:
saqg_downgrade: 해당 ticker SAQG를 EXCLUDED로 자동 격하 (BUY 완전 차단)
alpha_score_cap: alpha_lead_score 상한 50점 적용
llm_ban: LLM '이번엔 다르다' 서술 금지 — Override는 사용자 수동 확인만 허용
release_condition: 3회 연속 GOOD 이상 달성 시 블랙리스트 해제
output:
field: pattern_blacklist_status
values:
- TRIGGERED
- CLEAR
- NOT_APPLICABLE
additional_fields:
- blacklist_ticker
- accumulated_poor_count
- release_condition_met
ground_truth: harness
llm_allowed: cite_only
prohibition:
- TRIGGERED 종목에 예외 매수 서술 금지
- 블랙리스트 해제를 LLM이 임의 선언 금지 — 3회 연속 GOOD 조건 충족만
canonical_ref: AGENTS.md:Direction F2, TRADE_QUALITY_SCORER_V1, SAQG
version: 2026-05-22_3RD_HARNESS
owner: quant_team
lifecycle_state: active
input_fields:
- trade_quality_json
- monthly_history
output_fields:
- pattern_blacklist_status
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
FUNDAMENTAL_QUALITY_GATE_V1:
purpose: 펀더멘털 품질(ROE/이익성장/부채/현금흐름/밸류)을 결정론적으로 점수화해 BUY 허용 여부를 잠금.
inputs:
- field: roe_pct
unit: percent
optional: true
- field: op_income_growth_pct
unit: percent
optional: true
- field: debt_ratio_pct
unit: percent
optional: true
- field: operating_cf_krw
unit: KRW
optional: true
- field: pe_ttm
unit: ratio
optional: true
output:
field: fundamental_quality_json
llm_allowed: cite_only
version: 2026-05-25_PROPOSAL53
owner: quant_team
lifecycle_state: active
input_fields:
- roe_pct
- op_income_growth_pct
- debt_ratio_pct
- operating_cf_krw
- pe_ttm
output_fields:
- fundamental_quality_json
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
ROUTING_SERVING_DECISION_TRACE_V2:
purpose: 라우팅→서빙→게이트 경로를 단일 trace JSON으로 고정해 사후감사 가능성 확보.
inputs:
- field: routing_trace_json
unit: json
- field: export_gate_json
unit: json
output:
field: routing_serving_trace_v2_json
llm_allowed: cite_only
version: 2026-05-25_PROPOSAL53
owner: quant_team
lifecycle_state: active
input_fields:
- routing_trace_json
- export_gate_json
output_fields:
- routing_serving_trace_v2_json
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
EARNINGS_GROWTH_QUALITY_GATE_V1:
purpose: 분기/연간 이익 성장 일관성으로 매수 게이트를 잠금.
inputs:
- field: eps_growth_qoq_pct
unit: percent
optional: true
- field: eps_growth_yoy_pct
unit: percent
optional: true
output:
field: earnings_growth_quality_json
llm_allowed: cite_only
version: 2026-05-25_PROPOSAL54
owner: quant_team
lifecycle_state: active
input_fields:
- eps_growth_qoq_pct
- eps_growth_yoy_pct
output_fields:
- earnings_growth_quality_json
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
ROUTING_DECISION_EXPLAIN_LOCK_V1:
purpose: 최종 의사결정 게이트 경로와 차단사유를 JSON으로 고정.
inputs:
- field: export_gate_json
unit: json
output:
field: routing_decision_explain_json
llm_allowed: cite_only
version: 2026-05-25_PROPOSAL54
owner: quant_team
lifecycle_state: active
input_fields:
- export_gate_json
output_fields:
- routing_decision_explain_json
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
BLANK_CELL_AUDIT_V1:
purpose: '보고서 GFM 표의 빈 셀·일률 stub 라벨을 감사하여 셀-레벨 결정론 충족 여부를 판정한다. 금지 일률값(데이터 누락/NEUTRAL/LOSING/정상/-/빈문자)이
하나라도 있으면 INCOMPLETE_TABLE. enforcement_mode_until 이전은 WARN_ONLY, 이후 hard-block.
'
inputs:
- field: operational_report_json
unit: json
output:
field: blank_cell_audit_v1_json
expected_outputs:
- gate
- blank_fill_pct
- incomplete_tables
- enforcement_mode
llm_allowed: cite_only
version: 2026-05-27_PHASE1
owner: quant_team
lifecycle_state: active
input_fields:
- operational_report_json
output_fields:
- blank_cell_audit_v1_json
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
EJCE_VIEW_RENDERER_V1:
purpose: 'ejce_consensus_table의 Analyst/Trader/Quant 본문 셀을 결정론 템플릿으로 채운다. AGENTS.md
EJ1 의무: 3관점 모두 인용. 본문 셀 비면 INCOMPLETE_EJCE_REPORT.
'
inputs:
- field: ejce_json
unit: json
- field: alpha_lead_json
unit: json
- field: breakout_quality_gate_json
unit: json
- field: anti_chasing_velocity_json
unit: json
- field: heat_concentration_json
unit: json
- field: portfolio_alpha_confidence
unit: score
output:
field: ejce_view_renderer_v1_json
expected_outputs:
- gate
- blank_view_count
- row_count
llm_allowed: cite_only
version: 2026-05-27_PHASE1
owner: quant_team
lifecycle_state: active
input_fields:
- ejce_json
- alpha_lead_json
- breakout_quality_gate_json
- anti_chasing_velocity_json
- heat_concentration_json
- portfolio_alpha_confidence
output_fields:
- ejce_view_renderer_v1_json
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
EARNINGS_QUALITY_SIGNAL_V1:
purpose: 'OPM(영업이익률) 기반 이익 품질을 결정론적으로 라벨링한다. EXPANDING/STABLE/CONTRACTING/VOLATILE/DATA_MISSING
라벨과 buy_modifier(+10 ~ -15)를 종목별로 산출한다.
'
output:
field: earnings_quality_signal_v1_json
expected_outputs:
- gate
- label_counts
- data_missing_pct
llm_allowed: cite_only
version: 2026-05-27_PHASE2B
owner: quant_team
lifecycle_state: active
input_fields: []
output_fields:
- earnings_quality_signal_v1_json
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
TRADE_QUALITY_FROM_T5_V1:
purpose: '운영(non-backfill) T+5 outcome MATCHED/MISMATCH 기반으로 per-ticker 및 전체 거래품질
점수를 산출한다. T+20 성숙 전 bridge; T+20 성숙 후 자동 승격.
'
output:
file: Temp/trade_quality_from_t5_v1.json
expected_outputs:
- gate
- summary_score
- scored_count
- trade_quality_basis
llm_allowed: cite_only
version: 2026-05-28_PHASE4
owner: quant_team
lifecycle_state: active
input_fields: []
output_fields: []
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
LLM_NARRATIVE_TEMPLATE_LOCK_V1:
purpose: 'operational_report.json 각 section.markdown에서 금지 어휘(같다/약간/곧/강한모멘텀 등)를
스캔한다. 발견 시 INVALID_NARRATIVE. gate=PASS: 금지어 0건 강제.
'
output:
file: Temp/llm_narrative_template_lock_v1.json
expected_outputs:
- gate
- total_violations
- sections_checked
llm_allowed: cite_only
version: 2026-05-28_PHASE5
owner: quant_team
lifecycle_state: active
input_fields: []
output_fields: []
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
EJCE_DIVERGENCE_AUDIT_V1:
purpose: 'EJCE 3관점 block_reasons 다양성 감사. 10/10 동일 사유 → ANALYST_VIEW_HOMOGENEOUS
경고. unique_reason_pct < 60% → WARN.
'
output:
file: Temp/ejce_divergence_audit_v1.json
expected_outputs:
- gate
- unique_reason_pct
- homogeneous_flag
- analyst_view_homogeneous
llm_allowed: cite_only
version: 2026-05-28_PHASE5
owner: quant_team
lifecycle_state: active
input_fields: []
output_fields: []
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
INVESTMENT_QUALITY_HEADLINE_V1:
purpose: 'schema_presence=100% vs investment_quality=13% 충돌을 보고서 CORE 첫 섹션으로 강제
표기. 거짓 표면화 게이트. effective_confidence = raw × cap_factor 적용 증빙. DATA_QUALITY_RECONCILIATION_V1
gate=CONFLICT 시 보고서 첫 섹션에 ⚠️ 경고 표시.
'
output:
section: investment_quality_headline
expected_outputs:
- quality_conflict_flag
- investment_quality_score
- schema_presence_score
llm_allowed: cite_only
version: 2026-05-28_PHASE6
owner: quant_team
lifecycle_state: active
input_fields: []
output_fields: []
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
CROSS_SECTION_CONSISTENCY_V1:
purpose: 'operational_report.json 섹션 markdown을 파싱해 CANONICAL_METRICS_V1 지표가 여러
섹션에서 동일한 canonical 값으로 렌더링됐는지 검증. 충돌 발견 시 gate=FAIL(WARN). AGENTS.md R1 enforcement_mode_until
단계적 차단 정책 적용.
'
input_fields:
- Temp/canonical_metrics_v1.json.metrics
- Temp/operational_report.json.sections[].markdown
expected_outputs:
- conflict_count
- conflicts
- forbidden_uniform_labels
- incomplete_tables
- score
- gate
- enforcement_mode_until
llm_allowed: cite_only
version: 2026-05-29_PHASE7
owner: quant_team
lifecycle_state: active
output_fields: []
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
ALGORITHM_GUIDANCE_PROOF_V1:
purpose: 'YAML↔GAS 커버리지·결정론·LLM 의존도를 종합해 알고리즘 안내 품질 점수를 산출한다.
'
input_fields:
- skeleton_score
- cell_coverage_pct
- harness_gate_pass
- outcome_quality_score
expected_outputs:
- algorithm_guidance_proof_score
- algorithm_guidance_proof_gate
llm_allowed: cite_only
version: 2026-06-03_ORPHAN_RECONCILE
owner: quant_team
lifecycle_state: active
output_fields: []
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
AUDIT_REPLAY_SNAPSHOT_V1:
purpose: 'replay 시뮬레이션의 스냅샷을 생성해 의사결정 재현 감사를 지원한다.
'
input_fields:
- replay_date
- portfolio_state
- decision_vector
expected_outputs:
- audit_snapshot
- replay_validation_status
llm_allowed: cite_only
version: 2026-06-03_ORPHAN_RECONCILE
owner: quant_team
lifecycle_state: active
output_fields: []
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
CONTINUOUS_EVALUATION_DASHBOARD_V1:
purpose: 'T+1/T+5/T+20 성과를 주간 자동 갱신하는 연속 평가 대시보드를 산출한다.
'
input_fields:
- trade_outcomes
- evaluation_period
expected_outputs:
- weekly_scorecard
- profit_giveback_pct
- expectancy_pct
llm_allowed: cite_only
version: 2026-06-03_ORPHAN_RECONCILE
owner: quant_team
lifecycle_state: active
output_fields: []
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
DATA_QUALITY_GATE_V2_PY:
purpose: 'Python 하네스 전용 데이터 품질 게이트 v2. GAS 버전과 parity 검증.
'
input_fields:
- harness_context
- required_fields
expected_outputs:
- data_quality_gate
- missing_fields
- quality_score
llm_allowed: cite_only
version: 2026-06-03_ORPHAN_RECONCILE
owner: quant_team
lifecycle_state: active
output_fields: []
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation
DATA_QUALITY_GATE_V3:
purpose: '데이터 품질 게이트 v3. imputed 데이터 비율·출처 신뢰도를 추가 검증한다.
'
input_fields:
- harness_context
- imputed_fields
- source_reliability
expected_outputs:
- data_quality_gate_v3
- imputed_ratio
- quality_grade
llm_allowed: cite_only
version: 2026-06-03_ORPHAN_RECONCILE
owner: quant_team
lifecycle_state: active
output_fields: []
missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
golden_cases: []
activation_threshold:
min_t20_sample: 30
retirement_condition: performance_degradation