2022-07-13 16:41:20 +00:00
|
|
|
package indicator
|
|
|
|
|
|
|
|
import "github.com/c9s/bbgo/pkg/types"
|
|
|
|
|
|
|
|
type KLineWindowUpdater interface {
|
|
|
|
OnKLineWindowUpdate(func(interval types.Interval, window types.KLineWindow))
|
|
|
|
}
|
|
|
|
|
2022-07-14 07:57:17 +00:00
|
|
|
type KLineClosedBinder interface {
|
|
|
|
BindK(target KLineClosedEmitter, symbol string, interval types.Interval)
|
|
|
|
}
|
|
|
|
|
|
|
|
// KLineClosedEmitter is currently applied to the market data stream
|
|
|
|
// the market data stream emits the KLine closed event to the listeners.
|
2022-07-14 02:33:10 +00:00
|
|
|
type KLineClosedEmitter interface {
|
2022-07-13 16:41:20 +00:00
|
|
|
OnKLineClosed(func(k types.KLine))
|
|
|
|
}
|
2022-07-13 17:12:36 +00:00
|
|
|
|
|
|
|
// KLinePusher provides an interface for API user to push kline value to the indicator.
|
|
|
|
// The indicator implements its own way to calculate the value from the given kline object.
|
|
|
|
type KLinePusher interface {
|
|
|
|
PushK(k types.KLine)
|
|
|
|
}
|
|
|
|
|
2022-07-26 09:56:31 +00:00
|
|
|
// Simple is the simple indicator that only returns one float64 value
|
|
|
|
type Simple interface {
|
|
|
|
KLinePusher
|
|
|
|
Last() float64
|
|
|
|
OnUpdate(f func(value float64))
|
|
|
|
}
|
|
|
|
|
2022-07-14 02:28:53 +00:00
|
|
|
type KLineCalculateUpdater interface {
|
2022-07-13 17:12:36 +00:00
|
|
|
CalculateAndUpdate(allKLines []types.KLine)
|
|
|
|
}
|