From 7a48d001a26aa64a3c122aafa575ef955fb3925e Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 1 Nov 2023 15:23:27 +0800 Subject: [PATCH] backtest: return closed kline channel when empty symbol is given --- pkg/backtest/exchange.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/backtest/exchange.go b/pkg/backtest/exchange.go index 851c4df14..28a6b49a4 100644 --- a/pkg/backtest/exchange.go +++ b/pkg/backtest/exchange.go @@ -382,6 +382,14 @@ func (e *Exchange) SubscribeMarketData( } log.Infof("querying klines from database with exchange: %v symbols: %v and intervals: %v for back-testing", e.Name(), symbols, intervals) + if len(symbols) == 0 { + log.Warnf("empty symbols, will not query kline data from the database") + + c := make(chan types.KLine) + close(c) + return c, nil + } + klineC, errC := e.srv.QueryKLinesCh(startTime, endTime, e, symbols, intervals) go func() { if err := <-errC; err != nil {