2020-10-15 14:36:22 +00:00
|
|
|
package main
|
2020-10-12 14:46:06 +00:00
|
|
|
|
|
|
|
import (
|
2020-10-15 14:36:22 +00:00
|
|
|
"strings"
|
2020-10-12 14:46:06 +00:00
|
|
|
|
|
|
|
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-12 14:46:06 +00:00
|
|
|
|
2020-10-16 02:09:30 +00:00
|
|
|
if err := buyandhold.Cmd.Execute(); err != nil {
|
2020-10-12 14:46:06 +00:00
|
|
|
log.WithError(err).Fatalf("cannot execute command")
|
|
|
|
}
|
|
|
|
}
|