diff --git a/pkg/bbgo/session.go b/pkg/bbgo/session.go index 13e500dbd..7aa3ba8b1 100644 --- a/pkg/bbgo/session.go +++ b/pkg/bbgo/session.go @@ -2,6 +2,7 @@ package bbgo import ( "context" + "errors" "fmt" "strings" "sync" @@ -25,6 +26,8 @@ import ( var KLinePreloadLimit int64 = 1000 +var ErrEmptyMarketInfo = errors.New("market info should not be empty, 0 markets loaded") + // ExchangeSession presents the exchange connection Session // It also maintains and collects the data returned from the stream. type ExchangeSession struct { @@ -177,6 +180,7 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment) var log = log.WithField("session", session.Name) // load markets first + log.Infof("querying market info from %s...", session.Name) var disableMarketsCache = false var markets types.MarketMap @@ -191,7 +195,7 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment) } if len(markets) == 0 { - return fmt.Errorf("market config should not be empty") + return ErrEmptyMarketInfo } session.markets = markets @@ -224,6 +228,8 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment) // query and initialize the balances if !session.PublicOnly { + log.Infof("querying account balances...") + account, err := session.Exchange.QueryAccount(ctx) if err != nil { return err @@ -233,7 +239,7 @@ func (session *ExchangeSession) Init(ctx context.Context, environ *Environment) session.Account = account session.accountMutex.Unlock() - log.Infof("%s account", session.Name) + log.Infof("account %s balances:", session.Name) account.Balances().Print() // forward trade updates and order updates to the order executor diff --git a/pkg/exchange/max/maxapi/restapi.go b/pkg/exchange/max/maxapi/restapi.go index 3b45af1df..97345aea2 100644 --- a/pkg/exchange/max/maxapi/restapi.go +++ b/pkg/exchange/max/maxapi/restapi.go @@ -165,6 +165,7 @@ func (c *RestClient) queryAndUpdateServerTimestamp(ctx context.Context) { if err != nil { return err } + if serverTs == 0 { return errors.New("unexpected zero server timestamp") } @@ -191,6 +192,8 @@ func (c *RestClient) queryAndUpdateServerTimestamp(ctx context.Context) { if err := backoff.RetryGeneral(ctx, op); err != nil { logger.WithError(err).Error("unable to sync timestamp with max") + } else { + return } } }