bbgo_origin/pkg/util/time.go

18 lines
360 B
Go
Raw Normal View History

package util
import (
"math/rand"
"time"
)
func MillisecondsJitter(d time.Duration, jitterInMilliseconds int) time.Duration {
n := rand.Intn(jitterInMilliseconds)
return d + time.Duration(n)*time.Millisecond
}
2021-06-26 12:09:26 +00:00
func BeginningOfTheDay(t time.Time) time.Time {
year, month, day := t.Date()
return time.Date(year, month, day, 0, 0, 0, 0, t.Location())
}