xbalance: use time util function from the util package

This commit is contained in:
c9s 2021-06-26 20:09:40 +08:00
parent c6d66ebb46
commit cef28fa651

View File

@ -56,7 +56,7 @@ func (s *State) SlackAttachment() slack.Attachment {
}
func (s *State) Reset() {
var beginningOfTheDay = Bod(time.Now())
var beginningOfTheDay = util.BeginningOfTheDay(time.Now().Local())
*s = State{
DailyNumberOfTransfers: 0,
DailyAmountOfTransfers: 0,
@ -304,11 +304,6 @@ func (s *Strategy) findLowBalanceLevelSession(sessions map[string]*bbgo.Exchange
return nil, balance, nil
}
func Bod(t time.Time) time.Time {
year, month, day := t.Date()
return time.Date(year, month, day, 0, 0, 0, 0, t.Location())
}
func (s *Strategy) SaveState() {
if err := s.Persistence.Save(s.state, ID, s.Asset, stateKey); err != nil {
log.WithError(err).Errorf("can not save state: %+v", s.state)