schema_version: formula_domain.v1
source: C:\Temp\data_feed\spec\13_formula_registry.yaml
domain: exit
formulas:
  STOP_PRICE_CORE_V1:
    purpose: 코어 포지션 HTS 입력용 손절가 계산
    inputs:
    - field: entry_price
      unit: KRW_per_share
    - field: atr20
      unit: KRW_per_share
    - field: current_price
      unit: KRW_per_share
    derived_fields:
      atr20_pct: atr20 / current_price * 100
      atr_multiplier: 2.0 if atr20_pct >= 8 else 1.5
    expression: max(entry_price * 0.92, entry_price - atr20 * atr_multiplier)
    output:
      field: stop_price
      unit: KRW_per_share
    missing_policy:
      atr20: entry_price * 0.92 with DATA_MISSING tag
      entry_price: NO_STOP_PRICE
    canonical_ref: spec/exit/stop_loss.yaml:stop_loss.core
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - entry_price
    - atr20
    - current_price
    output_fields:
    - stop_price
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  STOP_PROPOSAL_LADDER_V1:
    purpose: '사용자 판단용 proposal_reference_sheet에 표시할 손절 1/2/3 가격·수량 래더 산출. HTS 즉시 주문표가
      아니라 제안표 전용이며, 기존 손절 규칙과 profit preservation 결과만 사용한다.

      '
    inputs:
    - field: position_class
      unit: enum [core, satellite]
    - field: holding_quantity
      unit: shares
      optional: true
    - field: proposed_quantity
      unit: shares
      optional: true
    - field: stop_price
      unit: KRW_per_share
    - field: profit_lock_stage
      unit: enum
      optional: true
    - field: protected_stop_price
      unit: KRW_per_share
      optional: true
    - field: auto_trailing_stop
      unit: KRW_per_share
      optional: true
    - field: tp3_qty
      unit: shares
      optional: true
    derived_fields:
      base_stop_quantity: holding_quantity 우선, 없으면 proposed_quantity
    rules:
      stop1:
        price_expression: stop_price
        quantity_expression: core=floor(max(1, base_stop_quantity*0.50)), satellite=floor(max(1,
          base_stop_quantity*0.70))
        rationale: spec/exit/stop_loss.yaml core/satellite quantity_rule의 1차 손절
      stop2:
        price_expression: stop_price
        quantity_expression: max(base_stop_quantity - stop1_quantity, 0)
        rationale: 종가 회복 실패 시 잔여 청산
      stop3:
        price_expression: auto_trailing_stop 우선, 없으면 protected_stop_price
        quantity_expression: tp3_qty 우선, 없으면 base_stop_quantity - tp1_quantity - tp2_quantity
        activation: profit_lock_stage != NORMAL 또는 auto_trailing_stop 존재
        rationale: 수익보전 구간 러너 보호 스탑
    output:
      field: proposal_stop_ladder
      unit: object
    missing_policy:
      stop_price: NO_STOP_LADDER
      holding_quantity: proposed_quantity fallback
      protected_stop_price: stop3는 비움
    prohibition:
    - stop2/stop3를 차트 패턴이나 심리적 가격으로 임의 산출 금지
    - stop3 활성 근거가 없으면 null 유지
    canonical_ref: spec/00_execution_contract.yaml:proposal_policy.proposal_stop_ladder_selection
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - position_class
    - holding_quantity
    - proposed_quantity
    - stop_price
    - profit_lock_stage
    - protected_stop_price
    - auto_trailing_stop
    - tp3_qty
    output_fields:
    - proposal_stop_ladder
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  TRAILING_STOP_PRICE_V1:
    purpose: 고점 대비 ATR 기반 trailing stop 가격 계산
    inputs:
    - field: highest_price_since_entry
      unit: KRW_per_share
    - field: atr20
      unit: KRW_per_share
    - field: trailing_atr_multiplier
      unit: ratio
      default: 1.5
    expression: highest_price_since_entry - atr20 * trailing_atr_multiplier
    output:
      field: trailing_stop_price
      unit: KRW_per_share
    missing_policy:
      highest_price_since_entry: NO_TRAILING_PRICE
      atr20: NO_TRAILING_PRICE
    canonical_ref: spec/exit/take_profit.yaml:take_profit.trailing_stop
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - highest_price_since_entry
    - atr20
    - trailing_atr_multiplier
    output_fields:
    - trailing_stop_price
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  ABSOLUTE_RISK_STOP_V1:
    purpose: 절대 리스크 손절가와 청산 수량을 산출하는 taxonomy wrapper
    inputs:
    - field: holdings
      unit: object[]
    - field: df_map
      unit: object
    output:
      field: absolute_risk_stop_rows
      unit: object[]
    canonical_ref: spec/exit/stop_loss.yaml:stop_loss.core
    note: stop_loss.core/satellite 및 stop_adequacy 결과를 묶는 wrapper
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - holdings
    - df_map
    output_fields:
    - absolute_risk_stop_rows
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  RELATIVE_UNDERPERF_ALERT_V1:
    purpose: 상대성과 약화 경보를 산출하는 taxonomy wrapper
    inputs:
    - field: holdings
      unit: object[]
    - field: df_map
      unit: object
    - field: kospi_ret20d
      unit: pct
      optional: true
    output:
      field: relative_underperf_alert
      unit: object
    canonical_ref: spec/exit/stop_loss.yaml:stop_loss.relative_weakness_exit
    note: calcRelativeStopSignal_의 하위 wrapper
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - holdings
    - df_map
    - kospi_ret20d
    output_fields:
    - relative_underperf_alert
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  STOP_ACTION_LADDER_V1:
    purpose: 손절/익절/시간손절의 최종 액션 래더를 산출하는 taxonomy wrapper
    inputs:
    - field: context
      unit: object
    output:
      field: stop_action_ladder
      unit: object
    canonical_ref: spec/exit/stop_loss.yaml:stop_loss.sell_signal_priority
    note: calcSellDecision_ / SL003_PRIORITY_MATRIX 결과를 표준화
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - context
    output_fields:
    - stop_action_ladder
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  PROFIT_LOCK_RATCHET_V1:
    purpose: '분할 익절 단계별 손절선 상향(래칫) 공식. tier_1 익절 완료 후 손절선을 본절(average_cost)로 상향하여
      원금을 보호. tier_2 익절 완료 후 trailing stop으로 전환하여 추세 끝단 보유. TAKE_PROFIT_LADDER_V2.action_on_trigger에서
      참조.

      '
    inputs:
    - field: average_cost
      unit: KRW_per_share
    - field: tier_completed
      unit: enum [tier_1, tier_2]
    - field: highest_price_since_entry
      unit: KRW_per_share
      optional: true
      note: tier_2 완료 후 TRAILING_STOP_PRICE_V1 호출 시 필요
    - field: atr20
      unit: KRW_per_share
      optional: true
    rules:
      tier_1_completed:
        expression: ratchet_stop_price = average_cost
        label: 본절 보호 — 원금 방어선으로 상향
        rationale: tier_1(1.5R) 도달 시 원금 손실 구간 탈출. 손절이 더 이상 손실 없음.
      tier_2_completed:
        expression: ratchet_stop_price = TRAILING_STOP_PRICE_V1 result
        label: trailing stop 전환 — 추세 끝단까지 보유
        rationale: tier_2(3R) 도달 후 잔여는 trailing stop으로 추세 추종.
    output:
      field: ratchet_stop_price
      unit: KRW_per_share
    missing_policy:
      average_cost: NO_RATCHET_PRICE
      atr20: tier_2일 때 TRAILING_STOP_PRICE_V1 미산출. DATA_MISSING 표기 후 본절 유지.
      tier_completed_missing: NO_RATCHET_PRICE — tier 완료 여부 미확인 시 적용 금지
    prohibition:
    - 이 공식 외 임의 레이블(profit_lock_ratchet, 차트 지지선 등)로 보호스탑 생성 금지
    - tier_1 미완료 상태에서 본절 보호선 조기 적용 금지
    - tier_completed 명시 없이 ratchet_stop_price 산출 금지
    canonical_ref: spec/exit/take_profit.yaml:take_profit.tiered_ladder
    version: 2026-05-18_AUDIT_RESPONSE_V1
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - average_cost
    - tier_completed
    - highest_price_since_entry
    - atr20
    output_fields:
    - ratchet_stop_price
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  TAKE_PROFIT_LADDER_V1:
    purpose: 평단·보유수량 기준 3단계 익절 가격과 정수 수량 계산
    inputs:
    - field: average_cost
      unit: KRW_per_share
    - field: quantity
      unit: shares
    - field: position_class
      unit: enum
    output:
      field: take_profit_ladder
      unit: object
    rules:
      core:
        tier_1:
          price_expression: average_cost * 1.15
          quantity_expression: floor(quantity * 0.25)
        tier_2:
          price_expression: average_cost * 1.25
          quantity_expression: floor((quantity - tier_1_quantity) * 0.40)
        tier_3:
          price_expression: TRAILING_STOP_PRICE_V1
          quantity_expression: quantity - tier_1_quantity - tier_2_quantity
      satellite:
        tier_1:
          price_expression: average_cost * 1.10
          quantity_expression: floor(quantity * 0.50)
        tier_2:
          price_expression: average_cost * 1.20
          quantity_expression: floor((quantity - tier_1_quantity) * 0.50)
        tier_3:
          price_expression: TRAILING_STOP_PRICE_V1 or time_stop
          quantity_expression: quantity - tier_1_quantity - tier_2_quantity
    missing_policy:
      average_cost: NO_TAKE_PROFIT_PRICE
      quantity: NO_TAKE_PROFIT_QUANTITY
    canonical_ref: spec/exit/take_profit.yaml:take_profit.tiered_ladder
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - average_cost
    - quantity
    - position_class
    output_fields:
    - take_profit_ladder
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  TAKE_PROFIT_LADDER_V2:
    purpose: '평단·ATR20·보유수량 기준 3단계 익절 가격과 정수 수량 계산. 각 단계 가격 = max(고정% 기준가, ATR R-Multiple
      기준가). 고정% 최저선을 보장하면서도 고변동성 종목은 ATR 기반으로 더 늦게 익절. ATR 미확인 시 TAKE_PROFIT_LADDER_V1(고정%
      전용)으로 자동 fallback.

      '
    design_rationale: 'R = ATR20 (1일 평균 변동폭 = 1 위험단위). 1.5R 도달 = 손절 리스크(1R)의 1.5배
      수익 → 본절 스탑 상향 근거 확보. 3.0R 도달 = 확실한 수익 구간. 고정% 최저선(코어+15%, 위성+10%) 보장으로 저변동성
      종목이 너무 일찍 익절되는 것을 방지한다.

      '
    inputs:
    - field: average_cost
      unit: KRW_per_share
    - field: atr20
      unit: KRW_per_share
      optional: true
    - field: quantity
      unit: shares
    - field: position_class
      unit: enum
    derived_fields:
      r_unit: 'atr20  # 1R = ATR20 (1일 평균 변동폭)'
      atr_tier1_price: 'average_cost + atr20 * 1.5  # 1.5R 수익점'
      atr_tier2_price: 'average_cost + atr20 * 3.0  # 3.0R 수익점'
      break_even_trigger: 'atr_tier1_price  # 1.5R 도달 시 손절선 → 본절 상향'
    output:
      field: take_profit_ladder_v2
      unit: object
    rules:
      core:
        tier_1:
          price_expression: max(average_cost * 1.15, average_cost + atr20 * 1.5)
          quantity_expression: floor(quantity * 0.25)
          action_on_trigger: 25% 익절 + 손절선 본절(average_cost)로 즉시 상향
          rationale: 1.5R 이상이면 리스크 무위험 상태 전환. 고정% 최저선 +15% 보장.
        tier_2:
          price_expression: max(average_cost * 1.25, average_cost + atr20 * 3.0)
          quantity_expression: floor((quantity - tier_1_quantity) * 0.40)
          action_on_trigger: 40% 추가 익절
          rationale: 3.0R = 확실한 수익 구간. 고정% 최저선 +25% 보장.
        tier_3:
          price_expression: TRAILING_STOP_PRICE_V1
          quantity_expression: quantity - tier_1_quantity - tier_2_quantity
          action_on_trigger: 잔여 전량 trailing으로 추세 끝단까지 보유
      satellite:
        tier_1:
          price_expression: max(average_cost * 1.10, average_cost + atr20 * 1.5)
          quantity_expression: floor(quantity * 0.33)
          action_on_trigger: 33% 익절 + 손절선 본절 상향. 잔여 67% 추세 추종.
          rationale: '위성 50% 즉시 익절(V1)은 단기 익절 편향. V2에서 33%로 조정하여 중장기 추세 추종 원칙에 부합.
            1.5R이면 무위험 상태로 전환 후 보유 연장.

            '
        tier_2:
          price_expression: max(average_cost * 1.20, average_cost + atr20 * 3.0)
          quantity_expression: floor((quantity - tier_1_quantity) * 0.50)
          action_on_trigger: 50% 추가 익절
        tier_3:
          price_expression: TRAILING_STOP_PRICE_V1 or time_stop
          quantity_expression: quantity - tier_1_quantity - tier_2_quantity
          action_on_trigger: 잔여 전량 trailing or time_stop 청산
    missing_policy:
      atr20: 'TAKE_PROFIT_LADDER_V1 fallback. DATA_MISSING_ATR 태그 출력. fixed_pct 가격만
        산출 (tier_1: +10%/+15%, tier_2: +20%/+25%).

        '
      average_cost: NO_TAKE_PROFIT_PRICE
      quantity: NO_TAKE_PROFIT_QUANTITY
    output_columns:
    - 계좌
    - 종목명
    - 평단(원)
    - ATR20(원)
    - 1R(%)
    - tier_1_ATR가격
    - tier_1_고정%가격
    - tier_1_최종가격(max)
    - tier_1_수량
    - tier_2_ATR가격
    - tier_2_고정%가격
    - tier_2_최종가격(max)
    - tier_2_수량
    - tier_3_기준가(원)
    - 잔여수량
    canonical_ref: spec/exit/take_profit.yaml:take_profit.tiered_ladder
    version: 2026-05-18_ADVANCED_EXIT_V2
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - average_cost
    - atr20
    - quantity
    - position_class
    output_fields:
    - take_profit_ladder_v2
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  DIVERGENCE_SCORE_V1:
    purpose: '가격이 MA20 위로 상승하는 국면에서 외국인·기관이 동반 이탈하고 flow_credit이 낮으면 개인이 받아주는 취약한
      구조임을 0~1 점수로 계량화. 코스피 상승 중에도 경고가 나와야 하는 핵심 선제 레이더.

      '
    applicable: 보유 종목 분석 시 항상 실행. 매수/매도 요청 불문.
    inputs:
    - field: close_price
      unit: KRW_per_share
    - field: ma20
      unit: KRW_per_share
    - field: frg_5d_sh
      unit: shares
    - field: inst_5d_sh
      unit: shares
    - field: flow_credit
      unit: ratio_0_1
      note: FLOW_CREDIT_V1 결과
    - field: frg_20d_sh
      unit: shares
      optional: true
      note: 존재 시 추세 확인 가중치 상향
    derived_flags:
      price_above_ma20: 1 if close_price > ma20 else 0
      foreign_net_sell: 1 if frg_5d_sh < 0 else 0
      institution_net_sell: 1 if inst_5d_sh < 0 else 0
      flow_quality_low: 1 if flow_credit < 0.40 else 0
    expression: "divergence_score = price_above_ma20 *\n  (foreign_net_sell * 0.40\
      \ + institution_net_sell * 0.30 + flow_quality_low * 0.30)\n"
    output:
      field: divergence_score
      unit: ratio_0_1
    gates:
    - if: divergence_score >= 0.70
      status: DIVERGENCE_ALERT
      note: 20D 동반 이탈 확인 시 임계값 0.60으로 하향
    - if: 0.40 <= divergence_score < 0.70
      status: DIVERGENCE_CAUTION
    - if: divergence_score < 0.40 OR price_above_ma20 == 0
      status: PASS
    missing_policy:
      frg_5d_sh: W1 DATA_MISSING. 레이더 결과 무효.
      inst_5d_sh: foreign_net_sell만 사용 (inst 가중치 0 처리)
      flow_credit: FLOW_CREDIT_V1 먼저 실행 후 재시도
      frg_20d_sh: DATA_MISSING 시 5D 기준만 적용. 임계값 0.70 유지.
    canonical_ref: spec/exit/proactive_exit_radar.yaml:divergence_alert
    version: 2026-05-19_PROACTIVE_RADAR_V1
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - close_price
    - ma20
    - frg_5d_sh
    - inst_5d_sh
    - flow_credit
    - frg_20d_sh
    output_fields:
    - divergence_score
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  OVERHANG_PRESSURE_V1:
    purpose: '외국인 매도 속도가 최근 20D 평균 대비 급가속하면서 거래대금이 감소하면 오버행(대기 매도 물량) 누적으로 가격 지지 실패
      가능성을 사전 경고.

      '
    applicable: 보유 종목 분석 시 항상 실행.
    inputs:
    - field: frg_5d_sh
      unit: shares
    - field: frg_20d_sh
      unit: shares
      optional: true
    - field: volume
      unit: shares
    - field: avg_volume_5d
      unit: shares
    - field: flow_credit
      unit: ratio_0_1
      optional: true
    derived_flags:
      selling_acceleration:
        with_20d: 'frg_5d_sh < 0 AND frg_20d_sh < 0 AND frg_5d_sh < (frg_20d_sh /
          4) * (-1.5)

          '
        without_20d_fallback: 'frg_5d_sh < -500000  # 절대값 기준 임시 적용 OR flow_credit
          < 0.30

          '
      volume_weakness: volume < avg_volume_5d * 0.80
    overhang_score:
      expression: '(selling_acceleration ? 0.60 : 0) + (volume_weakness ? 0.40 : 0)'
    output:
      field: overhang_score
      unit: ratio_0_1
    gates:
    - if: overhang_score >= 1.00
      status: OVERHANG_ALERT
      note: 매도 가속 + 거래대금 감소 동시 발생
    - if: overhang_score >= 0.60
      status: OVERHANG_CAUTION
      note: 둘 중 하나만 발생
    - if: overhang_score < 0.60
      status: PASS
    missing_policy:
      frg_5d_sh: W2 DATA_MISSING. 레이더 결과 무효.
      avg_volume_5d: volume_weakness=false 처리 (보수적)
      frg_20d_sh: DATA_MISSING 시 fallback 기준 적용
    cross_alert:
      rule: W1_DIVERGENCE_ALERT + W2_OVERHANG_ALERT 동시 → CRITICAL_ALERT 상향
      output_tag: '[W1+W2_CRITICAL_ALERT]'
    canonical_ref: spec/exit/proactive_exit_radar.yaml:overhang_warning
    version: 2026-05-19_PROACTIVE_RADAR_V1
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - frg_5d_sh
    - frg_20d_sh
    - volume
    - avg_volume_5d
    - flow_credit
    output_fields:
    - overhang_score
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  SECTOR_ROTATION_RADAR_V1:
    purpose: '보유 섹터의 SmartMoney 5D 점수가 -0.5 이하로 하락하고 타 섹터로 자금이 이동하는 로테이션 초기 신호를 포착한다.
      주가 꺾임보다 2~4주 선행하는 수급 선행 지표.

      '
    applicable: 보유 종목의 sector_flow 데이터 존재 시 실행.
    inputs:
    - field: sector_smartmoney_5d
      unit: normalized_score
      source: sector_flow 탭 — 보유 종목 섹터
    - field: sector_rank
      unit: integer
      optional: true
      note: 이전 주 대비 순위 변화
    - field: sector_top2_names
      unit: list
      optional: true
      note: 자금 유입 상위 2개 섹터
    derived_flags:
      held_sector_outflow: sector_smartmoney_5d < -0.50
      rank_deterioration: sector_rank가 이전 주 대비 2단계 이상 하락
      rotation_destination: sector_top2_names에 보유 종목 섹터 없음
    gates:
    - if: held_sector_outflow AND (rank_deterioration OR rotation_destination)
      status: ROTATION_ALERT
      note: 선제 TRIM 최적 시점. tier_1 익절 미실행 즉시 검토.
    - if: held_sector_outflow AND NOT rank_deterioration AND NOT rotation_destination
      status: ROTATION_CAUTION
      note: 초기 신호. 다음 5D 업데이트 후 재확인.
    - if: NOT held_sector_outflow
      status: PASS
    output:
      field: rotation_radar_status
      unit: enum
    missing_policy:
      sector_flow_missing: W3 DATA_MISSING. sector_flow 탭 점검 권고.
    cross_alert:
      rule: W3_ROTATION_ALERT + (W1 OR W2 ALERT) 동시 → CRITICAL_ALERT
      output_tag: '[W3+CRITICAL_ALERT: 섹터 로테이션 + 수급 이탈 동시. 익절 최적 시점.]'
    canonical_ref: spec/exit/proactive_exit_radar.yaml:sector_rotation_radar
    version: 2026-05-19_PROACTIVE_RADAR_V1
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - sector_smartmoney_5d
    - sector_rank
    - sector_top2_names
    output_fields:
    - rotation_radar_status
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  FLOW_ACCELERATION_V1:
    purpose: '가격 상승 중 외국인 매수 강도가 20D 평균 대비 급격히 둔화되는 에너지 소진(Distribution) 초기 신호를 포착.
      W1보다 선행. W1(방향 전환) 이전에 설거지 구간을 조기 경고.

      '
    applicable: 보유 포지션 분석 시 항상 실행. W1/W2/W3와 동시.
    inputs:
    - field: frg_5d_sh
      unit: shares
      note: 외국인 5D 순매수
    - field: frg_20d_sh
      unit: shares
      note: 외국인 20D 누적 순매수
    - field: close_price
      unit: KRW_per_share
    - field: ma20
      unit: KRW_per_share
    derived_flags:
      buy_energy_20d_avg: 'frg_20d_sh / 4  # 20D 평균의 5D 기대값'
      flow_accel_ratio: frg_5d_sh / buy_energy_20d_avg  (>0인 경우)
      price_above_ma20: 1 if close_price > ma20 else 0
    gates:
    - if: price_above_ma20 AND frg_5d_sh > 0 AND flow_accel_ratio < 0.50
      status: FLOW_DECEL_WARNING
      note: 매수 에너지 20D 평균 절반 미만. 설거지 초기. W1과 동시 발화 시 CRITICAL_ALERT.
    - if: price_above_ma20 AND frg_5d_sh <= 0
      status: W1_DOMAIN
      note: 순매도 전환 -- W1 DIVERGENCE_SCORE_V1 처리
    - if: NOT price_above_ma20 OR buy_energy_20d_avg <= 0
      status: PASS
    output:
      field: flow_acceleration_status
      unit: enum
    cross_alert:
      rule: FLOW_DECEL_WARNING + W1_DIVERGENCE_ALERT -> CRITICAL_ALERT
      output_tag: '[W4+W1_CRITICAL: 설거지 에너지 소진 + 수급 이탈 동시]'
    missing_policy:
      frg_20d_sh: W4 DATA_MISSING. 가속도 산출 불가.
      frg_5d_sh: W4 DATA_MISSING.
    canonical_ref: spec/exit/proactive_exit_radar.yaml:flow_acceleration_radar
    version: 2026-05-19_ALPHA_SHIELD_V1
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - frg_5d_sh
    - frg_20d_sh
    - close_price
    - ma20
    output_fields:
    - flow_acceleration_status
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  RS_RATIO_V1:
    purpose: '종목의 5D 수익률을 KOSPI 5D 수익률로 나눠 상대강도(RS)를 계산한다. sell_priority_engine의 rw_ge_4_or_rs_laggard
      판정 공식. RS 강세 종목(rs_ratio >= 1.20)은 손실 중에도 매도 후순위로 보호.

      '
    applicable: 매도 후보 종목 분석 시 항상 실행.
    inputs:
    - field: stock_close_5d_return
      unit: ratio
      note: (close - close_5d_ago) / close_5d_ago
    - field: kospi_close_5d_return
      unit: ratio
      note: KOSPI 기준 동일 계산
    expression: 'rs_ratio = stock_close_5d_return / kospi_close_5d_return (kospi_close_5d_return
      == 0 이면 1.0 처리)

      '
    output:
      field: rs_ratio
      unit: ratio
    gates:
    - if: rs_ratio >= 1.20
      status: RS_LEADER
      note: 시장 대비 20%+ 강세. sell_priority 보호. core_quality_protection에 준하는 후순위.
    - if: 0.80 <= rs_ratio < 1.20
      status: RS_NEUTRAL
    - if: rs_ratio < 0.80
      status: RS_LAGGARD
      note: '시장 대비 20%+ 약세. rw_ge_4_or_rs_laggard: 35점 발동.'
    missing_policy:
      stock_close_5d_return: RS_LAGGARD=false (보수적). 데이터 확보 후 재산출.
      kospi_close_5d_return: RS_LAGGARD=false (보수적).
    canonical_ref: spec/risk/portfolio_exposure.yaml:sell_priority_engine.components.weakness_points
    version: 2026-05-19_ALPHA_SHIELD_V1
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - stock_close_5d_return
    - kospi_close_5d_return
    output_fields:
    - rs_ratio
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  RS_VERDICT_V1:
    purpose: '종목의 10일 수익률을 KOSPI 10일 수익률과 비교해 초과 수익률(excess_ret_10d)을 계산하고 LEADER/MARKET/LAGGARD/BROKEN
      4단계 판정을 내린다. composite_verdict, SFG_V1, RAG_V1의 선행 입력으로 사용된다.

      '
    applicable: 매 buildTickerRow_ 실행 시 _addTickerGates_ 내에서 계산. LLM 재계산 금지.
    inputs:
    - field: price.ret10D
      unit: pct
      note: 종목 10일 수익률
    - field: globalKospiRet10D_
      unit: pct
      note: KOSPI 10일 수익률 (preReads)
    - field: rw_partial
      unit: int_0_5
      note: 상대약세 청산 신호 합계
    - field: flow_credit
      unit: ratio_0_1
      note: FLOW_CREDIT_V1 결과
    derived:
      excess_ret_10d: (price.ret10D - globalKospiRet10D_) if both available else null
    gates:
    - if: excess_ret_10d < -10 AND rw_partial >= 3
      verdict: BROKEN
      note: 구조적 이탈
    - if: excess_ret_10d < -3 OR (excess_ret_10d < 0 AND rw_partial >= 3)
      verdict: LAGGARD
      note: 시장 대비 약세
    - if: excess_ret_10d > 3 AND flowCredit >= 0.6
      verdict: LEADER
      note: 시장 대비 강세
    - if: otherwise
      verdict: MARKET
      note: 시장 중립
    output:
      field: rs_verdict
      unit: enum [LEADER, MARKET, LAGGARD, BROKEN, UNKNOWN]
      additional_fields:
      - excess_ret_10d
    missing_policy:
      price.ret10D: rs_verdict = UNKNOWN. composite_verdict = WATCH_CANDIDATE.
      globalKospiRet10D_: rs_verdict = UNKNOWN.
    ground_truth: harness
    llm_allowed: cite_only
    prohibition:
    - LLM이 뉴스·차트 감각으로 rs_verdict를 LEADER로 상향 금지
    - rs_verdict = BROKEN 종목을 'RS가 곧 회복될 것'으로 임의 완화 금지
    canonical_ref: spec/risk/portfolio_exposure.yaml:sell_priority_engine.weakness_points
    version: 2026-05-21_CLA_HARNESS_V1
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - price.ret10D
    - globalKospiRet10D_
    - rw_partial
    - flow_credit
    output_fields:
    - rs_verdict
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  SATELLITE_LIFECYCLE_GATE_V1:
    purpose: '위성 종목에 WATCH/PILOT/CONFIRMED/REVIEW/EXIT 5단계 라이프사이클을 부여한다. 각 단계는 전환
      조건, 허용 액션, 보유 기준이 명확히 다르다. 이진 CORE/SATELLITE 분류를 확장하며 기존 분류와 병렬 적용.

      '
    applicable: _addTickerGates_ 내 COMPOSITE_VERDICT_V1 이후 실행.
    inputs:
    - field: ticker
      unit: string
    - field: composite_verdict
      unit: enum
    - field: brt_verdict
      unit: enum
    - field: excess_drawdown_pctp
      unit: pct_points
    - field: entry_date
      unit: date
    - field: alpha_evaluation_window_json
      unit: array
      optional: true
    output:
      field: satellite_lifecycle_stage
      additional_fields:
      - lifecycle_transition_reason
      - lifecycle_days_in_stage
      - review_warning
    lifecycle_stages:
      WATCH:
        definition: 관심종목. 미투자. SAQG_V1 ELIGIBLE 미달.
        transition_to_PILOT: saqg_v1=ELIGIBLE AND rag_v1=PASS AND brt_verdict IN [LEADER,MARKET]
        allowed_actions:
        - WATCH
      PILOT:
        definition: 소액 파일럿. T1 트랜치 30% 진입.
        transition_to_CONFIRMED: t20_vs_core_pctp >= 0 AND brt_verdict=LEADER AND
          composite_verdict=PRIME_CANDIDATE
        transition_to_REVIEW: t5_alpha_gate=alpha_negative 연속2회 OR brt_verdict=LAGGARD
          OR excess_drawdown_pctp > 8
        allowed_actions:
        - HOLD_PILOT
        - ADD_T2_IF_CONFIRMED
      CONFIRMED:
        definition: 알파 검증됨. 정규 비중 편입.
        transition_to_REVIEW: t20_vs_core_pctp < -5 OR brt_verdict=LAGGARD OR composite_verdict=REDUCE_CANDIDATE
        allowed_actions:
        - HOLD
        - ADD_T2
        - ADD_T3
        - PARTIAL_TP
      REVIEW:
        definition: 알파 훼손. 감시, 축소 모드.
        transition_to_CONFIRMED: brt_verdict=LEADER 연속2주 AND composite_verdict=PRIME_CANDIDATE
        transition_to_EXIT: brt_verdict=BROKEN OR composite_verdict=CLOSE_POSITION
          OR t20_vs_core_pctp < -10 OR excess_drawdown_pctp >= 15
        forced_reduce: 4주 이상 REVIEW 시 비중 50% 감축 권고
        allowed_actions:
        - HOLD_REDUCED
        - TRIM_ON_REBOUND
        - NO_ADD
      EXIT:
        definition: 정리 확정. 다음 반등 시 전량 청산.
        allowed_actions:
        - FULL_EXIT_ON_TRIGGER
        - STAGED_EXIT
        prevent: EXIT 진입 후 LLM이 단계 복귀 금지
    output_fields:
    - field: satellite_lifecycle_stage
      unit: enum [WATCH,PILOT,CONFIRMED,REVIEW,EXIT]
    - field: lifecycle_transition_reason
      unit: string
    - field: lifecycle_days_in_stage
      unit: int
    hard_rules:
    - EXIT 단계 종목에 신규 ADD/BUY 금지
    - REVIEW 단계 종목에 T3 트랜치 진입 금지
    ground_truth: harness
    llm_allowed: cite_only
    prohibition:
    - LLM이 lifecycle_stage 임의 격상 금지
    - EXIT -> CONFIRMED 복귀는 하네스 재산출 후만 가능
    version: 2026-05-21_SLG_V1
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - ticker
    - composite_verdict
    - brt_verdict
    - excess_drawdown_pctp
    - entry_date
    - alpha_evaluation_window_json
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  CLA_REGIME_EXIT_CONDITION_V1:
    purpose: 'CONCENTRATED_LEADER_ADVANCE 국면의 종료 조건을 결정론적으로 탐지한다. CLA 활성 중에도 하네스가
      주기적으로 종료 신호(S1~S5)를 스캔한다. 종료 조건 충족 시 market_regime을 CLA -> NEUTRAL 전환 권고.

      '
    applicable: buildHarnessContext_ 내 market_regime=CLA일 때만 실행.
    inputs:
    - field: ticker
      unit: string
    - field: rs_verdict
      unit: enum
    - field: brt_verdict
      unit: enum
    - field: frg_5d_sh
      unit: shares
    - field: volume
      unit: shares
    - field: avg_volume_5d
      unit: shares
    - field: market_regime
      unit: string
    output:
      field: cla_exit_status
      additional_fields:
      - cla_exit_signals_triggered
      - cla_exit_total_weight
    exit_signals:
      S1_rs_degradation:
        condition: (삼성전자 OR SK하이닉스 rs_verdict=LAGGARD) 연속5영업일
        weight: 3
      S2_kospi_contribution_drop:
        condition: 삼성전자+SK하이닉스 최근20D KOSPI 기여도 < 30%
        weight: 2
      S3_foreign_flow_reversal:
        condition: 삼성전자 frg_5d_sh < 0 AND SK하이닉스 frg_5d_sh < 0 연속3일
        weight: 2
      S4_volume_exhaustion:
        condition: 삼성전자+SK하이닉스 volume < avgVolume5d*0.6 연속3일
        weight: 1
      S5_brt_degradation:
        condition: 삼성전자 brt_verdict=MARKET AND SK하이닉스 brt_verdict=MARKET (LEADER에서
          하락)
        weight: 2
    exit_decision:
      CLA_EXIT_CONFIRMED:
        condition: total_weight >= 5
        action: market_regime -> NEUTRAL 권고. O2 반도체 25% 상한 재적용.
      CLA_EXIT_WARNING:
        condition: total_weight IN [3,4]
        action: CLA 종료 경보. 위성 신규매수 제한 해제 준비.
      CLA_ACTIVE:
        condition: total_weight < 3
        action: CLA 계속 유지. 기존 보호 규칙 적용.
    output_fields:
    - field: cla_exit_status
      unit: enum [CLA_ACTIVE,CLA_EXIT_WARNING,CLA_EXIT_CONFIRMED]
    - field: cla_exit_signals_triggered
      unit: list
    - field: cla_exit_total_weight
      unit: int
    ground_truth: harness
    llm_allowed: cite_only
    prohibition:
    - LLM이 CLA 종료를 임의 선언 금지
    - CLA_EXIT_CONFIRMED 없이 O2 반도체 25% 상한 재적용 금지
    version: 2026-05-21_CLA_EXIT_V1
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - ticker
    - rs_verdict
    - brt_verdict
    - frg_5d_sh
    - volume
    - avg_volume_5d
    - market_regime
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  SELL_PRICE_SANITY_V1:
    purpose: 'HTS 입력 전 매도 지정가의 역전, 비현실가, 호가단위 불일치를 100% 차단한다. LS전기(E1 오류) 재발 방지: 지정가
      < 손절가 역전 사례를 하네스가 선점 차단.

      '
    applicable: calcApexExecutionHarness_ 주문 최종 검증 단계. TICK_NORMALIZER_V1 직후 실행.
    inputs:
    - field: sell_limit_price
      unit: KRW_per_share
    - field: stop_loss_price
      unit: KRW_per_share
    - field: current_price
      unit: KRW_per_share
    - field: tick_unit
      unit: KRW_per_share
      note: TICK_NORMALIZER_V1 산출값
    validation_rules:
      INVALID_PRICE_INVERSION:
        condition: sell_limit_price < stop_loss_price
        action: HTS 주문표 제거. Shadow Ledger 이동. reason_code=INVALID_PRICE_INVERSION.
        example: 지정가 261,000 < 손절가 291,000 → 즉시 차단
      INVALID_CHASE_UP_SELL:
        condition: sell_limit_price > current_price * 1.03
        action: 사용자 Override 없이 주문표 제거.
      INVALID_TICK:
        condition: sell_limit_price % tick_unit != 0
        action: TICK_NORMALIZER_V1 자동 재정규화 후 재산출. (HS008 통합)
      WARN_DEEP_DISCOUNT_SELL:
        condition: sell_limit_price < current_price * 0.90
        action: 주문표 유지, 보고서 상단 경고 표시.
    output:
      field: sell_price_sanity_status
      values:
      - PASS
      - INVALID_PRICE_INVERSION
      - INVALID_CHASE_UP_SELL
      - INVALID_TICK
      - WARN_DEEP_DISCOUNT_SELL
      additional_fields:
      - sanity_fail_reason
      - corrected_limit_price
    ground_truth: harness
    llm_allowed: cite_only
    prohibition:
    - INVALID_PRICE_INVERSION 행을 HTS 주문표에 기재 금지
    - LLM이 '임시로' 역전 가격을 주문표에 넣는 행위 절대 금지
    - TICK 재정규화 전 가격을 HTS에 입력 금지 (HS008)
    canonical_ref: AGENTS.md:Direction A1, HS008(TICK_NORMALIZER_V1)
    version: 2026-05-22_3RD_HARNESS
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - sell_limit_price
    - stop_loss_price
    - current_price
    - tick_unit
    output_fields:
    - sell_price_sanity_status
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  DISTRIBUTION_SELL_DETECTOR_V1:
    purpose: 'PRE_DISTRIBUTION_EARLY_WARNING(2신호)의 정밀도 한계 보완. 기관·외인이 개인에게 물량을 넘기는
      설거지 구간을 6신호 합산으로 조기 감지.

      '
    applicable: _addTickerGates_ 내 FLOW_ACCELERATION_V1 직후.
    inputs:
    - field: close
      unit: KRW_per_share
    - field: high52w
      unit: KRW_per_share
      optional: true
    - field: avg_volume_5d
      unit: shares
    - field: volume
      unit: shares
    - field: ret5d
      unit: percent
    - field: flow_credit
      unit: ratio_0_1
    - field: frg_5d_sh
      unit: shares
    - field: inst_5d_sh
      unit: shares
    - field: rsi14
      unit: score_0_100
      optional: true
    - field: obv_slope_20d
      unit: float
      optional: true
    signals:
      SIG_1:
        condition: high52w > 0 AND close >= high52w * 0.97 AND volume < avg_volume_5d
          * 0.80
        label: 신고가 근접 + 거래량 수축
        weight: 2.0
      SIG_2:
        condition: ret5d >= 5 AND flow_credit < 0.45
        label: 5일 급등 + 수급 약화
        weight: 2.0
      SIG_3:
        condition: frg_5d_sh < 0 AND inst_5d_sh < 0
        label: 외인+기관 동반 순매도 (3일 연속)
        weight: 1.5
      SIG_4:
        condition: rsi14 != null AND rsi14 >= 75 AND close < open_today
        label: RSI 과열 + 당일 음봉
        weight: 1.5
      SIG_5:
        condition: obv_slope_20d != null AND obv_slope_20d < 0
        label: OBV 20일 기울기 음수
        weight: 1.0
      SIG_6:
        condition: ret1d_prev >= 5 AND close < open_today * 0.98
        label: 전일 급등 후 당일 -2% 갭하락
        weight: 1.0
    classification:
      weighted_sum: sum of (signal.weight for each triggered signal)
      DISTRIBUTION_CONFIRMED:
        condition: weighted_sum >= 4.0
        action: BUY 완전 차단 + TRIM_REVIEW 발동
      DISTRIBUTION_WARNING:
        condition: weighted_sum >= 2.0 AND weighted_sum < 4.0
        action: BUY 보류 권고 + EARLY_WARNING 표기
      DISTRIBUTION_CLEAR:
        condition: weighted_sum < 2.0
        action: 정상 진행
    output:
      field: distribution_sell_detector_status
      values:
      - DISTRIBUTION_CONFIRMED
      - DISTRIBUTION_WARNING
      - DISTRIBUTION_CLEAR
      additional_fields:
      - weighted_sum
      - signals_triggered
    ground_truth: harness
    llm_allowed: cite_only
    prohibition:
    - DISTRIBUTION_CONFIRMED 상태에서 LLM '단기 조정이니 괜찮다' 우회 금지
    - PRE_DISTRIBUTION_EARLY_WARNING과 독립적으로 둘 다 체크 (OR 아님, AND 독립)
    - LLM이 신호 합산을 직접 계산 금지
    canonical_ref: AGENTS.md:Direction B3, L4(PRE_DISTRIBUTION)
    version: 2026-05-22_3RD_HARNESS
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - close
    - high52w
    - avg_volume_5d
    - volume
    - ret5d
    - flow_credit
    - frg_5d_sh
    - inst_5d_sh
    - rsi14
    - obv_slope_20d
    output_fields:
    - distribution_sell_detector_status
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  PROFIT_RATCHET_TIERED_V2:
    purpose: '기존 L2(RATCHET_TRAILING_AUTO_V1)에 APEX_SUPER(+60%+) 구간 신설. 삼성전자 +61.5%(E3
      오류) 재발 방지: 단순 ''보유 유지'' 서술 없이 래칫 스탑 필수 표기.

      '
    applicable: PROFIT_LOCK_STAGE_CLASSIFIER_V1 직후. 수익 구간별 자동 적용.
    inputs:
    - field: profit_pct
      unit: percent
    - field: profit_lock_stage
      unit: enum
      note: PROFIT_LOCK_STAGE_CLASSIFIER_V1 산출
    - field: highest_close
      unit: KRW_per_share
    - field: atr20
      unit: KRW_per_share
    - field: average_cost
      unit: KRW_per_share
    - field: quantity
      unit: shares
    - field: secular_leader_gate_active
      unit: boolean
      optional: true
    ratchet_table_v2:
      NORMAL:
        trailing_stop: 'null'
        tp_ladder_action: 없음
      BREAKEVEN_RATCHET:
        trailing_stop: average_cost * 1.005 (세후)
        tp_ladder_action: 없음
      PROFIT_LOCK_10:
        trailing_stop: highest_close - 2.5 * atr20
        tp_ladder_action: 없음
        note: '[신규 V2]'
      PROFIT_LOCK_20:
        trailing_stop: highest_close - 1.5 * atr20
        tp_ladder_action: tp1_qty 확인
      PROFIT_LOCK_30:
        trailing_stop: highest_close - 1.8 * atr20
        tp_ladder_action: tp1+tp2 확인
        note: 'V2: 1.8 (V1: 2.0 보다 타이트)'
      APEX_TRAILING:
        trailing_stop: highest_close - 1.5 * atr20
        tp_ladder_action: tp1+tp2 확인
        note: 'V2: 1.5 (V1: 2.0 보다 타이트)'
      APEX_SUPER:
        condition: profit_pct >= 60
        trailing_stop: max(ratchet_stop, highest_close - 1.2 * atr20)
        tp_ladder_action: 강제 10% 익절 권고 (quantity * 0.10, 매 +10%마다)
        llm_obligation: '보고서에 ''APEX_SUPER 구간: trailing_stop=XXX원, 10% 익절 검토'' 필수
          표기'
        note: '[신규 V2] +60% 초과 종목 전용. 삼성전자 현재 해당.'
      SECULAR_LEADER_DEFERRED:
        trailing_stop: 'null'
        tp_ladder_action: H3 연동 유지
    output:
      field: auto_trailing_stop_v2
      additional_fields:
      - ratchet_stage_v2
      - apex_super_active
      - tp_ladder_qty_v2
    ground_truth: harness
    llm_allowed: cite_only
    prohibition:
    - APEX_SUPER 구간 종목에 '보유 유지' 단독 서술 금지 — trailing_stop 병기 필수
    - LLM이 trailing_stop을 재계산 금지 — 하네스 산출값 그대로 사용
    - SECULAR_LEADER_DEFERRED 구간에서 H3 규칙 무시 금지
    canonical_ref: AGENTS.md:Direction E1, L2(RATCHET_TRAILING_AUTO_V1), M3
    version: 2026-05-22_3RD_HARNESS
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - profit_pct
    - profit_lock_stage
    - highest_close
    - atr20
    - average_cost
    - quantity
    - secular_leader_gate_active
    output_fields:
    - auto_trailing_stop_v2
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  SELL_VALUE_PRESERVATION_TIERED_V2:
    purpose: '현금확보 매도 시 ''좋은 매도''와 ''나쁜 매도''를 하네스가 자동 판별. 반등 시 추가 수익까지 고려한 세련된 매도
      결정 트리 (K2 + SELL_WATERFALL 통합).

      '
    applicable: SELL_WATERFALL_ENGINE_V1 이후. 종목별 최적 매도 스타일 확정.
    inputs:
    - field: emergency_full_sell
      unit: boolean
    - field: oversold_gate
      unit: enum
    - field: rsi14
      unit: score
    - field: profit_lock_stage
      unit: enum
    - field: velocity_5d
      unit: percent
    - field: h2_priority_rank
      unit: int
    - field: rs_verdict
      unit: enum
    - field: cash_shortfall_min_krw
      unit: KRW
    - field: waterfall_plan_json
      unit: json
    decision_tree:
    - if: emergency_full_sell == true
      verdict: EMERGENCY_EXIT
      plan: SELL_WATERFALL stage_4 실행
    - elif: oversold_gate == OVERSOLD AND rsi14 < 30
      verdict: OVERSOLD_REBOUND_SELL
      plan: K2 + SELL_WATERFALL stage_2. rebound_tp_price = prev_close + 1.0 * atr20
    - elif: profit_lock_stage IN [PROFIT_LOCK_20, APEX_TRAILING, APEX_SUPER] AND velocity_5d
        > 8
      verdict: APEX_TRIM
      plan: tp_quantity_ladder.tp1_qty 즉시 매도. limit = current - 0.5 * atr20
    - elif: h2_priority_rank == 1 AND rs_verdict == BROKEN
      verdict: STAGED_EXIT
      plan: SELL_WATERFALL stage_1 → stage_2 → stage_3 순서
    - elif: cash_shortfall_min_krw > 0
      verdict: PRESERVE_TIERED
      plan: CASH_RECOVERY_OPTIMIZER_V1 조합 실행
    - else: null
      verdict: HOLD
      plan: 매도 조건 미충족
    output:
      field: preservation_verdict
      additional_fields:
      - recommended_plan_ref
      - rebound_upside_krw
    ground_truth: harness
    llm_allowed: cite_only
    prohibition:
    - decision_tree 순서 임의 변경 금지
    - EMERGENCY_EXIT 외 조건에서 전량 즉시 매도 지시 금지
    canonical_ref: AGENTS.md:Direction E2, K2, SELL_WATERFALL_ENGINE_V1
    version: 2026-05-22_3RD_HARNESS
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - emergency_full_sell
    - oversold_gate
    - rsi14
    - profit_lock_stage
    - velocity_5d
    - h2_priority_rank
    - rs_verdict
    - cash_shortfall_min_krw
    - waterfall_plan_json
    output_fields:
    - preservation_verdict
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  VALUE_PRESERVATION_SCORER_V1:
    purpose: '종목별 가치 훼손 점수(value_damage_score 0~100) + 반등 잠재력(rebound_potential 0~100)
      + 권고 동작(recommended_action)을 결정론 공식으로 산출한다. SCRS-V2 selected_combo의 빈 셀에 주입하여
      LLM 자유 해석을 차단한다.

      '
    inputs:
    - field: Close
      unit: KRW_per_share
    - field: MA20
      unit: KRW_per_share
    - field: MA60
      unit: KRW_per_share
    - field: ATR20
      unit: KRW_per_share
    - field: RSI14
      unit: percent
    - field: BB_Position
      unit: 0to1_scale
    - field: Frg_5D
      unit: KRW
    - field: Inst_5D
      unit: KRW
    - field: AvgTradeValue_5D_M
      unit: KRW_hundred_million
    - field: AvgTradeValue_20D_M
      unit: KRW_hundred_million
    - field: Recovery_Ratio_5D
      unit: ratio
    - field: Stock_Drawdown_From_High_Pct
      unit: percent
    output:
      field: value_preservation_scorer_v1_json
    expected_outputs:
    - gate
    - distinct_actions
    - row_count
    llm_allowed: cite_only
    version: 2026-05-27_PHASE1
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - Close
    - MA20
    - MA60
    - ATR20
    - RSI14
    - BB_Position
    - Frg_5D
    - Inst_5D
    - AvgTradeValue_5D_M
    - AvgTradeValue_20D_M
    - Recovery_Ratio_5D
    - Stock_Drawdown_From_High_Pct
    output_fields:
    - value_preservation_scorer_v1_json
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  RATCHET_TRAILING_GENERAL_V1:
    purpose: '모든 보유 종목(수익률≥0%)에 7-tier 공식으로 auto_trailing_stop을 산출한다. 기존 APEX 한정 trailing을
      전 종목으로 일반화. 수익 보호 + 뒷박 재진입 차단.

      '
    inputs:
    - field: Profit_Pct
      unit: percent
    - field: Close
      unit: KRW_per_share
    - field: ATR20
      unit: KRW_per_share
    - field: High52W
      unit: KRW_per_share
    - field: Stop_Price_Est
      unit: KRW_per_share
    - field: Account_Avg_Cost
      unit: KRW_per_share
    output:
      field: ratchet_trailing_general_v1_json
    expected_outputs:
    - gate
    - coverage_pct
    llm_allowed: cite_only
    version: 2026-05-27_PHASE1
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - Profit_Pct
    - Close
    - ATR20
    - High52W
    - Stop_Price_Est
    - Account_Avg_Cost
    output_fields:
    - ratchet_trailing_general_v1_json
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  SELL_WATERFALL_ENGINE_V2:
    purpose: 'V1 4단계 유지 + 호가단위 슬리피지(bps) 시뮬, TWAP/지정가 분할(유동성기반), 부분체결 잔량 자동 stage
      승격(단계 건너뜀 금지).

      '
    output:
      file: Temp/sell_waterfall_engine_v2.json
    expected_outputs:
    - gate
    - stage_counts
    - escalation_skip_violations
    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
  FINAL_JUDGMENT_GATE_V1:
    purpose: '판단 결정론 계층 — 키스톤. 모든 게이트·신호 JSON + _harness_context를 읽어 종목별 단일 action_verdict를
      AND-11 조건으로 결정론 산출. action_verdict in {BUY_PILOT, HOLD, TRIM, SELL, WATCH, BLOCKED}.
      harness_key 부재 시 DATA_MISSING 명시(silent PASS 금지). effective_confidence = raw_confidence
      × (0.4 + 0.6 × invest_quality/100).

      '
    output:
      file: Temp/final_judgment_gate_v1.json
    expected_outputs:
    - gate
    - coverage_pct
    - verdict_counts
    - silent_pass_violations
    - late_chase_buy_violations
    - ticker_count
    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
  VERDICT_CONSISTENCY_LOCK_V1:
    purpose: '판단 일관성 잠금 — operational_report.json의 서술을 final_judgment_gate_v1.json
      verdict와 대조. verdict=BLOCKED/SELL인데 보고서가 긍정 BUY 서술 → INVALID_VERDICT_OVERRIDE
      위반, gate=FAIL. LLM의 verdict 자유도를 0으로 제거. 사용자 H10 수동 오버라이드는 예외.

      '
    output:
      file: Temp/verdict_consistency_lock_v1.json
    expected_outputs:
    - gate
    - override_count
    - warn_count
    - violations
    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
  K2_STAGED_REBOUND_SELL_V1:
    purpose: '과매도 구간 현금확보 매도를 50/50 분할과 반등 대기로 구조화한다.

      '
    inputs:
    - field: base_sell_qty
      unit: shares
    - field: previous_close_price
      unit: KRW_per_share
    - field: atr20
      unit: KRW_per_share
    output:
      field: immediate_sell_qty
    input_fields:
    - baseQty
    - prev_close
    - atr20
    expected_outputs:
    - immediate_sell_qty
    - rebound_wait_qty
    - rebound_trigger_price
    llm_allowed: cite_only
    version: 2026-05-30_PHASE8
    owner: quant_team
    lifecycle_state: active
    output_fields:
    - immediate_sell_qty
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  STOP_BREACH_ALERT_V1:
    purpose: '손절가 이탈 여부와 즉시 청산 경보를 결정한다.

      '
    inputs:
    - field: close_price
      unit: KRW_per_share
    - field: stop_price
      unit: KRW_per_share
    output:
      field: stop_breach_gate
    input_fields:
    - close
    - stop_price
    expected_outputs:
    - stop_breach_gate
    - gap_pct
    llm_allowed: cite_only
    version: 2026-05-30_PHASE8
    owner: quant_team
    lifecycle_state: active
    output_fields:
    - stop_breach_gate
    missing_policy: DATA_MISSING. 계산 결과를 추정하지 않는다.
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
  REBOUND_CAPTURE_THESIS_FACTOR_V1:
    purpose: 과매도 반등 진입을 thesis 팩터로 명시 — 영구 약세편향 해소 (Direction SFP1)
    agents_md_ref: 'Direction SFP1: SINGLE_FACTOR_DOMINANCE_CAP_V1 — REBOUND_CAPTURE
      thesis 반영'
    inputs:
    - field: rsi14
      unit: index_0_100
    - field: current_price
      unit: KRW_per_share
    - field: ma20
      unit: KRW_per_share
    - field: flow_credit
      unit: ratio_0_1
    - field: down_streak
      unit: days_integer
    expression: thesis_bonus = 15.0 if (25<=rsi14<=40) AND (current_price<=ma20*1.03)
      AND (flow_credit>=0.5) AND (down_streak>=2) else 0
    components:
      REBOUND_CAPTURE_WEIGHT:
        value: 15.0
        unit: thesis_points
        calibration_status: EXPERT_PRIOR
        note: 과매도 반등 4조건 동시 충족 시 thesis 점수 가산
    conditions:
      rsi14_range: 25 <= rsi14 <= 40 (과매도~회복 초입)
      price_pullback: current_price <= ma20 x 1.03 (MA20 ±3% 눌림목)
      flow_quality: flow_credit >= 0.5 (자금 유입 최소 기준)
      down_streak: down_streak >= 2 (연속 하락 2일 이상)
    output:
      field: rebound_capture_hit
      unit: boolean
    missing_policy: 4개 조건 중 1개라도 데이터 없으면 rebound_capture_hit=false
    implementation: tools/build_predictive_alpha_dialectic_engine_v2.py:NF2
    calibration_ref: spec/calibration_registry.yaml:NF2 (EXPERT_PRIOR)
    version: 2026-06-04_NF2
    owner: quant_team
    lifecycle_state: active
    input_fields:
    - rsi14
    - current_price
    - ma20
    - flow_credit
    - down_streak
    output_fields:
    - rebound_capture_hit
    golden_cases: []
    activation_threshold:
      min_t20_sample: 30
    retirement_condition: performance_degradation
