From e3a18a20d3962e4fde3aaabd5a3c3e59ea8348eb Mon Sep 17 00:00:00 2001 From: Beast Date: Mon, 15 Jun 2026 12:50:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20fetch=5Fmarket.py=20change=5Fpct=20?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E7=BA=AF=E6=95=B0=E5=80=BC=EF=BC=8C=E6=96=B9?= =?UTF-8?q?=E5=90=91=E7=AC=A6=E5=8F=B7=E7=94=B1=E5=89=8D=E7=AB=AF=E6=B8=B2?= =?UTF-8?q?=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - change_pct 从 "▲ 2.26%" 改为 "2.26%",is_up 控制方向 - 与 brief.html 前端渲染逻辑对齐,避免重复方向符号 - 修复 A 股超时后 cn_indices 为空导致行情行缺失的问题 --- scripts/fetch_market.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/fetch_market.py b/scripts/fetch_market.py index 1fb3ccb..40d9a51 100644 --- a/scripts/fetch_market.py +++ b/scripts/fetch_market.py @@ -23,13 +23,12 @@ def fetch_crypto(): continue price = data[coin_id]["usd"] change = data[coin_id].get("usd_24h_change", 0) or 0 - direction = "▲" if change >= 0 else "▼" items.append({ "type": "crypto", "symbol": names[coin_id], "icon": icon, "price": f"${price:,.2f}", - "change_pct": f"{direction} {abs(change):.2f}%", + "change_pct": f"{abs(change):.2f}%", "is_up": change >= 0, }) return items @@ -49,13 +48,11 @@ def fetch_cn_indices(): price = diff.get("f2", 0) change = diff.get("f4", 0) pct = diff.get("f3", 0) - direction = "▲" if change >= 0 else "▼" items.append({ "type": "cn_index", "symbol": name, "price": f"{price:.2f}", - "change": f"{direction} {abs(change):.2f}", - "change_pct": f"{direction} {abs(pct):.2f}%", + "change_pct": f"{abs(pct):.2f}%", "is_up": change >= 0, }) return items