fix: refresh_macro_context大盘描述用真实温区(不写死震荡)——当前trend_up→大盘强势(趋势市)
This commit is contained in:
@@ -42,15 +42,39 @@ def main():
|
|||||||
# 计算偏向
|
# 计算偏向
|
||||||
sh = indices.get("上证指数", {})
|
sh = indices.get("上证指数", {})
|
||||||
sh_change = sh.get("change_pct", 0) if sh else 0
|
sh_change = sh.get("change_pct", 0) if sh else 0
|
||||||
if sh_change < -1.5:
|
# 2026-08-19 修复:大盘描述用 market_regime 真实温区(不写死"震荡")
|
||||||
overall = "bearish"
|
# 原逻辑:涨跌±1.5%内→永远"大盘震荡"(每30min一条无意义通知,老莫)
|
||||||
desc = "大盘偏弱"
|
# 温区映射:trend_up=强势 / trend_down=弱势 / choppy=震荡(真实ADX判定)
|
||||||
elif sh_change > 1.0:
|
_regime = "unknown"
|
||||||
|
try:
|
||||||
|
import sqlite3 as _sq3
|
||||||
|
_c3 = _sq3.connect(str(DB), timeout=5)
|
||||||
|
_r3 = _c3.execute("SELECT regime FROM market_regime WHERE market='a' ORDER BY date DESC LIMIT 1").fetchone()
|
||||||
|
_c3.close()
|
||||||
|
if _r3:
|
||||||
|
_regime = _r3[0] or "unknown"
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if _regime == "trend_up":
|
||||||
overall = "bullish"
|
overall = "bullish"
|
||||||
desc = "大盘偏强"
|
desc = "大盘强势(趋势市)"
|
||||||
else:
|
elif _regime == "trend_down":
|
||||||
|
overall = "bearish"
|
||||||
|
desc = "大盘弱势(下跌趋势)"
|
||||||
|
elif _regime == "choppy":
|
||||||
overall = "neutral"
|
overall = "neutral"
|
||||||
desc = "大盘震荡"
|
desc = "大盘震荡(ADX<20)"
|
||||||
|
else:
|
||||||
|
# 温区不可用 → 退回涨跌幅度判断
|
||||||
|
if sh_change < -1.5:
|
||||||
|
overall = "bearish"
|
||||||
|
desc = "大盘偏弱"
|
||||||
|
elif sh_change > 1.0:
|
||||||
|
overall = "bullish"
|
||||||
|
desc = "大盘偏强"
|
||||||
|
else:
|
||||||
|
overall = "neutral"
|
||||||
|
desc = "大盘震荡"
|
||||||
|
|
||||||
structure = json.dumps({"overall": overall, "description": desc}, ensure_ascii=False)
|
structure = json.dumps({"overall": overall, "description": desc}, ensure_ascii=False)
|
||||||
indices_json = json.dumps(indices, ensure_ascii=False)
|
indices_json = json.dumps(indices, ensure_ascii=False)
|
||||||
|
|||||||
Reference in New Issue
Block a user