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]
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 {
@ -246,6 +247,8 @@ func (s *Strategy) selectSessionForCurrency(
Market: market,
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:
@ -288,6 +291,8 @@ func (s *Strategy) selectSessionForCurrency(
Market: market,
TimeInForce: types.TimeInForceGTC,
}
} else {
log.Warnf("The amount %f is not greater than the minimal order quantity for %s", q.Float64(), market.Symbol)
}
}