Skip to content

Commit 756a3bb

Browse files
committed
grid2: add base round down for buy order
1 parent 62eed96 commit 756a3bb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pkg/strategy/grid2/strategy.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,15 @@ func (s *Strategy) processFilledOrder(o types.Order) {
432432
// for quote amount, always round down with price precision to prevent the quote currency fund locking rounding issue
433433
origQuoteAmount := orderExecutedQuoteAmount
434434
orderExecutedQuoteAmount = orderExecutedQuoteAmount.Round(s.Market.PricePrecision, fixedpoint.Down)
435+
s.logger.Infof("round down %s %s order quote quantity %s to %s by quote precision %d", s.Symbol, newSide, origQuoteAmount.String(), orderExecutedQuoteAmount.String(), s.Market.PricePrecision)
435436

436-
s.logger.Infof("round down buy order quote quantity %s to %s by quote quantity precision %d", origQuoteAmount.String(), orderExecutedQuoteAmount.String(), s.Market.PricePrecision)
437+
newQuantity = orderExecutedQuoteAmount.Div(newPrice)
437438

438-
newQuantity = fixedpoint.Max(orderExecutedQuoteAmount.Div(newPrice), s.Market.MinQuantity)
439+
origQuantity := newQuantity
440+
newQuantity = newQuantity.Round(s.Market.VolumePrecision, fixedpoint.Down)
441+
s.logger.Infof("round down %s %s order base quantity %s to %s by base precision %d", s.Symbol, newSide, origQuantity.String(), newQuantity.String(), s.Market.VolumePrecision)
442+
443+
newQuantity = fixedpoint.Max(newQuantity, s.Market.MinQuantity)
439444
} else if s.QuantityOrAmount.Quantity.Sign() > 0 {
440445
newQuantity = s.QuantityOrAmount.Quantity
441446
}

0 commit comments

Comments
 (0)