strategy: fix load CurrentHighestPrice bug

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

View File

@ -332,6 +332,8 @@ func (s *Strategy) LoadState() error {
if s.trailingStopControl != nil {
if s.state.CurrentHighestPrice == nil {
s.trailingStopControl.CurrentHighestPrice = fixedpoint.NewFromInt(0)
} else {
s.trailingStopControl.CurrentHighestPrice = *s.state.CurrentHighestPrice
}
s.state.CurrentHighestPrice = &s.trailingStopControl.CurrentHighestPrice
}
@ -599,7 +601,7 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
if s.trailingStopControl.IsHigherThanMin(minTargetPrice) {
orderForm := s.trailingStopControl.GenerateStopOrder(s.state.Position.Base)
orders, err := s.submitOrders(ctx, orderExecutor, orderForm)
if err != nil {
if err != nil || orders == nil {
log.WithError(err).Errorf("submit %s profit trailing stop order error", s.Symbol)
s.Notify("submit %s profit trailing stop order error", s.Symbol)
} else {