fix: change_pct 统一按小数存储并前端乘以100展示

This commit is contained in:
2026-07-04 11:06:41 +08:00
parent 5bf4949999
commit 2d967f21ec
2 changed files with 6 additions and 5 deletions
+3 -2
View File
@@ -38,13 +38,14 @@ type Quote struct {
} `json:"ext"`
}
// ChangePct 优先使用 ext.change_pct,否则根据 close/prev_close 计算。
// ChangePct 优先使用 ext.change_pcttickflow 返回小数,如 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
}