feat: batch_reassess SIGNAL_JSON重打(prompt末尾机器可读行要求+parse_response直读字段)——上一版fix_structured因mofin_db缩进错误中断未commit被deploy_guard回滚
This commit is contained in:
@@ -712,9 +712,14 @@ accumulation / b_td1_v3 / v_mr / hk_pe_mom / hk_pe_oversold / p_oversold / s2_pa
|
||||
|
||||
⚠️ 输出纪律(必须遵守):
|
||||
1. 直接以【维持或修改】开头,禁止任何寒暄、开场白、分隔线
|
||||
2. 禁止输出 <structured_data> 或任何 XML/JSON/代码块
|
||||
2. 禁止输出 <structured_data> 或任何 XML/代码块(唯一例外:末尾的 SIGNAL_JSON 行)
|
||||
3. 所有【】节标题一个都不能少
|
||||
4. 止损<区间下沿<区间上沿<止盈,违反任一条=输出作废重想"""
|
||||
4. 止损<区间下沿<区间上沿<止盈,违反任一条=输出作废重想
|
||||
5. ⚠️ 最后一行必须是机器可读结论(单行,不加代码块标记):
|
||||
SIGNAL_JSON: {"signal":"买入|可买入|可加仓|关注|观望|持有|弱势持有|卖出|止盈","actionable":true或false,"entry_low":数字或0,"entry_high":数字或0,"stop_loss":数字或0,"take_profit":数字或0,"position_pct":数字0到20,"reason":"一句话"}
|
||||
- signal 必须与【综合结论】完全一致
|
||||
- actionable=true 仅当"当前价格下立即可执行的买入/卖出操作";观望/等待/条件未满足/不符合建仓条件一律 false
|
||||
- 数字字段与【买入区间】【建议止损】【建议止盈】【建议仓位】一致,无则0"""
|
||||
def parse_response(text):
|
||||
"""从LLM回复中提取策略参数。
|
||||
⚠️ 节标题精确匹配:只认行首【买入区间】【综合结论】等节行。
|
||||
@@ -821,6 +826,26 @@ def parse_response(text):
|
||||
result["strategy_switch_to"] = c
|
||||
break
|
||||
|
||||
# ── 2026-08-25 机器可读结论优先(老莫:结构化标注,不靠关键词匹配散文)──
|
||||
_m_json = re.search(r'^SIGNAL_JSON:\s*(\{.*\})\s*$', text, re.M)
|
||||
if _m_json:
|
||||
try:
|
||||
import json as _js
|
||||
_sj = _js.loads(_m_json.group(1))
|
||||
result["signal_json"] = _sj
|
||||
if _sj.get("signal"):
|
||||
result["signal"] = _sj["signal"]
|
||||
for _k, _rk in (("entry_low","entry_low"),("entry_high","entry_high"),
|
||||
("stop_loss","stop_loss"),("take_profit","take_profit")):
|
||||
if _sj.get(_k):
|
||||
result[_rk] = float(_sj[_k])
|
||||
if _sj.get("position_pct") is not None:
|
||||
result["position"] = f"{_sj['position_pct']}%(SIGNAL_JSON)"
|
||||
if result["signal"] in ("买入","可买入","可加仓") and _sj.get("actionable") is False:
|
||||
result["signal"] = "关注"
|
||||
result["actionable_downgraded"] = True
|
||||
except Exception:
|
||||
pass
|
||||
return result
|
||||
|
||||
def save_result(code, full_text, parsed, ta_levels=None):
|
||||
|
||||
Reference in New Issue
Block a user