修复分时K线成交量数据未除以100的问题,修改成交量为int64,浮点时0是很长的小数0.0...xxx

This commit is contained in:
钱纯净
2024-11-14 22:46:51 +08:00
parent 063527dbd8
commit cc02843a1e
2 changed files with 7 additions and 3 deletions

View File

@@ -42,7 +42,7 @@ type Kline struct {
High Price //最高价 High Price //最高价
Low Price //最低价 Low Price //最低价
Close Price //收盘价,如果是当天,则是最新价/实时价 Close Price //收盘价,如果是当天,则是最新价/实时价
Volume float64 //成交量 Volume int64 //成交量
Amount float64 //成交额 Amount float64 //成交额
Time time.Time //时间 Time time.Time //时间
} }
@@ -52,7 +52,7 @@ func (this *Kline) String() string {
this.Time.Format("2006-01-02 15:04:05"), this.Time.Format("2006-01-02 15:04:05"),
this.Last, this.Open, this.High, this.Low, this.Close, this.Last, this.Open, this.High, this.Low, this.Close,
this.RisePrice(), this.RiseRate(), this.RisePrice(), this.RiseRate(),
FloatUnitString(this.Volume), FloatUnitString(this.Amount), Int64UnitString(this.Volume), FloatUnitString(this.Amount),
) )
} }
@@ -137,7 +137,7 @@ func (kline) Decode(bs []byte, Type uint8) (*KlineResp, error) {
k.Low = (open + last + low) / 10 k.Low = (open + last + low) / 10
last = last + open + _close last = last + open + _close
k.Volume = getVolume(Uint32(bs[:4])) k.Volume = int64(getVolume(Uint32(bs[:4])) / 100)
k.Amount = getVolume(Uint32(bs[4:8])) k.Amount = getVolume(Uint32(bs[4:8]))
bs = bs[8:] bs = bs[8:]

View File

@@ -89,6 +89,10 @@ func IntUnitString(n int) string {
return FloatUnitString(float64(n)) return FloatUnitString(float64(n))
} }
func Int64UnitString(n int64) string {
return FloatUnitString(float64(n))
}
func GetHourMinute(bs [2]byte) string { func GetHourMinute(bs [2]byte) string {
n := Uint16(bs[:]) n := Uint16(bs[:])
h := n / 60 h := n / 60