QTrade/configs/global.yaml
cuizhan 0f23037448 重构架构:实现单一职责原则和最小接口设计
主要修改:
1. CacheManager 负责数据库降级(单一职责)
   - 缓存未命中自动从数据库加载
   - 移除 StrategyManager/Context 的 db_manager 依赖

2. 添加 StrategyContext 核心组件
   - Position: 持仓管理
   - Capital: 资金管理
   - RiskState: 风险控制
   - BaseStrategy: 策略基类

3. 配置与类型修复
   - global.yaml 添加完整缓存配置
   - 修复 Pylance 类型推断错误
   - Config.load_with_global() 合并全局配置

4. 技术设计文档
   - 架构重构总结
   - 缓存设计方案
   - Context 共享策略
   - 接口最小化原则
2025-12-27 22:52:40 +08:00

143 lines
3.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# QTrade 全局公共配置
# 说明: 此文件包含所有服务共用的配置项
# 环境变量配置(对应 .env 文件内容)
environment:
# 当前环境: backtest, simulation, production
env: "backtest"
# 配置文件路径
config_file: "configs/backtest.yaml"
# 环境对应的配置文件映射
config_mapping:
backtest: "configs/backtest.yaml"
simulation: "configs/simulation.yaml"
production: "configs/production.yaml"
# 应用配置
app:
version: "2.0.0" # 公用版本号
# MySQL 配置(公用)
database:
host: "127.0.0.1"
port: 3306
user: "root"
password: "1234"
pool_size: 5
pool_recycle: 3600
echo: false
# 缓存配置(公用)
cache:
enabled: true
type: "memory" # memory-内存缓存
max_memory_mb: 4096 # 最大内存限制 4GB
capacity: 10000 # 最大缓存条目数
ttl: 3600 # 缓存过期时间(秒)
# 日志配置(公用)
logging:
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
file:
enabled: true
max_size: 10485760 # 10MB
backup_count: 5
# 数据源配置(公用)
data_source:
# 数据下载器类型: xtquant, qmt, tushare, akshare 等
downloader: "xtquant"
# XtQuant 下载器配置
xtquant:
xtquant_path: "C:\\Program Files\\国金证券QMT交易端\\userdata_mini\\datadir"
xtquant_token: "e83d8eec5226c0b4db4a1d40830e09e4ffe73e15" # XtQuant 数据接口 token(需要申请)
# XtQuant 优化地址(可选,用于提升数据下载速度)
optimize_addresses:
- "115.231.218.73:55310"
- "115.231.218.79:55310"
- "218.16.123.11:55310"
- "218.16.123.27:55310"
# 未来扩展:其他下载器配置
# qmt:
# ...
# tushare:
# token: "your_token_here"
# 数据检查器配置
data_checker:
# 报告配置
report:
enabled: false # 是否启用报告生成(默认关闭)
directory: "reports/datacheck" # 报告保存目录
# 行情配置(公用)
market:
kline_periods:
- "tick"
- "1m"
- "5m"
- "15m"
- "30m"
- "60m"
- "1d"
- "1w"
cache_ttl: 60
# 技术指标配置(公用)
indicators:
# 是否启用指标计算
enabled: true
# 要计算的指标列表
# 支持的指标类型: macd, kdj, boll, rsi, ma
enabled_indicators:
- macd
- kdj
- boll
- rsi
- ma
# 各指标的参数配置
macd:
fast_period: 6 # 快速EMA周期
slow_period: 13 # 慢速EMA周期
signal_period: 5 # 信号线周期
kdj:
period: 9 # RSV计算周期
k_period: 3 # K值平滑周期
d_period: 3 # D值平滑周期
boll:
period: 20 # 移动平均周期
std_multiplier: 2.0 # 标准差倍数
rsi:
fast: 6 # 快速RSI周期
mid: 12 # 中速RSI周期
slow: 24 # 慢速RSI周期
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"
# QMT交易配置(公用部分)
qmt:
account_type: "STOCK" # STOCK-股票账户, CREDIT-信用账户