gitee.com/quant1x/engine@v1.8.4/command/command_backtesting.go (about) 1 package command 2 3 import ( 4 "gitee.com/quant1x/engine/models" 5 "gitee.com/quant1x/engine/tracker" 6 "gitee.com/quant1x/exchange" 7 cmder "github.com/spf13/cobra" 8 "strings" 9 ) 10 11 var ( 12 strategyCode uint64 // 策略ID 13 securityCode string // 证券代码 14 topN int // 统计前N 15 days int // 统计多少天 16 ) 17 18 // CmdBackTesting 回测 19 var CmdBackTesting = &cmder.Command{ 20 Use: "backtesting", 21 Short: "回测", 22 Run: func(cmd *cmder.Command, args []string) { 23 securityCode = strings.TrimSpace(securityCode) 24 securityCode = exchange.CorrectSecurityCode(securityCode) 25 if len(securityCode) > 0 { 26 tracker.CheckStrategy(strategyCode, securityCode) 27 } else { 28 tracker.BackTesting(strategyCode, days, topN) 29 } 30 }, 31 } 32 33 func initBackTesting() { 34 CmdBackTesting.Flags().IntVar(&days, "count", 0, "统计多少天") 35 CmdBackTesting.Flags().IntVar(&topN, "top", models.AllStockTopN(), "输出前排几名") 36 CmdBackTesting.Flags().Uint64Var(&strategyCode, "strategy", 0, "策略ID") 37 CmdBackTesting.Flags().StringVar(&securityCode, "code", "", "证券代码") 38 }