This commit is contained in:
2021-12-22 19:09:04 +08:00
parent 0ac81a4405
commit 4e0cb3c02c
9 changed files with 126 additions and 72 deletions

View File

@@ -21,6 +21,7 @@ import (
"regexp"
"strconv"
"sync"
"time"
)
const (
@@ -40,6 +41,7 @@ type fund struct {
EstimateVal string `json:"gsz"`
RisePer string `json:"gszzl"`
UpdateTime string `json:"gztime"`
CheckTime time.Time
}
func (f *fund) Name() string {
@@ -64,11 +66,21 @@ func (f *fund) Update() error {
f.EstimateVal = ff.EstimateVal
f.RisePer = ff.RisePer
f.UpdateTime = ff.UpdateTime
f.CheckTime = time.Now()
}
return err
}
func (f *fund) Msg() string {
now := time.Now()
h := now.Hour()
if h > 9 && h < 15 && now.Sub(f.CheckTime) > time.Minute*5 {
err := f.Update()
if err != nil {
logx.Error(err)
}
}
var rise string
last, err1 := strconv.ParseFloat(f.UnitVal, 64)
cur, err2 := strconv.ParseFloat(f.EstimateVal, 64)