diff --git a/pkg/indicator/ghfilter.go b/pkg/indicator/ghfilter.go index 97db2fbd6..f5794d4d5 100644 --- a/pkg/indicator/ghfilter.go +++ b/pkg/indicator/ghfilter.go @@ -65,32 +65,10 @@ func (inc *GHFilter) Last() float64 { return inc.Values.Last() } +// interfaces implementation check +var _ Simple = &GHFilter{} var _ types.SeriesExtend = &GHFilter{} func (inc *GHFilter) PushK(k types.KLine) { inc.update(k.Close.Float64(), k.High.Float64()-k.Low.Float64()) } - -func (inc *GHFilter) CalculateAndUpdate(allKLines []types.KLine) { - if inc.Values != nil { - k := allKLines[len(allKLines)-1] - inc.PushK(k) - inc.EmitUpdate(inc.Last()) - return - } - for _, k := range allKLines { - inc.PushK(k) - inc.EmitUpdate(inc.Last()) - } -} - -func (inc *GHFilter) handleKLineWindowUpdate(interval types.Interval, window types.KLineWindow) { - if inc.Interval != interval { - return - } - inc.CalculateAndUpdate(window) -} - -func (inc *GHFilter) Bind(updater KLineWindowUpdater) { - updater.OnKLineWindowUpdate(inc.handleKLineWindowUpdate) -} diff --git a/pkg/indicator/kalmanfilter.go b/pkg/indicator/kalmanfilter.go index c49f22388..5d8345729 100644 --- a/pkg/indicator/kalmanfilter.go +++ b/pkg/indicator/kalmanfilter.go @@ -77,32 +77,10 @@ func (inc *KalmanFilter) Last() float64 { return inc.Values.Last() } +// interfaces implementation check +var _ Simple = &KalmanFilter{} var _ types.SeriesExtend = &KalmanFilter{} func (inc *KalmanFilter) PushK(k types.KLine) { inc.update(k.Close.Float64(), (k.High.Float64()-k.Low.Float64())/2) } - -func (inc *KalmanFilter) CalculateAndUpdate(allKLines []types.KLine) { - if inc.Values != nil { - k := allKLines[len(allKLines)-1] - inc.PushK(k) - inc.EmitUpdate(inc.Last()) - return - } - for _, k := range allKLines { - inc.PushK(k) - inc.EmitUpdate(inc.Last()) - } -} - -func (inc *KalmanFilter) handleKLineWindowUpdate(interval types.Interval, window types.KLineWindow) { - if inc.Interval != interval { - return - } - inc.CalculateAndUpdate(window) -} - -func (inc *KalmanFilter) Bind(updater KLineWindowUpdater) { - updater.OnKLineWindowUpdate(inc.handleKLineWindowUpdate) -}