strategy: cache orders.IDs() in orderIds

This commit is contained in:
Andy Cheng 2022-03-15 16:44:43 +08:00
parent 822fea44fc
commit b94096cb2e
No known key found for this signature in database
GPG Key ID: 936427CF651A9D28

View File

@ -428,8 +428,9 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
if err != nil {
log.WithError(err).Error("submit profit trailing stop order error")
} else {
if len(orders.IDs()) > 0 {
s.trailingStopControl.OrderID = orders.IDs()[0]
orderIds := orders.IDs()
if len(orderIds) > 0 {
s.trailingStopControl.OrderID = orderIds[0]
} else {
log.Error("submit profit trailing stop order error. unknown error")
s.trailingStopControl.OrderID = 0