- Configure workspace Git repository with comprehensive .gitignore - Add Odoo as submodule for ERP reference code - Include documentation: SETUP.md, GIT-STRUCTURE.md - Add gitignore templates for projects (backend, frontend, database) - Structure supports independent repos per project/subproject level Workspace includes: - core/ - Reusable patterns, modules, orchestration system - projects/ - Active projects (erp-suite, gamilit, trading-platform, etc.) - knowledge-base/ - Reference code and patterns (includes Odoo submodule) - devtools/ - Development tools and templates - customers/ - Client implementations template 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
310 lines
7.7 KiB
Markdown
310 lines
7.7 KiB
Markdown
# Resumen de Configuración Python - OrbiQuant IA Trading Platform
|
|
|
|
**Fecha**: 2025-12-05
|
|
**Agente**: Python Agent
|
|
**Estado**: Completado ✓
|
|
|
|
## Tarea Completada
|
|
|
|
Se ha configurado el entorno de desarrollo Python con Miniconda para todos los servicios ML/AI del proyecto OrbiQuant IA Trading Platform.
|
|
|
|
## Servicios Configurados
|
|
|
|
### 1. Data Service (`apps/data-service/`)
|
|
- **Propósito**: Sincronización de datos de mercado
|
|
- **Puerto**: 8001
|
|
- **Environment**: `orbiquant-data-service`
|
|
- **Stack**:
|
|
- Python 3.11+
|
|
- aiohttp (HTTP async)
|
|
- asyncpg (PostgreSQL async)
|
|
- APScheduler (jobs programados)
|
|
- websockets (tiempo real)
|
|
|
|
### 2. ML Engine (`apps/ml-engine/`)
|
|
- **Propósito**: Modelos de predicción y análisis
|
|
- **Puerto**: 8002
|
|
- **Environment**: `orbiquant-ml-engine`
|
|
- **Stack**:
|
|
- Python 3.11+
|
|
- PyTorch 2.0+ (Deep Learning)
|
|
- scikit-learn, XGBoost
|
|
- FastAPI + uvicorn
|
|
- ta (análisis técnico)
|
|
|
|
### 3. LLM Agent (`apps/llm-agent/`) - NUEVO
|
|
- **Propósito**: Agente de trading con Claude AI
|
|
- **Puerto**: 8003
|
|
- **Environment**: `orbiquant-llm-agent`
|
|
- **Stack**:
|
|
- Python 3.11+
|
|
- Anthropic SDK (Claude API)
|
|
- LangChain
|
|
- ChromaDB (vector DB para RAG)
|
|
- FastAPI + uvicorn
|
|
|
|
## Archivos Creados
|
|
|
|
### Por Servicio
|
|
|
|
Cada servicio incluye:
|
|
|
|
```
|
|
apps/{service}/
|
|
├── environment.yml # Configuración Conda
|
|
├── requirements.txt # Dependencias pip
|
|
├── .env.example # Variables de entorno
|
|
├── pyproject.toml # Metadata del proyecto (llm-agent)
|
|
├── README.md # Documentación (llm-agent)
|
|
└── src/ # Código fuente
|
|
├── __init__.py
|
|
├── main.py
|
|
├── config.py
|
|
├── models/
|
|
├── services/
|
|
├── repositories/
|
|
└── api/
|
|
```
|
|
|
|
### Scripts de Automatización
|
|
|
|
1. **`scripts/setup-python-envs.sh`** (NUEVO)
|
|
- Script automatizado para crear todos los entornos
|
|
- Soporta instalación individual o masiva
|
|
- Verifica estado de instalación
|
|
- Maneja recreación de entornos
|
|
|
|
2. **`scripts/verify-setup.sh`** (NUEVO)
|
|
- Verificación rápida del setup
|
|
- Chequea instalación de Conda
|
|
- Valida entornos y archivos
|
|
|
|
3. **`scripts/README.md`** (NUEVO)
|
|
- Documentación de scripts
|
|
|
|
### Documentación
|
|
|
|
1. **`docs/95-guias-desarrollo/ml-engine/SETUP-PYTHON.md`** (NUEVO)
|
|
- Guía completa de setup Python
|
|
- Instrucciones de instalación
|
|
- Principios SOLID aplicados
|
|
- Troubleshooting
|
|
- Comandos útiles
|
|
|
|
### Estructura LLM Agent (Completa)
|
|
|
|
Se creó completamente el servicio `llm-agent`:
|
|
|
|
```
|
|
apps/llm-agent/
|
|
├── src/
|
|
│ ├── __init__.py
|
|
│ ├── main.py # FastAPI app con endpoints básicos
|
|
│ ├── config.py # Configuración con Pydantic Settings
|
|
│ ├── models/
|
|
│ ├── services/
|
|
│ ├── repositories/
|
|
│ └── api/
|
|
├── tests/
|
|
│ ├── __init__.py
|
|
│ └── conftest.py # Fixtures para pytest
|
|
├── config/
|
|
├── environment.yml
|
|
├── requirements.txt
|
|
├── pyproject.toml # Configuración black, isort, mypy, pytest
|
|
├── .env.example
|
|
└── README.md
|
|
```
|
|
|
|
## Principios SOLID Aplicados
|
|
|
|
Todos los servicios siguen arquitectura SOLID:
|
|
|
|
### 1. Single Responsibility Principle (SRP)
|
|
- `config.py` - Solo configuración
|
|
- `services/` - Lógica de negocio
|
|
- `repositories/` - Acceso a datos
|
|
- `api/` - Endpoints HTTP
|
|
|
|
### 2. Open/Closed Principle (OCP)
|
|
- Interfaces abstractas en `services/interfaces.py`
|
|
- Implementaciones concretas extensibles
|
|
|
|
### 3. Liskov Substitution Principle (LSP)
|
|
- Todas las implementaciones sustituibles
|
|
- Dependency Injection en FastAPI
|
|
|
|
### 4. Interface Segregation Principle (ISP)
|
|
- Interfaces específicas y pequeñas
|
|
- No interfaces monolíticas
|
|
|
|
### 5. Dependency Inversion Principle (DIP)
|
|
- Dependencias de abstracciones, no implementaciones
|
|
- Uso de Protocols y ABCs
|
|
|
|
## Uso
|
|
|
|
### Instalación Rápida
|
|
|
|
```bash
|
|
# Todos los servicios
|
|
./scripts/setup-python-envs.sh all
|
|
|
|
# Un servicio específico
|
|
./scripts/setup-python-envs.sh llm-agent
|
|
```
|
|
|
|
### Verificación
|
|
|
|
```bash
|
|
# Validación sin instalación
|
|
~/miniconda3/bin/conda env create -f apps/ml-engine/environment.yml --dry-run
|
|
|
|
# Listar entornos
|
|
~/miniconda3/bin/conda env list
|
|
```
|
|
|
|
### Activar y Usar
|
|
|
|
```bash
|
|
# Activar entorno
|
|
conda activate orbiquant-llm-agent
|
|
|
|
# Verificar instalación
|
|
python -c "import anthropic, langchain; print('OK')"
|
|
|
|
# Configurar variables
|
|
cp apps/llm-agent/.env.example apps/llm-agent/.env
|
|
# Editar .env con tus API keys
|
|
|
|
# Ejecutar servicio
|
|
cd apps/llm-agent
|
|
uvicorn src.main:app --reload --port 8003
|
|
```
|
|
|
|
## Stack Tecnológico Completo
|
|
|
|
### Core
|
|
- **Python**: 3.11+
|
|
- **Package Manager**: Conda (Miniconda)
|
|
|
|
### Web Framework
|
|
- **FastAPI**: 0.104+
|
|
- **Uvicorn**: 0.24+ (ASGI server)
|
|
- **Pydantic**: 2.0+ (validación)
|
|
|
|
### ML/AI
|
|
- **PyTorch**: 2.0+ (deep learning)
|
|
- **scikit-learn**: 1.3+ (ML tradicional)
|
|
- **XGBoost**: 2.0+ (gradient boosting)
|
|
- **Anthropic**: 0.18+ (Claude API)
|
|
- **LangChain**: 0.1+ (framework LLM)
|
|
- **ChromaDB**: 0.4+ (vector database)
|
|
|
|
### Databases
|
|
- **PostgreSQL**: asyncpg 0.29+
|
|
- **Redis**: redis-py 5.0+
|
|
|
|
### Data Processing
|
|
- **NumPy**: 1.24+
|
|
- **Pandas**: 2.0+
|
|
- **TA-Lib**: análisis técnico
|
|
|
|
### Development
|
|
- **pytest**: 7.4+ (testing)
|
|
- **black**: 23.0+ (formatting)
|
|
- **isort**: 5.12+ (import sorting)
|
|
- **flake8**: 6.1+ (linting)
|
|
- **mypy**: 1.5+ (type checking)
|
|
|
|
## Validaciones Realizadas
|
|
|
|
Todos los `environment.yml` fueron validados con:
|
|
|
|
```bash
|
|
~/miniconda3/bin/conda env create -f <file> --dry-run
|
|
```
|
|
|
|
**Resultado**: ✓ Todos válidos y listos para crear
|
|
|
|
## Próximos Pasos
|
|
|
|
1. **Crear los entornos**:
|
|
```bash
|
|
./scripts/setup-python-envs.sh all
|
|
```
|
|
|
|
2. **Configurar variables de entorno**:
|
|
```bash
|
|
cp apps/llm-agent/.env.example apps/llm-agent/.env
|
|
# Editar y agregar ANTHROPIC_API_KEY
|
|
```
|
|
|
|
3. **Ejecutar tests**:
|
|
```bash
|
|
conda activate orbiquant-llm-agent
|
|
pytest
|
|
```
|
|
|
|
4. **Desarrollar servicios**:
|
|
- Implementar lógica de negocio en `services/`
|
|
- Crear repositorios en `repositories/`
|
|
- Definir endpoints en `api/`
|
|
- Escribir tests en `tests/`
|
|
|
|
## Referencias
|
|
|
|
- [Conda Documentation](https://docs.conda.io/)
|
|
- [FastAPI Documentation](https://fastapi.tiangolo.com/)
|
|
- [PyTorch Documentation](https://pytorch.org/docs/)
|
|
- [Anthropic Claude API](https://docs.anthropic.com/)
|
|
- [LangChain Documentation](https://python.langchain.com/)
|
|
- [SOLID Principles](https://realpython.com/solid-principles-python/)
|
|
|
|
## Notas Técnicas
|
|
|
|
### Dependencias Principales
|
|
|
|
**data-service**:
|
|
- 36 paquetes conda + pip
|
|
- Enfoque en async I/O y data processing
|
|
|
|
**ml-engine**:
|
|
- 180+ paquetes (incluye PyTorch con CUDA)
|
|
- Soporte GPU opcional
|
|
- Jupyter para desarrollo
|
|
|
|
**llm-agent**:
|
|
- 50+ paquetes
|
|
- Incluye frameworks LLM completos
|
|
- Vector DB para RAG
|
|
|
|
### Gestión de Entornos
|
|
|
|
Los entornos son completamente aislados:
|
|
- No hay conflictos entre dependencias
|
|
- Cada servicio tiene su propio Python 3.11
|
|
- Actualizaciones independientes
|
|
|
|
### Code Quality
|
|
|
|
Todos los servicios incluyen:
|
|
- Black (formatting)
|
|
- isort (import organization)
|
|
- flake8 (linting)
|
|
- mypy (type checking)
|
|
- pytest (testing)
|
|
|
|
## Contacto y Soporte
|
|
|
|
Para preguntas o problemas:
|
|
1. Revisar documentación en `/docs`
|
|
2. Consultar `SETUP-PYTHON.md`
|
|
3. Crear issue en el repositorio
|
|
|
|
---
|
|
|
|
**Configuración completada exitosamente** ✓
|
|
|
|
Todos los servicios Python están listos para desarrollo siguiendo principios SOLID y mejores prácticas de la industria.
|