Merge pull request #1608 from c9s/narumi/xalign/fix-max-amount

FIX: [xalign] fix buy side max amount
This commit is contained in:
なるみ 2024-03-28 14:09:08 +08:00 committed by GitHub
commit 3881039bfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -231,9 +231,10 @@ func (s *Strategy) selectSessionForCurrency(
} }
maxAmount, ok := s.MaxAmounts[market.QuoteCurrency] maxAmount, ok := s.MaxAmounts[market.QuoteCurrency]
if ok { if ok && requiredQuoteAmount.Compare(maxAmount) > 0 {
requiredQuoteAmount = bbgo.AdjustQuantityByMaxAmount(requiredQuoteAmount, price, maxAmount) log.Infof("adjusted required quote ammount %f %s by max amount %f %s", requiredQuoteAmount.Float64(), market.QuoteCurrency, maxAmount.Float64(), market.QuoteCurrency)
log.Infof("adjusted quantity %f %s by max amount %f %s", requiredQuoteAmount.Float64(), market.BaseCurrency, maxAmount.Float64(), market.QuoteCurrency)
requiredQuoteAmount = maxAmount
} }
if quantity, ok := market.GreaterThanMinimalOrderQuantity(side, price, requiredQuoteAmount); ok { if quantity, ok := market.GreaterThanMinimalOrderQuantity(side, price, requiredQuoteAmount); ok {
@ -246,6 +247,8 @@ func (s *Strategy) selectSessionForCurrency(
Market: market, Market: market,
TimeInForce: types.TimeInForceGTC, TimeInForce: types.TimeInForceGTC,
} }
} else {
log.Warnf("The amount %f is not greater than the minimal order quantity for %s", requiredQuoteAmount.Float64(), market.Symbol)
} }
case types.SideTypeSell: case types.SideTypeSell:
@ -288,6 +291,8 @@ func (s *Strategy) selectSessionForCurrency(
Market: market, Market: market,
TimeInForce: types.TimeInForceGTC, TimeInForce: types.TimeInForceGTC,
} }
} else {
log.Warnf("The amount %f is not greater than the minimal order quantity for %s", q.Float64(), market.Symbol)
} }
} }