mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
improve/db: query futures kilne if session 'futures' is true when sync
This commit is contained in:
parent
d5cbcc3fb2
commit
5b0b5428fb
|
@ -25,13 +25,26 @@ type BacktestService struct {
|
||||||
func (s *BacktestService) SyncKLineByInterval(ctx context.Context, exchange types.Exchange, symbol string, interval types.Interval, startTime, endTime time.Time) error {
|
func (s *BacktestService) SyncKLineByInterval(ctx context.Context, exchange types.Exchange, symbol string, interval types.Interval, startTime, endTime time.Time) error {
|
||||||
log.Infof("synchronizing %s klines with interval %s: %s <=> %s", exchange.Name(), interval, startTime, endTime)
|
log.Infof("synchronizing %s klines with interval %s: %s <=> %s", exchange.Name(), interval, startTime, endTime)
|
||||||
|
|
||||||
// TODO: use isFutures here
|
_, isFutures, isIsolated, isolatedSymbol := exchange2.GetSessionAttributes(exchange)
|
||||||
_, _, isIsolated, isolatedSymbol := exchange2.GetSessionAttributes(exchange)
|
|
||||||
// override symbol if isolatedSymbol is not empty
|
// override symbol if isolatedSymbol is not empty
|
||||||
if isIsolated && len(isolatedSymbol) > 0 {
|
if isIsolated && len(isolatedSymbol) > 0 {
|
||||||
symbol = isolatedSymbol
|
symbol = isolatedSymbol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isFutures {
|
||||||
|
futuresExchange, ok := exchange.(types.FuturesExchange)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("exchange %s does not support futures", exchange.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
if isIsolated {
|
||||||
|
futuresExchange.UseIsolatedFutures(symbol)
|
||||||
|
} else {
|
||||||
|
futuresExchange.UseFutures()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if s.DB.DriverName() == "sqlite3" {
|
if s.DB.DriverName() == "sqlite3" {
|
||||||
_, _ = s.DB.Exec("PRAGMA journal_mode = WAL")
|
_, _ = s.DB.Exec("PRAGMA journal_mode = WAL")
|
||||||
_, _ = s.DB.Exec("PRAGMA synchronous = NORMAL")
|
_, _ = s.DB.Exec("PRAGMA synchronous = NORMAL")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user