pivotshort: add safety check

This commit is contained in:
c9s 2022-06-26 19:20:30 +08:00
parent 279bb66a4d
commit e1a9df0a2d
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -168,6 +168,10 @@ func (s *ProtectionStopLoss) handleChange(ctx context.Context, position *types.P
}
func (s *ProtectionStopLoss) checkStopPrice(closePrice fixedpoint.Value, position *types.Position) {
if s.stopLossPrice.IsZero() {
return
}
if s.shouldStop(closePrice) {
log.Infof("[ProtectionStopLoss] protection stop order is triggered at price %f, position = %+v", closePrice.Float64(), position)
if err := s.orderExecutor.ClosePosition(context.Background(), one); err != nil {