# Roadmap ML-First - Trading Platform
# Q1 2026

id: "ROADMAP-ML-FIRST-2026-Q1"
project: trading-platform
created_date: "2026-01-04"
author: "Orquestador"
version: "1.0.0"

# Objetivos del Roadmap
objectives:
  primary:
    - id: OBJ-01
      name: "80% Win Rate en Operaciones"
      description: "Lograr 80% de operaciones ganadoras validadas en datos out-of-sample"
      kpi: "win_rate >= 0.80"
      priority: P0

    - id: OBJ-02
      name: "30-100% Rendimiento Semanal"
      description: "Capacidad de generar rendimientos semanales significativos"
      kpi: "weekly_return >= 0.30"
      priority: P1

    - id: OBJ-03
      name: "Prediccion Max/Min Multi-TF"
      description: "Prediccion de maximos y minimos en multiples temporalidades"
      kpi: "directional_accuracy >= 0.70"
      priority: P0

  secondary:
    - id: OBJ-04
      name: "LLM con Decision-Making Autonomo"
      description: "Agente LLM fine-tuned que tome decisiones de trading"
      kpi: "decision_accuracy >= 0.75"
      priority: P0

    - id: OBJ-05
      name: "Ejecucion Automatizada MT4+Binance"
      description: "Sistema de ejecucion automatizada via MCP Server"
      kpi: "execution_success >= 0.99"
      priority: P0

