diff --git a/pkg/bbgo/exit_cumulated_volume_take_profit.go b/pkg/bbgo/exit_cumulated_volume_take_profit.go index f469c26b0..03738715a 100644 --- a/pkg/bbgo/exit_cumulated_volume_take_profit.go +++ b/pkg/bbgo/exit_cumulated_volume_take_profit.go @@ -38,6 +38,7 @@ func (s *CumulatedVolumeTakeProfit) Bind(session *ExchangeSession, orderExecutor session.MarketDataStream.OnKLineClosed(types.KLineWith(s.Symbol, s.Interval, func(kline types.KLine) { closePrice := kline.Close + openPrice := kline.Open if position.IsClosed() || position.IsDust(closePrice) { return } @@ -65,17 +66,29 @@ func (s *CumulatedVolumeTakeProfit) Bind(session *ExchangeSession, orderExecutor cbv = cbv.Add(last.Volume) } - if cqv.Compare(s.MinQuoteVolume) > 0 { - Notify("[CumulatedVolumeTakeProfit] %s TakeProfit triggered by cumulated volume (window: %d) %f > %f, price = %f", - position.Symbol, - s.Window, - cqv.Float64(), - s.MinQuoteVolume.Float64(), kline.Close.Float64()) - - if err := orderExecutor.ClosePosition(context.Background(), fixedpoint.One, "cumulatedVolumeTakeProfit"); err != nil { - log.WithError(err).Errorf("close position error") - } + if cqv.Compare(s.MinQuoteVolume) < 0 { return } + + // If the closed price is below the open price, it means the sell taker is still strong. + if closePrice.Compare(openPrice) < 0 { + log.Infof("[CumulatedVolumeTakeProfit] closePrice %f is below openPrice %f, skip taking profit", closePrice.Float64(), openPrice.Float64()) + return + } + + kline.GetUpperShadowHeight() + if kline.High.Sub(closePrice).Compare(closePrice.Sub(kline.Low)) < 0 { + + } + + Notify("[CumulatedVolumeTakeProfit] %s TakeProfit triggered by cumulated volume (window: %d) %f > %f, price = %f", + position.Symbol, + s.Window, + cqv.Float64(), + s.MinQuoteVolume.Float64(), kline.Close.Float64()) + + if err := orderExecutor.ClosePosition(context.Background(), fixedpoint.One, "cumulatedVolumeTakeProfit"); err != nil { + log.WithError(err).Errorf("close position error") + } })) }