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
|
# go run ./cmd/bbgo optimize --config bollmaker_ethusdt.yaml --optimizer-config optimizer.yaml --debug
|
||||||
#
|
#
|
||||||
---
|
---
|
||||||
|
maxThread: 10
|
||||||
matrix:
|
matrix:
|
||||||
- type: iterate
|
- type: iterate
|
||||||
label: interval
|
label: interval
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# go run ./cmd/bbgo optimize --config bollmaker_ethusdt.yaml --optimizer-config optimizer.yaml --debug
|
# go run ./cmd/bbgo optimize --config bollmaker_ethusdt.yaml --optimizer-config optimizer.yaml --debug
|
||||||
#
|
#
|
||||||
---
|
---
|
||||||
|
maxThread: 10
|
||||||
matrix:
|
matrix:
|
||||||
- type: iterate
|
- type: iterate
|
||||||
path: '/exchangeStrategies/0/bollmaker/interval'
|
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
|
# go run ./cmd/bbgo optimize --config config/pivotshort-ETHUSDT.yaml --optimizer-config config/pivotshort_optimizer.yaml --debug
|
||||||
#
|
#
|
||||||
---
|
---
|
||||||
|
maxThread: 10
|
||||||
matrix:
|
matrix:
|
||||||
|
|
||||||
- type: iterate
|
- type: iterate
|
||||||
|
|
|
@ -19,7 +19,8 @@ type SelectorConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Matrix []SelectorConfig `yaml:"matrix"`
|
MaxThread int `yaml:"maxThread,omitempty"`
|
||||||
|
Matrix []SelectorConfig `yaml:"matrix"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadConfig(yamlConfigFileName string) (*Config, error) {
|
func LoadConfig(yamlConfigFileName string) (*Config, error) {
|
||||||
|
@ -33,5 +34,10 @@ func LoadConfig(yamlConfigFileName string) (*Config, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The default of MaxThread is 5
|
||||||
|
if optConfig.MaxThread <= 0 {
|
||||||
|
optConfig.MaxThread = 5
|
||||||
|
}
|
||||||
|
|
||||||
return &optConfig, nil
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
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) {
|
func (e *LocalProcessExecutor) Run(ctx context.Context, taskC chan BacktestTask) (chan BacktestTask, error) {
|
||||||
var maxNumOfProcess = 5
|
var maxNumOfProcess = ctx.Value("MaxThread").(int)
|
||||||
var resultsC = make(chan BacktestTask, 10)
|
var resultsC = make(chan BacktestTask, maxNumOfProcess*2)
|
||||||
|
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
wg.Add(maxNumOfProcess)
|
wg.Add(maxNumOfProcess)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user