Skip to content

Commit 8be0e4e

Browse files
committed
remove intelligent evolution ai capabilities
1 parent b32667c commit 8be0e4e

10 files changed

Lines changed: 454 additions & 1808 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# 背景 / 目标
2+
3+
用户要求去掉“智能进化”中的“AI能力”模块及相关内容。目标是在保留当前工作区既有未提交改动的前提下,移除对应前端区块、交互逻辑、后端 API/服务引用和 README/文档描述。
4+
5+
# 任务分解(checklist)
6+
7+
- [x] 定位智能进化页内 AI 能力模块的前端入口、请求逻辑和后端接口。
8+
- [x] 删除前端 AI 能力展示、按钮、状态渲染和相关样式。
9+
- [x] 清理后端 AI 能力 API、服务实例、调度或无用引用。
10+
- [x] 更新 README/相关文档中的 AI 能力描述。
11+
- [x] 执行静态检查、相关测试并重启服务。
12+
- [x] 提交并推送到 `origin/main`
13+
14+
# 验收标准
15+
16+
- 智能进化页不再展示 AI 能力模块。
17+
- 前端不再请求 AI 能力相关 API。
18+
- 后端不再暴露对应 AI 能力接口或无用服务入口。
19+
- 文档不再把该模块列为现有能力。
20+
- 服务可启动,相关检查通过。
21+
22+
验证记录:AI 能力模块关键字扫描仅剩已移除接口测试项;`python3 -m compileall app/main.py app/services/hermes_runtime.py app/services/backtest_lab.py` 通过;`node --check app/static/app.js` 通过;`pytest tests/test_transition_rules.py tests/test_custom_strategy.py tests/test_first_limit_alpha.py tests/test_kline_store.py tests/test_kline_cache_service.py` 通过;`./restart.sh` 成功启动服务,`/api/hermes-ai/risk``/api/hermes-ai/weekly-report/run` 返回 404。
23+
24+
# 风险与回滚
25+
26+
- 当前工作区已有未提交改动,提交时需要只暂存本任务相关文件/片段。
27+
- 若 AI 能力模块与 Agent 基础任务共享 HermesRuntime,应只移除模块入口和扩展能力,保留智能进化基础状态、任务历史、手动诊断等能力。
28+
29+
# 关键决策记录
30+
31+
- 以“智能进化页内 AI 能力模块”为删除边界;除非代码只服务该模块,否则不删除 Agent 基础运行框架。

README.md

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -210,23 +210,7 @@ Hermes Agent 支持两种运行模式,自动探测并切换:
210210
|------|------|------|
211211
| **15:30** | `daily_review` | 盘后复盘:分析漏斗三池变化、评分表现,输出诊断与后续建议 |
212212
| **21:00** | `notice_review` | 公告复盘:审视当日公告筛选效果,输出规则观察与优化建议 |
213-
| **盘中每 30s** | `risk_guardian` | 监控模拟盘持仓,触发止盈/止损/冲高回落告警(可选自动平仓) |
214-
| **盘中每 60s** | `auto_trade` | 根据 buy 池分数自动下模拟单,到达阈值自动平仓(可开关/Dry Run) |
215213
| **盘中** | 智能监控 | 按间隔执行 LLM 市场分析,推送主线动态到前端 |
216-
| **周五 15:30** | `weekly_report` | 自动生成周报(市场+系统+模拟盘)并推送飞书 |
217-
218-
### Hermes AI 能力扩展(6 项)
219-
220-
前端入口:**智能监控 / 进化 → AI 能力** 子 Tab。
221-
222-
| 代号 | 能力 | 说明 |
223-
|------|------|------|
224-
| **A** | 自动交易闭环 | buy 池分数 ≥70 自动下模拟单 + tp/sl 自动平仓,完整的"选股→决策→执行→复盘"闭环 |
225-
| **B** | 风险守门人 | 盘中 30s 扫描,触发止盈 (+8%)/止损 (-5%)/冲高回落规则,告警卡片可选自动平仓 |
226-
| **C** | 策略回测实验室 | 任意自定义策略(含 3 条内置预设)在全 A 股 × 180 天历史上回测,返回胜率/累计收益/最大回撤(示例:576 信号 / 46% 胜率 / +390% 累计 / 87 秒) |
227-
| **D** | 深度个股研报 | LLM 聚合"K线 + Kronos 预测 + 概念 + 公告"生成 200 字研报卡(含 verdict/confidence/利好/风险/操作建议) |
228-
| **F** | 消息驱动分析 | 把公告+龙虎榜+概念融合 LLM 上下文,输出"消息→标的→操作"链路(含情绪/置信度/理由) |
229-
| **G** | 周报生成 | 周五 15:30 自动汇总一周热门概念/漏斗/模拟盘业绩并推飞书,也可手动触发 |
230214

