indicator: GH & Kalman filters: remove deprecated method implementation

This commit is contained in:
Raphanus Lo 2022-09-05 16:51:30 +08:00
parent 9c684c124c
commit 425d9e0475
2 changed files with 4 additions and 48 deletions

View File

@ -65,32 +65,10 @@ func (inc *GHFilter) Last() float64 {
return inc.Values.Last() return inc.Values.Last()
} }
// interfaces implementation check
var _ Simple = &GHFilter{}
var _ types.SeriesExtend = &GHFilter{} var _ types.SeriesExtend = &GHFilter{}
func (inc *GHFilter) PushK(k types.KLine) { func (inc *GHFilter) PushK(k types.KLine) {
inc.update(k.Close.Float64(), k.High.Float64()-k.Low.Float64()) 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)
}

View File

@ -77,32 +77,10 @@ func (inc *KalmanFilter) Last() float64 {
return inc.Values.Last() return inc.Values.Last()
} }
// interfaces implementation check
var _ Simple = &KalmanFilter{}
var _ types.SeriesExtend = &KalmanFilter{} var _ types.SeriesExtend = &KalmanFilter{}
func (inc *KalmanFilter) PushK(k types.KLine) { func (inc *KalmanFilter) PushK(k types.KLine) {
inc.update(k.Close.Float64(), (k.High.Float64()-k.Low.Float64())/2) 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)
}