Files
trading_gnn/docker-compose.yml
fegger 46657c7ffe Add Docker support and fix benchmark/data pipeline bugs
Containerize the application with ROCm GPU support for AMD Radeon R9700:
- Add Dockerfile with PyTorch/PyG ROCm 5.6 wheels
- Add docker-compose.yml with dashboard, live-trading, and train services
- Add .dockerignore and .env.example for configuration

Fix benchmark script to use batch_size instead of num_stocks for variable
dimensions, and replace fragile partial model surgery with a standalone MLP
for memory estimation.

Fix data pipeline to skip dates with no next trading date instead of
fabricating zero returns.

Add slippage to paper broker, optional mark-to-market prices to broker
interface, and health check endpoint for container orchestration.
2026-05-26 15:07:28 +02:00

184 lines
4.5 KiB
YAML

# =============================================================================
# StockGNN R9700 — Docker Compose Stack
# =============================================================================
# Services:
# - dashboard : FastAPI web frontend (http://localhost:8000)
# - live-trading: Continuous paper/live trading engine
# - train : One-off model training & backtesting
#
# Requirements:
# - Docker 20.10+ with Compose v2
# - AMD GPU + ROCm 5.6+ drivers on host
# - docker-compose run --rm train # manual training
# =============================================================================
services:
# -------------------------------------------------------------------------
# Base image build (shared by all services)
# -------------------------------------------------------------------------
dashboard:
build:
context: .
dockerfile: Dockerfile
image: stockgnn:r9700
container_name: stockgnn-dashboard
restart: unless-stopped
# Override default CMD for the web dashboard
command: >
python -m uvicorn src.web.app:app
--host 0.0.0.0
--port 8000
--reload
ports:
- "8000:8000"
volumes:
# Persist data & model artefacts across restarts
- ./data:/app/data
- ./models:/app/models
- ./logs:/app/logs
# Optional: mount source for live-reload during development
# - ./src:/app/src
env_file:
- .env
environment:
# ROCm / AMD GPU tuning
HSA_OVERRIDE_GFX_VERSION: "${HSA_OVERRIDE_GFX_VERSION:-10.3.0}"
PYTORCH_HIP_ALLOC_CONF: "expandable_segments:True"
# Ensure the app knows it is inside a container
STOCKGNN_ENV: docker
# AMD GPU device access
devices:
- /dev/kfd
- /dev/dri
# Required groups for GPU access inside the container
group_add:
- video
- render
# Security / capability settings for ROCm
security_opt:
- seccomp:unconfined
# Shared memory size for PyTorch DataLoader multiprocessing
shm_size: "8gb"
# Health-check for the web dashboard
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/api/dashboard/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- stockgnn-net
# -------------------------------------------------------------------------
# Live Trading Engine (paper or live — controlled via config.py)
# -------------------------------------------------------------------------
live-trading:
build:
context: .
dockerfile: Dockerfile
image: stockgnn:r9700
container_name: stockgnn-live-trading
restart: unless-stopped
command: >
python live_trading.py
volumes:
- ./data:/app/data
- ./models:/app/models
- ./logs:/app/logs
env_file:
- .env
environment:
HSA_OVERRIDE_GFX_VERSION: "${HSA_OVERRIDE_GFX_VERSION:-10.3.0}"
PYTORCH_HIP_ALLOC_CONF: "expandable_segments:True"
STOCKGNN_ENV: docker
devices:
- /dev/kfd
- /dev/dri
group_add:
- video
- render
security_opt:
- seccomp:unconfined
shm_size: "8gb"
networks:
- stockgnn-net
# Do not auto-start live trading until the user explicitly brings it up
profiles:
- live
# -------------------------------------------------------------------------
# Model Training & Backtesting (run manually)
# -------------------------------------------------------------------------
# Usage:
# docker compose run --rm train
# -------------------------------------------------------------------------
train:
build:
context: .
dockerfile: Dockerfile
image: stockgnn:r9700
container_name: stockgnn-train
command: >
python main.py
volumes:
- ./data:/app/data
- ./models:/app/models
- ./logs:/app/logs
env_file:
- .env
environment:
HSA_OVERRIDE_GFX_VERSION: "${HSA_OVERRIDE_GFX_VERSION:-10.3.0}"
PYTORCH_HIP_ALLOC_CONF: "expandable_segments:True"
STOCKGNN_ENV: docker
devices:
- /dev/kfd
- /dev/dri
group_add:
- video
- render
security_opt:
- seccomp:unconfined
shm_size: "16gb"
networks:
- stockgnn-net
profiles:
- train
# -----------------------------------------------------------------------------
# Shared network
# -----------------------------------------------------------------------------
networks:
stockgnn-net:
driver: bridge