231215
### 智能监控数据采集
232216

@@ -464,6 +448,7 @@ Alpha/
464448
│ ├── strategy_engine.py # 三池盘中实时评分 + 迁池规则
465449
│ ├── strategy_rules.py # ★ 自定义策略:12 条原子规则(注册表 + 参数 schema + 评估器)
466450
│ ├── custom_strategy.py # ★ 自定义策略数据模型 + 3 条内置预设 + CustomStrategyScanner
451+
│ ├── backtest_lab.py # 自定义策略历史回测
467452
│ ├── quiet_breakout_scanner.py # 缩量启动扫描(兼容保留,供 legacy API / Hermes 工具复用)
468453
│ ├── concept_engine.py # 概念热度评分 + 个股板块映射
469454
│ ├── notice_service.py # 公告抓取 + 规则/LLM 双引擎打分
@@ -592,24 +577,6 @@ pip3 install -r requirements.txt
592577
| POST | `/api/strategy/first-limit-alpha/inference/run` | 对最新或指定交易日样本执行模型打分 |
593578
| POST | `/api/strategy/first-limit-alpha/backtest` | 基于最近一次 baseline 结果执行 TopK 回测 |
594579

595-
### Hermes AI 扩展能力
596-
597-
| 方法 | 路径 | 说明 |
598-
|------|------|------|
599-
| GET | `/api/hermes-ai/risk` | 风险守门人配置与告警快照 |
600-
| POST | `/api/hermes-ai/risk/config` | 更新 tp/sl/冲高回落阈值 + 自动平仓开关 |
601-
| POST | `/api/hermes-ai/risk/tick` | 立即扫描一次持仓 |
602-
| GET | `/api/hermes-ai/auto-trade` | 自动交易配置与最近动作 |
603-
| POST | `/api/hermes-ai/auto-trade/config` | 开关启用/dry_run/最多持仓/每笔股数 |
604-
| POST | `/api/hermes-ai/auto-trade/tick` | 立即执行一次自动交易扫描 |
605-
| GET | `/api/hermes-ai/backtest` | 最近一次回测结果 |
606-
| POST | `/api/hermes-ai/backtest/run` | 触发缩量启动策略在全 A 股 × 180 天上回测 |
607-
| POST | `/api/hermes-ai/research/{symbol}` | 为指定个股生成聚合研报卡 |
608-
| GET | `/api/hermes-ai/news-insight` | 最近一次消息驱动分析 |
609-
| POST | `/api/hermes-ai/news-insight/run` | 重新生成消息驱动分析 |
610-
| GET | `/api/hermes-ai/weekly-report` | 最近一次周报 |
611-
| POST | `/api/hermes-ai/weekly-report/run` | 立即生成周报并推飞书 |
612-
613580
### 公告选股
614581

615582
| 方法 | 路径 | 说明 |
@@ -693,9 +660,8 @@ pip3 install -r requirements.txt
693660
| K 线缓存 | 6 | stats / status / progress / logs / report / 单股 |
694661
| 公告 | 2 | funnel + keywords |
695662
| Hermes Agent | 4 | status / tasks / 监控 |
696-
| Hermes AI 扩展 | 5 | risk / auto-trade / backtest / news / weekly |
697663
| 模拟盘 | 5 | positions / history / summary / trades / settings |
698-
| 已移除接口 | 8 | proposal / proposal-learner 路由应返回 404 |
664+
| 已移除接口 | 21 | proposal / proposal-learner / hermes-ai 路由应返回 404 |
699665
| 公告详情 | 1 | 容忍 200/404 |
700666
| 性能巡检 | 5 | 关键只读端点 < 3s |
701667

app/main.py

Lines changed: 2 additions & 197 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,7 @@
3434
StrategyRuleRef,
3535
)
3636
from app.services.strategy_rules import RULE_REGISTRY, list_rules as list_strategy_rules
37-
from app.services.hermes_ai_extensions import (
38-
AutoTradeLoop,
39-
BacktestLab,
40-
NewsInsightExtractor,
41-
ResearchCardGenerator,
42-
WeeklyReportBuilder,
43-
)
44-
from app.services.risk_guardian import RiskGuardian, risk_guardian_loop
37+
from app.services.backtest_lab import BacktestLab
4538

