bbgo_origin/strategies/buyandhold/main.go

30 lines
721 B
Go
Raw Normal View History

2020-10-15 14:36:22 +00:00
package main
import (
2020-10-15 14:36:22 +00:00
"strings"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"github.com/c9s/bbgo/pkg/bbgo"
"github.com/c9s/bbgo/pkg/strategy/buyandhold"
)
func init() {
2020-10-16 02:09:30 +00:00
// persistent flags for trading environment
bbgo.PersistentFlags(buyandhold.Cmd.PersistentFlags())
}
2020-10-15 14:36:22 +00:00
2020-10-16 02:09:30 +00:00
func main() {
// general viper setup for trading environment
2020-10-15 14:36:22 +00:00
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
viper.AutomaticEnv()
2020-10-16 02:09:30 +00:00
if err := viper.BindPFlags(buyandhold.Cmd.PersistentFlags()); err != nil {
2020-10-15 14:36:22 +00:00
log.WithError(err).Errorf("failed to bind persistent flags. please check the flag settings.")
}
2020-10-16 02:09:30 +00:00
if err := buyandhold.Cmd.Execute(); err != nil {
log.WithError(err).Fatalf("cannot execute command")
}
}