Compare commits

...

3 Commits

Author SHA1 Message Date
injoyai
80d6d6dfc5 优化 2025-03-20 13:37:34 +08:00
injoyai
a27461740a Merge remote-tracking branch 'origin/master' 2025-03-20 13:19:05 +08:00
injoyai
7a9d59f8f1 优化 2025-03-20 13:18:49 +08:00
3 changed files with 22 additions and 2 deletions

View File

@@ -15,6 +15,16 @@ import (
"time"
)
const (
LevelNone = 0
LevelDebug = 2
LevelWrite = 3
LevelRead = 4
LevelInfo = 5
LevelError = 7
LevelAll = 999
)
// WithDebug 是否打印通讯数据
func WithDebug(b ...bool) client.Option {
return func(c *client.Client) {
@@ -22,6 +32,12 @@ func WithDebug(b ...bool) client.Option {
}
}
func WithLevel(level int) client.Option {
return func(c *client.Client) {
c.Logger.SetLevel(level)
}
}
// WithRedial 断线重连
func WithRedial(b ...bool) client.Option {
return func(c *client.Client) {
@@ -31,6 +47,7 @@ func WithRedial(b ...bool) client.Option {
// DialDefault 默认连接方式
func DialDefault(op ...client.Option) (cli *Client, err error) {
op = append([]client.Option{WithRedial()}, op...)
return DialHostsRange(Hosts, op...)
}

View File

@@ -77,7 +77,10 @@ func (this *Kline) RisePrice() Price {
// RiseRate 涨跌比例/涨跌幅,第一个数据不准,仅做参考
func (this *Kline) RiseRate() float64 {
return float64(this.RisePrice()) / float64(this.Open) * 100
if this.Last == 0 {
return float64(this.Close-this.Open) / float64(this.Open) * 100
}
return float64(this.Close-this.Last) / float64(this.Last) * 100
}
type kline struct{}

View File

@@ -77,7 +77,7 @@ func (this *Workday) Update() error {
now := time.Now()
if lastWorkday == nil || lastWorkday.Unix < IntegerDay(now).Unix() {
resp, err := this.Client.GetKlineDayAll("sh000001")
resp, err := this.Client.GetIndexDayAll("sh000001")
if err != nil {
logs.Err(err)
return err