mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Merge pull request #963 from frin1/feature/limit_number_of_optimizer_results
Feature: limit how many metrics is shown by optimizer
This commit is contained in:
commit
0ef565ec81
|
@ -18,6 +18,7 @@ func init() {
|
|||
optimizeCmd.Flags().String("output", "output", "backtest report output directory")
|
||||
optimizeCmd.Flags().Bool("json", false, "print optimizer metrics in json format")
|
||||
optimizeCmd.Flags().Bool("tsv", false, "print optimizer metrics in csv format")
|
||||
optimizeCmd.Flags().Int("limit", 50, "limit how many results to print pr metric")
|
||||
RootCmd.AddCommand(optimizeCmd)
|
||||
}
|
||||
|
||||
|
@ -54,6 +55,11 @@ var optimizeCmd = &cobra.Command{
|
|||
return err
|
||||
}
|
||||
|
||||
resultLimit, err := cmd.Flags().GetInt("limit")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
yamlBody, err := ioutil.ReadFile(configFile)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -124,6 +130,10 @@ var optimizeCmd = &cobra.Command{
|
|||
continue
|
||||
}
|
||||
|
||||
if len(values) < resultLimit && resultLimit != 0 {
|
||||
values = values[:resultLimit]
|
||||
}
|
||||
|
||||
fmt.Printf("%v => %s\n", values[0].Labels, n)
|
||||
for _, m := range values {
|
||||
fmt.Printf("%v => %s %v\n", m.Params, n, m.Value)
|
||||
|
|
Loading…
Reference in New Issue
Block a user