Skip to content

Commit

Permalink
remove unused log
Browse files Browse the repository at this point in the history
remove running field
  • Loading branch information
kbearXD committed Jan 23, 2024
1 parent 1b33308 commit d13d882
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
13 changes: 0 additions & 13 deletions pkg/strategy/dca2/open_position.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
5 changes: 0 additions & 5 deletions pkg/strategy/dca2/profit_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
9 changes: 3 additions & 6 deletions pkg/strategy/dca2/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit d13d882

Please sign in to comment.