mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
optimizer: wrap error with the output if err is not nil
This commit is contained in:
parent
9819f0941b
commit
9ebb8ada13
|
@ -12,6 +12,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/cheggaaa/pb/v3"
|
"github.com/cheggaaa/pb/v3"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
|
@ -81,15 +82,19 @@ func (e *LocalProcessExecutor) readReport(reportPath string) (*backtest.SummaryR
|
||||||
// Prepare prepares the environment for the following back tests
|
// Prepare prepares the environment for the following back tests
|
||||||
// this is a blocking operation
|
// this is a blocking operation
|
||||||
func (e *LocalProcessExecutor) Prepare(configJson []byte) error {
|
func (e *LocalProcessExecutor) Prepare(configJson []byte) error {
|
||||||
log.Debugln("Sync database before launching backtests...")
|
log.Debugln("syncing backtest data before starting backtests...")
|
||||||
tf, err := jsonToYamlConfig(e.ConfigDir, configJson)
|
tf, err := jsonToYamlConfig(e.ConfigDir, configJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
c := exec.Command(e.Bin, "backtest", "--sync", "--sync-only", "--config", tf.Name())
|
c := exec.Command(e.Bin, "backtest", "--sync", "--sync-only", "--config", tf.Name())
|
||||||
_, err = c.Output()
|
output, err := c.Output()
|
||||||
return err
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "failed to sync backtest data: %s", string(output))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *LocalProcessExecutor) Run(ctx context.Context, taskC chan BacktestTask, bar *pb.ProgressBar) (chan BacktestTask, error) {
|
func (e *LocalProcessExecutor) Run(ctx context.Context, taskC chan BacktestTask, bar *pb.ProgressBar) (chan BacktestTask, error) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user