mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
move verbose flag detection before we setup the environment
This commit is contained in:
parent
6c2aef31a3
commit
f5b17193c5
|
@ -30,6 +30,18 @@ var BacktestCmd = &cobra.Command{
|
|||
Short: "backtest your strategies",
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
log.SetLevel(log.ErrorLevel)
|
||||
verboseCnt, err := cmd.Flags().GetCount("verbose")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if verboseCnt == 2 {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
} else if verboseCnt > 0 {
|
||||
log.SetLevel(log.InfoLevel)
|
||||
}
|
||||
|
||||
configFile, err := cmd.Flags().GetString("config")
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -39,6 +51,7 @@ var BacktestCmd = &cobra.Command{
|
|||
return errors.New("--config option is required")
|
||||
}
|
||||
|
||||
|
||||
wantSync, err := cmd.Flags().GetBool("sync")
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -119,18 +132,6 @@ var BacktestCmd = &cobra.Command{
|
|||
log.Warnf("backtest does not support CrossExchangeStrategy, strategies won't be added.")
|
||||
}
|
||||
|
||||
log.SetLevel(log.ErrorLevel)
|
||||
verboseCnt, err := cmd.Flags().GetCount("verbose")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if verboseCnt == 2 {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
} else if verboseCnt > 0 {
|
||||
log.SetLevel(log.InfoLevel)
|
||||
}
|
||||
|
||||
if err := trader.Run(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user