mirror of
https://github.com/injoyai/tdx.git
synced 2025-11-26 21:25:35 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80d6d6dfc5 | ||
|
|
a27461740a | ||
|
|
7a9d59f8f1 |
17
client.go
17
client.go
@@ -15,6 +15,16 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
LevelNone = 0
|
||||||
|
LevelDebug = 2
|
||||||
|
LevelWrite = 3
|
||||||
|
LevelRead = 4
|
||||||
|
LevelInfo = 5
|
||||||
|
LevelError = 7
|
||||||
|
LevelAll = 999
|
||||||
|
)
|
||||||
|
|
||||||
// WithDebug 是否打印通讯数据
|
// WithDebug 是否打印通讯数据
|
||||||
func WithDebug(b ...bool) client.Option {
|
func WithDebug(b ...bool) client.Option {
|
||||||
return func(c *client.Client) {
|
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 断线重连
|
// WithRedial 断线重连
|
||||||
func WithRedial(b ...bool) client.Option {
|
func WithRedial(b ...bool) client.Option {
|
||||||
return func(c *client.Client) {
|
return func(c *client.Client) {
|
||||||
@@ -31,6 +47,7 @@ func WithRedial(b ...bool) client.Option {
|
|||||||
|
|
||||||
// DialDefault 默认连接方式
|
// DialDefault 默认连接方式
|
||||||
func DialDefault(op ...client.Option) (cli *Client, err error) {
|
func DialDefault(op ...client.Option) (cli *Client, err error) {
|
||||||
|
op = append([]client.Option{WithRedial()}, op...)
|
||||||
return DialHostsRange(Hosts, op...)
|
return DialHostsRange(Hosts, op...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,10 @@ func (this *Kline) RisePrice() Price {
|
|||||||
|
|
||||||
// RiseRate 涨跌比例/涨跌幅,第一个数据不准,仅做参考
|
// RiseRate 涨跌比例/涨跌幅,第一个数据不准,仅做参考
|
||||||
func (this *Kline) RiseRate() float64 {
|
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{}
|
type kline struct{}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ func (this *Workday) Update() error {
|
|||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
if lastWorkday == nil || lastWorkday.Unix < IntegerDay(now).Unix() {
|
if lastWorkday == nil || lastWorkday.Unix < IntegerDay(now).Unix() {
|
||||||
resp, err := this.Client.GetKlineDayAll("sh000001")
|
resp, err := this.Client.GetIndexDayAll("sh000001")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logs.Err(err)
|
logs.Err(err)
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user