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.
35 lines
865 B
35 lines
865 B
package strategy |
|
|
|
import ( |
|
"sig-pub/pkg/indicator" |
|
"sig-pub/pkg/types" |
|
"sig-pub/pkg/types/series" |
|
) |
|
|
|
// todo Exit 止盈止损策略(trading service 管理) |
|
// todo Meta 策略调参, 回测引擎自动调参回测(最佳参数) argGenerator.next() (arg, ok) |
|
type Strategy interface { |
|
New() Strategy |
|
Meta() StrategyMeta |
|
Update(ctx StrategyContext) |
|
} |
|
|
|
type StrategyMeta struct { |
|
// Id string `json:"id"` // 策略注册/执行器系统分配 |
|
Name string |
|
Desc string |
|
} |
|
|
|
// StrategyContext 策略外部访问能力 |
|
// klineSeries, Indicator |
|
type StrategyContext interface { |
|
Buy() // 发出多信号 |
|
Sell() // 发出空信号 |
|
|
|
// Get [0]当前k线 |
|
Get(offset int16) types.Kline |
|
// Series [offset...end] |
|
Series(offset, count int16) (klines series.Klines) |
|
// 获取窗口类型指标 |
|
IndicatorW(name string, window int) indicator.IIndicatorSeries |
|
}
|
|
|