fix: change_pct 统一按小数存储并前端乘以100展示
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user