mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Merge pull request #753 from andycheng123/improve/optimizer-config
optimizer: add max num of thread in config
This commit is contained in:
commit
16682596df
|
@ -3,6 +3,7 @@
|
|||
# go run ./cmd/bbgo optimize --config bollmaker_ethusdt.yaml --optimizer-config optimizer.yaml --debug
|
||||
#
|
||||
---
|
||||
maxThread: 10
|
||||
matrix:
|
||||
- type: iterate
|
||||
label: interval
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# go run ./cmd/bbgo optimize --config bollmaker_ethusdt.yaml --optimizer-config optimizer.yaml --debug
|
||||
#
|
||||
---
|
||||
maxThread: 10
|
||||
matrix:
|
||||
- type: iterate
|
||||
path: '/exchangeStrategies/0/bollmaker/interval'
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# go run ./cmd/bbgo optimize --config config/pivotshort-ETHUSDT.yaml --optimizer-config config/pivotshort_optimizer.yaml --debug
|
||||
#
|
||||
---
|
||||
maxThread: 10
|
||||
matrix:
|
||||
|
||||
- type: iterate
|
||||
|
|
|
@ -19,6 +19,7 @@ type SelectorConfig struct {
|
|||
}
|
||||
|
||||
type Config struct {
|
||||
MaxThread int `yaml:"maxThread,omitempty"`
|
||||
Matrix []SelectorConfig `yaml:"matrix"`
|
||||
}
|
||||
|
||||
|
@ -33,5 +34,10 @@ func LoadConfig(yamlConfigFileName string) (*Config, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// The default of MaxThread is 5
|
||||
if optConfig.MaxThread <= 0 {
|
||||
optConfig.MaxThread = 5
|
||||
}
|
||||
|
||||
return &optConfig, nil
|
||||
}
|
||||
|
|
|
@ -199,7 +199,8 @@ func (o *GridOptimizer) Run(executor Executor, configJson []byte) (map[string][]
|
|||
}
|
||||
}
|
||||
|
||||
resultsC, err := executor.Run(context.Background(), taskC)
|
||||
ctx := context.WithValue(context.Background(), "MaxThread", o.Config.MaxThread)
|
||||
resultsC, err := executor.Run(ctx, taskC)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -73,8 +73,8 @@ func (e *LocalProcessExecutor) readReport(output []byte) (*backtest.SummaryRepor
|
|||
}
|
||||
|
||||
func (e *LocalProcessExecutor) Run(ctx context.Context, taskC chan BacktestTask) (chan BacktestTask, error) {
|
||||
var maxNumOfProcess = 5
|
||||
var resultsC = make(chan BacktestTask, 10)
|
||||
var maxNumOfProcess = ctx.Value("MaxThread").(int)
|
||||
var resultsC = make(chan BacktestTask, maxNumOfProcess*2)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(maxNumOfProcess)
|
||||
|
|
Loading…
Reference in New Issue
Block a user