ML Engine Updates: - Updated BTCUSD with Polygon API data (2024-2025): 215,699 new records - Re-trained all ML models: Attention (R²: 0.223), Base, Metamodel (87.3% confidence) - Backtest results: +176.71R profit with aggressive_filter strategy Documentation Consolidation: - Created docs/99-analisis/_MAP.md index with 13 new analysis documents - Consolidated inventories: removed duplicates from orchestration/inventarios/ - Updated ML_INVENTORY.yml with BTCUSD metrics and training results - Added execution reports: FASE11-BTCUSD, correction issues, alignment validation Architecture & Integration: - Updated all module documentation with NEXUS v3.4 frontmatter - Fixed _MAP.md indexes across all folders - Updated orchestration plans and traces Files: 229 changed, 5064 insertions(+), 1872 deletions(-) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
521 lines
14 KiB
YAML
521 lines
14 KiB
YAML
# MATRIZ-DEPENDENCIAS-TRADING.yml
|
|
# Trading Platform Trading Platform
|
|
# Sistema de Dependencias del Ecosistema de Trading
|
|
# Fecha: 2025-12-12
|
|
# Version: 1.0.0
|
|
|
|
metadata:
|
|
proyecto: "Trading Platform - Trading Platform"
|
|
proposito: "Mapa completo de dependencias entre componentes del sistema de trading"
|
|
ultima_actualizacion: "2025-12-12"
|
|
autor: "Architecture-Analyst"
|
|
|
|
# ============================================
|
|
# GRAFO DE DEPENDENCIAS
|
|
# ============================================
|
|
# Direccion: componente -> depende_de
|
|
|
|
dependencias:
|
|
# -----------------------------------------
|
|
# MT4 Gateway Service (apps/mt4-gateway/)
|
|
# -----------------------------------------
|
|
mt4_gateway:
|
|
id: "SVC-MT4GW"
|
|
tipo: "Python/FastAPI"
|
|
puerto: 8090
|
|
depende_de:
|
|
internos:
|
|
- id: "SVC-ML"
|
|
nombre: "ML Engine"
|
|
tipo: "Senales de trading"
|
|
protocolo: "HTTP REST"
|
|
endpoint: "http://localhost:8000/api/v1/signals"
|
|
criticidad: "Alta"
|
|
estado: "Pendiente integrar"
|
|
|
|
- id: "SVC-DATA"
|
|
nombre: "Data Service"
|
|
tipo: "Datos de mercado"
|
|
protocolo: "HTTP REST"
|
|
endpoint: "http://localhost:8001/api/v1"
|
|
criticidad: "Media"
|
|
estado: "Referencia"
|
|
|
|
externos:
|
|
- id: "EXT-MT4-EA"
|
|
nombre: "MT4 Terminal + EA Bridge"
|
|
tipo: "Broker Connection"
|
|
protocolo: "HTTP REST"
|
|
puertos: [8081, 8082, 8083]
|
|
criticidad: "Critica"
|
|
estado: "Configurado"
|
|
|
|
- id: "EXT-BROKER"
|
|
nombre: "EBC Financial Group"
|
|
tipo: "Broker MT4"
|
|
servidor: "EBCFinancialGroupKY-Demo02"
|
|
criticidad: "Critica"
|
|
estado: "Activo"
|
|
|
|
provee_a:
|
|
- id: "SVC-BACKEND"
|
|
nombre: "Backend Express"
|
|
tipo: "Trading API"
|
|
endpoint: "/api/trading/*"
|
|
criticidad: "Alta"
|
|
estado: "Pendiente"
|
|
|
|
- id: "SVC-LLM"
|
|
nombre: "LLM Agent"
|
|
tipo: "Trade Execution"
|
|
protocolo: "HTTP REST"
|
|
criticidad: "Media"
|
|
estado: "Planificado"
|
|
|
|
# -----------------------------------------
|
|
# ML Engine (apps/ml-engine/)
|
|
# -----------------------------------------
|
|
ml_engine:
|
|
id: "SVC-ML"
|
|
tipo: "Python/FastAPI"
|
|
puerto: 8000
|
|
depende_de:
|
|
internos:
|
|
- id: "SVC-DATA"
|
|
nombre: "Data Service"
|
|
tipo: "Datos historicos"
|
|
protocolo: "HTTP REST"
|
|
criticidad: "Alta"
|
|
estado: "Activo"
|
|
|
|
- id: "DB-PG"
|
|
nombre: "PostgreSQL"
|
|
tipo: "Feature Store"
|
|
schema: "ml"
|
|
criticidad: "Alta"
|
|
estado: "Activo"
|
|
|
|
externos:
|
|
- id: "EXT-POLYGON"
|
|
nombre: "Polygon.io / Massive.com"
|
|
tipo: "Market Data API"
|
|
rate_limit: "5 req/min"
|
|
criticidad: "Alta"
|
|
estado: "Configurado"
|
|
|
|
provee_a:
|
|
- id: "SVC-MT4GW"
|
|
nombre: "MT4 Gateway"
|
|
tipo: "Trading Signals"
|
|
endpoint: "/api/v1/signals"
|
|
modelos:
|
|
- AMDDetector
|
|
- RangePredictor
|
|
- TPSLClassifier
|
|
criticidad: "Alta"
|
|
estado: "Pendiente integrar"
|
|
|
|
- id: "SVC-BACKEND"
|
|
nombre: "Backend Express"
|
|
tipo: "Predictions API"
|
|
endpoint: "/api/v1/predictions"
|
|
criticidad: "Alta"
|
|
estado: "Parcial"
|
|
|
|
- id: "SVC-LLM"
|
|
nombre: "LLM Agent"
|
|
tipo: "Analysis Data"
|
|
protocolo: "HTTP REST"
|
|
criticidad: "Media"
|
|
estado: "Planificado"
|
|
|
|
# -----------------------------------------
|
|
# Data Service (apps/data-service/)
|
|
# -----------------------------------------
|
|
data_service:
|
|
id: "SVC-DATA"
|
|
tipo: "Python/FastAPI"
|
|
puerto: 8001
|
|
depende_de:
|
|
externos:
|
|
- id: "EXT-POLYGON"
|
|
nombre: "Polygon.io / Massive.com"
|
|
tipo: "Market Data API"
|
|
api_key: "Configurado en .env"
|
|
rate_limit: "5 req/min"
|
|
criticidad: "Critica"
|
|
estado: "Verificado OK"
|
|
|
|
- id: "EXT-MT4-FEED"
|
|
nombre: "MT4 Price Feed"
|
|
tipo: "Real-time Prices"
|
|
protocolo: "EA Bridge"
|
|
criticidad: "Media"
|
|
estado: "Opcional"
|
|
|
|
internos:
|
|
- id: "DB-PG"
|
|
nombre: "PostgreSQL"
|
|
tipo: "Storage"
|
|
schemas: ["public", "market_data"]
|
|
criticidad: "Alta"
|
|
estado: "Activo"
|
|
|
|
- id: "CACHE-REDIS"
|
|
nombre: "Redis"
|
|
tipo: "Cache"
|
|
puerto: 6379
|
|
criticidad: "Media"
|
|
estado: "Activo"
|
|
|
|
provee_a:
|
|
- id: "SVC-ML"
|
|
nombre: "ML Engine"
|
|
tipo: "Historical Data"
|
|
criticidad: "Alta"
|
|
|
|
- id: "SVC-BACKEND"
|
|
nombre: "Backend Express"
|
|
tipo: "Market Data API"
|
|
criticidad: "Alta"
|
|
|
|
# -----------------------------------------
|
|
# LLM Agent (apps/llm-agent/) - PLANIFICADO
|
|
# -----------------------------------------
|
|
llm_agent:
|
|
id: "SVC-LLM"
|
|
tipo: "Python/FastAPI"
|
|
puerto: 8002
|
|
estado: "Planificado (20%)"
|
|
depende_de:
|
|
internos:
|
|
- id: "SVC-ML"
|
|
nombre: "ML Engine"
|
|
tipo: "Analysis & Signals"
|
|
criticidad: "Alta"
|
|
estado: "Planificado"
|
|
|
|
- id: "SVC-MT4GW"
|
|
nombre: "MT4 Gateway"
|
|
tipo: "Trade Execution"
|
|
criticidad: "Alta"
|
|
estado: "Planificado"
|
|
|
|
- id: "SVC-DATA"
|
|
nombre: "Data Service"
|
|
tipo: "Market Context"
|
|
criticidad: "Media"
|
|
estado: "Planificado"
|
|
|
|
externos:
|
|
- id: "EXT-CLAUDE"
|
|
nombre: "Claude API / Anthropic"
|
|
tipo: "LLM Provider"
|
|
modelo: "claude-3.5-sonnet"
|
|
criticidad: "Critica"
|
|
estado: "Planificado"
|
|
|
|
- id: "EXT-OPENAI"
|
|
nombre: "OpenAI API"
|
|
tipo: "LLM Provider (Fallback)"
|
|
modelo: "gpt-4-turbo"
|
|
criticidad: "Media"
|
|
estado: "Planificado"
|
|
|
|
provee_a:
|
|
- id: "SVC-BACKEND"
|
|
nombre: "Backend Express"
|
|
tipo: "Conversational API"
|
|
criticidad: "Alta"
|
|
|
|
# -----------------------------------------
|
|
# Backend Express (apps/backend/)
|
|
# -----------------------------------------
|
|
backend:
|
|
id: "SVC-BACKEND"
|
|
tipo: "Node.js/Express"
|
|
puerto: 3001
|
|
depende_de:
|
|
internos:
|
|
- id: "DB-PG"
|
|
nombre: "PostgreSQL"
|
|
tipo: "Primary Database"
|
|
puerto: 5432
|
|
criticidad: "Critica"
|
|
estado: "Activo"
|
|
|
|
- id: "CACHE-REDIS"
|
|
nombre: "Redis"
|
|
tipo: "Session/Cache"
|
|
puerto: 6379
|
|
criticidad: "Alta"
|
|
estado: "Activo"
|
|
|
|
- id: "SVC-ML"
|
|
nombre: "ML Engine"
|
|
tipo: "Predictions"
|
|
criticidad: "Alta"
|
|
estado: "Parcial"
|
|
|
|
- id: "SVC-DATA"
|
|
nombre: "Data Service"
|
|
tipo: "Market Data"
|
|
criticidad: "Alta"
|
|
estado: "Parcial"
|
|
|
|
- id: "SVC-MT4GW"
|
|
nombre: "MT4 Gateway"
|
|
tipo: "Trading Operations"
|
|
criticidad: "Alta"
|
|
estado: "Pendiente"
|
|
|
|
- id: "SVC-LLM"
|
|
nombre: "LLM Agent"
|
|
tipo: "AI Assistant"
|
|
criticidad: "Media"
|
|
estado: "Planificado"
|
|
|
|
externos:
|
|
- id: "EXT-STRIPE"
|
|
nombre: "Stripe"
|
|
tipo: "Payment Processing"
|
|
criticidad: "Alta"
|
|
estado: "Parcial"
|
|
|
|
provee_a:
|
|
- id: "SVC-FRONTEND"
|
|
nombre: "Frontend React"
|
|
tipo: "REST API"
|
|
criticidad: "Critica"
|
|
|
|
# -----------------------------------------
|
|
# Frontend React (apps/frontend/)
|
|
# -----------------------------------------
|
|
frontend:
|
|
id: "SVC-FRONTEND"
|
|
tipo: "React/Vite"
|
|
puerto: 5173
|
|
depende_de:
|
|
internos:
|
|
- id: "SVC-BACKEND"
|
|
nombre: "Backend Express"
|
|
tipo: "API Gateway"
|
|
criticidad: "Critica"
|
|
estado: "Activo"
|
|
|
|
provee_a:
|
|
- id: "USER"
|
|
nombre: "End Users"
|
|
tipo: "Web Application"
|
|
|
|
# ============================================
|
|
# MATRIZ DE IMPACTO
|
|
# ============================================
|
|
# Si X falla, que sistemas se ven afectados
|
|
|
|
matriz_impacto:
|
|
# Si PostgreSQL falla
|
|
postgresql_down:
|
|
afectados:
|
|
- servicio: "Backend Express"
|
|
impacto: "Critico - Sin acceso a datos"
|
|
- servicio: "ML Engine"
|
|
impacto: "Alto - Sin feature store"
|
|
- servicio: "Data Service"
|
|
impacto: "Alto - Sin storage persistente"
|
|
mitigacion: "Implementar cache en Redis para operaciones criticas"
|
|
|
|
# Si Polygon API falla o rate limit
|
|
polygon_unavailable:
|
|
afectados:
|
|
- servicio: "Data Service"
|
|
impacto: "Alto - Sin datos nuevos"
|
|
- servicio: "ML Engine"
|
|
impacto: "Medio - Usa datos en cache"
|
|
mitigacion: "Fallback a MT4 price feed via EA Bridge"
|
|
|
|
# Si MT4 Terminal desconectado
|
|
mt4_disconnected:
|
|
afectados:
|
|
- servicio: "MT4 Gateway"
|
|
impacto: "Critico - Sin ejecucion de trades"
|
|
- servicio: "LLM Agent"
|
|
impacto: "Alto - No puede operar"
|
|
mitigacion: "Alertas inmediatas, cola de ordenes pendientes"
|
|
|
|
# Si ML Engine falla
|
|
ml_engine_down:
|
|
afectados:
|
|
- servicio: "MT4 Gateway"
|
|
impacto: "Alto - Sin senales automaticas"
|
|
- servicio: "LLM Agent"
|
|
impacto: "Medio - Sin analisis ML"
|
|
- servicio: "Backend"
|
|
impacto: "Medio - Sin predicciones"
|
|
mitigacion: "Operacion manual via dashboard, senales manuales"
|
|
|
|
# Si Redis falla
|
|
redis_down:
|
|
afectados:
|
|
- servicio: "Backend Express"
|
|
impacto: "Medio - Sesiones afectadas"
|
|
- servicio: "Data Service"
|
|
impacto: "Bajo - Sin cache rapido"
|
|
mitigacion: "Fallback a DB para sesiones"
|
|
|
|
# ============================================
|
|
# FLUJOS DE DATOS CRITICOS
|
|
# ============================================
|
|
flujos_criticos:
|
|
# Flujo 1: Senal ML -> Trade Execution
|
|
senal_a_trade:
|
|
descripcion: "Flujo desde deteccion ML hasta ejecucion en MT4"
|
|
pasos:
|
|
- origen: "Data Service"
|
|
destino: "ML Engine"
|
|
datos: "OHLCV historico + Spread"
|
|
protocolo: "HTTP REST"
|
|
|
|
- origen: "ML Engine"
|
|
destino: "MT4 Gateway"
|
|
datos: "Signal {symbol, direction, confidence, tpsl}"
|
|
protocolo: "HTTP REST / WebSocket (futuro)"
|
|
|
|
- origen: "MT4 Gateway"
|
|
destino: "MT4 Terminal"
|
|
datos: "TradeRequest {symbol, action, lots, sl, tp}"
|
|
protocolo: "HTTP (EA Bridge)"
|
|
|
|
- origen: "MT4 Terminal"
|
|
destino: "Broker (EBC)"
|
|
datos: "Order Execution"
|
|
protocolo: "MT4 Protocol"
|
|
|
|
latencia_objetivo: "<2 segundos end-to-end"
|
|
criticidad: "Critica"
|
|
|
|
# Flujo 2: LLM Analysis -> Decision
|
|
llm_analysis:
|
|
descripcion: "Flujo de analisis LLM para decision de trading"
|
|
pasos:
|
|
- origen: "User/Scheduler"
|
|
destino: "LLM Agent"
|
|
datos: "Analysis Request"
|
|
|
|
- origen: "LLM Agent"
|
|
destino: "ML Engine"
|
|
datos: "Get Current Predictions"
|
|
|
|
- origen: "LLM Agent"
|
|
destino: "Data Service"
|
|
datos: "Get Market Context"
|
|
|
|
- origen: "LLM Agent"
|
|
destino: "Claude API"
|
|
datos: "Prompt + Context"
|
|
|
|
- origen: "LLM Agent"
|
|
destino: "MT4 Gateway"
|
|
datos: "Trade Decision (if approved)"
|
|
|
|
criticidad: "Alta"
|
|
|
|
# Flujo 3: Dashboard Update
|
|
dashboard_update:
|
|
descripcion: "Flujo de actualizacion del dashboard admin"
|
|
pasos:
|
|
- origen: "Frontend"
|
|
destino: "Backend"
|
|
datos: "GET /api/trading/summary"
|
|
|
|
- origen: "Backend"
|
|
destino: "MT4 Gateway"
|
|
datos: "GET /api/agents/summary"
|
|
|
|
- origen: "Backend"
|
|
destino: "ML Engine"
|
|
datos: "GET /api/v1/predictions/latest"
|
|
|
|
- origen: "Backend"
|
|
destino: "Frontend"
|
|
datos: "Consolidated Dashboard Data"
|
|
|
|
frecuencia: "Cada 5 segundos"
|
|
criticidad: "Media"
|
|
|
|
# ============================================
|
|
# CONFIGURACION DE PUERTOS (CONSOLIDADO)
|
|
# ============================================
|
|
puertos:
|
|
servicios_core:
|
|
- puerto: 3001
|
|
servicio: "Backend Express"
|
|
tipo: "Node.js"
|
|
|
|
- puerto: 5173
|
|
servicio: "Frontend React"
|
|
tipo: "Vite Dev Server"
|
|
|
|
servicios_python:
|
|
- puerto: 8000
|
|
servicio: "ML Engine"
|
|
tipo: "FastAPI"
|
|
|
|
- puerto: 8001
|
|
servicio: "Data Service"
|
|
tipo: "FastAPI"
|
|
|
|
- puerto: 8002
|
|
servicio: "LLM Agent"
|
|
tipo: "FastAPI"
|
|
|
|
- puerto: 8090
|
|
servicio: "MT4 Gateway"
|
|
tipo: "FastAPI"
|
|
|
|
agentes_mt4:
|
|
- puerto: 8081
|
|
servicio: "MT4 Agent 1 (Atlas)"
|
|
tipo: "EA Bridge"
|
|
|
|
- puerto: 8082
|
|
servicio: "MT4 Agent 2 (Orion)"
|
|
tipo: "EA Bridge"
|
|
|
|
- puerto: 8083
|
|
servicio: "MT4 Agent 3 (Nova)"
|
|
tipo: "EA Bridge"
|
|
|
|
infraestructura:
|
|
- puerto: 5432
|
|
servicio: "PostgreSQL"
|
|
tipo: "Database"
|
|
|
|
- puerto: 6379
|
|
servicio: "Redis"
|
|
tipo: "Cache"
|
|
|
|
# ============================================
|
|
# REFERENCIAS
|
|
# ============================================
|
|
referencias:
|
|
- documento: "MASTER_INVENTORY.yml"
|
|
path: "orchestration/inventarios/MASTER_INVENTORY.yml"
|
|
tipo: "Inventario principal"
|
|
|
|
- documento: "MT4_GATEWAY_INVENTORY.yml"
|
|
path: "docs/90-transversal/inventarios/MT4_GATEWAY_INVENTORY.yml"
|
|
tipo: "Inventario MT4 Gateway"
|
|
|
|
- documento: "INT-MT4-001-gateway-service.md"
|
|
path: "docs/90-transversal/integraciones/INT-MT4-001-gateway-service.md"
|
|
tipo: "Documento de integracion"
|
|
|
|
- documento: "ARQUITECTURA-MULTI-AGENTE-MT4.md"
|
|
path: "docs/01-arquitectura/ARQUITECTURA-MULTI-AGENTE-MT4.md"
|
|
tipo: "Arquitectura"
|
|
|
|
- documento: "ADR-002-MVP-OPERATIVO-TRADING.md"
|
|
path: "docs/97-adr/ADR-002-MVP-OPERATIVO-TRADING.md"
|
|
tipo: "Decision de arquitectura"
|