mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
service/backtest: filter klines that will be closed in the future
This commit is contained in:
parent
49728622bc
commit
5d85ceeec4
|
@ -37,6 +37,7 @@ func (s *BacktestService) SyncKLineByInterval(ctx context.Context, exchange type
|
|||
_, _ = s.DB.Exec("PRAGMA synchronous = NORMAL")
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
tasks := []SyncTask{
|
||||
{
|
||||
Type: types.KLine{},
|
||||
|
@ -46,7 +47,16 @@ func (s *BacktestService) SyncKLineByInterval(ctx context.Context, exchange type
|
|||
},
|
||||
Filter: func(obj interface{}) bool {
|
||||
k := obj.(types.KLine)
|
||||
return !k.EndTime.Before(k.StartTime.Time().Add(k.Interval.Duration() - time.Second))
|
||||
if k.EndTime.Before(k.StartTime.Time().Add(k.Interval.Duration() - time.Second)) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Filter klines that has the endTime closed in the future
|
||||
if k.EndTime.After(now) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
ID: func(obj interface{}) string {
|
||||
kline := obj.(types.KLine)
|
||||
|
|
Loading…
Reference in New Issue
Block a user