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

This commit is contained in:
kbearXD 2024-10-21 14:52:40 +08:00
parent df377698c8
commit 704924a905

View File

@ -503,7 +503,6 @@ func (s *Strategy) processFilledOrder(o types.Order) {
newQuantity = newQuantity.Round(s.Market.VolumePrecision, fixedpoint.Down) 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) 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 { } else if s.QuantityOrAmount.Quantity.Sign() > 0 {
newQuantity = s.QuantityOrAmount.Quantity newQuantity = s.QuantityOrAmount.Quantity
} }
@ -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 EarnBase is enabled, we should sell less to get the same quote amount back
if s.EarnBase { 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 // always round down the base quantity for placing sell order to avoid the base currency fund locking issue
@ -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) 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{ orderForm := types.SubmitOrder{
Symbol: s.Symbol, Symbol: s.Symbol,
Market: s.Market, Market: s.Market,
@ -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("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 { if s.ProfitSpread.Sign() > 0 {
s.ProfitSpread = s.Market.TruncatePrice(s.ProfitSpread) s.ProfitSpread = s.Market.TruncatePrice(s.ProfitSpread)
} }