add rsi
This commit is contained in:
parent
3b357f0912
commit
7b4e6bdce5
20
rsi.go
20
rsi.go
@ -10,11 +10,12 @@ import (
|
||||
// "os"
|
||||
// "strconv"
|
||||
// "strings"
|
||||
"encoding/json"
|
||||
"time"
|
||||
// simple "github.com/bitly/go-simplejson"
|
||||
// "github.com/go-redis/redis"
|
||||
// "github.com/phyer/texus/utils"
|
||||
// logrus "github.com/sirupsen/logrus"
|
||||
logrus "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type Rsi struct {
|
||||
@ -23,6 +24,7 @@ type Rsi struct {
|
||||
InstID string `json:"instID"`
|
||||
Period string `json:"period"`
|
||||
Timestamp time.Time `json:"timeStamp"`
|
||||
Ts float64 `json:"ts"`
|
||||
LastUpdate time.Time `json:"lastUpdate"`
|
||||
RsiVol float64 `json:"rsiVol"`
|
||||
Confirm bool `json:"confirm"`
|
||||
@ -33,3 +35,19 @@ type RsiList struct {
|
||||
UpdateNickName string `json:"updateNickName"`
|
||||
List []*Rsi `json:"list"`
|
||||
}
|
||||
|
||||
func (rsi *Rsi) PushToWriteLogChan(cr *Core) error {
|
||||
did := rsi.InstID + rsi.Period + ToString(rsi.Ts)
|
||||
rsi.Id = HashString(did)
|
||||
cd, err := json.Marshal(rsi)
|
||||
if err != nil {
|
||||
logrus.Error("PushToWriteLog json marshal rsi err: ", err)
|
||||
}
|
||||
wg := WriteLog{
|
||||
Content: cd,
|
||||
Tag: "sardine.log.rsi." + rsi.Period,
|
||||
Id: rsi.Id,
|
||||
}
|
||||
cr.WriteLogChan <- &wg
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user