trading-platform/docs/02-definicion-modulos/_MAP.md
Adrian Flores Cortes df43dd90cb [F0-F2] feat: Coherence analysis baseline + entity types + frontend stores
FASE 0 - Preparación y Purga:
- Archived 21 completed tasks to _archive/2026-01/
- Marked 4 docs as DEPRECATED
- Created 3 baseline coherence reports

FASE 1 - DDL-Backend Coherence:
- audit.types.ts: +4 types (SystemEvent, TradingAudit, ApiRequestLog, DataAccessLog)
- investment.types.ts: +4 types (RiskQuestionnaire, WithdrawalRequest, DailyPerformance, DistributionHistory)
- entity.types.ts: +5 types (Symbol, TradingBot, TradingSignal, TradingMetrics, PaperBalance)

FASE 2 - Backend-Frontend Coherence:
- investmentStore.ts: New Zustand store with 20+ actions
- mlStore.ts: New Zustand store with signal caching
- alerts.service.ts: New service with 15 functions

FASE 3 - Documentation:
- OQI-009: Updated to 100% coverage, added ET-MKT-004-productos.md
- OQI-010: Created full structure (STATUS.md, ROADMAP-MT4.md, ET-MT4-001-gateway.md)

Coherence Baseline Established:
- DDL-Backend: 31% (target 95%)
- Backend-Frontend: 72% (target 85%)
- Global: 39.6% (target 90%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 22:08:04 -06:00

556 lines
17 KiB
Markdown

---
id: "MAP-02-definicion-modulos"
title: "Mapa de 02-definicion-modulos"
type: "Index"
project: "trading-platform"
updated_date: "2026-01-28"
---
# _MAP: Definicion de Modulos - Trading Platform
**Ultima actualizacion:** 2026-01-28
**Estado:** En Desarrollo
**Version:** 2.1.0
**Total Epicas:** 11 (8 core + 3 expansion)
**Total Story Points:** ~551 SP (estimado)
---
## Proposito
Este directorio contiene la documentacion completa de todas las epicas del proyecto Trading Platform, organizadas en dos fases:
### Fase 1 - MVP (6 Epicas, 287 SP)
- Sistema de autenticacion multi-proveedor
- Modulo educativo basico
- Plataforma de trading con charts y ML overlay
- Sistema de cuentas de inversion con agentes IA
- Integracion de pagos con Stripe
- Senales ML del TradingAgent existente
### Fase 2 - Avanzado (2 Epicas, 120 SP)
- LLM Strategy Agent (Copiloto de trading con IA)
- Portfolio Manager (Gestion de carteras a largo plazo)
---
## Configuracion SaaS Multi-tenant
| Feature | Free | Basic | Pro | Premium |
|---------|------|-------|-----|---------|
| Autenticacion | ✅ | ✅ | ✅ | ✅ |
| Cursos basicos | ✅ | ✅ | ✅ | ✅ |
| Cursos avanzados | ❌ | ✅ | ✅ | ✅ |
| Paper trading | ✅ | ✅ | ✅ | ✅ |
| Trading real | ❌ | ✅ | ✅ | ✅ |
| Senales ML | 3/dia | 10/dia | Ilimitado | Ilimitado |
| Agentes IA | ❌ | 1 (Atlas) | 3 | 3 |
| **LLM Copiloto** | ❌ | ❌ | ✅ | ✅ |
| **Portfolio Manager** | ❌ | ❌ | ❌ | ✅ |
| **API Access** | ❌ | ❌ | ❌ | ✅ |
| Soporte | Community | Email | Prioritario | Dedicado |
| **Precio** | $0/mes | $19/mes | $49/mes | $99/mes |
---
## Contenido
### Fase 1 - MVP (6 Epicas)
| Codigo | Nombre | SP | Presupuesto | Estado | Prioridad |
|--------|--------|-----|-------------|--------|-----------|
| [OQI-001](./OQI-001-fundamentos-auth/) | Fundamentos y Auth | 50 | $25,000 | ✅ Completado | P0 |
| [OQI-002](./OQI-002-education/) | Modulo Educativo | 45 | $22,500 | Pendiente | P1 |
| [OQI-003](./OQI-003-trading-charts/) | Trading y Charts | 55 | $27,500 | Pendiente | P1 |
| [OQI-004](./OQI-004-investment-accounts/) | Cuentas de Inversion | 57 | $28,500 | Pendiente | P1 |
| [OQI-005](./OQI-005-payments-stripe/) | Pagos y Stripe | 40 | $25,000 | Pendiente | P0 |
| [OQI-006](./OQI-006-ml-signals/) | Senales ML | 40 | $25,000 | Pendiente | P2 |
**Subtotal Fase 1:** 287 SP | $153,500 MXN
### Fase 2 - Avanzado (2 Epicas)
| Codigo | Nombre | SP | Presupuesto | Estado | Prioridad |
|--------|--------|-----|-------------|--------|-----------|
| [OQI-007](./OQI-007-llm-agent/) | LLM Strategy Agent | 55 | $27,500 | Planificado | P1 |
| [OQI-008](./OQI-008-portfolio-manager/) | Portfolio Manager | 65 | $32,500 | Planificado | P1 |
**Subtotal Fase 2:** 120 SP | $60,000 MXN
### Fase 3 - Expansion (Incubacion)
| Codigo | Nombre | SP | Presupuesto | Estado | Prioridad |
|--------|--------|-----|-------------|--------|-----------|
| [OQI-009](./OQI-009-marketplace/) | Marketplace | TBD | TBD | Planificado | P3 |
| [OQI-010](./OQI-010-mt4-gateway/) | MT4 Gateway | 55 | $27,500 | NO FUNCIONAL (15%) | P2 |
| [OQI-010-llm](./OQI-010-llm-trading-integration/) | LLM Trading Integration | 89 | $44,500 | Planning | P0 |
**Nota:** OQI-010-mt4-gateway esta actualmente NO FUNCIONAL. Ver documentacion de estado.
**Subtotal Fase 3:** ~144 SP | ~$72,000 MXN (estimado)
---
**TOTAL PROYECTO:** ~551 SP | ~$285,500 MXN (incluyendo Fase 3)
---
## Desglose por Epica
### OQI-001: Fundamentos y Autenticacion
**Objetivo:** Infraestructura base con autenticacion multi-proveedor completa.
**Entregables:**
- Autenticacion OAuth (Google, Facebook, X, Apple, GitHub)
- Autenticacion email/password con verificacion
- Autenticacion por telefono (SMS/WhatsApp)
- JWT con refresh tokens
- 2FA (TOTP + backup codes)
- RBAC (roles y permisos)
- Gestion de sesiones
**Documentos clave:**
- Requerimientos: RF-AUTH-001 a RF-AUTH-005
- Especificaciones: ET-AUTH-001 a ET-AUTH-005
- User Stories: US-AUTH-001 a US-AUTH-012
**Modulos afectados:**
- BD: `public` schema (users, profiles, oauth_accounts, sessions)
- Backend: `auth` module
- Frontend: `auth` feature
**Estado:** ✅ Completado (50 SP)
---
### OQI-002: Modulo Educativo
**Objetivo:** Plataforma de cursos con contenido estructurado y progreso.
**Entregables:**
- Catalogo de cursos con categorias
- Sistema de lecciones (video, texto, quiz)
- Progreso y completitud
- Certificaciones basicas
- Gamificacion (XP, badges)
**Documentos clave:**
- Requerimientos: RF-EDU-001 a RF-EDU-006
- Especificaciones: ET-EDU-001 a ET-EDU-006
- User Stories: US-EDU-001 a US-EDU-015
**Modulos afectados:**
- BD: `education` schema
- Backend: `education` module
- Frontend: `education` feature
**Reutilizacion Gamilit:** 70% (estructura de cursos, progreso, gamificacion)
**Estado:** Pendiente (45 SP)
---
### OQI-003: Trading y Charts
**Objetivo:** Plataforma de trading con charts profesionales y watchlists.
**Entregables:**
- Charts con Lightweight Charts
- Timeframes multiples (1m, 5m, 15m, 1h, 4h, 1D)
- Indicadores tecnicos basicos
- Watchlists personalizables
- Paper trading (simulacion)
- Historial de operaciones
**Documentos clave:**
- Requerimientos: RF-TRD-001 a RF-TRD-008
- Especificaciones: ET-TRD-001 a ET-TRD-008
- User Stories: US-TRD-001 a US-TRD-018
**Modulos afectados:**
- BD: `trading` schema
- Backend: `trading` module
- Frontend: `trading` feature
- ML Engine: data feeds
**Reutilizacion TradingAgent:** 40% (conectores de datos)
**Estado:** Pendiente (55 SP)
---
### OQI-004: Cuentas de Inversion
**Objetivo:** Sistema de cuentas gestionadas por agentes IA.
**Entregables:**
- 3 productos de inversion (Atlas, Orion, Nova)
- Apertura de cuentas con KYC basico
- Dashboard de portfolio
- Historial de transacciones
- Reportes de rendimiento
- Distribucion de utilidades
**Documentos clave:**
- Requerimientos: RF-INV-001 a RF-INV-007
- Especificaciones: ET-INV-001 a ET-INV-007
- User Stories: US-INV-001 a US-INV-014
**Modulos afectados:**
- BD: `investment` schema
- Backend: `investment` module
- Frontend: `investment` feature
- ML Engine: agentes de trading
**Estado:** Pendiente (50 SP)
---
### OQI-005: Pagos y Stripe
**Objetivo:** Sistema de pagos completo con Stripe.
**Entregables:**
- Suscripciones (Free, Basic, Pro)
- Checkout con Stripe Elements
- Wallet interno
- Depositos y retiros
- Facturacion automatica
- Webhooks de eventos
**Documentos clave:**
- Requerimientos: RF-PAY-001 a RF-PAY-006
- Especificaciones: ET-PAY-001 a ET-PAY-006
- User Stories: US-PAY-001 a US-PAY-012
**Modulos afectados:**
- BD: `financial` schema
- Backend: `payments` module
- Frontend: billing components
**Estado:** Pendiente (40 SP)
---
### OQI-006: Senales ML
**Objetivo:** Sistema de predicciones y senales de trading.
**Entregables:**
- RangePredictor (prediccion ΔHigh/ΔLow)
- TPSLClassifier (clasificacion TP vs SL)
- SignalGenerator (senales de entrada)
- Feature store
- API de predicciones
- Notificaciones de senales
**Documentos clave:**
- Requerimientos: RF-ML-001 a RF-ML-005
- Especificaciones: ET-ML-001 a ET-ML-005
- User Stories: US-ML-001 a US-ML-010
**Modulos afectados:**
- BD: `ml` schema
- Backend: `signals` module
- ML Engine: modelos completos
- Frontend: signal alerts
**Reutilizacion TradingAgent:** 80% (modelos, features, training)
**Estado:** Pendiente (40 SP)
---
### OQI-007: LLM Strategy Agent (Fase 2)
**Objetivo:** Copiloto de trading conversacional potenciado por LLM.
**Entregables:**
- Chat conversacional con contexto persistente
- Interpretacion de senales ML en lenguaje natural
- Sugerencias de estrategias personalizadas
- Modo proactivo con alertas inteligentes
- Ejecucion de ordenes via comandos naturales
- Historial de conversaciones
**Documentos clave:**
- Requerimientos: RF-LLM-001 a RF-LLM-006
- Especificaciones: ET-LLM-001 a ET-LLM-006
- User Stories: US-LLM-001 a US-LLM-010
**Modulos afectados:**
- BD: `llm` schema (conversations, messages, executions)
- Backend: `llm-agent` module
- Frontend: `copilot` feature (chat widget)
- Integracion: Claude API / OpenAI API
**Herramientas del Agente:**
- `get_signal`: Obtener senal ML actual
- `analyze_chart`: Analizar grafico con indicadores
- `get_portfolio`: Estado actual del portfolio
- `execute_trade`: Ejecutar orden de trading
- `set_alert`: Configurar alerta personalizada
- `explain_decision`: Explicar decision de agente
**Estado:** Planificado (55 SP)
---
### OQI-008: Portfolio Manager (Fase 2)
**Objetivo:** Sistema profesional de gestion de carteras a largo plazo.
**Entregables:**
- Cuestionario de perfil de riesgo
- 5 perfiles predefinidos (Ultra Conservador a Ultra Agresivo)
- Asignacion automatica entre agentes (Atlas/Orion/Nova)
- Rebalanceo automatico por drift, calendario o eventos
- Distribucion de rendimientos (80% reinversion / 20% usuario)
- Proyecciones Monte Carlo
- Metas de inversion con tracking
- Reportes fiscales y exportacion
**Documentos clave:**
- Requerimientos: RF-PFM-001 a RF-PFM-007
- Especificaciones: ET-PFM-001 a ET-PFM-007
- User Stories: US-PFM-001 a US-PFM-012
**Modulos afectados:**
- BD: `portfolio` schema
- Backend: `portfolio` module
- Frontend: `portfolio` feature
- Calculos: Python (NumPy, SciPy) para Monte Carlo
- Jobs: Bull Queue para rebalanceo y distribuciones
**Metricas del Portfolio:**
- TWR (Time-Weighted Return)
- MWR (Money-Weighted Return)
- Sharpe Ratio, Sortino Ratio
- Maximum Drawdown, VaR
**Estado:** Planificado (65 SP)
---
### OQI-009: Marketplace
**Objetivo:** Plataforma de mercado para estrategias y senales de trading.
**Estado:** Planificado - Documentacion pendiente
---
### OQI-010: MT4 Gateway Integration
> **ESTADO: NO FUNCIONAL (15%)**
**Objetivo:** Integracion con MetaTrader 4 para trading automatizado en forex/CFDs.
**Entregables:**
- MCP MT4 Connector (herramientas MCP)
- MT4 Gateway Service (puente HTTP)
- Expert Advisor MQL4 (ejecucion en MT4)
- Paper trading mode
- Risk management integrado
**Documentos clave:**
- [README.md](./OQI-010-mt4-gateway/README.md) - Vision general
- [STATUS.md](./OQI-010-mt4-gateway/STATUS.md) - Estado y bloqueos
- [ROADMAP-MT4.md](./OQI-010-mt4-gateway/ROADMAP-MT4.md) - Plan de implementacion
- [ET-MT4-001-gateway.md](./OQI-010-mt4-gateway/especificaciones/ET-MT4-001-gateway.md) - Spec tecnica
**Modulos afectados:**
- MCP: `mcp-mt4-connector/` (parcial)
- Gateway: No existe
- EA: No existe
**Bloqueos actuales:**
1. MT4 Gateway Service no implementado
2. Expert Advisor MQL4 no desarrollado
3. Ambiente de desarrollo pendiente
**Estado:** NO FUNCIONAL (15% - solo skeleton MCP)
---
### OQI-010-LLM: LLM Trading Integration
**Objetivo:** Integracion avanzada del LLM con fine-tuning para trading autonomo.
**Estado:** Planning (89 SP estimado)
Ver: [OQI-010-llm-trading-integration/README.md](./OQI-010-llm-trading-integration/README.md)
---
## Resumen Tecnico
### Base de Datos
| Schema | Tablas | ENUMs | Functions | Triggers |
|--------|--------|-------|-----------|----------|
| public | 10 | 5 | 2 | 6 |
| education | 11 | 4 | 1 | 5 |
| trading | 10 | 6 | 2 | 5 |
| investment | 8 | 4 | 3 | 4 |
| financial | 10 | 5 | 4 | 5 |
| ml | 8 | 3 | 2 | 3 |
| **llm** | 5 | 2 | 1 | 2 |
| **portfolio** | 8 | 4 | 3 | 4 |
| audit | 7 | 3 | 1 | 2 |
### Backend (Express.js + TypeScript)
| Modulo | Controllers | Services | Endpoints |
|--------|-------------|----------|-----------|
| auth | 1 | 5 | 25 |
| education | 3 | 4 | 18 |
| trading | 2 | 3 | 15 |
| investment | 2 | 3 | 12 |
| payments | 2 | 2 | 10 |
| **llm-agent** | 1 | 3 | 8 |
| **portfolio** | 2 | 4 | 15 |
| admin | 3 | 3 | 20 |
### Frontend (React + TypeScript)
| Feature | Pages | Components | Stores |
|---------|-------|------------|--------|
| auth | 6 | 8 | 1 |
| education | 4 | 12 | 2 |
| trading | 3 | 15 | 2 |
| investment | 3 | 10 | 1 |
| **copilot** | 1 | 8 | 1 |
| **portfolio** | 3 | 12 | 2 |
| settings | 1 | 8 | 1 |
| dashboard | 1 | 6 | 1 |
### ML Engine (Python + FastAPI)
| Modelo | Algoritmo | Features | Accuracy |
|--------|-----------|----------|----------|
| RangePredictor | XGBoost GPU | 21 | 85.9% |
| TPSLClassifier | XGBoost GPU | 15 | 94% AUC |
| AMDDetector | GRU Attention | 30 | 78% |
| SignalGenerator | Ensemble 3-Level | 21 | 75% |
### LLM Integration
| Componente | Tecnologia | Proposito |
|------------|------------|-----------|
| Provider | Claude API / OpenAI | LLM base |
| Tools | Function Calling | Acciones del agente |
| Context | Vector DB (futuro) | Memoria persistente |
| Safety | Guardrails | Validacion de ordenes |
---
## Metricas del Proyecto
| Metrica | Target | Actual |
|---------|--------|--------|
| Story Points Total | 407 | 50 (12%) |
| Presupuesto Total | $213,500 | $25,000 (12%) |
| Epicas completadas | 8 | 1 (12.5%) |
| Cobertura de tests | 80% | TBD |
| Documentacion | 100% | 95% |
---
## Hitos Planeados
### Fase 1 - MVP
| Sprint | Hito | Epicas |
|--------|------|--------|
| 1-2 | Auth completado | OQI-001 ✅ |
| 3-4 | Education + Trading | OQI-002, OQI-003 |
| 5-6 | Investment + Payments | OQI-004, OQI-005 |
| 7-8 | ML + Integration | OQI-006, Testing |
### Fase 2 - Avanzado
| Sprint | Hito | Epicas |
|--------|------|--------|
| 9-10 | LLM Agent Beta | OQI-007 |
| 11-12 | Portfolio Manager | OQI-008 |
| 13 | Integration + Testing | Full System |
---
## Dependencias
```
FASE 1 - MVP
┌─────────────────────────────────────────────────────────────────┐
│ │
│ OQI-001 (Auth) ─────────────────────────────────┐ │
│ │ │
│ OQI-005 (Payments) ─────────────────────────────┼──▶ MVP │
│ │ │
│ OQI-002 (Education) ────▶ OQI-003 (Trading) ────┤ │
│ │ │
│ OQI-004 (Investment) ◀── OQI-006 (ML Signals) ──┘ │
│ │
└────────────────────────────┬────────────────────────────────────┘
FASE 2 - AVANZADO
┌─────────────────────────────────────────────────────────────────┐
│ │
│ OQI-006 (ML) ──────────▶ OQI-007 (LLM Agent) ───┐ │
│ │ │
│ OQI-004 (Investment) ──▶ OQI-008 (Portfolio) ───┼──▶ FULL │
│ │ │
│ OQI-005 (Payments) ─────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
```
---
## Criterios de Aceptacion
### Fase 1 - MVP
- [ ] Todos los usuarios pueden registrarse con al menos 3 metodos
- [ ] Al menos 5 cursos publicados con quizzes
- [ ] Charts funcionales con 3 timeframes y ML overlay
- [ ] 3 productos de inversion disponibles (Atlas, Orion, Nova)
- [ ] Pagos con tarjeta funcionando
- [ ] Senales ML generandose cada hora
- [ ] Tests con >70% cobertura
### Fase 2 - Avanzado
- [ ] LLM Copiloto respondiendo con contexto
- [ ] Ejecucion de ordenes via chat
- [ ] Cuestionario de perfil de riesgo
- [ ] Rebalanceo automatico funcionando
- [ ] Distribuciones de rendimientos procesadas
- [ ] Proyecciones Monte Carlo precisas
- [ ] Tests con >80% cobertura
---
## Arquitectura y Documentacion Clave
| Documento | Ubicacion |
|-----------|-----------|
| Arquitectura Unificada | `docs/01-arquitectura/ARQUITECTURA-UNIFICADA.md` |
| Integracion TradingAgent | `docs/01-arquitectura/INTEGRACION-TRADINGAGENT.md` |
| Contexto del Proyecto | `orchestration/00-guidelines/CONTEXTO-PROYECTO.md` |
| TradingAgent Original | `[LEGACY: apps/ml-engine - migrado desde TradingAgent]/` |
---
## Referencias
- [README Principal](../README.md)
- [Vision General](../00-vision-general/_MAP.md)
- [ADRs](../97-adr/)
- [Guias de Desarrollo](../95-guias-desarrollo/)
- [Arquitectura Unificada](../01-arquitectura/ARQUITECTURA-UNIFICADA.md)
- [Integracion TradingAgent](../01-arquitectura/INTEGRACION-TRADINGAGENT.md)