mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
indicator: GH & Kalman filters: remove deprecated method implementation
This commit is contained in:
parent
9c684c124c
commit
425d9e0475
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user