strategy: fix a bug when 'trailingStopControl' is not used

This commit is contained in:
Andy Cheng 2022-01-28 13:26:10 +08:00
parent 571c3834c5
commit 8b009a984a
No known key found for this signature in database
GPG Key ID: 936427CF651A9D28

View File

@ -235,10 +235,12 @@ func (s *Strategy) LoadState() error {
s.state.Position = types.NewPositionFromMarket(s.Market)
}
if s.state.CurrentHighestPrice == nil {
s.trailingStopControl.CurrentHighestPrice = fixedpoint.NewFromInt(0)
if s.trailingStopControl != nil {
if s.state.CurrentHighestPrice == nil {
s.trailingStopControl.CurrentHighestPrice = fixedpoint.NewFromInt(0)
}
s.state.CurrentHighestPrice = &s.trailingStopControl.CurrentHighestPrice
}
s.state.CurrentHighestPrice = &s.trailingStopControl.CurrentHighestPrice
return nil
}