mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
optimizer: prepare database before executing backtests
This commit is contained in:
parent
7daa73917c
commit
4985c760be
|
@ -101,6 +101,10 @@ var optimizeCmd = &cobra.Command{
|
|||
Config: optConfig,
|
||||
}
|
||||
|
||||
if err := executor.Prepare(configJson); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
metrics, err := optz.Run(executor, configJson)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -76,6 +76,20 @@ func (e *LocalProcessExecutor) readReport(output []byte) (*backtest.SummaryRepor
|
|||
return summaryReport, nil
|
||||
}
|
||||
|
||||
// Prepare prepares the environment for the following back tests
|
||||
// this is a blocking operation
|
||||
func (e *LocalProcessExecutor) Prepare(configJson []byte) error {
|
||||
log.Debugln("Sync database before launching backtests...")
|
||||
tf, err := jsonToYamlConfig(e.ConfigDir, configJson)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := exec.Command(e.Bin, "backtest", "--sync", "--sync-only", "--config", tf.Name())
|
||||
_, err = c.Output()
|
||||
return err
|
||||
}
|
||||
|
||||
func (e *LocalProcessExecutor) Run(ctx context.Context, taskC chan BacktestTask, bar *pb.ProgressBar) (chan BacktestTask, error) {
|
||||
var maxNumOfProcess = e.Config.MaxNumberOfProcesses
|
||||
var resultsC = make(chan BacktestTask, maxNumOfProcess*2)
|
||||
|
|
Loading…
Reference in New Issue
Block a user