From d13d882fc4f0f6bfdb731721689e38c4ac6343d6 Mon Sep 17 00:00:00 2001 From: "chiahung.lin" Date: Tue, 23 Jan 2024 15:40:03 +0800 Subject: [PATCH] remove unused log remove running field --- pkg/strategy/dca2/open_position.go | 13 ------------- pkg/strategy/dca2/profit_stats.go | 5 ----- pkg/strategy/dca2/strategy.go | 9 +++------ 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/pkg/strategy/dca2/open_position.go b/pkg/strategy/dca2/open_position.go index 457549af6..3c7afc48e 100644 --- a/pkg/strategy/dca2/open_position.go +++ b/pkg/strategy/dca2/open_position.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/c9s/bbgo/pkg/bbgo" "github.com/c9s/bbgo/pkg/exchange/retry" "github.com/c9s/bbgo/pkg/fixedpoint" "github.com/c9s/bbgo/pkg/types" @@ -33,18 +32,6 @@ func (s *Strategy) placeOpenPositionOrders(ctx context.Context) error { s.debugOrders(createdOrders) - // Running is false means this is new bot (no matter it has trades or not) in persistence - if !s.ProfitStats.Running { - for _, createdOrder := range createdOrders { - if s.ProfitStats.FromOrderID == 0 || s.ProfitStats.FromOrderID > createdOrder.OrderID { - s.ProfitStats.FromOrderID = createdOrder.OrderID - } - } - s.ProfitStats.Running = true - - bbgo.Sync(ctx, s) - } - return nil } diff --git a/pkg/strategy/dca2/profit_stats.go b/pkg/strategy/dca2/profit_stats.go index e0b1ce568..2c02512b3 100644 --- a/pkg/strategy/dca2/profit_stats.go +++ b/pkg/strategy/dca2/profit_stats.go @@ -21,11 +21,6 @@ type ProfitStats struct { TotalProfit fixedpoint.Value `json:"totalProfit,omitempty"` TotalFee map[string]fixedpoint.Value `json:"totalFee,omitempty"` - // Running is used for testing by the same account - // Running is true -> this bot is still working, we need to use the values in persistence - // Running is false -> this bot is closed, we can reset all the values in persistence - Running bool `json:"running,omitempty"` - types.PersistenceTTL } diff --git a/pkg/strategy/dca2/strategy.go b/pkg/strategy/dca2/strategy.go index dd98434ec..be89baf22 100644 --- a/pkg/strategy/dca2/strategy.go +++ b/pkg/strategy/dca2/strategy.go @@ -133,11 +133,11 @@ func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) { func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.ExchangeSession) error { instanceID := s.InstanceID() s.Session = session - if s.ProfitStats == nil || !s.ProfitStats.Running { + if s.ProfitStats == nil { s.ProfitStats = newProfitStats(s.Market, s.QuoteInvestment) } - if s.Position == nil || !s.ProfitStats.Running { + if s.Position == nil { s.Position = types.NewPositionFromMarket(s.Market) } @@ -161,7 +161,6 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo. // order executor s.OrderExecutor.TradeCollector().OnPositionUpdate(func(position *types.Position) { - s.logger.Infof("[DCA] POSITION CHANGE: %s", position.String()) s.logger.Infof("[DCA] POSITION UPDATE: %s", s.Position.String()) bbgo.Sync(ctx, s) @@ -203,7 +202,7 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo. s.logger.Info("[DCA] user data stream authenticated") time.AfterFunc(3*time.Second, func() { if isInitialize := s.initializeNextStateC(); !isInitialize { - if s.RecoverWhenStart && s.ProfitStats.Running { + if s.RecoverWhenStart { // recover if err := s.recover(ctx); err != nil { s.logger.WithError(err).Error("[DCA] something wrong when state recovering") @@ -264,8 +263,6 @@ func (s *Strategy) Close(ctx context.Context) error { s.logger.WithError(err).Errorf("[DCA] there are errors when cancelling orders at close") } - s.ProfitStats.Running = false - bbgo.Sync(ctx, s) return err }