Skip to content

Commit

Permalink
Merge pull request #1588 from c9s/c9s/xalign-add-check-expected-balance
Browse files Browse the repository at this point in the history
FIX: [xalign] check if the quote balance will be used up and below the expected balance
  • Loading branch information
c9s committed Mar 18, 2024
2 parents 239f7ea + 7f1e876 commit ee21e9e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/strategy/xalign/strategy.go
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 ee21e9e

Please sign in to comment.