debug
This commit is contained in:
parent
191a813108
commit
05a1c4529c
34
candle.go
34
candle.go
@ -228,13 +228,13 @@ func (core *Core) SaveCandle(instId string, period string, rsp *CandleData, dura
|
|||||||
func (candle *Candle) PushToWriteLogChan(cr *Core) error {
|
func (candle *Candle) PushToWriteLogChan(cr *Core) error {
|
||||||
did := candle.InstID + candle.Period + candle.Data[0].(string)
|
did := candle.InstID + candle.Period + candle.Data[0].(string)
|
||||||
candle.Id = HashString(did)
|
candle.Id = HashString(did)
|
||||||
ncd, _ := candle.ToStruct(cr)
|
cl, _ := candle.ToStruct(cr)
|
||||||
logrus.Debug("ncd: ", ncd)
|
logrus.Debug("cl: ", cl)
|
||||||
cd, err := json.Marshal(ncd)
|
cd, err := json.Marshal(cl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("PushToWriteLog json marshal candle err: ", err)
|
logrus.Error("PushToWriteLog json marshal candle err: ", err)
|
||||||
}
|
}
|
||||||
candle = ncd
|
candle = cl
|
||||||
wg := WriteLog{
|
wg := WriteLog{
|
||||||
Content: cd,
|
Content: cd,
|
||||||
Tag: "sardine.log.candle." + candle.Period,
|
Tag: "sardine.log.candle." + candle.Period,
|
||||||
@ -264,57 +264,49 @@ func HashString(input string) string {
|
|||||||
|
|
||||||
func (cl *Candle) ToStruct(core *Core) (*Candle, error) {
|
func (cl *Candle) ToStruct(core *Core) (*Candle, error) {
|
||||||
// cl.Timestamp
|
// cl.Timestamp
|
||||||
ncd := Candle{}
|
|
||||||
ncd.Id = cl.Id
|
|
||||||
ncd.Period = cl.Period
|
|
||||||
ncd.InstID = cl.InstID
|
|
||||||
ncd.From = cl.From
|
|
||||||
ncd.LastUpdate = cl.LastUpdate
|
|
||||||
ncd.Data = cl.Data
|
|
||||||
|
|
||||||
// 将字符串转换为 int64 类型的时间戳
|
// 将字符串转换为 int64 类型的时间戳
|
||||||
ts, err := strconv.ParseInt(cl.Data[0].(string), 10, 64)
|
ts, err := strconv.ParseInt(cl.Data[0].(string), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("Error parsing timestamp:", err)
|
logrus.Error("Error parsing timestamp:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ncd.Timestamp = time.Unix(ts/1000, (ts%1000)*1000000) // 纳秒级别
|
cl.Timestamp = time.Unix(ts/1000, (ts%1000)*1000000) // 纳秒级别
|
||||||
op, err := strconv.ParseFloat(cl.Data[1].(string), 64)
|
op, err := strconv.ParseFloat(cl.Data[1].(string), 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("Error parsing string to float64:", err)
|
logrus.Error("Error parsing string to float64:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ncd.Open = op
|
cl.Open = op
|
||||||
hi, err := strconv.ParseFloat(cl.Data[2].(string), 64)
|
hi, err := strconv.ParseFloat(cl.Data[2].(string), 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("Error parsing string to float64:", err)
|
logrus.Error("Error parsing string to float64:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ncd.High = hi
|
cl.High = hi
|
||||||
lo, err := strconv.ParseFloat(cl.Data[3].(string), 64)
|
lo, err := strconv.ParseFloat(cl.Data[3].(string), 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("Error parsing string to float64:", err)
|
logrus.Error("Error parsing string to float64:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ncd.Low = lo
|
cl.Low = lo
|
||||||
clse, err := strconv.ParseFloat(cl.Data[4].(string), 64)
|
clse, err := strconv.ParseFloat(cl.Data[4].(string), 64)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("Error parsing string to float64:", err)
|
logrus.Error("Error parsing string to float64:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ncd.Close = clse
|
cl.Close = clse
|
||||||
ncd.VolCcy, err = strconv.ParseFloat(cl.Data[6].(string), 64)
|
cl.VolCcy, err = strconv.ParseFloat(cl.Data[6].(string), 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("Error parsing string to float64:", err)
|
logrus.Error("Error parsing string to float64:", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if cl.Data[6].(string) == "1" {
|
if cl.Data[6].(string) == "1" {
|
||||||
ncd.Confirm = true
|
cl.Confirm = true
|
||||||
} else {
|
} else {
|
||||||
ncd.Confirm = false
|
cl.Confirm = false
|
||||||
}
|
}
|
||||||
return &ncd, nil
|
return cl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保证同一个 period, keyName ,在一个周期里,SaveToSortSet只会被执行一次
|
// 保证同一个 period, keyName ,在一个周期里,SaveToSortSet只会被执行一次
|
||||||
|
Loading…
x
Reference in New Issue
Block a user