bbgo: protective stop should send notification when it's activated

This commit is contained in:
c9s 2022-09-07 00:50:16 +08:00
parent bf77f67cbb
commit 62fb09c8d9
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -175,7 +175,7 @@ func (s *ProtectiveStopLoss) handleChange(ctx context.Context, position *types.P
s.stopLossPrice = position.AverageCost.Mul(one.Add(s.StopLossRatio))
}
log.Infof("[ProtectiveStopLoss] %s protection stop loss activated, current price = %f, average cost = %f, stop loss price = %f",
Notify("[ProtectiveStopLoss] %s protection stop loss activated, current price = %f, average cost = %f, stop loss price = %f",
position.Symbol, closePrice.Float64(), position.AverageCost.Float64(), s.stopLossPrice.Float64())
if s.PlaceStopOrder {
@ -200,7 +200,7 @@ func (s *ProtectiveStopLoss) checkStopPrice(closePrice fixedpoint.Value, positio
}
if s.shouldStop(closePrice, position) {
log.Infof("[ProtectiveStopLoss] protection stop order is triggered at price %f, position = %+v", closePrice.Float64(), position)
Notify("[ProtectiveStopLoss] protection stop order is triggered at price %f", closePrice.Float64(), position)
if err := s.orderExecutor.ClosePosition(context.Background(), one, "protectiveStopLoss"); err != nil {
log.WithError(err).Errorf("failed to close position")
}