version: 1
name: ai_invest_risk_gates
mode: hard_block # hard_block | warn_only

portfolio_limits:
  max_single_position_pct: 0.12         # 单票最大仓位 12%
  max_industry_exposure_pct: 0.35       # 单行业最大暴露 35%
  max_daily_turnover_pct: 0.40          # 单日最大换手 40%
  max_total_leverage: 1.0               # 禁杠杆时保持 1.0

order_limits:
  max_orders_per_symbol_per_day: 3
  max_notional_per_order_cny: 50000000
  max_slippage_bps: 30
  reject_if_price_stale_seconds: 10

loss_controls:
  max_daily_drawdown_pct: 0.03          # 组合当日最大回撤 3%
  max_weekly_drawdown_pct: 0.06
  strategy_kill_switch:
    enabled: true
    trigger:
      any:
        - daily_drawdown_gt_pct: 0.03
        - consecutive_rejects_gte: 5
        - data_quality_score_lt: 0.75
    action: halt_new_orders_and_alert

data_quality_gates:
  required_fields:
    - symbol
    - last_price
    - market_cap
    - pe_ttm
    - event_summary_7d
  min_independent_sources: 2
  freshness:
    quote_max_age_sec: 10
    fundamentals_max_age_days: 30
    event_max_age_days: 7
  consistency:
    price_deviation_max_pct: 0.8
    market_cap_deviation_max_pct: 2.0

execution_guards:
  trading_session_required: true
  exchange_enum_mapping_check: true
  quote_band_check: true
  lot_size_check: true
  t_plus_one_check: true

trading_sessions:
  timezone: Asia/Shanghai
  windows:
    - "09:30-11:30"
    - "13:00-15:00"

enum_mapping:
  xtp_market_type:
    SH: 2
    SZ: 1
  xtp_exchange_type:
    SH: 1
    SZ: 2

compliance:
  require_audit_log: true
  require_decision_trace: true
  blocked_phrases:
    - 众所周知
    - 普遍认为
    - 大概率

fallback_policy:
  on_primary_data_failure:
    retry_order:
      - tavily
      - serper
      - jina
    max_retries: 3
  on_broker_reject:
    action: stop_and_reprice_once
    max_reprice_attempts: 1
