From 552645b3070d6fdbcd5b4036da43cf61b3c85e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Thu, 9 Jul 2026 21:30:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=B7=E6=A0=BC=E4=BB=8E=E8=85=BE?= =?UTF-8?q?=E8=AE=AFAPI=E5=AE=9E=E6=97=B6=E6=8B=89(=E7=9B=98=E5=90=8E?= =?UTF-8?q?=E5=8F=AF=E7=94=A8)+=E8=A1=8C=E4=B8=9A=E4=BB=8Estock=5Fsectors?= =?UTF-8?q?=E8=A1=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/per_stock_reassess.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/per_stock_reassess.py b/scripts/per_stock_reassess.py index a33204b9..b905e03f 100644 --- a/scripts/per_stock_reassess.py +++ b/scripts/per_stock_reassess.py @@ -83,7 +83,7 @@ def _build_full_analysis(code, entry, result): macro_desc = "腾讯实时 " + " ".join(_parts[:3]) except: pass - # 基本面:直接从腾讯API拉(静态数据,随时可用) + # 基本面+实时价:直接从腾讯API拉(盘后也有收盘价) try: _pfx = "sh" if str(code).startswith(("6", "9")) else "sz" _r3 = __import__('subprocess').run(["curl", "-s", f"http://qt.gtimg.cn/q={_pfx}{code}"], @@ -94,15 +94,15 @@ def _build_full_analysis(code, entry, result): _pe = _p3[39] if _p3[39] else "" _pb = _p3[40] if len(_p3) > 40 and _p3[40] else "" _mcap = _p3[44] if len(_p3) > 44 and _p3[44] else "" - _name3 = _p3[1] if _p3[1] else "" + _price_now = float(_p3[3]) if _p3[3] else 0 + _chg_now = float(_p3[32]) if len(_p3) > 32 and _p3[32] else 0 + if _price_now > 0: + price = _price_now # 覆盖策略中的price=0 if _pe: pe_val = f"PE={_pe}" if _pb: pb_val = f"PB={_pb}" if _mcap: mcap_val = f"市值{float(_mcap)/10000:.1f}亿" if float(_mcap) > 10000 else f"市值{_mcap}万" pe_val += f" {mcap_val}" if pe_val else mcap_val - # 如果还没有大盘数据,顺便从同一响应拿指数 - if not macro_desc: - macro_desc = f"{_name3}实时行情" except: pass _db.close() @@ -140,6 +140,16 @@ def _build_full_analysis(code, entry, result): lines.append(f"⑥ 支撑阻力:强撑{sr_m.group(1)}→弱撑{sr_m.group(2)}→弱压{sr_m.group(3)}→强压{sr_m.group(4)}") if sector: lines.append(f"⑦ 行业背景:{sector}") + else: + # 从stock_sectors表补行业 + try: + _s2 = __import__('sqlite3').connect("/home/hmo/MoFin/data/mofin.db") + _sr = _s2.execute("SELECT sector FROM stock_sectors WHERE code=? LIMIT 1", (code,)).fetchone() + if _sr and _sr[0]: + lines.append(f"⑦ 行业背景:{_sr[0]}") + _s2.close() + except: + pass if category: lines.append(f"⑧ 分类评级:{category}") lines.append(f"⑨ 策略信号:{signal}")