三修:建议去重+闭环跟踪+模糊用词禁令

server.py:
- /api/advice/record 加去重(同天+同方向+同摘要前40字=跳过)
- /api/advice/confirm 支持 executed 动作+自动打 evaluated 标记

cron prompts:
- MoFin盘前中监控 + 午后监控 加入 advice/record 调用指令
- 模糊用词禁令嵌入 cron prompt
This commit is contained in:
知微
2026-06-21 23:00:53 +08:00
parent 9d85601904
commit a8c3ec5db9
2 changed files with 8381 additions and 4 deletions
+8358
View File
File diff suppressed because it is too large Load Diff
+23 -4
View File
@@ -586,12 +586,15 @@ def get_pending_decisions():
@app.route("/api/advice/record", methods=["POST"])
def record_advice():
"""记录一条分析建议到 decisions.json 的 advice_timeline"""
"""记录一条分析建议,自动去重(相同code+同天+同方向=跳过)"""
data = request.get_json(force=True) or {}
code = data.get("code", "")
if not code:
return jsonify({"status": "error", "message": "code required"}), 400
direction = data.get("direction", "持有")
today = datetime.now().strftime("%Y-%m-%d")
d = _load_json(DATA_DIR / "decisions.json", {"decisions": []})
entry = None
@@ -604,9 +607,19 @@ def record_advice():
return jsonify({"status": "error", "message": f"no active decision for {code}"}), 404
timeline = entry.setdefault("advice_timeline", [])
# 去重:同一天+同方向+摘要前40字相似 → 跳过
summary_short = (data.get("summary", "") or "")[:40]
for a in timeline:
a_date = a.get("date", "")[:10]
a_dir = a.get("direction", "")
a_summary = (a.get("summary", "") or "")[:40]
if a_date == today and a_dir == direction and a_summary == summary_short:
return jsonify({"status": "skipped", "reason": "duplicate", "advice": a})
advice = {
"date": datetime.now().strftime("%Y-%m-%d %H:%M"),
"direction": data.get("direction", "持有"),
"direction": direction,
"price": data.get("price", ""),
"summary": data.get("summary", ""),
"status": "pending",
@@ -618,11 +631,12 @@ def record_advice():
@app.route("/api/advice/confirm", methods=["POST"])
def confirm_advice():
"""确认/忽略一条建议"""
"""确认/忽略/标记已执行"""
data = request.get_json(force=True) or {}
code = data.get("code", "")
idx = data.get("index", -1)
action = data.get("action", "confirmed") # confirmed | ignored
action = data.get("action", "confirmed") # confirmed | ignored | executed
result = data.get("result", "")
d = _load_json(DATA_DIR / "decisions.json", {"decisions": []})
for e in d["decisions"]:
@@ -630,6 +644,11 @@ def confirm_advice():
timeline = e.get("advice_timeline", [])
if 0 <= idx < len(timeline):
timeline[idx]["status"] = action
if action == "executed":
timeline[idx]["evaluated"] = True
timeline[idx]["evaluated_at"] = datetime.now().strftime("%Y-%m-%d %H:%M")
if result:
timeline[idx]["result"] = result
_save_json(DATA_DIR / "decisions.json", d)
return jsonify({"status": "ok"})
return jsonify({"status": "error", "message": "not found"}), 404