package elliottwave import ( "bytes" "io" "strconv" "git.qtrade.icu/lychiyu/bbgo/pkg/bbgo" "git.qtrade.icu/lychiyu/bbgo/pkg/dynamic" "git.qtrade.icu/lychiyu/bbgo/pkg/interact" "git.qtrade.icu/lychiyu/bbgo/pkg/style" "github.com/jedib0t/go-pretty/v6/table" ) func (s *Strategy) initOutputCommands() { bbgo.RegisterCommand("/config", "Show latest config", func(reply interact.Reply) { var buffer bytes.Buffer s.Print(&buffer, false) reply.Message(buffer.String()) }) bbgo.RegisterCommand("/dump", "Dump internal params", func(reply interact.Reply) { reply.Message("Please enter series output length:") }).Next(func(length string, reply interact.Reply) { var buffer bytes.Buffer l, err := strconv.Atoi(length) if err != nil { dynamic.ParamDump(s, &buffer) } else { dynamic.ParamDump(s, &buffer, l) } reply.Message(buffer.String()) }) bbgo.RegisterModifier(s) } func (s *Strategy) Print(f io.Writer, pretty bool, withColor ...bool) { var tableStyle *table.Style if pretty { tableStyle = style.NewDefaultTableStyle() } dynamic.PrintConfig(s, f, tableStyle, len(withColor) > 0 && withColor[0], dynamic.DefaultWhiteList()...) }