diff --git a/.env.example b/.env.example index 912fdf3ef..45a86b111 100644 --- a/.env.example +++ b/.env.example @@ -127,7 +127,8 @@ BRAVE_API_KEYS=your_brave_key_here # 推荐:趋势 + 金叉 + 缩量回踩(兼顾多种市场形态) # AGENT_SKILLS=bull_trend,ma_golden_cross,shrink_pullback # -# 完整启用所有内置策略: +# 完整启用所有内置策略(两种写法等效): +# AGENT_SKILLS=all # AGENT_SKILLS=bull_trend,ma_golden_cross,volume_breakout,shrink_pullback,bottom_volume,dragon_head,one_yang_three_yin,box_oscillation,chan_theory,wave_theory,emotion_cycle # AGENT_SKILLS=bull_trend,ma_golden_cross,volume_breakout,shrink_pullback diff --git a/README.md b/README.md index be26fb082..87240739a 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ | `NEWS_MAX_AGE_DAYS` | 新闻最大时效(天),默认 3,避免使用过时信息 | 可选 | | `BIAS_THRESHOLD` | 乖离率阈值(%),默认 5.0,超过提示不追高;强势趋势股自动放宽 | 可选 | | `AGENT_MODE` | 开启 Agent 策略问股模式(`true`/`false`,默认 false) | 可选 | +| `AGENT_SKILLS` | 激活的策略(逗号分隔),`all` 启用全部 11 个;不配置时默认 4 个,详见 `.env.example` | 可选 | | `AGENT_MAX_STEPS` | Agent 最大推理步数(默认 10) | 可选 | | `AGENT_STRATEGY_DIR` | 自定义策略目录(默认内置 `strategies/`) | 可选 | | `TRADING_DAY_CHECK_ENABLED` | 交易日检查(默认 `true`):非交易日跳过执行;设为 `false` 或使用 `--force-run` 强制执行 | 可选 | diff --git a/docker/Dockerfile b/docker/Dockerfile index d0818fc05..ae60ed151 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -47,6 +47,7 @@ COPY data_provider/ ./data_provider/ COPY bot/ ./bot/ COPY patch/ ./patch/ COPY src/ ./src/ +COPY strategies/ ./strategies/ COPY --from=web-builder /app/static ./static/ # 创建数据目录 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0e1be213d..2cbaef73b 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -24,6 +24,7 @@ x-common: &common - ../logs:/app/logs - ../reports:/app/reports - ../.env:/app/.env + - ../strategies:/app/strategies:ro # 如需覆盖前端静态资源,可挂载本地 static 目录 # - ../static:/app/static:ro diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 79a643f76..ca55610b6 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -35,6 +35,11 @@ - 扩展 `analysis_tools` 与 `data_tools`,优化策略问股的工具调用链路与分析覆盖 ### 修复(#patch) +- 🐛 **Agent 策略渲染遗漏 framework 分类**(Issue #403) + - 根因:`get_skill_instructions()` 仅遍历 `trend/pattern/reversal` 三个分类,`category: framework` 的 4 个策略(箱体震荡、缠论、波浪理论、情绪周期)被静默丢弃 + - 修复:补充 `framework` 分类,并增加动态回退机制,确保未来自定义分类不会遗漏 + - 文档:`.env.example` 补充 `AGENT_SKILLS=all` 写法,`README.md` 配置表新增 `AGENT_SKILLS` + - Docker:Dockerfile 补充 `COPY strategies/`,docker-compose.yml 挂载 `strategies/` 目录(此前容器内策略目录缺失,导致所有策略均无法加载) - 🐛 **支持 DeepSeek 思考模式**(Issue #379) - 根因:Agent 模式(tool calls)下使用 DeepSeek 思考模式时,未在 assistant 消息中回传 `reasoning_content`,导致 API 返回 400 - 修复:`llm_adapter._call_openai` 解析并透传 `reasoning_content`;`executor` 在 assistant_msg 中写入该字段 diff --git a/src/agent/skills/base.py b/src/agent/skills/base.py index c17781f59..ad84f0ca3 100644 --- a/src/agent/skills/base.py +++ b/src/agent/skills/base.py @@ -35,7 +35,7 @@ class Skill: display_name: Human-readable name (e.g., "龙头策略"). description: Brief description of when to apply this strategy. instructions: Detailed natural language instructions injected into the system prompt. - category: Strategy category — "trend" (趋势), "pattern" (形态), "reversal" (反转). + category: Strategy category — "trend" (趋势), "pattern" (形态), "reversal" (反转), "framework" (框架). core_rules: List of core trading rule numbers this strategy relates to (1-7). required_tools: List of tool names this strategy depends on. enabled: Whether this strategy is currently active. @@ -254,7 +254,7 @@ class SkillManager: return "" # Group by category - categories = {"trend": "趋势", "pattern": "形态", "reversal": "反转"} + categories = {"trend": "趋势", "pattern": "形态", "reversal": "反转", "framework": "框架"} grouped: Dict[str, List[Skill]] = {} for skill in active: cat = skill.category or "trend" @@ -262,7 +262,9 @@ class SkillManager: parts = [] idx = 1 - for cat_key in ["trend", "pattern", "reversal"]: + # Render known categories in fixed order, then any remaining custom categories + ordered_keys = ["trend", "pattern", "reversal", "framework"] + for cat_key in ordered_keys + [k for k in grouped if k not in ordered_keys]: skills_in_cat = grouped.get(cat_key, []) if not skills_in_cat: continue diff --git a/strategies/README.md b/strategies/README.md index de123c5be..a2efdc0ff 100644 --- a/strategies/README.md +++ b/strategies/README.md @@ -26,7 +26,7 @@ name: my_strategy display_name: 我的策略 description: 简短描述策略适用的市场场景 -# 策略分类:trend(趋势)、pattern(形态)、reversal(反转) +# 策略分类:trend(趋势)、pattern(形态)、reversal(反转)、framework(框架) category: trend # 关联的核心交易理念编号(1-7),可选