fix: fetch_market.py change_pct 输出纯数值,方向符号由前端渲染
- change_pct 从 "▲ 2.26%" 改为 "2.26%",is_up 控制方向 - 与 brief.html 前端渲染逻辑对齐,避免重复方向符号 - 修复 A 股超时后 cn_indices 为空导致行情行缺失的问题
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user