# Timeline por Semanas
timeline:
  # FASE 0: Preparacion
  week_01:
    name: "Preparacion de Datos"
    phase: "F0"
    tasks:
      - id: F0-01
        name: "Pipeline de ingesta de datos"
        assignee: "ML-SPECIALIST"
        status: pending
        effort: 2d

      - id: F0-02
        name: "Split temporal (excluir ultimo ano)"
        assignee: "ML-SPECIALIST"
        status: pending
        effort: 1d
        depends_on: [F0-01]

      - id: F0-03
        name: "Datasets por temporalidad"
        assignee: "ML-SPECIALIST"
        status: pending
        effort: 2d
        depends_on: [F0-02]

    deliverables:
      - "Datasets preparados con split temporal correcto"
      - "Ultimo ano excluido para validacion OOS"

  # FASE 1: ML Training
  week_02:
    name: "ML - RangePredictor Extension"
    phase: "F1"
    tasks:
      - id: F1-01
        name: "Extender RangePredictor multi-TF"
        assignee: "ML-SPECIALIST-1"
        status: pending
        effort: 3d
        depends_on: [F0-03]

      - id: F1-02
        name: "Feature engineering multi-TF"
        assignee: "ML-SPECIALIST-1"
        status: pending
        effort: 2d
        depends_on: [F1-01]

  week_03:
    name: "ML - Training y Validacion"
    phase: "F1"
    tasks:
      - id: F1-03
        name: "Entrenar modelos walk-forward"
        assignee: "ML-SPECIALIST-1"
        status: pending
        effort: 3d
        depends_on: [F1-02]

      - id: F1-04
        name: "Optimizar hiperparametros"
        assignee: "ML-SPECIALIST-2"
        status: pending
        effort: 2d
        depends_on: [F1-03]

      - id: F1-06
        name: "Completar AMDDetector"
        assignee: "ML-SPECIALIST-2"
        status: pending
        effort: 3d
        parallel_with: [F1-03]

  week_04:
    name: "ML - TPSL y Orchestrator"
    phase: "F1"
    tasks:
      - id: F1-05
        name: "Evaluar en datos OOS"
        assignee: "ML-SPECIALIST-1"
        status: pending
        effort: 1d
        depends_on: [F1-04]

      - id: F1-09
        name: "Ajustar TPSL para 80% WR"
        assignee: "ML-SPECIALIST-1"
        status: pending
        effort: 2d
        depends_on: [F1-05]

      - id: F1-12
        name: "Implementar StrategyOrchestrator"
        assignee: "ML-SPECIALIST-2"
        status: pending
        effort: 3d
        depends_on: [F1-06]

      - id: F1-14
        name: "Backtesting completo"
        assignee: "ML-SPECIALIST-1"
        status: pending
        effort: 2d
        depends_on: [F1-09, F1-12]

    milestone:
      name: "M1: Modelos ML Validados"
      criteria:
        - "RangePredictor MAE < 0.5%"
        - "AMD Accuracy > 70%"
        - "TPSL Win Rate > 80%"
        - "OOS Performance > 60% del in-sample"

  # FASE 2: LLM Fine-tuning
  week_05:
    name: "LLM - Setup y Dataset"
    phase: "F2"
    tasks:
      - id: F2-01
        name: "Configurar Ollama en GPU"
        assignee: "DEVOPS"
        status: pending
        effort: 1d

      - id: F2-04
        name: "Definir estructura dataset"
        assignee: "ML-SPECIALIST"
        status: pending
        effort: 1d

      - id: F2-05
        name: "Crear ejemplos estrategias AMD"
        assignee: "TRADING-STRATEGIST"
        status: pending
        effort: 3d
        depends_on: [F2-04]

      - id: F2-06
        name: "Crear ejemplos estrategias ICT"
        assignee: "TRADING-STRATEGIST"
        status: pending
        effort: 3d
        parallel_with: [F2-05]

  week_06:
    name: "LLM - Dataset y Training"
    phase: "F2"
    tasks:
      - id: F2-07
        name: "Crear ejemplos analisis ML"
        assignee: "ML-SPECIALIST"
        status: pending
        effort: 2d
        depends_on: [F1-14]

      - id: F2-08
        name: "Formatear dataset JSONL"
        assignee: "ML-SPECIALIST"
        status: pending
        effort: 1d
        depends_on: [F2-05, F2-06, F2-07]

      - id: F2-09
        name: "Setup fine-tuning (unsloth)"
        assignee: "ML-SPECIALIST"
        status: pending
        effort: 1d
        depends_on: [F2-01]

      - id: F2-10
        name: "Ejecutar fine-tuning LoRA"
        assignee: "ML-SPECIALIST"
        status: pending
        effort: 2d
        depends_on: [F2-08, F2-09]

  week_07:
    name: "LLM - Evaluacion y Deploy"
    phase: "F2"
    tasks:
      - id: F2-11
        name: "Evaluar modelo fine-tuned"
        assignee: "ML-SPECIALIST"
        status: pending
        effort: 1d
        depends_on: [F2-10]

      - id: F2-12
        name: "Convertir a GGUF/Ollama"
        assignee: "ML-SPECIALIST"
        status: pending
        effort: 1d
        depends_on: [F2-11]

      - id: F2-13
        name: "Desplegar modelo"
        assignee: "DEVOPS"
        status: pending
        effort: 1d
        depends_on: [F2-12]

      - id: F2-14
        name: "Crear tools ML Engine"
        assignee: "BACKEND"
        status: pending
        effort: 2d
        depends_on: [F1-14, F2-13]

    milestone:
      name: "M2: LLM Fine-tuned Funcionando"
      criteria:
        - "Modelo fine-tuned desplegado"
        - "Decision accuracy > 75%"
        - "Integracion con ML Engine"

  # FASE 3: MCP Server
  week_08:
    name: "MCP - Core y Tools"
    phase: "F3"
    tasks:
      - id: F3-01
        name: "Disenar arquitectura MCP"
        assignee: "MCP-ARCHITECT"
        status: pending
        effort: 1d

      - id: F3-02
        name: "Implementar MCP Server core"
        assignee: "MCP-DEVELOPER"
        status: pending
        effort: 3d
        depends_on: [F3-01]

      - id: F3-03
        name: "Tools de trading"
        assignee: "MCP-DEVELOPER"
        status: pending
        effort: 2d
        depends_on: [F3-02]

      - id: F3-04
        name: "Tools de analisis"
        assignee: "MCP-DEVELOPER"
        status: pending
        effort: 2d
        parallel_with: [F3-03]

  week_09:
    name: "MCP - MT4 y Binance"
    phase: "F3"
    tasks:
      - id: F3-06
        name: "Cliente MetaAPI completo"
        assignee: "BACKEND-1"
        status: pending
        effort: 3d
        depends_on: [F3-03]

      - id: F3-07
        name: "Risk manager MT4"
        assignee: "BACKEND-1"
        status: pending
        effort: 2d
        depends_on: [F3-06]

      - id: F3-10
        name: "Cliente Binance BTC"
        assignee: "BACKEND-2"
        status: pending
        effort: 2d
        parallel_with: [F3-06]

      - id: F3-11
        name: "Adaptar modelos para BTC"
        assignee: "ML-SPECIALIST"
        status: pending
        effort: 2d
        parallel_with: [F3-10]

  week_10:
    name: "MCP - Integracion y Tests"
    phase: "F3"
    tasks:
      - id: F3-09
        name: "Tests cuenta demo MT4"
        assignee: "TESTING"
        status: pending
        effort: 2d
        depends_on: [F3-07]

      - id: F3-13
        name: "Tests Binance Testnet"
        assignee: "TESTING"
        status: pending
        effort: 2d
        depends_on: [F3-10, F3-11]

      - id: F3-14
        name: "Integrar MCP con LLM"
        assignee: "BACKEND"
        status: pending
        effort: 2d
        depends_on: [F2-14]

      - id: F3-17
        name: "Tests E2E"
        assignee: "TESTING"
        status: pending
        effort: 3d
        depends_on: [F3-09, F3-13, F3-14]

    milestone:
      name: "M3: Ejecucion Automatizada"
      criteria:
        - "MCP Server funcionando"
        - "MT4 y Binance integrados"
        - "Ejecucion success > 99%"

  # FASE 4: Visualizacion
  week_11:
    name: "UI - Charts y Overlays"
    phase: "F4"
    tasks:
      - id: F4-01
        name: "Componente Chart base"
        assignee: "FRONTEND-1"
        status: pending
        effort: 3d

      - id: F4-02
        name: "Overlay predicciones ML"
        assignee: "FRONTEND-1"
        status: pending
        effort: 2d
        depends_on: [F4-01]

      - id: F4-03
        name: "Indicador fase AMD"
        assignee: "FRONTEND-2"
        status: pending
        effort: 1d
        depends_on: [F4-01]

      - id: F4-05
        name: "Layout dashboard"
        assignee: "FRONTEND-2"
        status: pending
        effort: 2d
        parallel_with: [F4-01]

  week_12:
    name: "UI - Dashboard Completo"
    phase: "F4"
    tasks:
      - id: F4-06
        name: "Panel performance"
        assignee: "FRONTEND-1"
        status: pending
        effort: 2d
        depends_on: [F4-05]

      - id: F4-07
        name: "Historial trades"
        assignee: "FRONTEND-2"
        status: pending
        effort: 1d
        depends_on: [F4-05]

      - id: F4-09
        name: "WebSocket real-time"
        assignee: "FRONTEND-1"
        status: pending
        effort: 2d
        depends_on: [F4-06]

  week_13:
    name: "UI - Integracion Final"
    phase: "F4"
    tasks:
      - id: F4-10
        name: "API endpoints dashboard"
        assignee: "BACKEND"
        status: pending
        effort: 2d
        depends_on: [F3-17]

      - id: F4-11
        name: "WebSocket server"
        assignee: "BACKEND"
        status: pending
        effort: 2d
        depends_on: [F4-10]

      - id: F4-12
        name: "Conectar frontend"
        assignee: "FRONTEND"
        status: pending
        effort: 2d
        depends_on: [F4-09, F4-11]

      - id: F4-13
        name: "Tests UI"
        assignee: "TESTING"
        status: pending
        effort: 2d
        depends_on: [F4-12]

    milestone:
      name: "M4: MVP Completo"
      criteria:
        - "Dashboard funcionando"
        - "Visualizacion predicciones ML"
        - "Ejecucion via MCP"
        - "Objetivos de rendimiento validados"

