mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
improve/backtest: backtest with futures klines
This commit is contained in:
parent
66718e0d37
commit
0ac720c4cb
|
@ -30,6 +30,7 @@ package backtest
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
exchange2 "github.com/c9s/bbgo/pkg/exchange"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -381,7 +382,13 @@ func (e *Exchange) SubscribeMarketData(
|
||||||
intervals = append(intervals, interval)
|
intervals = append(intervals, interval)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, 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)
|
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 {
|
if len(symbols) == 0 {
|
||||||
log.Warnf("empty symbols, will not query kline data from the database")
|
log.Warnf("empty symbols, will not query kline data from the database")
|
||||||
|
|
||||||
|
@ -390,7 +397,7 @@ func (e *Exchange) SubscribeMarketData(
|
||||||
return c, nil
|
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() {
|
go func() {
|
||||||
if err := <-errC; err != nil {
|
if err := <-errC; err != nil {
|
||||||
log.WithError(err).Error("backtest data feed error")
|
log.WithError(err).Error("backtest data feed error")
|
||||||
|
|
|
@ -279,6 +279,7 @@ var BacktestCmd = &cobra.Command{
|
||||||
exchangeFromConfig := userConfig.Sessions[name.String()]
|
exchangeFromConfig := userConfig.Sessions[name.String()]
|
||||||
if exchangeFromConfig != nil {
|
if exchangeFromConfig != nil {
|
||||||
session.UseHeikinAshi = exchangeFromConfig.UseHeikinAshi
|
session.UseHeikinAshi = exchangeFromConfig.UseHeikinAshi
|
||||||
|
session.Futures = exchangeFromConfig.Futures
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user