Changes include: - Updated architecture documentation - Enhanced module definitions (OQI-001 to OQI-008) - ML integration documentation updates - Trading strategies documentation - Orchestration and inventory updates - Docker configuration updates 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
369 lines
9.7 KiB
Markdown
369 lines
9.7 KiB
Markdown
---
|
|
id: "PLAN-LLM-TRADING-INTEGRATION-2026"
|
|
title: "Plan de Desarrollo - LLM Trading Integration 2026"
|
|
type: "Development Plan"
|
|
project: "trading-platform"
|
|
version: "1.0.0"
|
|
created_date: "2026-01-04"
|
|
updated_date: "2026-01-04"
|
|
author: "Orquestador Agent - OrbiQuant IA"
|
|
status: "Active"
|
|
---
|
|
|
|
# Plan de Desarrollo: LLM Trading Integration 2026
|
|
|
|
**Fecha:** 2026-01-04
|
|
**Epica:** OQI-010 - LLM Trading Integration
|
|
**Estado:** Planificacion Activa
|
|
**Story Points Total:** 89 SP
|
|
|
|
---
|
|
|
|
## Resumen Ejecutivo
|
|
|
|
Este plan detalla la implementacion de la integracion avanzada del LLM para trading autonomo, incluyendo fine-tuning, MCP servers, gestion de riesgo y API de predicciones.
|
|
|
|
### Hardware Disponible
|
|
|
|
| Recurso | Especificacion |
|
|
|---------|----------------|
|
|
| GPU | NVIDIA 16GB VRAM |
|
|
| Modelo Base | chatgpt-oss / Llama 3 8B |
|
|
| Quantizacion | Q5_K_M (balance calidad/VRAM) |
|
|
| Fine-tuning | LoRA (r=16, alpha=32) |
|
|
|
|
### Entregables Principales
|
|
|
|
1. **MCP Binance Connector** - Puerto 3606
|
|
2. **LLM Fine-tuned** con estrategias AMD/ICT/SMC
|
|
3. **Risk Management Service** integrado
|
|
4. **API de Predicciones** para frontend
|
|
5. **Sistema de Tracking** de predicciones
|
|
|
|
---
|
|
|
|
## Fase 1: Infraestructura (Semanas 1-2)
|
|
|
|
### Objetivo
|
|
Establecer la infraestructura base para los nuevos componentes.
|
|
|
|
### Tareas
|
|
|
|
#### 1.1 MCP Binance Connector
|
|
- [ ] Crear estructura del proyecto `apps/mcp-binance-connector/`
|
|
- [ ] Implementar tools de market data (get_ticker, get_klines, get_orderbook)
|
|
- [ ] Implementar tools de account (get_account, get_positions)
|
|
- [ ] Implementar tools de orders (create_order, cancel_order)
|
|
- [ ] Implementar tools de futures (positions, leverage)
|
|
- [ ] Configurar Docker y puerto 3606
|
|
- [ ] Tests unitarios y de integracion
|
|
|
|
**Responsable:** Backend Developer
|
|
**Story Points:** 8
|
|
|
|
#### 1.2 DDL PostgreSQL
|
|
- [ ] Crear tabla `ml.llm_predictions`
|
|
- [ ] Crear tabla `ml.prediction_outcomes`
|
|
- [ ] Crear tabla `ml.llm_decisions`
|
|
- [ ] Crear tabla `ml.risk_events`
|
|
- [ ] Crear funcion `ml.calculate_prediction_accuracy()`
|
|
- [ ] Crear indices de performance
|
|
|
|
**Responsable:** Database Developer
|
|
**Story Points:** 5
|
|
|
|
#### 1.3 Pipeline de Fine-Tuning
|
|
- [ ] Configurar ambiente de entrenamiento
|
|
- [ ] Crear script de generacion de dataset
|
|
- [ ] Implementar dataset de estrategias AMD
|
|
- [ ] Implementar dataset de conceptos ICT/SMC
|
|
- [ ] Implementar dataset de risk management
|
|
- [ ] Crear script de entrenamiento LoRA
|
|
- [ ] Crear script de merge y conversion a GGUF
|
|
|
|
**Responsable:** ML Specialist
|
|
**Story Points:** 8
|
|
|
|
### Entregables Fase 1
|
|
- MCP Binance Connector funcionando en testnet
|
|
- Tablas de PostgreSQL creadas
|
|
- Pipeline de fine-tuning configurado
|
|
|
|
---
|
|
|
|
## Fase 2: Core LLM Features (Semanas 3-5)
|
|
|
|
### Objetivo
|
|
Implementar las funcionalidades core del LLM trading agent.
|
|
|
|
### Tareas
|
|
|
|
#### 2.1 Fine-Tuning del Modelo
|
|
- [ ] Generar dataset completo (>20,000 ejemplos)
|
|
- [ ] Ejecutar entrenamiento LoRA (3 epochs)
|
|
- [ ] Evaluar modelo con dataset de validacion
|
|
- [ ] Optimizar hiperparametros si es necesario
|
|
- [ ] Convertir a GGUF y cargar en Ollama
|
|
- [ ] Validar respuestas del modelo fine-tuned
|
|
|
|
**Responsable:** ML Specialist
|
|
**Story Points:** 8
|
|
|
|
#### 2.2 Risk Management Service
|
|
- [ ] Implementar RiskManager class
|
|
- [ ] Implementar position sizing calculator
|
|
- [ ] Implementar drawdown monitor
|
|
- [ ] Implementar circuit breaker
|
|
- [ ] Implementar exposure tracker
|
|
- [ ] Integrar con LLM decision flow
|
|
- [ ] Tests unitarios
|
|
|
|
**Responsable:** Backend Developer
|
|
**Story Points:** 8
|
|
|
|
#### 2.3 ML Analyzer Service
|
|
- [ ] Implementar MLAnalyzer class
|
|
- [ ] Integracion con ML Engine (AMD, Range, ICT)
|
|
- [ ] Calculo de confluence score
|
|
- [ ] Generacion de explicaciones en lenguaje natural
|
|
- [ ] Cache de predicciones en Redis
|
|
|
|
**Responsable:** ML Specialist
|
|
**Story Points:** 5
|
|
|
|
#### 2.4 Risk Validation Pre-Trade
|
|
- [ ] Implementar validacion antes de execute_trade
|
|
- [ ] Verificar position size limits
|
|
- [ ] Verificar daily drawdown
|
|
- [ ] Verificar exposure total
|
|
- [ ] Verificar trades diarios
|
|
- [ ] Responder con razon si rechazado
|
|
|
|
**Responsable:** Backend Developer
|
|
**Story Points:** 5
|
|
|
|
### Entregables Fase 2
|
|
- Modelo LLM fine-tuned funcionando
|
|
- Risk Manager integrado
|
|
- ML Analyzer con confluence score
|
|
|
|
---
|
|
|
|
## Fase 3: API e Integracion (Semanas 6-7)
|
|
|
|
### Objetivo
|
|
Exponer APIs para frontend y completar integracion entre servicios.
|
|
|
|
### Tareas
|
|
|
|
#### 3.1 API de Predicciones REST
|
|
- [ ] Endpoint POST /api/v1/predictions/analyze
|
|
- [ ] Endpoint GET /api/v1/predictions/history/{symbol}
|
|
- [ ] Endpoint GET /api/v1/predictions/accuracy/{symbol}
|
|
- [ ] Endpoint GET /api/v1/predictions/active-signals
|
|
- [ ] Documentacion OpenAPI
|
|
|
|
**Responsable:** Backend Developer
|
|
**Story Points:** 5
|
|
|
|
#### 3.2 WebSocket Predicciones
|
|
- [ ] Implementar PredictionWebSocketManager
|
|
- [ ] Endpoint WS /ws/predictions/{symbol}
|
|
- [ ] Broadcast de predicciones cada 5s
|
|
- [ ] Manejo de conexiones/desconexiones
|
|
- [ ] Rate limiting
|
|
|
|
**Responsable:** Backend Developer
|
|
**Story Points:** 5
|
|
|
|
#### 3.3 MCP Orchestrator
|
|
- [ ] Implementar MCPOrchestrator class
|
|
- [ ] Metodo call_tool(server, tool, params)
|
|
- [ ] Metodo get_combined_portfolio()
|
|
- [ ] Metodo execute_trade_on_best_venue()
|
|
- [ ] Integracion con LLM decision flow
|
|
|
|
**Responsable:** Backend Developer
|
|
**Story Points:** 5
|
|
|
|
#### 3.4 Ejecucion de Trades MT4/Binance
|
|
- [ ] Integracion completa con MCP MT4
|
|
- [ ] Integracion completa con MCP Binance
|
|
- [ ] Seleccion automatica de venue
|
|
- [ ] Logging de trades ejecutados
|
|
- [ ] Persistencia de decisiones
|
|
|
|
**Responsable:** Backend Developer
|
|
**Story Points:** 8
|
|
|
|
### Entregables Fase 3
|
|
- API REST de predicciones funcionando
|
|
- WebSocket real-time
|
|
- Ejecucion de trades via MCP
|
|
|
|
---
|
|
|
|
## Fase 4: Tracking y Optimizacion (Semanas 8-9)
|
|
|
|
### Objetivo
|
|
Implementar tracking de outcomes y optimizar el sistema.
|
|
|
|
### Tareas
|
|
|
|
#### 4.1 Tracking de Outcomes
|
|
- [ ] Servicio de monitoreo de predicciones
|
|
- [ ] Deteccion automatica de outcomes
|
|
- [ ] Calculo de accuracy por simbolo
|
|
- [ ] Calculo de profit factor
|
|
- [ ] Persistencia en prediction_outcomes
|
|
|
|
**Responsable:** Backend Developer
|
|
**Story Points:** 5
|
|
|
|
#### 4.2 Metricas de Accuracy
|
|
- [ ] Dashboard de accuracy por modelo
|
|
- [ ] Grafico de accuracy temporal
|
|
- [ ] Filtros por simbolo/timeframe
|
|
- [ ] Export de datos
|
|
|
|
**Responsable:** Frontend Developer
|
|
**Story Points:** 5
|
|
|
|
#### 4.3 Circuit Breaker Automatico
|
|
- [ ] Deteccion de daily drawdown limit
|
|
- [ ] Deteccion de perdidas consecutivas
|
|
- [ ] Pausa automatica de trading
|
|
- [ ] Alertas a usuario
|
|
- [ ] Resume manual requerido
|
|
|
|
**Responsable:** Backend Developer
|
|
**Story Points:** 3
|
|
|
|
#### 4.4 Fine-Tuning con Datos de Produccion
|
|
- [ ] Recolectar decisiones correctas
|
|
- [ ] Generar nuevos ejemplos de training
|
|
- [ ] Re-entrenar modelo
|
|
- [ ] A/B testing de versiones
|
|
- [ ] Rollout gradual
|
|
|
|
**Responsable:** ML Specialist
|
|
**Story Points:** 8
|
|
|
|
### Entregables Fase 4
|
|
- Sistema de tracking funcionando
|
|
- Dashboard de accuracy
|
|
- Circuit breaker automatico
|
|
|
|
---
|
|
|
|
## Fase 5: Testing y Deployment (Semana 10)
|
|
|
|
### Objetivo
|
|
Validar el sistema completo y desplegar a produccion.
|
|
|
|
### Tareas
|
|
|
|
#### 5.1 Tests de Integracion
|
|
- [ ] Tests E2E del flujo completo
|
|
- [ ] Tests de MCP Binance con testnet
|
|
- [ ] Tests de risk management
|
|
- [ ] Tests de persistence
|
|
- [ ] Coverage > 70%
|
|
|
|
**Responsable:** Testing
|
|
**Story Points:** 3
|
|
|
|
#### 5.2 Backtesting de Decisiones
|
|
- [ ] Ejecutar backtesting con datos historicos
|
|
- [ ] Validar que risk limits se respetan
|
|
- [ ] Comparar accuracy real vs backtesting
|
|
- [ ] Documentar resultados
|
|
|
|
**Responsable:** ML Specialist
|
|
**Story Points:** 5
|
|
|
|
#### 5.3 Documentacion Final
|
|
- [ ] Actualizar README de cada componente
|
|
- [ ] Documentar APIs con OpenAPI
|
|
- [ ] Crear guia de operaciones
|
|
- [ ] Actualizar AGENTS.md
|
|
|
|
**Responsable:** Tech Writer
|
|
**Story Points:** 3
|
|
|
|
#### 5.4 Deployment
|
|
- [ ] Build de imagenes Docker
|
|
- [ ] Configurar docker-compose.llm-advanced.yaml
|
|
- [ ] Deploy a staging
|
|
- [ ] Smoke tests
|
|
- [ ] Deploy a produccion
|
|
- [ ] Monitoreo inicial
|
|
|
|
**Responsable:** DevOps
|
|
**Story Points:** 5
|
|
|
|
### Entregables Fase 5
|
|
- Sistema completo testeado
|
|
- Documentacion actualizada
|
|
- Deploy a produccion
|
|
|
|
---
|
|
|
|
## Resumen de Story Points por Fase
|
|
|
|
| Fase | Descripcion | SP | Duracion |
|
|
|------|-------------|-----|----------|
|
|
| Fase 1 | Infraestructura | 21 | 2 semanas |
|
|
| Fase 2 | Core LLM | 26 | 2-3 semanas |
|
|
| Fase 3 | API e Integracion | 23 | 2 semanas |
|
|
| Fase 4 | Tracking y Optimizacion | 21 | 2 semanas |
|
|
| Fase 5 | Testing y Deployment | 16 | 1 semana |
|
|
| **Total** | | **107** | **9-10 semanas** |
|
|
|
|
---
|
|
|
|
## Riesgos y Mitigaciones
|
|
|
|
| Riesgo | Probabilidad | Impacto | Mitigacion |
|
|
|--------|--------------|---------|------------|
|
|
| VRAM insuficiente | Media | Alto | LoRA + quantizacion Q5_K_M |
|
|
| Latencia alta | Media | Alto | Cache, batch processing |
|
|
| Errores del LLM | Alta | Critico | Risk limits, paper trading |
|
|
| Rate limits Binance | Media | Medio | Rate limiter, caching |
|
|
| Fine-tuning overfitting | Media | Alto | Validacion, early stopping |
|
|
|
|
---
|
|
|
|
## Metricas de Exito
|
|
|
|
| Metrica | Target | Medicion |
|
|
|---------|--------|----------|
|
|
| Direction Accuracy | >65% | Semanal |
|
|
| Response Time | <5s | Continuo |
|
|
| Risk Adherence | 100% | Continuo |
|
|
| System Uptime | >99% | Continuo |
|
|
| Fine-tuning Perplexity | <3.0 | Post-training |
|
|
|
|
---
|
|
|
|
## Siguiente Paso Inmediato
|
|
|
|
1. **Crear MCP Binance Connector** - Estructura base del proyecto
|
|
2. **Ejecutar DDL** - Crear nuevas tablas en PostgreSQL
|
|
3. **Preparar Dataset** - Iniciar recoleccion de ejemplos de training
|
|
|
|
---
|
|
|
|
## Referencias
|
|
|
|
- [Epica OQI-010](../docs/02-definicion-modulos/OQI-010-llm-trading-integration/README.md)
|
|
- [Integracion LLM Fine-Tuning](../docs/01-arquitectura/INTEGRACION-LLM-FINE-TUNING.md)
|
|
- [MCP Binance Spec](../docs/01-arquitectura/MCP-BINANCE-CONNECTOR-SPEC.md)
|
|
- [Plan ML-LLM-Trading Original](./PLAN-ML-LLM-TRADING.md)
|
|
|
|
---
|
|
|
|
**Documento Generado:** 2026-01-04
|
|
**Autor:** Orquestador Agent - OrbiQuant IA
|
|
**Version:** 1.0.0
|