Skip to content

Commit

Permalink
autobuy: improve balance checking
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Dec 16, 2024
1 parent f259f0b commit 93bb7a3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/strategy/autobuy/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,14 @@ func (s *Strategy) cancelOrders(ctx context.Context) {
func (s *Strategy) autobuy(ctx context.Context) {
s.cancelOrders(ctx)

baseBalance, ok := s.Session.GetAccount().Balance(s.Market.BaseCurrency)
if !ok {
baseBalance = types.NewZeroBalance(s.Market.BaseCurrency)
}
account := s.Session.GetAccount()
baseBalance, _ := account.Balance(s.Market.BaseCurrency)

log.Infof("balance: %s", baseBalance.String())

quoteBalance, ok := s.Session.GetAccount().Balance(s.Market.QuoteCurrency)
quoteBalance, ok := account.Balance(s.Market.QuoteCurrency)
if !ok {
log.Errorf("%s balance not found", s.Market.QuoteCurrency)
log.Errorf("quote balance is zero")
return
}

Expand Down

0 comments on commit 93bb7a3

Please sign in to comment.