Files
sanguo_quant_live/strategies/guanyu_config.py
T
cfdaily 63d58ec123 docs(jiangwei): 更新基础设施环境检查结果到整合报告
补充内容:
- Python环境检查(3.14.3,核心依赖完整)
- vn.py环境检查(4.3.0,sanguo集成)
- 数据库配置检查
- 目录结构验证
- 模块导入测试
- 四位将军环境就绪状态
- 综合环境评估(9.5/10)
- 完整部署说明
- 依赖列表安装指南

更新人:姜维(伯约)
检查时间:2026-03-24 12:33 GMT+8
更新时间:2026-03-24 18:24 GMT+8
结论:环境完全就绪
2026-03-24 18:28:54 +08:00

139 lines
4.4 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
关羽策略配置文件
=================
定义策略的各种参数和配置
"""
# 风险偏好配置
RISK_PROFILES = {
'conservative': {
'name': '保守型',
'description': '低风险偏好,追求稳健收益',
'pe_max': 15,
'pb_max': 1.5,
'roe_min': 12.0,
'single_stock_max': 0.08, # 单票最大仓位8%
'industry_max': 0.20, # 单行业最大仓位20%
'stock_count': (15, 20), # 持股数量范围
'stop_loss_pct': 0.05, # 止损幅度5%
'max_drawdown': 0.20, # 最大回撤控制20%
},
'balanced': {
' 'name': '平衡型',
'description': '中等风险偏好,平衡收益与风险',
'pe_max': 25,
'pb_max': 2.5,
'roe_min': 10.0,
'single_stock_max': 0.15, # 单票最大仓位15%
'industry_max': 0.25, # 单行业最大仓位25%
'stock_count': (10, 15), # 持股数量范围
'stop_loss_pct': 0.06, # 止损幅度6%
'max_drawdown': 0.30, # 最大回撤控制30%
},
'aggressive': {
'name': '进取型',
'description': '高风险偏好,追求更高收益',
'pe_max': 35,
'pb_max': 3.0,
'roe_min': 8.0,
'single_stock_max': 0.25, # 单票最大仓位25%
'industry_max': 0.30, # 单行业最大仓位30%
'stock_count': (5, 10), # 持股数量范围
'stop_loss_pct': 0.08, # 止损幅度8%
'max_drawdown': 0.40, # 最大回撤控制40%
},
}
# 技术指标配置
TECHNICAL_CONFIG = {
'ma_days': 20, # 均线天数
'atr_period': 14, # ATR周期
'max_drawdown_period': 20, # 回撤检查周期
'max_drawdown_limit': 0.20, # 最大允许回撤20%
'volume_surge_threshold': 3.0, # 放量阈值3倍
}
# 价值筛选配置
VALUE_FILTER_CONFIG = {
'min_market_cap': 100000, # 最小流通市值10亿(万元)
'min_turnover': 0.5, # 最小换手率0.5%
'max_new_stock_days': 180, # 新股过滤天数
}
# 止损配置
STOP_LOSS_CONFIG = {
'methods': ['ma', 'atr', 'pct'], # 支持的止损方法
'default_method': 'ma', # 默认止损方法
'atr_multiplier': 2.0, # ATR止损倍数
}
# 止盈配置(可选)
TAKE_PROFIT_CONFIG = {
'enabled': False, # 是否启用止盈
'target_profit_pct': 0.30, # 目标收益率30%
'partial_profit_levels': [ # 分批止盈
{'pct': 0.20, 'sell_ratio': 0.3}, # 20%收益时卖出30%
{'pct': 0.30, 'sell_ratio': 0.4}, # 30%收益时卖出40%
{'pct': 0.50, 'sell_ratio': 0.3}, # 50%收益时卖出30%
],
}
# 数据配置
DATA_CONFIG = {
'source': 'akshare', # 数据源
'default_history_days': 120, # 默认获取历史数据天数
}
# 日志配置
LOG_CONFIG = {
'enabled': True,
'level': 'INFO',
'file': 'guanyu_strategy.log',
}
# 获取默认配置
def get_default_config():
"""获取默认配置"""
return {
'risk_profile': 'balanced',
'total_capital': 1000000.0,
'technical': TECHNICAL_CONFIG,
'value_filter': VALUE_FILTER_CONFIG,
'stop_loss': STOP_LOSS_CONFIG,
'take_profit': TAKE_PROFIT_CONFIG,
'data': DATA_CONFIG,
}
if __name__ == '__main__':
# 打印所有配置
print("=" * 60)
print("关羽策略配置")
print("=" * 60)
print("\n风险偏好配置:")
for profile_name, profile_config in RISK_PROFILES.items():
print(f"\n {profile_name}:")
for key, value in profile_config.items():
if key == 'stock_count':
print(f" {key}: {value[0]}-{value[1]}")
elif isinstance(value, float):
print(f" {key}: {value*100:.1f}%")
else:
print(f" {key}: {value}")
print("\n技术指标配置:")
for key, value in TECHNICAL_CONFIG.items():
print(f" {key}: {value}")
print("\n价值筛选配置:")
for key, value in VALUE_FILTER_CONFIG.items():
print(f" {key}: {value}")
print("\n止损配置:")
for key, value in STOP_LOSS_CONFIG.items():
print(f" {key}: {value}")