4639
from app.routers.kline import init_kline_router, kline_cache_loop
4740
from app.routers.first_limit_alpha import init_first_limit_alpha_router
@@ -133,46 +126,11 @@ def _load_custom_strategy(strategy_id: str) -> CustomStrategy:
133126
kline_cache_service=kline_cache_service,
134127
)
135128

136-
risk_guardian = RiskGuardian(
137-
paper_trading=paper_trading,
138-
get_realtime_price=lambda sym: _get_realtime_price(sym),
139-
is_market_open=lambda: _is_a_market_open(),
140-
)
141-
142-
auto_trade_loop = AutoTradeLoop(
143-
paper_trading=paper_trading,
144-
funnel_service=service,
145-
hermes_memory=hermes_memory,
146-
get_realtime_price=lambda sym: _get_realtime_price(sym),
147-
is_market_open=lambda: _is_a_market_open(),
148-
)
149-
150129
backtest_lab = BacktestLab(
151130
kline_store=_kline_store,
152131
name_lookup=_qb_name_lookup,
153132
)
154133

155-
research_card_gen = ResearchCardGenerator(
156-
runtime=hermes_runtime,
157-
kronos_service=kronos_service,
158-
kline_store=_kline_store,
159-
data_provider=provider,
160-
notice_service=notice_service,
161-
)
162-
163-
news_insight = NewsInsightExtractor(
164-
runtime=hermes_runtime,
165-
notice_service=notice_service,
166-
funnel_service=service,
167-
)
168-
169-
weekly_report = WeeklyReportBuilder(
170-
runtime=hermes_runtime,
171-
funnel_service=service,
172-
notice_service=notice_service,
173-
paper_trading=paper_trading,
174-
)
175-
176134

177135
async def _broadcast_snapshot() -> None:
178136
funnel = await service.get_funnel()
@@ -200,39 +158,6 @@ async def _ticker_loop() -> None:
200158
await asyncio.sleep(60)
201159

202160

