mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
improve/backtest: backtest with futures klines
This commit is contained in:
parent
66718e0d37
commit
0ac720c4cb
|
@ -30,6 +30,7 @@ package backtest
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
exchange2 "github.com/c9s/bbgo/pkg/exchange"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -381,7 +382,13 @@ func (e *Exchange) SubscribeMarketData(
|
|||
intervals = append(intervals, interval)
|
||||
}
|
||||
|
||||
log.Infof("querying klines from database with exchange: %v symbols: %v and intervals: %v for back-testing", e.Name(), symbols, intervals)
|
||||
_, isFutures, _, _ := exchange2.GetSessionAttributes(e.publicExchange)
|
||||
if isFutures {
|
||||
log.Infof("querying futures klines from database with exchange: %v symbols: %v and intervals: %v for back-testing", e.Name(), symbols, intervals)
|
||||
} else {
|
||||
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")
|
||||
|
||||
|
@ -390,7 +397,7 @@ func (e *Exchange) SubscribeMarketData(
|
|||
return c, nil
|
||||
}
|
||||
|
||||
klineC, errC := e.srv.QueryKLinesCh(startTime, endTime, e, symbols, intervals)
|
||||
klineC, errC := e.srv.QueryKLinesCh(startTime, endTime, e.publicExchange, symbols, intervals)
|
||||
go func() {
|
||||
if err := <-errC; err != nil {
|
||||
log.WithError(err).Error("backtest data feed error")
|
||||
|
|
|
@ -279,6 +279,7 @@ var BacktestCmd = &cobra.Command{
|
|||
exchangeFromConfig := userConfig.Sessions[name.String()]
|
||||
if exchangeFromConfig != nil {
|
||||
session.UseHeikinAshi = exchangeFromConfig.UseHeikinAshi
|
||||
session.Futures = exchangeFromConfig.Futures
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user