From cc02843a1e3556e4a49dff2059a9e8c76202791c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=92=B1=E7=BA=AF=E5=87=80?= <1113655791@qq.com> Date: Thu, 14 Nov 2024 22:46:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=86=E6=97=B6K=E7=BA=BF?= =?UTF-8?q?=E6=88=90=E4=BA=A4=E9=87=8F=E6=95=B0=E6=8D=AE=E6=9C=AA=E9=99=A4?= =?UTF-8?q?=E4=BB=A5100=E7=9A=84=E9=97=AE=E9=A2=98,=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=88=90=E4=BA=A4=E9=87=8F=E4=B8=BAint64,=E6=B5=AE=E7=82=B9?= =?UTF-8?q?=E6=97=B60=E6=98=AF=E5=BE=88=E9=95=BF=E7=9A=84=E5=B0=8F?= =?UTF-8?q?=E6=95=B00.0...xxx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocol/model_kline.go | 6 +++--- protocol/unit.go | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/protocol/model_kline.go b/protocol/model_kline.go index 666bafb..bd27f70 100644 --- a/protocol/model_kline.go +++ b/protocol/model_kline.go @@ -42,7 +42,7 @@ type Kline struct { High Price //最高价 Low Price //最低价 Close Price //收盘价,如果是当天,则是最新价/实时价 - Volume float64 //成交量 + Volume int64 //成交量 Amount float64 //成交额 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(), - 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 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])) bs = bs[8:] diff --git a/protocol/unit.go b/protocol/unit.go index 7601ca6..9ddda2c 100644 --- a/protocol/unit.go +++ b/protocol/unit.go @@ -89,6 +89,10 @@ func IntUnitString(n int) string { return FloatUnitString(float64(n)) } +func Int64UnitString(n int64) string { + return FloatUnitString(float64(n)) +} + func GetHourMinute(bs [2]byte) string { n := Uint16(bs[:]) h := n / 60