Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: no use MAX(quantity, minQuantity) to avoid sufficient quantity #1784

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading