diff --git a/pkg/cmd/balances.go b/pkg/cmd/balances.go index 2ec725192..c9b8f2798 100644 --- a/pkg/cmd/balances.go +++ b/pkg/cmd/balances.go @@ -6,10 +6,6 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "github.com/spf13/viper" - - "github.com/c9s/bbgo/pkg/exchange/ftx" - "github.com/c9s/bbgo/pkg/types" ) //godotenv -f .env.local go run ./cmd/bbgo balances --session=ftx @@ -41,16 +37,3 @@ func init() { RootCmd.AddCommand(balancesCmd) } - -func newExchange(session string) (types.Exchange, error) { - switch session { - case "ftx": - return ftx.NewExchange( - viper.GetString("ftx-api-key"), - viper.GetString("ftx-api-secret"), - viper.GetString("ftx-subaccount-name"), - ), nil - - } - return nil, fmt.Errorf("unsupported session %s", session) -} diff --git a/pkg/cmd/utils.go b/pkg/cmd/utils.go index 7aca4e9cb..26fcf8d8a 100644 --- a/pkg/cmd/utils.go +++ b/pkg/cmd/utils.go @@ -1,6 +1,11 @@ package cmd import ( + "fmt" + + "github.com/spf13/viper" + + "github.com/c9s/bbgo/pkg/exchange/ftx" "github.com/c9s/bbgo/pkg/types" ) @@ -10,3 +15,15 @@ func inBaseAsset(balances types.BalanceMap, market types.Market, price float64) return (base.Locked.Float64() + base.Available.Float64()) + ((quote.Locked.Float64() + quote.Available.Float64()) / price) } +func newExchange(session string) (types.Exchange, error) { + switch session { + case "ftx": + return ftx.NewExchange( + viper.GetString("ftx-api-key"), + viper.GetString("ftx-api-secret"), + viper.GetString("ftx-subaccount-name"), + ), nil + + } + return nil, fmt.Errorf("unsupported session %s", session) +}