# ============================================================================
# VALIDATION OUT-OF-SAMPLE CONFIGURATION
# ============================================================================
# Archivo: config/validation_oos.yaml
# Proposito: Configurar validacion out-of-sample con exclusion dinamica
# Fecha: 2026-01-27 (actualizado)
# Creado por: ML-Specialist (NEXUS v4.0)
# ============================================================================

validation:
  # -------------------------------------------------------------------------
  # MODO DINAMICO (RECOMENDADO)
  # -------------------------------------------------------------------------
  # Calcula automaticamente OOS = ultimos N meses desde max fecha en BD
  # Si dynamic.enabled = true, ignora train/test_oos fijos
  dynamic:
    enabled: true
    oos_months: 12  # Ultimos 12 meses = OOS
    description: "OOS dinamico: excluye ultimos 12 meses desde max fecha en BD"

  # -------------------------------------------------------------------------
  # PERIODO DE TRAINING (fallback si dynamic.enabled = false)
  # -------------------------------------------------------------------------
  train:
    start_date: "2023-01-01T00:00:00"
    end_date: "2024-12-31T23:59:59"
    description: "Datos historicos para entrenamiento de modelos"

  # -------------------------------------------------------------------------
  # PERIODO DE VALIDACION OUT-OF-SAMPLE (fallback si dynamic.enabled = false)
  # -------------------------------------------------------------------------
  test_oos:
    start_date: "2025-01-01T00:00:00"
    end_date: "2025-12-31T23:59:59"
    description: "Datos del 2025 excluidos del training para validacion"

  # -------------------------------------------------------------------------
  # METODO DE EXCLUSION
  # -------------------------------------------------------------------------
  exclusion_method: "temporal"  # Options: temporal, walk_forward

  # -------------------------------------------------------------------------
  # WALK-FORWARD CONFIGURATION (si exclusion_method = walk_forward)
  # -------------------------------------------------------------------------
  walk_forward:
    enabled: false
    n_splits: 5
    expanding_window: false
    test_size: 0.2
    gap: 0  # Barras de gap entre train y test (evitar look-ahead)
    min_train_size: 10000

# ============================================================================
# METRICAS OBJETIVO (TRADING-STRATEGIST)
# ============================================================================
# Umbrales minimos para aprobar el modelo
# Referencia: PERFIL-TRADING-STRATEGIST.md

metrics_thresholds:
  # =========================================================================
  # OBJETIVOS ML-FIRST (Actualizado 2026-01-04)
  # Target: 80% win rate, 30-100% rendimiento semanal
  # =========================================================================

  # Ratios Risk-Adjusted
  sharpe_ratio_min: 1.5
  sharpe_ratio_target: 2.5
  sortino_ratio_min: 2.0
  calmar_ratio_min: 1.5

  # Riesgo
  max_drawdown_max: 0.15  # 15% maximo drawdown (mas conservador)

  # Performance - OBJETIVO PRINCIPAL
  win_rate_min: 0.75      # 75% minimo (target 80%)
  win_rate_target: 0.80   # 80% objetivo
  profit_factor_min: 2.0  # Profit factor minimo 2.0
  profit_factor_target: 4.0  # Con 80% WR y RR 1:1 = PF 4.0

  # Rendimiento semanal
  weekly_return_min: 0.10   # 10% semanal minimo
  weekly_return_target: 0.30  # 30% semanal objetivo

  # Overfitting detection
  in_sample_vs_oos_threshold: 0.40  # Si OOS < 60% de in-sample, posible overfitting

# ============================================================================
# CONFIGURACION DE BACKTEST
# ============================================================================

backtest:
  initial_capital: 10000.0
  risk_per_trade: 0.02  # 2% por trade
  max_concurrent_trades: 1
  commission_pct: 0.001  # 0.1%
  slippage_pct: 0.0005  # 0.05%

  # Configuraciones R:R a probar
  rr_configs:
    # Configuraciones agresivas (mayor profit potencial, menor win rate)
    - name: "rr_2_1"
      sl_pips: 5.0
      tp_pips: 10.0
      target_win_rate: 0.50

    - name: "rr_3_1"
      sl_pips: 5.0
      tp_pips: 15.0
      target_win_rate: 0.40

    # Configuraciones conservadoras para 80% WR (mayor SL, menor TP)
    - name: "rr_1_2_80wr"
      sl_pips: 10.0
      tp_pips: 5.0
      target_win_rate: 0.80
      description: "Conservador 80% WR - TP pequeño, SL amplio"

    - name: "rr_1_3_80wr"
      sl_pips: 15.0
      tp_pips: 5.0
      target_win_rate: 0.85
      description: "Muy conservador 85% WR"

    # Range-based (usa predicciones de RangePredictorV2)
    - name: "range_adaptive"
      use_range_predictions: true
      tp_range_pct: 0.5   # TP al 50% del rango predicho
      sl_range_pct: 1.5   # SL al 150% del rango opuesto
      target_win_rate: 0.80

  # Filtros de entrada
  min_confidence: 0.55
  filter_by_amd: true
  favorable_amd_phases:
    - "accumulation"
    - "distribution"
  filter_by_volatility: true
  min_volatility_regime: "medium"

  # Timeout
  max_position_time_minutes: 60

# ============================================================================
# SIMBOLOS A EVALUAR
# ============================================================================

symbols:
  - symbol: "XAUUSD"
    description: "Gold vs USD"
    enabled: true

  - symbol: "EURUSD"
    description: "Euro vs USD"
    enabled: true

  - symbol: "GBPUSD"
    description: "GBP vs USD"
    enabled: true

  - symbol: "BTCUSD"
    description: "Bitcoin vs USD"
    enabled: true

  - symbol: "USDJPY"
    description: "USD vs JPY"
    enabled: true

  - symbol: "GBPJPY"
    description: "GBP vs JPY"
    enabled: true

# ============================================================================
# REPORTES
# ============================================================================

reports:
  output_dir: "reports/validation"
  formats:
    - json
    - csv
  include_equity_curve: true
  include_trade_log: true
  include_metrics_by_segment: true
  segments:
    - by_horizon
    - by_rr_config
    - by_amd_phase
    - by_volatility
    - by_direction
