From 711575c6d05170401042e985d414601b1ed40b54 Mon Sep 17 00:00:00 2001 From: TonyQ Date: Sun, 19 Dec 2021 12:10:46 +0800 Subject: [PATCH] backtest : fix auto sync missing the part from last db kiline to end time --- pkg/service/backtest.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/service/backtest.go b/pkg/service/backtest.go index cb6d9b434..f239480d9 100644 --- a/pkg/service/backtest.go +++ b/pkg/service/backtest.go @@ -337,13 +337,15 @@ func (s *BacktestService) SyncExist(ctx context.Context, exchange types.Exchange nowStartTime := fromTime 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) - 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 { return err }