From c7bba2cb517d32203f5badadfeb2c6436e9a5192 Mon Sep 17 00:00:00 2001 From: narumi <4680567+narumiruna@users.noreply.github.com> Date: Wed, 27 Mar 2024 16:35:22 +0800 Subject: [PATCH] fix xalign max amount --- pkg/strategy/xalign/strategy.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/strategy/xalign/strategy.go b/pkg/strategy/xalign/strategy.go index 9faa96a8b1..010ba4e39f 100644 --- a/pkg/strategy/xalign/strategy.go +++ b/pkg/strategy/xalign/strategy.go @@ -231,9 +231,10 @@ func (s *Strategy) selectSessionForCurrency( } maxAmount, ok := s.MaxAmounts[market.QuoteCurrency] - if ok { - requiredQuoteAmount = bbgo.AdjustQuantityByMaxAmount(requiredQuoteAmount, price, maxAmount) - log.Infof("adjusted quantity %f %s by max amount %f %s", requiredQuoteAmount.Float64(), market.BaseCurrency, maxAmount.Float64(), market.QuoteCurrency) + if ok && requiredQuoteAmount.Compare(maxAmount) > 0 { + log.Infof("adjusted required quote ammount %f %s by max amount %f %s", requiredQuoteAmount.Float64(), market.QuoteCurrency, maxAmount.Float64(), market.QuoteCurrency) + + requiredQuoteAmount = maxAmount } if quantity, ok := market.GreaterThanMinimalOrderQuantity(side, price, requiredQuoteAmount); ok {