mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
service/backtest: check and filter kline by its endTime
This commit is contained in:
parent
834487d568
commit
5e1e0c7661
|
@ -44,6 +44,10 @@ func (s *BacktestService) SyncKLineByInterval(ctx context.Context, exchange type
|
|||
Time: func(obj interface{}) time.Time {
|
||||
return obj.(types.KLine).StartTime.Time()
|
||||
},
|
||||
Filter: func(obj interface{}) bool {
|
||||
k := obj.(types.KLine)
|
||||
return !k.EndTime.Before(k.StartTime.Time().Add(k.Interval.Duration() - time.Millisecond))
|
||||
},
|
||||
ID: func(obj interface{}) string {
|
||||
kline := obj.(types.KLine)
|
||||
return strconv.FormatInt(kline.StartTime.UnixMilli(), 10)
|
||||
|
|
|
@ -35,6 +35,8 @@ type SyncTask struct {
|
|||
OnLoad func(objs interface{})
|
||||
|
||||
// Filter is an optional field, which is used for filtering the remote records
|
||||
// Return true to keep the record,
|
||||
// Return false to filter the record.
|
||||
Filter func(obj interface{}) bool
|
||||
|
||||
// BatchQuery is used for querying remote records.
|
||||
|
|
Loading…
Reference in New Issue
Block a user