tickerInfo id

This commit is contained in:
zhangkun9038@dingtalk.com 2024-12-23 15:15:37 +08:00
parent 041e79fff0
commit db7fe10de5

View File

@ -5,15 +5,17 @@ import (
"fmt" "fmt"
"reflect" "reflect"
"strconv" "strconv"
"time"
) )
type TickerInfo struct { type TickerInfo struct {
Id string `json:"_id"` Id string `json:"_id"`
InstID string `json:"instID"` InstID string `json:"instID"`
Last float64 `json:"last"` Last float64 `json:"last"`
InstType string `json:"instType"` LastUpdate time.Time `json:"lastUpdate"`
VolCcy24h float64 `json:"volCcy24h"` InstType string `json:"instType"`
Ts int64 `json:"ts"` VolCcy24h float64 `json:"volCcy24h"`
Ts int64 `json:"ts"`
} }
type TickerInfoResp struct { type TickerInfoResp struct {
@ -26,12 +28,13 @@ type TickerInfoResp struct {
func (tir *TickerInfoResp) Convert() TickerInfo { func (tir *TickerInfoResp) Convert() TickerInfo {
ti := TickerInfo{ ti := TickerInfo{
Id: HashString(tir.InstID + tir.Ts), Id: HashString(tir.InstID + tir.Ts),
InstID: tir.InstID, InstID: tir.InstID,
InstType: tir.InstType, InstType: tir.InstType,
Last: ToFloat64(tir.Last), Last: ToFloat64(tir.Last),
VolCcy24h: ToFloat64(tir.VolCcy24h), VolCcy24h: ToFloat64(tir.VolCcy24h),
Ts: ToInt64(tir.Ts), Ts: ToInt64(tir.Ts),
LastUpdate: time.Now(),
} }
return ti return ti
} }