mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 16:55:15 +00:00
Merge pull request #817 from COLDTURNIP/fix/optimizer_initial_storage
optimizer: prepare database before executing backtests
This commit is contained in:
commit
01d50496a1
|
@ -101,6 +101,10 @@ var optimizeCmd = &cobra.Command{
|
||||||
Config: optConfig,
|
Config: optConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := executor.Prepare(configJson); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
metrics, err := optz.Run(executor, configJson)
|
metrics, err := optz.Run(executor, configJson)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -76,6 +76,20 @@ func (e *LocalProcessExecutor) readReport(output []byte) (*backtest.SummaryRepor
|
||||||
return summaryReport, nil
|
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) {
|
func (e *LocalProcessExecutor) Run(ctx context.Context, taskC chan BacktestTask, bar *pb.ProgressBar) (chan BacktestTask, error) {
|
||||||
var maxNumOfProcess = e.Config.MaxNumberOfProcesses
|
var maxNumOfProcess = e.Config.MaxNumberOfProcesses
|
||||||
var resultsC = make(chan BacktestTask, maxNumOfProcess*2)
|
var resultsC = make(chan BacktestTask, maxNumOfProcess*2)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user