mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 08:11:08 +00:00
Merge pull request #1588 from c9s/c9s/xalign-add-check-expected-balance
FIX: [xalign] check if the quote balance will be used up and below the expected balance
This commit is contained in:
commit
ee21e9ea62
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user