Skip to content

Commit

Permalink
Merge pull request #1529 from c9s/narumi/atrpin/log2
Browse files Browse the repository at this point in the history
CHORE: [atrpin] modify log again
  • Loading branch information
narumiruna authored Feb 6, 2024
2 parents f186d69 + 502685f commit d34a410
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions pkg/strategy/atrpin/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ type Strategy struct {

func (s *Strategy) Initialize() error {
s.Strategy = &common.Strategy{}

log = log.WithField("symbol", s.Symbol)

return nil
}

Expand Down Expand Up @@ -122,19 +119,16 @@ 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")

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
}

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)

orderForms = append(orderForms, types.SubmitOrder{
Symbol: s.Symbol,
Expand All @@ -150,7 +144,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
Expand Down Expand Up @@ -184,14 +178,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)
}
}))

Expand Down

0 comments on commit d34a410

Please sign in to comment.