Merge pull request #296 from tony1223/feature/294-force-backtest

add force parameter for backtest
This commit is contained in:
Yo-An Lin 2021-12-05 00:25:23 +08:00 committed by GitHub
commit 19548a9449

View File

@ -27,6 +27,7 @@ func init() {
BacktestCmd.Flags().Bool("base-asset-baseline", false, "use base asset performance as the competitive baseline performance")
BacktestCmd.Flags().CountP("verbose", "v", "verbose level")
BacktestCmd.Flags().String("config", "config/bbgo.yaml", "strategy config file")
BacktestCmd.Flags().Bool("force", false, "force execution without confirm")
RootCmd.AddCommand(BacktestCmd)
}
@ -59,6 +60,11 @@ var BacktestCmd = &cobra.Command{
return err
}
force, err := cmd.Flags().GetBool("force")
if err != nil {
return err
}
syncOnly, err := cmd.Flags().GetBool("sync-only")
if err != nil {
return err
@ -207,9 +213,12 @@ var BacktestCmd = &cobra.Command{
log.Warn("!!! To run backtest, you should use an isolated database for storing backtest trades !!!")
log.Warn("!!! The trade record in the current database WILL ALL BE DELETE !!!")
if !force {
if !confirmation("Are you sure to continue?") {
return nil
}
}
if err := environ.TradeService.DeleteAll(); err != nil {
return err