From 37535e9f3e71fb496a54c6df15d29d2edfbf006a Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 24 Feb 2023 12:24:43 +0800 Subject: [PATCH 1/2] grid2: fix fee reduction by rounding --- pkg/strategy/grid2/strategy.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/strategy/grid2/strategy.go b/pkg/strategy/grid2/strategy.go index 7fc3c3754..5fb48ffeb 100644 --- a/pkg/strategy/grid2/strategy.go +++ b/pkg/strategy/grid2/strategy.go @@ -373,9 +373,11 @@ func (s *Strategy) processFilledOrder(o types.Order) { // if we don't reduce the sell quantity, than we might fail to place the sell order if o.Side == types.SideTypeBuy { baseSellQuantityReduction = s.aggregateOrderBaseFee(o) - s.logger.Infof("GRID BUY ORDER BASE FEE: %s %s", baseSellQuantityReduction.String(), s.Market.BaseCurrency) + baseSellQuantityReduction = baseSellQuantityReduction.Round(s.Market.VolumePrecision, fixedpoint.HalfUp) + s.logger.Infof("GRID BUY ORDER BASE FEE (Rounding): %s %s", baseSellQuantityReduction.String(), s.Market.BaseCurrency) + newQuantity = newQuantity.Sub(baseSellQuantityReduction) } From 5b903cd4ed1e1f95c176d70dc73069ade34b5f8a Mon Sep 17 00:00:00 2001 From: c9s Date: Fri, 24 Feb 2023 12:46:38 +0800 Subject: [PATCH 2/2] grid2: always round up --- pkg/strategy/grid2/strategy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/strategy/grid2/strategy.go b/pkg/strategy/grid2/strategy.go index 5fb48ffeb..c4a531a91 100644 --- a/pkg/strategy/grid2/strategy.go +++ b/pkg/strategy/grid2/strategy.go @@ -375,7 +375,7 @@ func (s *Strategy) processFilledOrder(o types.Order) { baseSellQuantityReduction = s.aggregateOrderBaseFee(o) s.logger.Infof("GRID BUY ORDER BASE FEE: %s %s", baseSellQuantityReduction.String(), s.Market.BaseCurrency) - baseSellQuantityReduction = baseSellQuantityReduction.Round(s.Market.VolumePrecision, fixedpoint.HalfUp) + baseSellQuantityReduction = baseSellQuantityReduction.Round(s.Market.VolumePrecision, fixedpoint.Up) s.logger.Infof("GRID BUY ORDER BASE FEE (Rounding): %s %s", baseSellQuantityReduction.String(), s.Market.BaseCurrency) newQuantity = newQuantity.Sub(baseSellQuantityReduction)