gitee.com/quant1x/engine@v1.8.4/command/command_safes.go (about) 1 package command 2 3 import ( 4 "fmt" 5 "gitee.com/quant1x/engine/trader" 6 cmder "github.com/spf13/cobra" 7 ) 8 9 var ( 10 safesSecureType int = 0 11 safesSecurityCode string 12 ) 13 14 var ( 15 // CmdSafes 安全类-黑白名单 16 CmdSafes *cmder.Command = nil 17 ) 18 19 func initSafes() { 20 CmdSafes = &cmder.Command{ 21 Use: "safes", 22 Example: Application + " safes --code=sh000001 --type=1", 23 Short: "黑白名单", 24 Run: func(cmd *cmder.Command, args []string) { 25 if len(safesSecurityCode) == 0 { 26 fmt.Println("证券代码不能为空") 27 return 28 } 29 trader.AddCodeToBlackList(safesSecurityCode, trader.SecureType(safesSecureType)) 30 }, 31 } 32 33 CmdSafes.Flags().StringVar(&safesSecurityCode, "code", "", "证券代码") 34 CmdSafes.Flags().IntVar(&safesSecureType, "type", 0, trader.UsageOfSecureType()) 35 }