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
1002 B

package strategy
import (
"sig-pub/api/pb"
"sig-pub/pkg/indicator"
"sig-pub/pkg/types"
"sig-pub/pkg/types/series"
)
// ISigStrategy 交易信号策略接口(单周期单交易所)
type ISigStrategy interface {
New() ISigStrategy
Meta() StrategyMeta
Init(param SigStrategyParam) (err error) // 校验参数, 并根据参数初始化策略
Update(ctx ISigStrategyContext) (side pb.Side)
}
type StrategyMeta struct {
Name string `json:"name"`
Desc string `json:"desc"`
MaxWindow int `json:"maxWindow"` // 需要的最大窗口数, 回测时用, 若不定义则取最大窗口值
Args []Param `json:"args"` // 参数定义
}
// ISigStrategyContext 策略外部访问能力
// klineSeries, Indicator
type ISigStrategyContext interface {
// Get [0]当前k线
Get(offset int16) types.Kline
// Series [offset...end]
Series(offset, count int16) (klines series.Klines)
// 获取窗口类型指标
IndicatorW(name string, window int16) indicator.IIndicatorSeries
}