From b9b2b8727a894cbf1d2c4f146d438a8d3963082d Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 20 May 2022 13:37:28 +0800 Subject: [PATCH] avoid emitting duplicated kline --- pkg/cmd/backtest.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/cmd/backtest.go b/pkg/cmd/backtest.go index 3379b3aac..e15f16645 100644 --- a/pkg/cmd/backtest.go +++ b/pkg/cmd/backtest.go @@ -391,7 +391,13 @@ var BacktestCmd = &cobra.Command{ var numOfExchangeSources = len(exchangeSources) if numOfExchangeSources == 1 { exSource := exchangeSources[0] + var lastk types.KLine for k := range exSource.C { + // avoid duplicated klines + if k == lastk { + continue + } + exSource.Exchange.ConsumeKLine(k) for _, h := range kLineHandlers {