修改金钱单位为分,类型Price,并校对分时数据

This commit is contained in:
钱纯净
2024-11-14 22:52:49 +08:00
parent cc02843a1e
commit 682c982ae2

View File

@@ -43,7 +43,7 @@ type Kline struct {
Low Price //最低价
Close Price //收盘价,如果是当天,则是最新价/实时价
Volume int64 //成交量
Amount float64 //成交额
Amount Price //成交额
Time time.Time //时间
}
@@ -52,7 +52,7 @@ func (this *Kline) String() string {
this.Time.Format("2006-01-02 15:04:05"),
this.Last, this.Open, this.High, this.Low, this.Close,
this.RisePrice(), this.RiseRate(),
Int64UnitString(this.Volume), FloatUnitString(this.Amount),
Int64UnitString(this.Volume), FloatUnitString(this.Amount.Float64()),
)
}
@@ -138,7 +138,7 @@ func (kline) Decode(bs []byte, Type uint8) (*KlineResp, error) {
last = last + open + _close
k.Volume = int64(getVolume(Uint32(bs[:4])) / 100)
k.Amount = getVolume(Uint32(bs[4:8]))
k.Amount = Price(getVolume(Uint32(bs[4:8])) * 100) //转为分,并去除多余的小数
bs = bs[8:]
resp.List = append(resp.List, k)