QTrade/configs/production.yaml
cuizhan 37a5df8bf6 重构配置系统:改为Config/Logger单例模式,拆分环境配置文件
主要改动:
1. Config类改为单例模式,支持根据global.yaml的current_mode自动加载环境配置
2. Logger类改为单例模式,通过类方法直接访问
3. 拆分配置文件:global.yaml仅指定模式,backtest.yaml/simulation.yaml/production.yaml存储各环境配置
4. 移除所有config参数传递,使用Config.get()直接访问
5. 移除所有logger实例传递,使用Logger.info()等类方法直接访问
6. 修复初始化顺序:Config.initialize() -> Logger.initialize() -> 其他组件
7. 修复Logger参数默认值,确保所有方法可正常调用
8. 新增三个环境配置文件结构统一,只有参数值不同
9. 客户端URL端口修正为8030(回测)/8020(模拟)/8010(实盘)

配置文件变更:
- configs/global.yaml:简化为仅包含current_mode
- configs/backtest.yaml:回测环境完整配置
- configs/simulation.yaml:模拟环境完整配置
- configs/production.yaml:实盘环境完整配置

代码重构:
- src/core/config.py:单例模式,自动加载环境配置
- src/core/logger.py:单例模式,类方法访问
- 所有模块:移除config/logger参数,使用单例访问
2026-01-12 19:07:23 +08:00

109 lines
2.3 KiB
YAML

# QTrade 实盘环境配置文件
# ==================== 环境配置 ====================
environment:
mode: "production"
# ==================== MySQL 配置 ====================
database:
host: "127.0.0.1"
port: 3306
user: "root"
password: "1234"
database: "qtrade_live"
pool_size: 5
pool_recycle: 3600
echo: false
# ==================== 缓存配置 ====================
cache:
type: "memory" # memory-内存缓存
max_memory_mb: 4096 # 最大内存限制 4GB
# ==================== 日志配置 ====================
logging:
enabled: true
filepath: "d:\\workspace\\QTrade\\logs"
max_size: 10485760 # 10MB
backup_count: 5
level: "INFO"
path: "logs/production"
# ==================== 策略配置 ====================
strategies:
strategy_folder: "d:/workspace/QTrade/configs/strategies"
max_concurrent_strategies: 50
# ==================== 客户端适配器配置 ====================
client_adapters:
production_adapter:
server_url: "ws://localhost:8010/ws/strategy"
timeout: 30 # seconds
# ==================== 下载数据源配置 ====================
data_downloader:
downloader: "xtquant"
xtquant:
xtquant_path: "C:\\Program Files\\国金证券QMT交易端\\userdata_mini\\datadir"
xtquant_token: "e83d8eec5226c0b4db4a1d40830e09e4ffe73e15"
optimize_addresses:
- "115.231.218.73:55310"
- "115.231.218.79:55310"
- "218.16.123.11:55310"
- "218.16.123.27:55310"
# ==================== 行情配置 ====================
market:
kline_periods:
- "tick"
- "1m"
- "5m"
- "15m"
- "30m"
- "60m"
- "1d"
- "1w"
# ==================== 技术指标配置 ====================
indicators:
enabled: true
enabled_indicators:
- macd
- kdj
- boll
- rsi
- ma
macd:
fast_period: 6
slow_period: 13
signal_period: 5
kdj:
period: 9
k_period: 3
d_period: 3
boll:
period: 20
std_multiplier: 2.0
rsi:
fast: 6
mid: 12
slow: 24
ma:
periods: [5, 10, 20, 60]
# ==================== 交易配置 ====================
trading:
sessions:
morning:
start: "09:30"
end: "11:30"
afternoon:
start: "13:00"
end: "15:00"
# ==================== 服务端口配置 ====================
services:
trading_service:
host: "0.0.0.0"
port: 8010