mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
cmd: move simple session factory to cmd/utils.go
This commit is contained in:
parent
5196df9620
commit
282ce3ee99
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user