fix(prompt): 修复stock_indicators查询—移除不存在的bias20列,补dist_ma20/vol_ratio
This commit is contained in:
@@ -165,16 +165,17 @@ def collect_data(code):
|
|||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
_db2 = sqlite3.connect(DB, timeout=30)
|
_db2 = sqlite3.connect(DB, timeout=30)
|
||||||
_fi = _db2.execute("SELECT mcap_q, pe_q, bias60, bias20, rsi, r5f, dist_lo20 FROM stock_indicators WHERE code=? ORDER BY date DESC LIMIT 1", (code,)).fetchone()
|
_fi = _db2.execute("SELECT mcap_q, pe_q, bias60, rsi, r5f, dist_lo20, dist_ma20, vol_ratio FROM stock_indicators WHERE code=? ORDER BY date DESC LIMIT 1", (code,)).fetchone()
|
||||||
if _fi:
|
if _fi:
|
||||||
data["factor_mcap_q"] = _fi[0] if _fi[0] is not None else None
|
data["factor_mcap_q"] = _fi[0] if _fi[0] is not None else None
|
||||||
data["factor_pe_q"] = _fi[1] if _fi[1] is not None else None
|
data["factor_pe_q"] = _fi[1] if _fi[1] is not None else None
|
||||||
data["factor_bias60"] = _fi[2] if _fi[2] is not None else None
|
data["factor_bias60"] = _fi[2] if _fi[2] is not None else None
|
||||||
data["factor_bias20"] = _fi[3] if _fi[3] is not None else None
|
if data.get("ta_rsi") is None and _fi[3] is not None:
|
||||||
if data.get("ta_rsi") is None and _fi[4] is not None:
|
data["ta_rsi"] = round(_fi[3], 1)
|
||||||
data["ta_rsi"] = round(_fi[4], 1)
|
data["factor_ret5d"] = _fi[4] if _fi[4] is not None else None
|
||||||
data["factor_ret5d"] = _fi[5] if _fi[5] is not None else None
|
data["factor_dist_lo20"] = _fi[5] if _fi[5] is not None else None
|
||||||
data["factor_dist_lo20"] = _fi[6] if _fi[6] is not None else None
|
data["factor_dist_ma20"] = _fi[6] if _fi[6] is not None else None
|
||||||
|
data["factor_vol_ratio"] = _fi[7] if _fi[7] is not None else None
|
||||||
_db2.close()
|
_db2.close()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
@@ -475,7 +476,7 @@ def build_prompt(data):
|
|||||||
if data.get("mtf_monthly_trend"):
|
if data.get("mtf_monthly_trend"):
|
||||||
_tech_parts.append(f"月线={data['mtf_monthly_trend']}")
|
_tech_parts.append(f"月线={data['mtf_monthly_trend']}")
|
||||||
_factor_parts = []
|
_factor_parts = []
|
||||||
for _fk, _fl in [("factor_mcap_q", "市值分位"), ("factor_pe_q", "PE分位"), ("factor_bias60", "bias60"), ("factor_bias20", "bias20"), ("factor_ret5d", "5日涨幅"), ("factor_dist_lo20", "距20日低点")]:
|
for _fk, _fl in [("factor_mcap_q", "市值分位"), ("factor_pe_q", "PE分位"), ("factor_bias60", "bias60"), ("factor_ret5d", "5日涨幅"), ("factor_dist_lo20", "距20日低点"), ("factor_dist_ma20", "距MA20"), ("factor_vol_ratio", "量比")]:
|
||||||
if data.get(_fk) is not None:
|
if data.get(_fk) is not None:
|
||||||
_factor_parts.append(f"{_fl}={data[_fk]}")
|
_factor_parts.append(f"{_fl}={data[_fk]}")
|
||||||
if _factor_parts:
|
if _factor_parts:
|
||||||
|
|||||||
Reference in New Issue
Block a user