From 34992de89851d4ef1985519a4364e560c0c57ad6 Mon Sep 17 00:00:00 2001 From: xxm Date: Fri, 21 Aug 2026 11:40:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(realtime=5Findicators):=20=E7=94=A8live=5Fp?= =?UTF-8?q?rices=E5=AE=9E=E6=97=B6=E4=BB=B7=E6=A0=BC=E6=9B=BF=E4=BB=A3stoc?= =?UTF-8?q?k=5Fdaily=E6=94=B6=E7=9B=98=E4=BB=B7,=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E4=BB=8A=E6=97=A5=E6=95=B0=E6=8D=AE=E5=86=99=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/realtime_indicators.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/deploy/profile-scripts/realtime_indicators.py b/deploy/profile-scripts/realtime_indicators.py index 7191dd82..8968f543 100644 --- a/deploy/profile-scripts/realtime_indicators.py +++ b/deploy/profile-scripts/realtime_indicators.py @@ -17,6 +17,15 @@ def calc_realtime_indicators(code, price, date_str=None): conn = sqlite3.connect(DB, timeout=30) + # 用 live_prices 的实时价格作为最新价(而非 stock_daily 的收盘价) + lp = conn.execute("SELECT price FROM live_prices WHERE code=?", (code,)).fetchone() + if lp and lp[0]: + latest_price = float(lp[0]) + else: + # fallback 到 stock_daily + dr = conn.execute("SELECT close FROM stock_daily WHERE code=? ORDER BY date DESC LIMIT 1", (code,)).fetchone() + latest_price = float(dr[0]) if dr and dr[0] else price + # 读最近60日K线(计算MA/RSI/bias60需要) rows = conn.execute( "SELECT date, close FROM stock_daily WHERE code=? ORDER BY date DESC LIMIT 60", @@ -27,6 +36,8 @@ def calc_realtime_indicators(code, price, date_str=None): return None closes = [r[1] for r in rows if r[1]] + if latest_price: + closes = [latest_price] + closes # 实时价格在最前 if not closes: conn.close() return None