feat: 重评带来源策略——collect_data读strategy_name,prompt顶部标'按此策略重评'(老莫)

This commit is contained in:
xxm
2026-08-18 15:11:21 +08:00
parent a65a351f32
commit a1e55e8ca8
+3 -2
View File
@@ -82,7 +82,7 @@ def collect_data(code):
# 从DB读策略(含 full_analysis / changelog_json / position_advice
conn = sqlite3.connect(DB, timeout=30)
r = conn.execute("SELECT name, entry_low, entry_high, stop_loss, take_profit, timing_signal, action, rr_ratio, tech_snapshot, sector_context, stock_category, full_analysis, changelog_json, reassessed_at, position_advice FROM holding_strategies WHERE code=? AND status='active'", (code,)).fetchone()
r = conn.execute("SELECT name, entry_low, entry_high, stop_loss, take_profit, timing_signal, action, rr_ratio, tech_snapshot, sector_context, stock_category, full_analysis, changelog_json, reassessed_at, position_advice, strategy_name FROM holding_strategies WHERE code=? AND status='active'", (code,)).fetchone()
if r:
data["name"] = r[0]
data["entry_low"] = r[1] or 0
@@ -98,6 +98,7 @@ def collect_data(code):
data["full_analysis"] = r[11] or ""
data["changelog_json"] = r[12] or ""
data["reassessed_at"] = r[13] or ""
data["strategy_name"] = r[15] or "" # 2026-08-18 来源策略
data["position_advice"] = r[14] or ""
# 持仓状态(2026-07-22 老爸要求:LLM 必须知道是否持有/成本/股数)
hr = conn.execute("SELECT shares, cost, price FROM holdings WHERE code=? AND is_active=1 AND shares>0", (code,)).fetchone()
@@ -318,7 +319,7 @@ def build_prompt(data):
pass
_position_context += _rotation_context
_orig_strategy_section = f"""当前策略参数: {_params_str}
_orig_strategy_section = f"""来源策略: {data.get("strategy_name") or "unknown"}(按此策略选股逻辑重评,可据最新情况调整参数)\n当前策略参数: {_params_str}
变更记录(最近3条):
{_changelog_str}