141 lines
3.3 KiB
YAML
141 lines
3.3 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# Redis - Message Stream Storage
|
|
redis:
|
|
image: redis:7.2-alpine
|
|
container_name: tradus-redis
|
|
ports:
|
|
- "6379:6379"
|
|
volumes:
|
|
- redis_data:/data
|
|
- ./redis.conf:/usr/local/etc/redis/redis.conf
|
|
command: redis-server /usr/local/etc/redis/redis.conf
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 3s
|
|
retries: 3
|
|
start_period: 10s
|
|
networks:
|
|
- tradus-network
|
|
restart: unless-stopped
|
|
|
|
# Binance WebSocket Ingestion Service
|
|
ingestion:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
container_name: tradus-ingestion
|
|
env_file: .env
|
|
volumes:
|
|
- llm_gate_data:/app/data # LLM Gate 状态文件持久化
|
|
environment:
|
|
# Binance Configuration
|
|
- BINANCE_WS_BASE_URL=wss://fstream.binance.com
|
|
- SYMBOL=btcusdt
|
|
- KLINE_INTERVAL=5m
|
|
|
|
# Redis Configuration
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- REDIS_DB=0
|
|
- REDIS_PASSWORD=
|
|
|
|
# Stream Keys
|
|
- REDIS_STREAM_KLINE=binance:raw:kline:5m
|
|
- REDIS_STREAM_DEPTH=binance:raw:depth:20
|
|
- REDIS_STREAM_TRADE=binance:raw:trade
|
|
|
|
# Performance Tuning
|
|
- MAX_BUFFER_SIZE=1000
|
|
- RATE_LIMIT_MESSAGES_PER_SEC=1000
|
|
- DEDUP_CACHE_SIZE=10000
|
|
- REDIS_STREAM_MAXLEN=10000
|
|
|
|
# Reconnection Strategy
|
|
- RECONNECT_INITIAL_DELAY=1.0
|
|
- RECONNECT_MAX_DELAY=60.0
|
|
- MAX_RECONNECT_ATTEMPTS=100
|
|
|
|
# Monitoring
|
|
- HEALTH_CHECK_INTERVAL=30
|
|
- LOG_LEVEL=INFO
|
|
|
|
depends_on:
|
|
redis:
|
|
condition: service_healthy
|
|
networks:
|
|
- tradus-network
|
|
restart: unless-stopped
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
|
|
# Signal Generator Scheduler - 定时生成交易信号
|
|
scheduler:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
container_name: tradus-scheduler
|
|
command: python -u scheduler.py
|
|
env_file: .env
|
|
volumes:
|
|
- llm_gate_data:/app/data # 共享 LLM Gate 状态
|
|
- ./output:/app/output # 输出信号文件
|
|
environment:
|
|
# Redis Configuration
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- REDIS_DB=0
|
|
- REDIS_PASSWORD=
|
|
|
|
# Signal generation interval
|
|
- SIGNAL_INTERVAL_MINUTES=15 # 每15分钟生成一次信号
|
|
|
|
# Note: LLM API and DingTalk configs are loaded from .env file
|
|
|
|
- LOG_LEVEL=INFO
|
|
|
|
depends_on:
|
|
redis:
|
|
condition: service_healthy
|
|
networks:
|
|
- tradus-network
|
|
restart: unless-stopped
|
|
logging:
|
|
driver: "json-file"
|
|
options:
|
|
max-size: "10m"
|
|
max-file: "3"
|
|
profiles:
|
|
- scheduler # Only start with: docker-compose --profile scheduler up
|
|
|
|
# Redis Commander - Optional Web UI for Redis
|
|
redis-commander:
|
|
image: rediscommander/redis-commander:latest
|
|
container_name: tradus-redis-ui
|
|
environment:
|
|
- REDIS_HOSTS=local:redis:6379
|
|
ports:
|
|
- "8081:8081"
|
|
depends_on:
|
|
- redis
|
|
networks:
|
|
- tradus-network
|
|
restart: unless-stopped
|
|
profiles:
|
|
- debug # Only start with: docker-compose --profile debug up
|
|
|
|
volumes:
|
|
redis_data:
|
|
driver: local
|
|
llm_gate_data:
|
|
driver: local
|
|
|
|
networks:
|
|
tradus-network:
|
|
driver: bridge
|