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.
38 lines
959 B
38 lines
959 B
package indicator |
|
|
|
import ( |
|
"sig-pub/pkg/types" |
|
"sig-pub/pkg/types/series" |
|
) |
|
|
|
const ( |
|
MaxWindow = 128 |
|
) |
|
|
|
// IIndicator 指标基础计算接口 |
|
type IIndicator interface { |
|
Name() string |
|
Calculate(kSeries IIndicatorContext) (vector float64) |
|
} |
|
|
|
// IIndicator 窗口指标基础计算接口 |
|
type IWindowIndicator interface { |
|
// Name 指标名称 |
|
Name() string |
|
// RequiredSeries 计算窗口大小的指标值需要的K线数量 |
|
RequiredSeries(window int16) int16 |
|
// Calculate 计算窗口大小的指标值 |
|
Calculate(ctx IIndicatorContext, window int16) (vector float64) |
|
} |
|
|
|
// IIndicatorContext k线序列, trading服务提供 |
|
type IIndicatorContext interface { |
|
Get(offset int16) (kline types.Kline) |
|
Series(offset, count int16) (klines series.Klines) |
|
} |
|
|
|
// IIndicatorSeries 指标序列, 供策略读取, trading服务提供 |
|
type IIndicatorSeries interface { |
|
Get(offset int16) (vector float64) |
|
Series(offset, count int16) (matrix series.Floats) |
|
}
|
|
|