diff --git a/backend/internal/datasource/tickflow.go b/backend/internal/datasource/tickflow.go index 834b44d..d9c2ec7 100644 --- a/backend/internal/datasource/tickflow.go +++ b/backend/internal/datasource/tickflow.go @@ -38,13 +38,14 @@ type Quote struct { } `json:"ext"` } -// ChangePct 优先使用 ext.change_pct,否则根据 close/prev_close 计算。 +// ChangePct 优先使用 ext.change_pct(tickflow 返回小数,如 0.30 = 30%), +// 否则根据 close/prev_close 计算并统一返回小数形式。 func (q *Quote) ChangePct() float64 { if q.Ext.ChangePct != 0 { return q.Ext.ChangePct } if q.PrevClose != 0 { - return (q.Close - q.PrevClose) / q.PrevClose * 100 + return (q.Close - q.PrevClose) / q.PrevClose } return 0 } diff --git a/frontend/src/components/StockOverview.tsx b/frontend/src/components/StockOverview.tsx index c117146..b2c6561 100644 --- a/frontend/src/components/StockOverview.tsx +++ b/frontend/src/components/StockOverview.tsx @@ -133,7 +133,7 @@ export function StockOverview({ role }: StockOverviewProps) { } label="平均涨跌" - value={`${avg_change_pct >= 0 ? '+' : ''}${avg_change_pct.toFixed(2)}%`} + value={`${avg_change_pct >= 0 ? '+' : ''}${(avg_change_pct * 100).toFixed(2)}%`} valueClass={avg_change_pct >= 0 ? 'text-bull' : 'text-bear'} /> @@ -186,7 +186,7 @@ function IndexCard({ item }: { item: StockRow }) { {item.close.toFixed(2)}
- {positive ? '+' : ''}{item.change_pct.toFixed(2)}% + {positive ? '+' : ''}{(item.change_pct * 100).toFixed(2)}%
) @@ -209,7 +209,7 @@ function StockList({
暂无数据
) : ( rows.map((item, idx) => { - const val = valueKey === 'amount' ? (item.amount ?? 0) / 1e8 : item.change_pct + const val = valueKey === 'amount' ? (item.amount ?? 0) / 1e8 : item.change_pct * 100 const isPositive = valueKey === 'amount' ? true : item.change_pct >= 0 return (