mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
bbgo: add strict condition for CumulatedVolumeTakeProfit
This commit is contained in:
parent
402ac58b53
commit
d022c80727
|
@ -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,7 +66,21 @@ func (s *CumulatedVolumeTakeProfit) Bind(session *ExchangeSession, orderExecutor
|
|||
cbv = cbv.Add(last.Volume)
|
||||
}
|
||||
|
||||
if cqv.Compare(s.MinQuoteVolume) > 0 {
|
||||
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,
|
||||
|
@ -75,7 +90,5 @@ func (s *CumulatedVolumeTakeProfit) Bind(session *ExchangeSession, orderExecutor
|
|||
if err := orderExecutor.ClosePosition(context.Background(), fixedpoint.One, "cumulatedVolumeTakeProfit"); err != nil {
|
||||
log.WithError(err).Errorf("close position error")
|
||||
}
|
||||
return
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user