From 00f6e84f2ebc1d31ba17becc0493e8825be58063 Mon Sep 17 00:00:00 2001 From: xxm Date: Mon, 17 Aug 2026 20:07:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=A1=E8=AE=A1=E4=BF=AE=E5=A4=8D(exp?= =?UTF-8?q?lore=E5=8F=91=E7=8E=B0)=20-=20candidate=5Ffilter=E8=B5=84?= =?UTF-8?q?=E9=87=91=E6=B5=81=E8=AF=BB=E5=88=B0=E6=97=A7id=3D194=E2=86=92W?= =?UTF-8?q?HERE=20id=3D1(critical)=20-=20strategy=5Flifecycle=20sector=5Fs?= =?UTF-8?q?napshots=E5=85=A8=E8=A1=A8133907=E8=A1=8C=E2=86=92=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E5=BF=AB=E7=85=A7(major)=20-=20strategy=5Flifecycle?= =?UTF-8?q?=E8=A1=8C=E4=B8=9A=E8=AF=BB=E5=8F=96=E5=8A=A0stock=5Fsectors=5F?= =?UTF-8?q?em=E5=9B=9E=E9=80=80(2=E5=A4=84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/candidate_filter.py | 2 +- deploy/profile-scripts/strategy_lifecycle.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/deploy/profile-scripts/candidate_filter.py b/deploy/profile-scripts/candidate_filter.py index d5fc1a52..f1a22dad 100644 --- a/deploy/profile-scripts/candidate_filter.py +++ b/deploy/profile-scripts/candidate_filter.py @@ -287,7 +287,7 @@ def stage6_narrative(code, name): flow_trend = "中性" try: import json as _j - fr = conn.execute("SELECT cache_json FROM capital_flow_cache ORDER BY id DESC LIMIT 1").fetchone() + fr = conn.execute("SELECT cache_json FROM capital_flow_cache WHERE id=1 ORDER BY updated_at DESC LIMIT 1").fetchone() if fr and fr[0]: fc = _j.loads(fr[0]) a = (fc.get("stocks", {}).get(code, {}) or {}).get("analysis", {}) diff --git a/deploy/profile-scripts/strategy_lifecycle.py b/deploy/profile-scripts/strategy_lifecycle.py index 1022a274..7dcf4d08 100644 --- a/deploy/profile-scripts/strategy_lifecycle.py +++ b/deploy/profile-scripts/strategy_lifecycle.py @@ -181,6 +181,8 @@ def enforce_strategy_quality(code, name, result): try: _db = sqlite3.connect("/home/hmo/MoFin/data/mofin.db", timeout=5) r = _db.execute("SELECT sector_name FROM stock_sectors WHERE code=?", (code_str,)).fetchone() + if not r or not r[0]: + r = _db.execute("SELECT sector FROM stock_sectors_em WHERE code=?", (code_str,)).fetchone() _db.close() return r[0] if r else None except: @@ -1337,7 +1339,7 @@ def reassess_strategy(code, name, price, cost, shares, current_action, try: _db2 = sqlite3.connect("/home/hmo/MoFin/data/mofin.db", timeout=5) _rows2 = _db2.execute( - "SELECT name, change_pct FROM sector_snapshots ORDER BY change_pct DESC" + "SELECT name, change_pct FROM sector_snapshots WHERE snapshot_id=(SELECT MAX(snapshot_id) FROM sector_snapshots) ORDER BY change_pct DESC" ).fetchall() if _rows2: # 找到该股所属行业(简单匹配name或通过stock_sectors) @@ -1345,6 +1347,11 @@ def reassess_strategy(code, name, price, cost, shares, current_action, "SELECT sector_name FROM stock_sectors WHERE code=?", (code,) ).fetchall() + if not _my_sectors: + _my_sectors = _db2.execute( + "SELECT sector FROM stock_sectors_em WHERE code=?", + (code,) + ).fetchall() if _my_sectors: for (_sn,) in _my_sectors: for r_name, r_chg in _rows2: