Merge pull request #1571 from c9s/narumi/rebalance/fix-cannot-lock-fund

FIX: [rebalance] fix cannot lock fund
This commit is contained in:
c9s 2024-03-08 22:03:50 +08:00 committed by GitHub
commit 4337662852
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -253,14 +253,14 @@ func (s *Strategy) generateOrder(ctx context.Context) (*types.SubmitOrder, error
return nil, err
}
price := s.PriceType.Map(ticker, side)
if side == types.SideTypeBuy {
quantity = fixedpoint.Min(quantity, balances[s.QuoteCurrency].Available.Div(price))
quantity = fixedpoint.Min(quantity, balances[s.QuoteCurrency].Available.Div(ticker.Sell))
} else if side == types.SideTypeSell {
quantity = fixedpoint.Min(quantity, balances[market.BaseCurrency].Available)
}
price := s.PriceType.Map(ticker, side)
if s.MaxAmount.Float64() > 0 {
quantity = bbgo.AdjustQuantityByMaxAmount(quantity, price, s.MaxAmount)
log.Infof("adjusted quantity %s (%s %s @ %s) by max amount %s",