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>
375 lines
16 KiB
Markdown
375 lines
16 KiB
Markdown
# FASE 4: ANALISIS DE DEPENDENCIAS DE ARCHIVOS
|
|
## Trading PlatformIA Trading Platform
|
|
|
|
**Fecha:** 2026-01-07
|
|
**Objetivo:** Mapear dependencias entre archivos a modificar para determinar orden correcto de ejecucion
|
|
**Estado:** COMPLETADO
|
|
|
|
---
|
|
|
|
## 1. GRAFO DE DEPENDENCIAS
|
|
|
|
### 1.1 Diagrama de Dependencias (ASCII)
|
|
|
|
```
|
|
NIVEL 0 - CONFIGURACION BASE (Sin dependencias)
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ docker-compose.yml │
|
|
│ ├── Define puertos, redes, volumenes │
|
|
│ └── Variables de entorno canonicas │
|
|
└────────────────────────────┬────────────────────────────────────┘
|
|
│
|
|
▼
|
|
NIVEL 1 - ARCHIVOS .ENV (Dependen de docker-compose)
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ apps/backend/.env.example │
|
|
│ apps/frontend/.env.example │
|
|
│ apps/ml-engine/.env │
|
|
│ apps/data-service/.env │
|
|
│ apps/llm-agent/.env │
|
|
│ apps/trading-agents/.env │
|
|
└────────────────────────────┬────────────────────────────────────┘
|
|
│
|
|
▼
|
|
NIVEL 2 - CONEXIONES BD (Dependen de .env)
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ apps/ml-engine/config/database.yaml │
|
|
│ apps/backend/src/shared/constants/database.constants.ts │
|
|
│ apps/data-service/src/config/database.py │
|
|
└────────────────────────────┬────────────────────────────────────┘
|
|
│
|
|
▼
|
|
NIVEL 3 - SERVICIOS DE DATOS (Dependen de BD config)
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ apps/data-service/src/services/polygon_client.py │
|
|
│ apps/data-service/src/services/asset_updater.py │
|
|
│ apps/data-service/src/services/scheduler.py │
|
|
│ apps/data-service/src/api/main.py │
|
|
└────────────────────────────┬────────────────────────────────────┘
|
|
│
|
|
▼
|
|
NIVEL 4 - ML ENGINE (Depende de Data Service)
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ apps/ml-engine/src/data/data_service_client.py │
|
|
│ apps/ml-engine/src/services/prediction_service.py │
|
|
│ apps/ml-engine/src/api/main.py │
|
|
└────────────────────────────┬────────────────────────────────────┘
|
|
│
|
|
▼
|
|
NIVEL 5 - LLM AGENT (Depende de ML Engine)
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ apps/llm-agent/src/services/ml_analyzer.py │
|
|
│ apps/llm-agent/src/services/mcp_orchestrator.py │
|
|
│ apps/llm-agent/src/api/routes.py │
|
|
└────────────────────────────┬────────────────────────────────────┘
|
|
│
|
|
▼
|
|
NIVEL 6 - BACKEND API (Depende de LLM/ML)
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ apps/backend/src/shared/clients/ml-engine.client.ts │
|
|
│ apps/backend/src/shared/clients/llm-agent.client.ts │
|
|
│ apps/backend/src/modules/ml/services/ │
|
|
│ apps/backend/src/modules/llm/services/ │
|
|
└────────────────────────────┬────────────────────────────────────┘
|
|
│
|
|
▼
|
|
NIVEL 7 - FRONTEND (Depende de Backend, ML, LLM)
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ apps/frontend/src/services/trading.service.ts │
|
|
│ apps/frontend/src/services/mlService.ts │
|
|
│ apps/frontend/src/services/llmAgentService.ts │
|
|
│ apps/frontend/src/services/websocket.service.ts │
|
|
│ apps/frontend/src/stores/ │
|
|
│ apps/frontend/src/modules/ │
|
|
└────────────────────────────┬────────────────────────────────────┘
|
|
│
|
|
▼
|
|
NIVEL 8 - DOCUMENTACION (Depende de todo lo anterior)
|
|
┌─────────────────────────────────────────────────────────────────┐
|
|
│ docs/api-contracts/openapi/*.yaml │
|
|
│ docs/api-contracts/SERVICE-INTEGRATION.md │
|
|
│ docs/00-vision-general/ARQUITECTURA-GENERAL.md │
|
|
│ docs/90-transversal/inventarios/DATABASE_INVENTORY.yml │
|
|
└─────────────────────────────────────────────────────────────────┘
|
|
```
|
|
|
|
---
|
|
|
|
## 2. MATRIZ DE DEPENDENCIAS DETALLADA
|
|
|
|
### 2.1 Nivel 0 - Configuracion Base
|
|
|
|
| Archivo | Tipo | Dependencias | Afecta A |
|
|
|---------|------|--------------|----------|
|
|
| `docker-compose.yml` | Config | NINGUNA | Todos los servicios |
|
|
|
|
**Contenido Critico:**
|
|
- Puertos de servicios
|
|
- Variables de entorno
|
|
- Redes Docker
|
|
- Volumenes persistentes
|
|
|
|
---
|
|
|
|
### 2.2 Nivel 1 - Variables de Entorno
|
|
|
|
| Archivo | Depende De | Afecta A | Variables Criticas |
|
|
|---------|------------|----------|-------------------|
|
|
| `apps/backend/.env.example` | docker-compose | Backend, DB clients | DB_HOST, DB_PORT, ML_URL, LLM_URL |
|
|
| `apps/frontend/.env.example` | docker-compose | Frontend services | VITE_API_URL, VITE_ML_URL, VITE_WS_URL |
|
|
| `apps/ml-engine/.env` | docker-compose | ML services, DB | DATABASE_URL, DATA_SERVICE_URL |
|
|
| `apps/data-service/.env` | docker-compose | Polygon client, DB | POLYGON_API_KEY, DATABASE_URL |
|
|
| `apps/llm-agent/.env` | docker-compose | ML client, MCP | ML_ENGINE_URL, MCP_MT4_URL |
|
|
| `apps/trading-agents/.env` | docker-compose | Exchange clients | BINANCE_API_KEY, ML_ENGINE_URL |
|
|
|
|
---
|
|
|
|
### 2.3 Nivel 2 - Configuracion de Base de Datos
|
|
|
|
| Archivo | Depende De | Afecta A | Config Critica |
|
|
|---------|------------|----------|----------------|
|
|
| `apps/ml-engine/config/database.yaml` | .env | Data access | host, port, database, pool |
|
|
| `apps/backend/src/shared/constants/database.constants.ts` | .env | DB queries | Schemas, table names |
|
|
| `apps/data-service/src/config/database.py` | .env | Data sync | Connection string |
|
|
|
|
---
|
|
|
|
### 2.4 Nivel 3 - Servicios de Data Service
|
|
|
|
| Archivo | Depende De | Afecta A | Funcion |
|
|
|---------|------------|----------|---------|
|
|
| `src/services/polygon_client.py` | .env (API_KEY) | asset_updater | API calls |
|
|
| `src/services/asset_updater.py` | polygon_client, DB config | scheduler | Update data |
|
|
| `src/services/scheduler.py` | asset_updater | API main | Trigger updates |
|
|
| `src/api/main.py` | Todos los services | ML Engine, Backend | Expose endpoints |
|
|
|
|
---
|
|
|
|
### 2.5 Nivel 4 - ML Engine Services
|
|
|
|
| Archivo | Depende De | Afecta A | Funcion |
|
|
|---------|------------|----------|---------|
|
|
| `src/data/data_service_client.py` | Data Service API | prediction_service | Get market data |
|
|
| `src/services/prediction_service.py` | data_client, models | api/main | Core predictions |
|
|
| `src/api/main.py` | prediction_service | LLM Agent, Backend | Expose endpoints |
|
|
|
|
---
|
|
|
|
### 2.6 Nivel 5 - LLM Agent Services
|
|
|
|
| Archivo | Depende De | Afecta A | Funcion |
|
|
|---------|------------|----------|---------|
|
|
| `src/services/ml_analyzer.py` | ML Engine API | routes | Get ML analysis |
|
|
| `src/services/mcp_orchestrator.py` | MCP connectors | routes | Execute trades |
|
|
| `src/api/routes.py` | ml_analyzer, mcp_orch | Backend, Frontend | Expose endpoints |
|
|
|
|
---
|
|
|
|
### 2.7 Nivel 6 - Backend Clients
|
|
|
|
| Archivo | Depende De | Afecta A | Funcion |
|
|
|---------|------------|----------|---------|
|
|
| `src/shared/clients/ml-engine.client.ts` | ML Engine API | modules/ml | Proxy ML |
|
|
| `src/shared/clients/llm-agent.client.ts` | LLM Agent API | modules/llm | Proxy LLM |
|
|
| `src/modules/ml/services/*` | ml-engine.client | routes | ML services |
|
|
| `src/modules/llm/services/*` | llm-agent.client | routes | LLM services |
|
|
|
|
---
|
|
|
|
### 2.8 Nivel 7 - Frontend Services
|
|
|
|
| Archivo | Depende De | Afecta A | Funcion |
|
|
|---------|------------|----------|---------|
|
|
| `src/services/trading.service.ts` | Backend API | stores, components | Market data |
|
|
| `src/services/mlService.ts` | ML Engine API | stores, components | ML signals |
|
|
| `src/services/llmAgentService.ts` | LLM Agent API | stores, components | Predictions |
|
|
| `src/services/websocket.service.ts` | WS endpoints | stores | Real-time |
|
|
| `src/stores/*.ts` | services | components | State mgmt |
|
|
| `src/modules/*` | stores | UI | Components |
|
|
|
|
---
|
|
|
|
### 2.9 Nivel 8 - Documentacion
|
|
|
|
| Archivo | Depende De | Proposito |
|
|
|---------|------------|-----------|
|
|
| `docs/api-contracts/openapi/*.yaml` | APIs finales | Documentar endpoints |
|
|
| `docs/api-contracts/SERVICE-INTEGRATION.md` | Todos los servicios | Guia integracion |
|
|
| `docs/00-vision-general/ARQUITECTURA-GENERAL.md` | Arquitectura final | Vision general |
|
|
| `docs/90-transversal/inventarios/DATABASE_INVENTORY.yml` | BD final | Inventario BD |
|
|
|
|
---
|
|
|
|
## 3. ORDEN DE MODIFICACION RECOMENDADO
|
|
|
|
### 3.1 Secuencia de Ejecucion
|
|
|
|
```
|
|
PASO 1: docker-compose.yml
|
|
└── Verificar puertos y variables canonicas
|
|
|
|
PASO 2: Todos los .env (paralelo)
|
|
├── apps/backend/.env.example
|
|
├── apps/frontend/.env.example
|
|
├── apps/ml-engine/.env
|
|
├── apps/data-service/.env
|
|
├── apps/llm-agent/.env (crear)
|
|
└── apps/trading-agents/.env (crear)
|
|
|
|
PASO 3: Config de BD (paralelo)
|
|
├── apps/ml-engine/config/database.yaml
|
|
├── apps/backend/src/shared/constants/database.constants.ts
|
|
└── apps/data-service/src/config/database.py
|
|
|
|
PASO 4: Data Service (secuencial)
|
|
├── src/services/polygon_client.py
|
|
├── src/services/asset_updater.py
|
|
├── src/services/scheduler.py
|
|
└── src/api/main.py
|
|
|
|
PASO 5: ML Engine (secuencial)
|
|
├── src/data/data_service_client.py
|
|
├── src/services/prediction_service.py
|
|
└── src/api/main.py (verificar)
|
|
|
|
PASO 6: LLM Agent (secuencial)
|
|
├── src/services/ml_analyzer.py
|
|
├── src/services/mcp_orchestrator.py
|
|
└── src/api/routes.py
|
|
|
|
PASO 7: Backend Clients (paralelo)
|
|
├── src/shared/clients/ml-engine.client.ts
|
|
├── src/shared/clients/llm-agent.client.ts
|
|
└── src/modules/*/services/*
|
|
|
|
PASO 8: Frontend Services (paralelo)
|
|
├── src/services/*.ts
|
|
├── src/stores/*.ts
|
|
└── src/modules/*
|
|
|
|
PASO 9: Documentacion (paralelo)
|
|
├── OpenAPI specs
|
|
├── SERVICE-INTEGRATION.md
|
|
├── ARQUITECTURA-GENERAL.md
|
|
└── DATABASE_INVENTORY.yml
|
|
```
|
|
|
|
---
|
|
|
|
## 4. IMPACTO DE CAMBIOS
|
|
|
|
### 4.1 Cambios de Alto Impacto (Afectan multiples archivos)
|
|
|
|
| Cambio | Archivos Afectados | Riesgo |
|
|
|--------|-------------------|--------|
|
|
| Cambiar puerto de servicio | docker-compose, .envs, services | ALTO |
|
|
| Cambiar nombre de BD | docker-compose, .envs, configs BD | ALTO |
|
|
| Cambiar URL de API | .envs, services, clients | MEDIO |
|
|
| Agregar nuevo endpoint | api/main, clients, services | BAJO |
|
|
|
|
### 4.2 Puntos de Ruptura Criticos
|
|
|
|
| Archivo | Si se modifica | Se rompe |
|
|
|---------|----------------|----------|
|
|
| `docker-compose.yml` (puertos) | SI | Todas las conexiones |
|
|
| `apps/backend/.env` (DB) | SI | Conexion a BD |
|
|
| `apps/ml-engine/src/services/prediction_service.py` | SI | Todas las predicciones |
|
|
| `apps/frontend/src/services/websocket.service.ts` | SI | Real-time updates |
|
|
|
|
---
|
|
|
|
## 5. CHECKLIST DE VALIDACION POR NIVEL
|
|
|
|
### 5.1 Nivel 0 - docker-compose.yml
|
|
- [ ] Todos los servicios definidos
|
|
- [ ] Puertos no conflictuan
|
|
- [ ] Variables de entorno completas
|
|
- [ ] Redes configuradas
|
|
- [ ] Volumenes persistentes
|
|
|
|
### 5.2 Nivel 1 - .env files
|
|
- [ ] Variables de BD consistentes
|
|
- [ ] URLs de servicios correctas
|
|
- [ ] API keys configuradas
|
|
- [ ] No hay valores hardcodeados
|
|
|
|
### 5.3 Nivel 2 - BD Config
|
|
- [ ] Pool size adecuado
|
|
- [ ] Timeout configurado
|
|
- [ ] SSL config correcta
|
|
- [ ] Schemas correctos
|
|
|
|
### 5.4 Nivel 3 - Data Service
|
|
- [ ] Polygon client funciona
|
|
- [ ] Datos se actualizan
|
|
- [ ] Scheduler ejecuta
|
|
- [ ] API responde
|
|
|
|
### 5.5 Nivel 4 - ML Engine
|
|
- [ ] Data client conecta
|
|
- [ ] Modelos cargan
|
|
- [ ] Predicciones funcionan
|
|
- [ ] API responde
|
|
|
|
### 5.6 Nivel 5 - LLM Agent
|
|
- [ ] ML client conecta
|
|
- [ ] MCP orchestrator funciona
|
|
- [ ] Routes expuestas
|
|
- [ ] API responde
|
|
|
|
### 5.7 Nivel 6 - Backend
|
|
- [ ] Clients conectan
|
|
- [ ] Services funcionan
|
|
- [ ] Routes correctas
|
|
- [ ] Auth funciona
|
|
|
|
### 5.8 Nivel 7 - Frontend
|
|
- [ ] Services conectan
|
|
- [ ] Stores actualizan
|
|
- [ ] WebSocket conecta
|
|
- [ ] UI renderiza
|
|
|
|
### 5.9 Nivel 8 - Documentacion
|
|
- [ ] OpenAPI valido
|
|
- [ ] Ejemplos correctos
|
|
- [ ] Links funcionan
|
|
- [ ] Contenido actualizado
|
|
|
|
---
|
|
|
|
## 6. ARCHIVOS QUE NO DEBEN MODIFICARSE
|
|
|
|
| Archivo | Razon |
|
|
|---------|-------|
|
|
| `apps/database/ddl/schemas/*.sql` | Ya validados, pueden romper BD |
|
|
| `apps/ml-engine/src/models/*.py` | Modelos entrenados, no tocar |
|
|
| `apps/*/node_modules/*` | Dependencias, no editar |
|
|
| `.git/*` | Control de version |
|
|
|
|
---
|
|
|
|
## 7. ESTRATEGIA DE ROLLBACK
|
|
|
|
### 7.1 Por Nivel
|
|
|
|
| Nivel | Estrategia Rollback |
|
|
|-------|---------------------|
|
|
| 0 | git checkout docker-compose.yml |
|
|
| 1 | Restaurar .env desde .env.example original |
|
|
| 2 | Restaurar config desde backup |
|
|
| 3-7 | git checkout archivos modificados |
|
|
| 8 | Regenerar docs |
|
|
|
|
### 7.2 Comando de Rollback Global
|
|
```bash
|
|
# Desde raiz del proyecto
|
|
git stash
|
|
# o
|
|
git checkout -- .
|
|
```
|
|
|
|
---
|
|
|
|
**Documento de dependencias completado**
|
|
**Siguiente fase:** FASE 5 - Refinamiento del plan
|