From 541d19d8268fee7f1873d9c3a715afedae156790 Mon Sep 17 00:00:00 2001 From: narumi <4680567+narumiruna@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:03:51 +0800 Subject: [PATCH 1/2] modify log again --- pkg/strategy/atrpin/strategy.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/strategy/atrpin/strategy.go b/pkg/strategy/atrpin/strategy.go index d95b02ddd..b8a87ff8a 100644 --- a/pkg/strategy/atrpin/strategy.go +++ b/pkg/strategy/atrpin/strategy.go @@ -39,9 +39,6 @@ type Strategy struct { func (s *Strategy) Initialize() error { s.Strategy = &common.Strategy{} - - log = log.WithField("symbol", s.Symbol) - return nil } @@ -123,7 +120,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se position := s.Strategy.OrderExecutor.Position() log.Infof("position: %+v", position) if !position.IsDust() { - log.Infof("position is not dust") + log.Infof("%s position is not dust", s.Symbol) side := types.SideTypeSell takerPrice := fixedpoint.Zero @@ -150,7 +147,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se log.Infof("SUBMIT TAKER ORDER: %+v", orderForms) if _, err := s.Strategy.OrderExecutor.SubmitOrders(ctx, orderForms...); err != nil { - log.WithError(err).Error("unable to submit orders") + log.WithError(err).Errorf("unable to submit orders: %+v", orderForms) } return @@ -184,14 +181,14 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se } if len(orderForms) == 0 { - log.Infof("no order to place") + log.Infof("no %s order to place", s.Symbol) return } - log.Infof("bid/ask: %f/%f", bidPrice.Float64(), askPrice.Float64()) + log.Infof("%s bid/ask: %f/%f", s.Symbol, bidPrice.Float64(), askPrice.Float64()) if _, err := s.Strategy.OrderExecutor.SubmitOrders(ctx, orderForms...); err != nil { - log.WithError(err).Error("unable to submit orders") + log.WithError(err).Errorf("unable to submit orders: %+v", orderForms) } })) From 502685f5d88a1dd59fad67aa59b5dfb5d56dfbc7 Mon Sep 17 00:00:00 2001 From: narumi <4680567+narumiruna@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:21:26 +0800 Subject: [PATCH 2/2] check dust quantity by taker price --- pkg/strategy/atrpin/strategy.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/strategy/atrpin/strategy.go b/pkg/strategy/atrpin/strategy.go index b8a87ff8a..87b8bdf49 100644 --- a/pkg/strategy/atrpin/strategy.go +++ b/pkg/strategy/atrpin/strategy.go @@ -119,20 +119,17 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se position := s.Strategy.OrderExecutor.Position() log.Infof("position: %+v", position) - if !position.IsDust() { + + side := types.SideTypeBuy + takerPrice := ticker.Sell + if position.IsLong() { + side = types.SideTypeSell + takerPrice = ticker.Buy + } + + if !position.IsDust(takerPrice) { log.Infof("%s position is not dust", s.Symbol) - side := types.SideTypeSell - takerPrice := fixedpoint.Zero - - if position.IsShort() { - side = types.SideTypeBuy - takerPrice = ticker.Sell - } else if position.IsLong() { - side = types.SideTypeSell - takerPrice = ticker.Buy - } - orderForms = append(orderForms, types.SubmitOrder{ Symbol: s.Symbol, Type: types.OrderTypeLimit,