Merge pull request #442 from kkc/fix_bollmaker_backtest

Fix: fallback to memory persistence if redis not found
This commit is contained in:
Yo-An Lin 2022-01-22 00:58:49 +08:00 committed by GitHub
commit e4b4f69716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/c9s/bbgo/pkg/service"
log "github.com/sirupsen/logrus"
)
type PersistenceSelector struct {
@ -27,6 +28,10 @@ func (p *Persistence) backendService(t string) (service.PersistenceService, erro
return p.Facade.Json, nil
case "redis":
if p.Facade.Redis == nil {
log.Warn("redis persistence is not available, fallback to memory backend")
return p.Facade.Memory, nil
}
return p.Facade.Redis, nil
case "memory":