Skip to content

Commit 8527d49

Browse files
committed
trailingstop: add default case
1 parent 8d3dfd1 commit 8527d49

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/bbgo/exit_trailing_stop.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (s *TrailingStop2) getRatio(price fixedpoint.Value, position *types.Positio
8080
return position.AverageCost.Sub(price).Div(position.AverageCost), nil
8181
case types.SideTypeSell:
8282
return price.Sub(position.AverageCost).Div(position.AverageCost), nil
83-
case types.SideTypeBoth:
83+
default:
8484
if position.IsLong() {
8585
return price.Sub(position.AverageCost).Div(position.AverageCost), nil
8686
} else if position.IsShort() {
@@ -123,7 +123,7 @@ func (s *TrailingStop2) checkStopPrice(price fixedpoint.Value, position *types.P
123123
s.latestHigh = fixedpoint.Min(price, s.latestHigh)
124124
case types.SideTypeSell:
125125
s.latestHigh = fixedpoint.Max(price, s.latestHigh)
126-
case types.SideTypeBoth:
126+
default:
127127
if position.IsLong() {
128128
s.latestHigh = fixedpoint.Max(price, s.latestHigh)
129129
} else if position.IsShort() {
@@ -149,7 +149,7 @@ func (s *TrailingStop2) checkStopPrice(price fixedpoint.Value, position *types.P
149149
// submit order
150150
return s.triggerStop(price)
151151
}
152-
case types.SideTypeBoth:
152+
default:
153153
if position.IsLong() {
154154
change := s.latestHigh.Sub(price).Div(s.latestHigh)
155155
if change.Compare(s.CallbackRate) >= 0 {

0 commit comments

Comments
 (0)