Merge pull request #376 from tony1223/bug/backtest-fix-auto-sync

backtest : fix auto sync missing the part from last db kiline to
This commit is contained in:
Yo-An Lin 2021-12-19 14:59:35 +08:00 committed by GitHub
commit 97f9285449
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -337,13 +337,15 @@ func (s *BacktestService) SyncExist(ctx context.Context, exchange types.Exchange
nowStartTime := fromTime nowStartTime := fromTime
for k := range klineC { for k := range klineC {
if nowStartTime.Add(interval.Duration()).Unix() < k.StartTime.Unix() { if nowStartTime.Unix() < k.StartTime.Unix() {
log.Infof("syncing %s interval %s syncing %s ~ %s ", symbol, interval, nowStartTime, k.EndTime) log.Infof("syncing %s interval %s syncing %s ~ %s ", symbol, interval, nowStartTime, k.EndTime)
s.Sync(ctx, exchange, symbol, nowStartTime.Add(interval.Duration()), k.EndTime.Time().Add(-1*interval.Duration()), interval) s.Sync(ctx, exchange, symbol, nowStartTime, k.EndTime.Time().Add(-1*interval.Duration()), interval)
} }
nowStartTime = k.StartTime.Time() nowStartTime = k.StartTime.Time().Add(interval.Duration())
} }
s.Sync(ctx, exchange, symbol, nowStartTime, endTime, interval)
if err := <-errC; err != nil { if err := <-errC; err != nil {
return err return err
} }