backtest: return closed kline channel when empty symbol is given

This commit is contained in:
c9s 2023-11-01 15:23:27 +08:00
parent 470eb7dc09
commit 7a48d001a2
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -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) 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) klineC, errC := e.srv.QueryKLinesCh(startTime, endTime, e, symbols, intervals)
go func() { go func() {
if err := <-errC; err != nil { if err := <-errC; err != nil {