2022-07-26 09:27:38 +00:00
|
|
|
package indicator
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2022-08-25 09:31:42 +00:00
|
|
|
"github.com/c9s/bbgo/pkg/datatype/floats"
|
2022-07-26 09:27:38 +00:00
|
|
|
"github.com/c9s/bbgo/pkg/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
//go:generate callbackgen -type Low
|
|
|
|
type Low struct {
|
|
|
|
types.IntervalWindow
|
|
|
|
types.SeriesBase
|
|
|
|
|
2022-08-25 09:31:42 +00:00
|
|
|
Values floats.Slice
|
2022-07-26 09:27:38 +00:00
|
|
|
EndTime time.Time
|
|
|
|
|
|
|
|
updateCallbacks []func(value float64)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (inc *Low) Update(value float64) {
|
|
|
|
if len(inc.Values) == 0 {
|
|
|
|
inc.SeriesBase.Series = inc
|
|
|
|
}
|
|
|
|
|
|
|
|
inc.Values.Push(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (inc *Low) PushK(k types.KLine) {
|
|
|
|
if k.EndTime.Before(inc.EndTime) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
inc.Update(k.Low.Float64())
|
|
|
|
inc.EndTime = k.EndTime.Time()
|
2023-05-31 11:35:44 +00:00
|
|
|
inc.EmitUpdate(inc.Last(0))
|
2022-07-26 09:27:38 +00:00
|
|
|
}
|