mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
add State PlainText method test
This commit is contained in:
parent
2652bee83b
commit
933765defb
|
@ -36,6 +36,12 @@ func (s *State) IsOver24Hours() bool {
|
|||
return time.Now().Sub(time.Unix(s.Since, 0)) >= 24*time.Hour
|
||||
}
|
||||
|
||||
func (s *State) PlainText() string {
|
||||
return util.Render(`{{ .Asset }} transfer stats:
|
||||
daily number of transfers: {{ .DailyNumberOfTransfers }}
|
||||
daily amount of transfers {{ .DailyAmountOfTransfers.Float64 }}`, s)
|
||||
}
|
||||
|
||||
func (s *State) SlackAttachment() slack.Attachment {
|
||||
return slack.Attachment{
|
||||
// Pretext: "",
|
||||
|
@ -276,7 +282,7 @@ func (s *Strategy) SaveState() {
|
|||
log.WithError(err).Errorf("can not save state: %+v", s.state)
|
||||
} else {
|
||||
log.Infof("%s %s state is saved: %+v", ID, s.Asset, s.state)
|
||||
s.Notifiability.Notify("%s %s state is saved => %f", ID, s.Asset, s.state)
|
||||
s.Notifiability.Notify("%s %s state is saved", ID, s.Asset, s.state)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
19
pkg/strategy/xbalance/strategy_test.go
Normal file
19
pkg/strategy/xbalance/strategy_test.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package xbalance
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestState_PlainText(t *testing.T) {
|
||||
var state = State{
|
||||
Asset: "USDT",
|
||||
DailyNumberOfTransfers: 1,
|
||||
DailyAmountOfTransfers: fixedpoint.NewFromFloat(1000.0),
|
||||
Since: 0,
|
||||
}
|
||||
|
||||
assert.Equal(t, "USDT transfer stats:\ndaily number of transfers: 1\ndaily amount of transfers 1000", state.PlainText())
|
||||
}
|
Loading…
Reference in New Issue
Block a user