mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
allow public session
This commit is contained in:
parent
67bfc508c8
commit
6c8babfb27
|
@ -218,6 +218,12 @@ func NewExchangeSessionFromConfig(name string, sessionConfig *ExchangeSession) (
|
||||||
var exchange types.Exchange
|
var exchange types.Exchange
|
||||||
|
|
||||||
if sessionConfig.Key != "" && sessionConfig.Secret != "" {
|
if sessionConfig.Key != "" && sessionConfig.Secret != "" {
|
||||||
|
if !sessionConfig.PublicOnly {
|
||||||
|
if len(sessionConfig.Key) == 0 || len(sessionConfig.Secret) == 0 {
|
||||||
|
return nil, fmt.Errorf("can not create exchange %s: empty key or secret", exchangeName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exchange, err = cmdutil.NewExchangeStandard(exchangeName, sessionConfig.Key, sessionConfig.Secret, sessionConfig.SubAccount)
|
exchange, err = cmdutil.NewExchangeStandard(exchangeName, sessionConfig.Key, sessionConfig.Secret, sessionConfig.SubAccount)
|
||||||
} else {
|
} else {
|
||||||
exchange, err = cmdutil.NewExchangeWithEnvVarPrefix(exchangeName, sessionConfig.EnvVarPrefix)
|
exchange, err = cmdutil.NewExchangeWithEnvVarPrefix(exchangeName, sessionConfig.EnvVarPrefix)
|
||||||
|
|
|
@ -5,8 +5,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/exchange/binance"
|
"github.com/c9s/bbgo/pkg/exchange/binance"
|
||||||
"github.com/c9s/bbgo/pkg/exchange/ftx"
|
"github.com/c9s/bbgo/pkg/exchange/ftx"
|
||||||
"github.com/c9s/bbgo/pkg/exchange/max"
|
"github.com/c9s/bbgo/pkg/exchange/max"
|
||||||
|
@ -14,10 +12,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewExchangeStandard(n types.ExchangeName, key, secret, subAccount string) (types.Exchange, error) {
|
func NewExchangeStandard(n types.ExchangeName, key, secret, subAccount string) (types.Exchange, error) {
|
||||||
if len(key) == 0 || len(secret) == 0 {
|
|
||||||
return nil, errors.New("binance: empty key or secret")
|
|
||||||
}
|
|
||||||
|
|
||||||
switch n {
|
switch n {
|
||||||
|
|
||||||
case types.ExchangeFTX:
|
case types.ExchangeFTX:
|
||||||
|
@ -45,7 +39,7 @@ func NewExchangeWithEnvVarPrefix(n types.ExchangeName, varPrefix string) (types.
|
||||||
key := os.Getenv(varPrefix + "_API_KEY")
|
key := os.Getenv(varPrefix + "_API_KEY")
|
||||||
secret := os.Getenv(varPrefix + "_API_SECRET")
|
secret := os.Getenv(varPrefix + "_API_SECRET")
|
||||||
if len(key) == 0 || len(secret) == 0 {
|
if len(key) == 0 || len(secret) == 0 {
|
||||||
return nil, fmt.Errorf("%s: empty key or secret, env var prefix: %s", n, varPrefix)
|
return nil, fmt.Errorf("can not initialize exchange %s: empty key or secret, env var prefix: %s", n, varPrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
subAccount := os.Getenv(varPrefix + "_SUBACCOUNT")
|
subAccount := os.Getenv(varPrefix + "_SUBACCOUNT")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user