mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
refactor: add IsOver
to check the since time is over given duration
This commit is contained in:
parent
2c4b6e8cd1
commit
52412d9ead
|
@ -240,9 +240,14 @@ func (s *ProfitStats) AddTrade(trade Trade) {
|
||||||
s.AccumulatedVolume = s.AccumulatedVolume.Add(trade.Quantity)
|
s.AccumulatedVolume = s.AccumulatedVolume.Add(trade.Quantity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsOver checks if the since time is over given duration
|
||||||
|
func (s *ProfitStats) IsOver(d time.Duration) bool {
|
||||||
|
return time.Since(time.Unix(s.TodaySince, 0)) >= d
|
||||||
|
}
|
||||||
|
|
||||||
// IsOver24Hours checks if the since time is over 24 hours
|
// IsOver24Hours checks if the since time is over 24 hours
|
||||||
func (s *ProfitStats) IsOver24Hours() bool {
|
func (s *ProfitStats) IsOver24Hours() bool {
|
||||||
return time.Since(time.Unix(s.TodaySince, 0)) >= 24*time.Hour
|
return s.IsOver(24 * time.Hour)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ProfitStats) ResetToday(t time.Time) {
|
func (s *ProfitStats) ResetToday(t time.Time) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user