remove unused log

remove running field
This commit is contained in:
chiahung.lin 2024-01-23 15:40:03 +08:00
parent 1b33308450
commit d13d882fc4
3 changed files with 3 additions and 24 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}