🚀 Lean Engine All-in-One
All-in-One Docker image for QuantConnect Lean algorithmic trading engine with GPU support, modern Web UI, REST API, and MCP integration.
✨ Features
- 🎯 GPU Auto-Selection - Automatically selects GPU with lowest memory usage
- 🌐 Modern Web UI - Responsive design with dark mode and i18n (EN/ZH/JA)
- 🔌 REST API - FastAPI with Swagger docs at
/docs - 🤖 MCP Server - Model Context Protocol for AI integration
- 📊 Real-time Monitoring - GPU status and backtest progress via WebSocket
- 🐳 All-in-One - Single container with nginx, API, and MCP services
🚀 Quick Start
docker run -d --gpus all \
-p 8280:80 -p 8281:8000 -p 8282:8001 \
--name lean-engine \
neosun/lean:latest
Access:
- Web UI: http://localhost:8280
- API Docs: http://localhost:8281/docs
- Health: http://localhost:8281/health
📦 Installation
Docker Compose (Recommended)
services:
lean:
image: neosun/lean:latest
container_name: lean-engine
restart: unless-stopped
ports:
- "8280:80" # Web UI
- "8281:8000" # REST API
- "8282:8001" # MCP Server
volumes:
- ./data:/Lean/Data
- ./results:/Lean/Results
- ./algorithms:/Lean/Algorithms
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
docker compose up -d
⚙️ Configuration
| Environment Variable | Default | Description |
|---|---|---|
MODE | all | Service mode: ui, api, mcp, all |
GPU_AUTO_SELECT | true | Auto-select GPU with lowest memory |
API_HOST | 0.0.0.0 | API bind address |
API_PORT | 8000 | API port |
MCP_HOST | 0.0.0.0 | MCP bind address |
MCP_PORT | 8001 | MCP port |
🔌 API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/health | GET | Health check |
/api/gpu/status | GET | GPU status |
/api/gpu/select | POST | Select GPU |
/api/algorithms | GET | List algorithms |
/api/backtest | POST | Run backtest |
/api/jobs | GET | List jobs |
/api/results/{id} | GET | Get results |
/ws | WS | WebSocket for real-time updates |
🤖 MCP Tools
| Tool | Description |
|---|---|
gpu_status | Get GPU information |
gpu_select | Select specific GPU |
list_algorithms | List available algorithms |
run_backtest | Execute backtest |
get_results | Retrieve backtest results |
📁 Project Structure
docker/
├── Dockerfile # Multi-stage build
├── docker-compose.yml # Compose configuration
├── nginx.conf # Reverse proxy config
├── supervisord.conf # Process manager
├── app/
│ ├── api_server.py # FastAPI REST API
│ ├── mcp_server.py # MCP Server
│ ├── gpu_manager.py # GPU auto-selection
│ └── static/
│ └── index.html # Web UI
└── .env.example # Environment template
🛠️ Tech Stack
- Base: QuantConnect Lean Engine
- Runtime: Python 3.10+, .NET 6
- API: FastAPI, Uvicorn
- GPU: NVIDIA CUDA, pynvml
- Frontend: Tailwind CSS, Alpine.js
- Process: Supervisord, Nginx
📝 License
Apache 2.0 - See LICENSE
⭐ Star History
📱 Follow Us
