update pivotlow on start

This commit is contained in:
c9s 2022-07-14 18:35:58 +08:00
parent 191e00adeb
commit 89ffd94d98
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -89,6 +89,20 @@ func (s *BreakLow) Bind(session *bbgo.ExchangeSession, orderExecutor *bbgo.Gener
} }
// update pivot low data // update pivot low data
session.MarketDataStream.OnStart(func() {
lastLow := fixedpoint.NewFromFloat(s.pivot.LastLow())
if lastLow.IsZero() {
return
}
if lastLow.Compare(s.lastLow) != 0 {
bbgo.Notify("%s new pivot low detected: %f %s", s.Symbol, s.pivot.LastLow(), kline.EndTime.Time().String())
}
s.lastLow = lastLow
s.pivotLowPrices = append(s.pivotLowPrices, s.lastLow)
})
session.MarketDataStream.OnKLineClosed(types.KLineWith(symbol, s.Interval, func(kline types.KLine) { session.MarketDataStream.OnKLineClosed(types.KLineWith(symbol, s.Interval, func(kline types.KLine) {
lastLow := fixedpoint.NewFromFloat(s.pivot.LastLow()) lastLow := fixedpoint.NewFromFloat(s.pivot.LastLow())
if lastLow.IsZero() { if lastLow.IsZero() {