diff --git a/app/api/trade_review.py b/app/api/trade_review.py index d9cfa4e..0a2408d 100644 --- a/app/api/trade_review.py +++ b/app/api/trade_review.py @@ -1044,6 +1044,37 @@ def api_delete_experience( return {"success": True, "message": "经验已删除"} +@router.get("/experiences/tag-stats") +def api_get_experience_tag_stats( + db: Session = Depends(get_analysis_db), +): + """按标签统计经验数量""" + from collections import Counter + + experiences = db.query(TradeExperience).all() + tag_counter = Counter() + for exp in experiences: + for tag in (exp.tags or []): + tag_counter[tag] += 1 + + # 同时返回所有标签的定义信息 + tags = db.query(TradeTag).all() + tag_map = {t.name: {"id": t.id, "category": t.category, "is_preset": t.is_preset} for t in tags} + + data = [] + for name, count in tag_counter.most_common(): + info = tag_map.get(name, {}) + data.append({ + "name": name, + "count": count, + "tag_id": info.get("id"), + "category": info.get("category", "custom"), + "is_preset": info.get("is_preset", False), + }) + + return {"success": True, "data": data} + + # ==================== AI 重新分析 ==================== class ReanalyzeRequest(BaseModel): diff --git a/openspec/changes/trade-reflection-system/tasks.md b/openspec/changes/trade-reflection-system/tasks.md index 0f85514..289b392 100644 --- a/openspec/changes/trade-reflection-system/tasks.md +++ b/openspec/changes/trade-reflection-system/tasks.md @@ -59,7 +59,7 @@ - [x] 7.2 实现按天获取交易+配对数据的前端调用 - [x] 7.3 实现交易配对卡片展示(开仓→平仓箭头样式) - [x] 7.4 实现未配对交易单独展示 -- [ ] 7.5 实现手动配对交互(选择开仓+平仓→确认配对) +- [x] 7.5 实现手动配对交互(选择开仓+平仓→确认配对) - [x] 7.6 实现当天统计卡片(总盈亏、交易笔数、胜率等) ## 8. 前端 - 反思编辑面板 @@ -81,7 +81,7 @@ ## 10. 前端 - AI 分析结果展示 - [x] 10.1 创建 AI 分析结果展示面板 -- [ ] 10.2 实现多版本分析结果切换 +- [x] 10.2 实现多版本分析结果切换 - [x] 10.3 实现经验提炼建议展示和编辑 - [x] 10.4 实现经验保存交互 @@ -96,8 +96,8 @@ - [x] 12.1 创建经验库独立页面/Tab - [x] 12.2 实现经验列表视图(卡片样式) - [x] 12.3 实现搜索框和筛选栏(标签筛选、类型筛选) -- [ ] 12.4 实现分页加载 -- [ ] 12.5 实现经验详情弹窗(含来源交易链接) +- [x] 12.4 实现分页加载 +- [x] 12.5 实现经验详情弹窗(含来源交易链接) - [x] 12.6 实现时间线视图切换 - [x] 12.7 实现分类视图切换(按标签分组)