# Milestones Resumen
milestones:
  - id: M1
    name: "Modelos ML Validados"
    week: 4
    phase: F1
    objectives: [OBJ-01, OBJ-03]

  - id: M2
    name: "LLM Fine-tuned"
    week: 7
    phase: F2
    objectives: [OBJ-04]

  - id: M3
    name: "Ejecucion Automatizada"
    week: 10
    phase: F3
    objectives: [OBJ-05]

  - id: M4
    name: "MVP Completo"
    week: 13
    phase: F4
    objectives: [OBJ-01, OBJ-02, OBJ-03, OBJ-04, OBJ-05]

# Recursos Requeridos
resources:
  teams:
    ml_team:
      members: 2
      profiles: [ML-SPECIALIST]
      phases: [F0, F1, F2]

    llm_team:
      members: 2
      profiles: [ML-SPECIALIST, BACKEND]
      phases: [F2]

    integration_team:
      members: 3
      profiles: [BACKEND, MCP-DEVELOPER]
      phases: [F3]

    frontend_team:
      members: 2
      profiles: [FRONTEND]
      phases: [F4]

    support:
      devops: 1
      testing: 1
      strategist: 1

  infrastructure:
    gpu: "NVIDIA RTX 5060 Ti (16GB VRAM)"
    servers:
      - "ML Engine Server"
      - "LLM Server (Ollama)"
      - "MCP Server"
      - "Backend API"
    databases:
      - "PostgreSQL 16"
      - "Redis"
    external:
      - "MetaAPI (MT4)"
      - "Binance API"

# Riesgos
risks:
  - id: R1
    description: "Modelos no alcanzan 80% WR"
    probability: medium
    impact: high
    mitigation: "Ajustar RR ratios, aumentar filtros de confianza"

  - id: R2
    description: "Fine-tuning LLM insuficiente"
    probability: medium
    impact: high
    mitigation: "Aumentar dataset, iterar training"

  - id: R3
    description: "Latencia de ejecucion alta"
    probability: low
    impact: high
    mitigation: "Usar MetaAPI cloud, optimizar network"

  - id: R4
    description: "GPU insuficiente"
    probability: low
    impact: medium
    mitigation: "Usar modelo mas pequeno (Mistral 7B)"
