fix(prompt): 修复数据断裂——行业强度进LLM+移除死数据
- collect_data(): 从sector_snapshots读取行业涨跌/排名 - build_prompt(): 注入行业强度数据(行业涨跌%+排名) - 移除current_regime_strategies死数据(旧策略名不匹配strategy_defs) - 港股缺资金流(数据采集层限制,非代码问题)
This commit is contained in:
@@ -178,6 +178,22 @@ def collect_data(code):
|
||||
_db2.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 行业强度(sector_snapshots: market_watch.py 写入的板块涨跌排名)
|
||||
try:
|
||||
_db3 = sqlite3.connect(DB, timeout=30)
|
||||
_sector = data.get("sector_context", "")
|
||||
if _sector:
|
||||
_ss = _db3.execute(
|
||||
"SELECT change_pct, rank_in_market FROM sector_snapshots "
|
||||
"WHERE sector_name LIKE ? ORDER BY date DESC LIMIT 1",
|
||||
(f"%{_sector}%",)).fetchone()
|
||||
if _ss:
|
||||
data["sector_change_pct"] = _ss[0] if _ss[0] is not None else None
|
||||
data["sector_rank"] = _ss[1] if _ss[1] is not None else None
|
||||
_db3.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 情势体检:温区 + 高风险消息 + 执行红线
|
||||
_sit = {"regime_a": "unknown", "regime_7d_ago": "unknown", "high_risk": "", "breach_stop": "否", "reach_tp": "否", "out_zone": "否", "over_hold": "否"}
|
||||
@@ -229,23 +245,7 @@ def collect_data(code):
|
||||
"status": _pm[6], "retired_reason": _pm[7], "superseded_by": _pm[8], "regime": _pm[9],
|
||||
}
|
||||
data["pos_mgmt_triggered"] = True
|
||||
# 当前温区合格策略
|
||||
try:
|
||||
import os as _os
|
||||
import json as _json2
|
||||
_wf = "/home/hmo/MoFin/data/strategy_weights.json"
|
||||
if _os.path.exists(_wf):
|
||||
_wdata = _json2.load(open(_wf, encoding="utf-8"))
|
||||
_ra = _wdata.get("regime_active", {})
|
||||
_cur_rg = data.get("situation", {}).get("regime_a", "unknown")
|
||||
data["current_regime_strategies"] = _ra.get(_cur_rg, [])
|
||||
data["current_regime"] = _cur_rg
|
||||
else:
|
||||
data["current_regime_strategies"] = []
|
||||
data["current_regime"] = data.get("situation", {}).get("regime_a", "unknown")
|
||||
except Exception:
|
||||
data["current_regime_strategies"] = []
|
||||
data["current_regime"] = data.get("situation", {}).get("regime_a", "unknown")
|
||||
# current_regime_strategies 已移除(旧策略名与strategy_defs不匹配)
|
||||
except Exception:
|
||||
pass
|
||||
conn.close()
|
||||
@@ -632,7 +632,7 @@ accumulation(主力建仓) / b_td1_v3(超跌原池优选) / v_mr(弱市深超跌
|
||||
大盘:{data.get('macro','震荡')}{_macro_label}
|
||||
最新价:{data.get('price',0)} 涨跌:{data.get('change_pct','0')}%{_price_label}
|
||||
PE={data.get('pe','?')}(最新财报) 市值={data.get('mcap','?')}亿
|
||||
行业:{data.get('sector_context','?')}(近一个交易日)
|
||||
行业:{data.get('sector_context','?')}(近一个交易日){(' 涨跌='+str(data.get('sector_change_pct',''))+'% 排名='+str(data.get('sector_rank',''))) if data.get('sector_change_pct') is not None else ''}{_sector_extra}
|
||||
技术面:{data.get('tech_snapshot','')[:300]}(MA=5/10/20/60日 支撑阻力=近20日 量价=当日+近5日趋势)
|
||||
{_tech_str}
|
||||
{_tech_str}
|
||||
|
||||
Reference in New Issue
Block a user