Skip to content

Commit

Permalink
xalign: check if the quote balance will be used up and below the expe…
Browse files Browse the repository at this point in the history
…cted balance line
  • Loading branch information
c9s committed Mar 18, 2024
1 parent 239f7ea commit 7f1e876
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/strategy/xalign/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ func (s *Strategy) selectSessionForCurrency(
continue
}

if expectedQuoteBalance, ok := s.ExpectedBalances[quoteCurrency]; ok {
rest := quoteBalance.Total().Sub(requiredQuoteAmount)
if rest.Compare(expectedQuoteBalance) < 0 {
log.Warnf("required quote amount %f will use up the expected balance %f, skip", requiredQuoteAmount.Float64(), expectedQuoteBalance.Float64())
continue
}
}

maxAmount, ok := s.MaxAmounts[market.QuoteCurrency]
if ok {
requiredQuoteAmount = bbgo.AdjustQuantityByMaxAmount(requiredQuoteAmount, price, maxAmount)
Expand Down

0 comments on commit 7f1e876

Please sign in to comment.