trailing stop: apply ClosePosition parameter

This commit is contained in:
c9s 2022-07-07 02:19:35 +08:00
parent d86338d6e6
commit d2637ce261
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -153,5 +153,10 @@ func (s *TrailingStop2) triggerStop(price fixedpoint.Value) error {
}() }()
Notify("[TrailingStop] %s stop loss triggered. price: %f callback rate: %f", s.Symbol, price.Float64(), s.CallbackRate.Float64()) Notify("[TrailingStop] %s stop loss triggered. price: %f callback rate: %f", s.Symbol, price.Float64(), s.CallbackRate.Float64())
ctx := context.Background() ctx := context.Background()
return s.orderExecutor.ClosePosition(ctx, fixedpoint.One, "trailingStop") p := fixedpoint.One
if !s.ClosePosition.IsZero() {
p = s.ClosePosition
}
return s.orderExecutor.ClosePosition(ctx, p, "trailingStop")
} }