strategy: check trailing stop order creation success

This commit is contained in:
Andy Cheng 2022-04-08 18:41:19 +08:00
parent f9052f3397
commit d94e8e3826
No known key found for this signature in database
GPG Key ID: 936427CF651A9D28

View File

@ -605,7 +605,14 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
log.WithError(err).Errorf("submit %s profit trailing stop order error", s.Symbol) log.WithError(err).Errorf("submit %s profit trailing stop order error", s.Symbol)
s.Notify("submit %s profit trailing stop order error", s.Symbol) s.Notify("submit %s profit trailing stop order error", s.Symbol)
} else { } else {
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.Notify("submit %s profit trailing stop order error", s.Symbol)
s.trailingStopControl.OrderID = 0
}
} }
} }
} }