Skip to content

Commit 3c707a5

Browse files
committed
check minimal order quantity
1 parent 1e4c4f5 commit 3c707a5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

pkg/strategy/rebalance/strategy.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ func (s *Strategy) generateSubmitOrders(ctx context.Context) (submitOrders []typ
247247
Price: currentPrice,
248248
}
249249

250-
submitOrders = append(submitOrders, order)
250+
if ok := s.checkMinimalOrderQuantity(order); ok {
251+
submitOrders = append(submitOrders, order)
252+
}
251253
}
252254

253255
return submitOrders
@@ -294,3 +296,16 @@ func (s *Strategy) adjustMaxAmountByBalance(side types.SideType, currency string
294296

295297
return maxAmount
296298
}
299+
300+
func (s *Strategy) checkMinimalOrderQuantity(order types.SubmitOrder) bool {
301+
if order.Quantity.Compare(order.Market.MinQuantity) < 0 {
302+
log.Infof("order quantity is too small: %f < %f", order.Quantity.Float64(), order.Market.MinQuantity.Float64())
303+
return false
304+
}
305+
306+
if order.Quantity.Mul(order.Price).Compare(order.Market.MinNotional) < 0 {
307+
log.Infof("order min notional is too small: %f < %f", order.Quantity.Mul(order.Price).Float64(), order.Market.MinNotional.Float64())
308+
return false
309+
}
310+
return true
311+
}

0 commit comments

Comments
 (0)