Skip to content

Commit

Permalink
Merge pull request #1784 from c9s/chiahung/grid2/not-use-minQuantity
Browse files Browse the repository at this point in the history
FEATURE: no use MAX(quantity, minQuantity) to avoid sufficient quantity
  • Loading branch information
kbearXD authored Oct 21, 2024
2 parents 859be58 + 704924a commit 5878fd8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/strategy/grid2/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ func (s *Strategy) processFilledOrder(o types.Order) {
newQuantity = newQuantity.Round(s.Market.VolumePrecision, fixedpoint.Down)
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)

newQuantity = fixedpoint.Max(newQuantity, s.Market.MinQuantity)
} else if s.QuantityOrAmount.Quantity.Sign() > 0 {
newQuantity = s.QuantityOrAmount.Quantity
}
Expand All @@ -527,7 +526,7 @@ func (s *Strategy) processFilledOrder(o types.Order) {

// if EarnBase is enabled, we should sell less to get the same quote amount back
if s.EarnBase {
newQuantity = fixedpoint.Max(orderExecutedQuoteAmount.Div(newPrice).Sub(fee), s.Market.MinQuantity)
newQuantity = orderExecutedQuoteAmount.Div(newPrice).Sub(fee)
}

// always round down the base quantity for placing sell order to avoid the base currency fund locking issue
Expand All @@ -536,6 +535,10 @@ func (s *Strategy) processFilledOrder(o types.Order) {
s.logger.Infof("round down sell order quantity %s to %s by base quantity precision %d", origQuantity.String(), newQuantity.String(), s.Market.VolumePrecision)
}

if newQuantity.Compare(s.Market.MinQuantity) < 0 {
s.logger.Infof("new quantity %s @ price %s is less than min base quantity %s, please check it. it may due to trading fee or the min base quantity setting changes", newQuantity.String(), newPrice.String(), s.Market.MinQuantity.String())
}

orderForm := types.SubmitOrder{
Symbol: s.Symbol,
Market: s.Market,
Expand Down Expand Up @@ -1849,6 +1852,8 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
s.logger.Infof("autoRange is enabled, using pivot high %f and pivot low %f", s.UpperPrice.Float64(), s.LowerPrice.Float64())
}

s.logger.Infof("market info: %+v", s.Market)

if s.ProfitSpread.Sign() > 0 {
s.ProfitSpread = s.Market.TruncatePrice(s.ProfitSpread)
}
Expand Down

0 comments on commit 5878fd8

Please sign in to comment.