meta:
  has_code_implementation: true
  code_path:
  - spec\profit_preservation_contract.yaml
schema_version: profit_preservation_contract.v2
goal: Define rules and metrics to preserve unrealized profits and enforce trailing
  stop policies.
metrics:
- id: profit_giveback
  description: Ratio of profit returned from peak price since entry
- id: trailing_stop
  description: Trailing stop price level determined by ratchet stage
- id: ratchet_stage
  description: Lock tier based on maximum achieved profit percentage (e.g. PROFIT_LOCK_10,
    APEX_SUPER)
- id: sell_slippage_budget
  description: Allowed slippage threshold during execution
rules:
- id: RULE_PROFIT_GIVEBACK_GUARD
  condition: profit_pct >= 20% and profit_giveback > 30% of peak gain
  action: Enforce trailing stop / lock remaining profit
- id: RULE_DRAWDOWN_GUARD_PRIORITY
  condition: portfolio in value_preservation_stage
  action: Prioritize drawdown guard over new alpha signals
- id: RULE_VALUE_DAMAGE_LIMIT
  condition: unrealized maximum drawdown per ticker
  limit: value_damage_pct_avg <= 10%
