You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

34 lines
1.0 KiB

package trader
import (
"sig-pub/pkg/types"
"github.com/govalues/decimal"
)
// 定义
// Dependes() []IndicatorDef // 需要订阅的指标列表(包括k线, 实时k线/关闭k线)
type IndicatorDef struct {
IndicatorName string
Intervals []types.Interval
}
// 指标定义接口
type Indicator interface {
Meta() IndicatorMeta
// init id, 计算完成 publish 时使用id,
// exchange: 封装indicator访问, 封装历史k线访问
// args: 动态指标参数定义, 执行时创建
Init(ctx Context, exchange any, args map[string]any) (code ErrorCode, err error) // 初始化指标参数, 上下文
Update(kline types.Kline) (err error) // 驱动k线数据, 待驱动k线到达后, 再待subscribe计算完成后执行
Emit(func(klineTs int64, indicators map[string]decimal.Decimal)) // 指标计算完成后发送, 由指标执行器进行存储或分发
}
// 窗口函数
type SeriesWindow interface {
Range(count int) // 当前k到
}
// 指标能力
type Context interface {
}