add environ.DatabaseService nil check for backtest

This commit is contained in:
c9s 2021-03-22 22:48:43 +08:00
parent 3a842836cd
commit 29f77c2176

View File

@ -95,7 +95,6 @@ var BacktestCmd = &cobra.Command{
return err
}
if userConfig.Backtest == nil {
return errors.New("backtest config is not defined")
}
@ -111,10 +110,14 @@ var BacktestCmd = &cobra.Command{
}
environ := bbgo.NewEnvironment()
if err := environ.ConfigureDatabase(ctx) ; err != nil {
if err := environ.ConfigureDatabase(ctx); err != nil {
return err
}
if environ.DatabaseService == nil {
return errors.New("database service is not enabled, please check your environment variables DB_DRIVER and DB_DSN")
}
backtestService := &service.BacktestService{DB: environ.DatabaseService.DB}
if wantSync {
@ -277,4 +280,3 @@ var BacktestCmd = &cobra.Command{
return nil
},
}