This commit is contained in:
injoyai
2025-03-20 13:18:49 +08:00
parent 3ea8d50cd7
commit 7a9d59f8f1
2 changed files with 21 additions and 1 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{}