feat: 股票详情页增加最新交易日PE/PB/ROE/换手率/市值等行情指标
- 后端tencent.py增加换手率/市盈率/市净率/总市值/流通市值字段提取 - 前端StockQuote接口新增对应字段类型定义 - 股票详情页增加"行情指标"卡片,展示PE/PB/ROE/换手率/总手/成交额/市值 - ROE取自财务分析数据的加权净资产收益率 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -142,10 +142,11 @@ async def fetch_quote(code: str) -> Optional[dict]:
|
||||
return None
|
||||
text = resp.content.decode("gbk", errors="replace")
|
||||
parts = parse_tencent_data(text)
|
||||
if not parts or len(parts) < 38:
|
||||
if not parts or len(parts) < 46:
|
||||
return None
|
||||
# 字段索引(1-based):1=名称, 3=当前价, 4=昨收, 5=今开, 6=成交量(手)
|
||||
# 字段索引:1=名称, 3=当前价, 4=昨收, 5=今开, 6=成交量(手)
|
||||
# 7=外盘, 8=内盘, 31=涨跌额, 32=涨跌幅%, 33=最高, 34=最低, 37=成交额(万)
|
||||
# 38=换手率%, 39=市盈率, 43=总市值, 44=流通市值, 45=市净率
|
||||
name = parts[1] or ""
|
||||
current_price = float(parts[3]) if parts[3] else 0
|
||||
yesterday_close = float(parts[4]) if parts[4] else 0
|
||||
@@ -158,6 +159,11 @@ async def fetch_quote(code: str) -> Optional[dict]:
|
||||
change_pct = float(parts[32]) if parts[32] else 0
|
||||
outer_disk = float(parts[7]) if parts[7] else 0
|
||||
inner_disk = float(parts[8]) if parts[8] else 0
|
||||
turnover_rate = float(parts[38]) if parts[38] else 0 # 换手率%
|
||||
pe = float(parts[39]) if parts[39] else 0 # 市盈率
|
||||
total_market_cap = float(parts[43]) if parts[43] else 0 # 总市值
|
||||
circulating_market_cap = float(parts[44]) if parts[44] else 0 # 流通市值
|
||||
pb = float(parts[45]) if parts[45] else 0 # 市净率
|
||||
|
||||
if not name or current_price == 0:
|
||||
return None
|
||||
@@ -186,6 +192,11 @@ async def fetch_quote(code: str) -> Optional[dict]:
|
||||
"time": now.strftime("%H:%M:%S"),
|
||||
"change": round(change, 2),
|
||||
"changePercent": round(change_percent, 2),
|
||||
"turnoverRate": round(turnover_rate, 2),
|
||||
"pe": round(pe, 2) if pe else 0,
|
||||
"pb": round(pb, 2) if pb else 0,
|
||||
"totalMarketCap": round(total_market_cap, 2),
|
||||
"circulatingMarketCap": round(circulating_market_cap, 2),
|
||||
}
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user