FIX: [grid2] specify client order id explicitly

This commit is contained in:
gx578007 2023-03-10 15:47:42 +08:00
parent 31e299baf2
commit 16b30960cc

View File

@ -11,6 +11,7 @@ import (
"time" "time"
"github.com/cenkalti/backoff/v4" "github.com/cenkalti/backoff/v4"
"github.com/google/uuid"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -494,6 +495,7 @@ func (s *Strategy) processFilledOrder(o types.Order) {
Quantity: newQuantity, Quantity: newQuantity,
Tag: orderTag, Tag: orderTag,
GroupID: s.OrderGroupID, GroupID: s.OrderGroupID,
ClientOrderID: uuid.New().String(),
} }
s.logger.Infof("SUBMIT GRID REVERSE ORDER: %s", orderForm.String()) s.logger.Infof("SUBMIT GRID REVERSE ORDER: %s", orderForm.String())
@ -1251,6 +1253,7 @@ func (s *Strategy) generateGridOrders(totalQuote, totalBase, lastPrice fixedpoin
TimeInForce: types.TimeInForceGTC, TimeInForce: types.TimeInForceGTC,
Tag: orderTag, Tag: orderTag,
GroupID: s.OrderGroupID, GroupID: s.OrderGroupID,
ClientOrderID: uuid.New().String(),
}) })
usedBase = usedBase.Add(quantity) usedBase = usedBase.Add(quantity)
} else { } else {
@ -1268,6 +1271,7 @@ func (s *Strategy) generateGridOrders(totalQuote, totalBase, lastPrice fixedpoin
TimeInForce: types.TimeInForceGTC, TimeInForce: types.TimeInForceGTC,
Tag: orderTag, Tag: orderTag,
GroupID: s.OrderGroupID, GroupID: s.OrderGroupID,
ClientOrderID: uuid.New().String(),
}) })
quoteQuantity := quantity.Mul(nextPrice) quoteQuantity := quantity.Mul(nextPrice)
usedQuote = usedQuote.Add(quoteQuantity) usedQuote = usedQuote.Add(quoteQuantity)
@ -1301,6 +1305,7 @@ func (s *Strategy) generateGridOrders(totalQuote, totalBase, lastPrice fixedpoin
TimeInForce: types.TimeInForceGTC, TimeInForce: types.TimeInForceGTC,
Tag: orderTag, Tag: orderTag,
GroupID: s.OrderGroupID, GroupID: s.OrderGroupID,
ClientOrderID: uuid.New().String(),
}) })
usedQuote = usedQuote.Add(quoteQuantity) usedQuote = usedQuote.Add(quoteQuantity)
} }