From fd772ebdf21b734273f921232df8ed07b2b22a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=B7=E5=B0=8F=E5=89=8D?= Date: Thu, 22 Jan 2026 17:48:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0ios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 44ecec06..a51acbf3 100755 --- a/app.py +++ b/app.py @@ -7128,6 +7128,18 @@ def get_watchlist_realtime(): change = latest['close'] - prev_close change_percent = (change / prev_close * 100) if prev_close > 0 else 0.0 + # 处理 timestamp:可能是 datetime 对象或 ISO 字符串 + ts = latest['timestamp'] + if ts: + if isinstance(ts, str): + # 从缓存获取的是 ISO 字符串,提取时间部分 + update_time = ts.split('T')[1][:8] if 'T' in ts else ts[:8] + else: + # 从 ClickHouse 获取的是 datetime 对象 + update_time = ts.strftime('%H:%M:%S') + else: + update_time = '--:--:--' + quotes_data[code6] = { 'price': latest['close'], 'prev_close': prev_close, @@ -7137,7 +7149,7 @@ def get_watchlist_realtime(): 'low': latest['low'], 'volume': latest['volume'], 'amount': latest['amount'], - 'update_time': latest['timestamp'].strftime('%H:%M:%S') + 'update_time': update_time } # 如果分钟数据为空,从 ea_trade 获取最新日线数据作为 fallback