trading-platform/orchestration/_archive/planes/PLAN-ML-LLM-TRADING.md
Adrian Flores Cortes 8293938cbe [ESTANDAR-ORCHESTRATION] refactor: Consolidate to standard structure
- Move 7 non-standard folders to _archive/
- Create 5 missing obligatory files
- Update _MAP.md with standardized structure

Standard: SIMCO-ESTANDAR-ORCHESTRATION v1.0.0
Level: CONSUMER (L2)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 14:38:26 -06:00

316 lines
13 KiB
Markdown

# Plan de Desarrollo: ML, LLM y Trading Operations
**Fecha:** 2025-12-07
**Tech Leader:** Agente Orquestador
**Estado:** En Desarrollo Paralelo
---
## Resumen Ejecutivo
Este plan coordina el desarrollo de las capacidades de Machine Learning, integración LLM local, y los agentes de trading operativos (Atlas, Orion, Nova) para Trading Platform.
### Recursos Disponibles
| Recurso | Especificación |
|---------|----------------|
| GPU | NVIDIA RTX 5060 Ti (16GB VRAM) |
| TradingAgent Original | `[LEGACY: apps/ml-engine - migrado desde TradingAgent]` |
| ML Engine Base | `apps/ml-engine/` (estructura migrada) |
| LLM Local | chatgpt-oss (a configurar en GPU) |
---
## Track 1: ML Engine - Migración Avanzada
### Objetivo
Migrar completamente los modelos del TradingAgent original al nuevo ML Engine con soporte GPU.
### Componentes a Migrar
| Componente | Origen | Destino | Estado |
|------------|--------|---------|--------|
| RangePredictor | TradingAgent/src/models/ | apps/ml-engine/src/models/ | Parcial |
| TPSLClassifier | TradingAgent/src/models/ | apps/ml-engine/src/models/ | Parcial |
| SignalGenerator | TradingAgent/src/models/ | apps/ml-engine/src/models/ | Parcial |
| AMDDetector | TradingAgent/src/models/ | apps/ml-engine/src/models/ | Pendiente |
| Phase2Pipeline | TradingAgent/src/pipelines/ | apps/ml-engine/src/pipelines/ | Pendiente |
| WalkForward | TradingAgent/src/training/ | apps/ml-engine/src/training/ | Pendiente |
| Backtesting | TradingAgent/src/backtesting/ | apps/ml-engine/src/backtesting/ | Pendiente |
| Dashboard RT | TradingAgent/src/visualization/ | apps/ml-engine/src/visualization/ | Pendiente |
### Tareas Específicas
1. **Migrar AMDDetector**
- Detector de fases Accumulation/Manipulation/Distribution
- Crítico para filtrado de señales
2. **Migrar Pipeline Phase2**
- Entrenamiento completo del sistema
- Walk-forward validation
3. **Configurar GPU Training**
- XGBoost con CUDA
- Configurar para RTX 5060 Ti
4. **Implementar API completa**
- Endpoints de señales en tiempo real
- WebSocket para streaming
5. **Integrar con datos históricos**
- 10 años de datos XAUUSD, EURUSD, GBPUSD
- Pipeline de ingesta desde MySQL
---
## Track 2: LLM Agent - Integración Local
### Objetivo
Implementar el copiloto de trading basado en LLM ejecutándose localmente en GPU.
### Arquitectura
```
┌─────────────────────────────────────────────────────────────┐
│ LLM SERVICE (Local GPU) │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ LLM Model │ │ Trading Tools │ │
│ │ (chatgpt-oss) │ │ (Functions) │ │
│ └────────┬────────┘ └────────┬────────┘ │
│ │ │ │
│ ┌────────▼────────────────────▼────────┐ │
│ │ LLM Orchestrator │ │
│ │ - Prompt Templates │ │
│ │ - Tool Calling │ │
│ │ - Context Management │ │
│ └──────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│ TRADING PLATFORM │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ ML Engine│ │ Market │ │ Portfolio│ │ Trading │ │
│ │ Signals │ │ Data │ │ State │ │ Execution│ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────────────────────┘
```
### Opciones de Modelo Local
| Modelo | VRAM Requerida | Capacidad | Recomendación |
|--------|----------------|-----------|---------------|
| Mistral 7B | ~8GB | Buena | Viable |
| Llama 3 8B | ~10GB | Muy buena | Recomendado |
| CodeLlama 7B | ~8GB | Code-focused | Alternativa |
| Phi-3 Mini | ~4GB | Compacto | Backup |
### Tareas Específicas
1. **Configurar servidor LLM local**
- Opciones: Ollama, vLLM, text-generation-webui
- Endpoint compatible OpenAI API
2. **Implementar Trading Tools**
- get_signal(symbol) → Señal ML actual
- analyze_chart(symbol, timeframe) → Análisis técnico
- check_portfolio() → Estado del portfolio
- execute_trade(params) → Ejecutar orden
- set_alert(params) → Crear alerta
3. **Prompt Engineering**
- System prompt especializado en trading
- Templates para análisis, estrategias, explicaciones
4. **Gestión de Contexto**
- Historial de conversación (Redis)
- Contexto de mercado en tiempo real
- Perfil del usuario
---
## Track 3: Trading Agents - Operaciones
### Objetivo
Implementar los agentes de trading automático (Atlas, Orion, Nova) que operan las cuentas de inversión.
### Arquitectura de Agentes
```
┌─────────────────────────────────────────────────────────────────┐
│ TRADING AGENTS SERVICE │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │
│ │ ATLAS │ │ ORION │ │ NOVA │ │
│ │ Conservador │ │ Moderado │ │ Agresivo │ │
│ │ - Grid │ │ - Trend │ │ - Momentum │ │
│ │ - Mean Rev │ │ - Breakout │ │ - Scalping │ │
│ │ - BTC/ETH │ │ - Top 10 │ │ - All Pairs │ │
│ └───────┬────────┘ └───────┬────────┘ └───────┬────────┘ │
│ │ │ │ │
│ ┌───────▼──────────────────▼──────────────────▼───────┐ │
│ │ EXECUTION ENGINE │ │
│ │ - Risk Management │ │
│ │ - Position Sizing │ │
│ │ - Order Execution (Binance API) │ │
│ │ - PnL Tracking │ │
│ └──────────────────────────────────────────────────────┘ │
│ │ │
│ ┌───────────────────────────▼──────────────────────────┐ │
│ │ SIGNAL CONSUMER │ │
│ │ - ML Engine Integration │ │
│ │ - Signal Filtering per Agent Profile │ │
│ │ - Trade Journaling │ │
│ └──────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
```
### Perfiles de Agentes
#### Atlas (Conservador)
```yaml
name: Atlas
profile: conservative
strategies:
- mean_reversion
- grid_trading
pairs:
- BTC/USDT
- ETH/USDT
risk:
max_drawdown: 5%
position_size: 2%
max_positions: 3
targets:
monthly_return: 3-5%
win_rate_min: 60%
```
#### Orion (Moderado)
```yaml
name: Orion
profile: moderate
strategies:
- trend_following
- breakout
pairs:
- BTC/USDT
- ETH/USDT
- SOL/USDT
- BNB/USDT
# + Top 10
risk:
max_drawdown: 10%
position_size: 3%
max_positions: 5
targets:
monthly_return: 5-10%
win_rate_min: 55%
```
#### Nova (Agresivo)
```yaml
name: Nova
profile: aggressive
strategies:
- momentum
- scalping
- altcoin_rotation
pairs:
- ALL available
risk:
max_drawdown: 20%
position_size: 5%
max_positions: 10
targets:
monthly_return: 10%+
win_rate_min: 50%
```
### Tareas Específicas
1. **Implementar Agent Base Class**
- Ciclo de vida del agente
- Risk management
- Position sizing
2. **Implementar Estrategias**
- MeanReversionStrategy
- GridTradingStrategy
- TrendFollowingStrategy
- BreakoutStrategy
- MomentumStrategy
- ScalpingStrategy
3. **Integración Binance**
- Paper trading (testnet)
- Real trading (mainnet)
- WebSocket feeds
4. **Sistema de Distribución**
- Cálculo de PnL
- Performance fees
- Distribución automática
---
## Dependencias entre Tracks
```
┌──────────────────────────────────────────────────────────────┐
│ DEPENDENCIAS │
├──────────────────────────────────────────────────────────────┤
│ │
│ Track 1 (ML Engine) ──────────────────┐ │
│ │ │ │
│ │ Señales │ Señales │
│ ▼ ▼ │
│ Track 2 (LLM Agent) ◄───────► Track 3 (Trading Agents) │
│ │
│ LLM interpreta Trading agents consumen │
│ señales y sugiere señales y ejecutan trades │
│ │
└──────────────────────────────────────────────────────────────┘
```
---
## Épicas Relacionadas
| Épica | Descripción | Tracks Involucrados |
|-------|-------------|---------------------|
| OQI-004 | Cuentas de Inversión | Track 3 |
| OQI-006 | Señales ML | Track 1 |
| OQI-007 | LLM Agent | Track 2 |
| OQI-008 | Portfolio Manager | Track 2, 3 |
---
## Próximos Pasos Inmediatos
### Track 1 - ML Engine
1. Migrar AMDDetector completo
2. Migrar Phase2Pipeline
3. Configurar entrenamiento GPU
4. Implementar API de señales
### Track 2 - LLM Agent
1. Configurar Ollama con Llama 3 8B
2. Crear servicio FastAPI para LLM
3. Implementar Trading Tools básicos
4. Crear prompt templates
### Track 3 - Trading Agents
1. Crear estructura base de agentes
2. Implementar Atlas (estrategia conservadora)
3. Integrar con señales ML
4. Paper trading en Binance Testnet
---
*Plan generado por Tech-Leader Agent*
*Fecha: 2025-12-07*