203-
async def _auto_trade_loop() -> None:
204-
"""盘中每 60s 执行一次 auto_trade.tick(enabled=False 时快速返回)。"""
205-
await asyncio.sleep(30)
206-
while True:
207-
try:
208-
await auto_trade_loop.tick()
209-
except Exception as exc:
210-
print(f"[auto_trade] loop error: {exc}")
211-
await asyncio.sleep(60)
212-
213-
214-
async def _weekly_report_scheduler() -> None:
215-
"""周五 15:30 后自动生成周报并推飞书(每周一次)。"""
216-
from app.services.time_utils import now_cn
217-
await asyncio.sleep(120)
218-
last_run_week: str | None = None
219-
while True:
220-
try:
221-
n = now_cn()
222-
if n.weekday() == 4 and n.hour == 15 and n.minute >= 30:
223-
wk = n.strftime("%Y-W%W")
224-
if last_run_week != wk:
225-
print(f"[weekly_report] scheduled run at {n.isoformat()}")
226-
try:
227-
await weekly_report.generate()
228-
last_run_week = wk
229-
except Exception as exc:
230-
print(f"[weekly_report] run failed: {exc}")
231-
except Exception as exc:
232-
print(f"[weekly_report] scheduler error: {exc}")
233-
await asyncio.sleep(600)
234-
235-
236161
async def _predict_funnel_scheduler_loop() -> None:
237162
"""收盘后 16:15 自动触发预测选股扫描(每日一次)。"""
238163
from app.services.time_utils import now_cn
@@ -298,13 +223,10 @@ async def _startup_backfill() -> None:
298223
app.state.monitor_task = asyncio.create_task(monitor_loop(hermes_runtime, hub))
299224
app.state.predict_funnel_task = asyncio.create_task(_predict_funnel_scheduler_loop())
300225
app.state.hot_stock_ai_task = asyncio.create_task(_hot_stock_ai_scheduler_loop())
301-
app.state.risk_guardian_task = asyncio.create_task(risk_guardian_loop(risk_guardian, interval_seconds=30))
302-
app.state.auto_trade_task = asyncio.create_task(_auto_trade_loop())
303-
app.state.weekly_report_task = asyncio.create_task(_weekly_report_scheduler())
304226
yield
305227
for key in [
306228
"backfill_task", "ticker_task", "kline_cache_task", "hermes_task", "monitor_task",
307-
"predict_funnel_task", "hot_stock_ai_task", "risk_guardian_task", "auto_trade_task", "weekly_report_task",
229+
"predict_funnel_task", "hot_stock_ai_task",
308230
]:
309231
task = getattr(app.state, key, None)
310232
if task:
@@ -635,123 +557,6 @@ async def backtest_custom_strategy(
635557
raise HTTPException(status_code=500, detail=f"回测失败: {exc}")
636558

637559

638-
# ============ Hermes AI 扩展能力 ============
639-
640-
@app.get("/api/hermes-ai/risk")
641-
async def get_risk_snapshot():
642-
return risk_guardian.get_snapshot()
643-
644-
645-
@app.post("/api/hermes-ai/risk/config")
646-
async def update_risk_config(payload: dict):
647-
risk_guardian.set_config(payload or {})
648-
return {"success": True, "snapshot": risk_guardian.get_snapshot()}
649-
650-
651-
@app.post("/api/hermes-ai/risk/tick")
652-
async def trigger_risk_tick():
653-
result = await risk_guardian.tick()
654-
return {"success": True, "result": result, "snapshot": risk_guardian.get_snapshot()}
655-
656-
657-
@app.get("/api/hermes-ai/auto-trade")
658-
async def get_auto_trade():
659-
return auto_trade_loop.get_snapshot()
660-
661-
662-
@app.post("/api/hermes-ai/auto-trade/config")
663-
async def update_auto_trade_config(payload: dict):
664-
auto_trade_loop.set_config(payload or {})
665-
return {"success": True, "snapshot": auto_trade_loop.get_snapshot()}
666-
667-
668-
@app.post("/api/hermes-ai/auto-trade/tick")
669-
async def trigger_auto_trade_tick():
670-
result = await auto_trade_loop.tick()
671-
return {"success": True, "result": result, "snapshot": auto_trade_loop.get_snapshot()}
672-
673-
674-
@app.get("/api/hermes-ai/backtest")
675-
async def get_backtest():
676-
snap = backtest_lab.get_snapshot()
677-
if not snap:
678-
return {"generated_at": None, "message": "尚未执行过回测"}
679-
return snap
680-
681-
682-
@app.post("/api/hermes-ai/backtest/run")
683-
async def run_backtest(
684-
lookback_days: int = 25,
685-
hold_days: int = 3,
686-
tp_pct: float = 8.0,
687-
sl_pct: float = -5.0,
688-
amp_threshold: float = 0.20,
689-
vol_cv_threshold: float = 0.40,
690-
vol_spike_ratio: float = 3.0,
691-
require_limit_up: bool = True,
692-
limit: int | None = None,
693-
):
694-
if backtest_lab._running:
695-
raise HTTPException(409, "回测正在运行中")
696-
try:
697-
return await backtest_lab.run(
698-
lookback_days=lookback_days,
699-
hold_days=hold_days,
700-
tp_pct=tp_pct,
701-
sl_pct=sl_pct,
702-
amp_threshold=amp_threshold,
703-
vol_cv_threshold=vol_cv_threshold,
704-
vol_spike_ratio=vol_spike_ratio,
705-
require_limit_up=require_limit_up,
706-
limit=limit,
707-
)
708-
except Exception as exc:
709-
raise HTTPException(500, f"回测失败: {exc}")
710-
711-
712-
@app.post("/api/hermes-ai/research/{symbol}")
713-
async def gen_research_card(symbol: str, name: str = ""):
714-
cached = research_card_gen.get_cached(symbol)
715-
if cached:
716-
return cached
717-
try:
718-
return await research_card_gen.generate(symbol, name)
719-
except Exception as exc:
720-
raise HTTPException(500, f"研报生成失败: {exc}")
721-
722-
723-
@app.get("/api/hermes-ai/news-insight")
724-
async def get_news_insight():
725-
snap = news_insight.get_snapshot()
726-
if not snap:
727-
return {"message": "尚未生成", "generated_at": None}
728-
return snap
729-
730-
731-
@app.post("/api/hermes-ai/news-insight/run")
732-
async def run_news_insight(trade_date: str | None = None):
733-
try:
734-
return await news_insight.generate(trade_date=trade_date)
735-
except Exception as exc:
736-
raise HTTPException(500, f"消息分析失败: {exc}")
737-
738-
739-
@app.get("/api/hermes-ai/weekly-report")
740-
async def get_weekly_report():
741-
snap = weekly_report.get_snapshot()
742-
if not snap:
743-
return {"message": "尚未生成", "generated_at": None}
744-
return snap
745-
746-
747-
@app.post("/api/hermes-ai/weekly-report/run")
748-
async def run_weekly_report():
749-
try:
750-
return await weekly_report.generate()
751-
except Exception as exc:
752-
raise HTTPException(500, f"周报生成失败: {exc}")
753-
754-
755560
@app.get("/api/notice/funnel")
756561
async def get_notice_funnel(trade_date: str | None = None):
757562
return await notice_service.get_notice_funnel(trade_date)

0 commit comments

Comments
 (0)