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.
42 lines
1.1 KiB
42 lines
1.1 KiB
package trader |
|
|
|
import "sig-pub/pkg/types" |
|
|
|
type StrategyName string |
|
|
|
// 下单策略接口 |
|
type Strategy interface { |
|
Meta() StrategyMeta |
|
// init id, 计算完成 publish 时使用id, |
|
// exchange: 封装indicator访问, 封装历史k线访问 |
|
// args: 动态策略参数, 执行时创建 |
|
Init(ctx StrategyContext, args map[string]any) (code ErrorCode, err error) |
|
Update(ctx StrategyContext, kline types.Kline) (code ErrorCode, err error) |
|
// Emit() // 下单: sell/buy -> 持单,双方向?, score(分数权重) |
|
} |
|
|
|
type StrategyMeta struct { |
|
// Id string `json:"id"` // 策略注册/执行器系统分配 |
|
Name string |
|
Desc string |
|
SubIntervals []types.Interval // 订阅k线周期 |
|
} |
|
|
|
// KlineServiceClient |
|
// IndicatorClient.Sub(MACD5) stream[Indicator] |
|
// IndicatorClient.Sub(ALMA) stream[Indicator] |
|
// |
|
|
|
// 持单策略接口,动态止盈/止损/加仓/减仓 |
|
type OrderStrategy interface { |
|
} |
|
|
|
// 策略外部访问能力 |
|
type StrategyContext interface { |
|
Previous(offset int) types.Kline |
|
Range(offset int) []types.Kline |
|
} |
|
|
|
// 策略a |
|
type StrategyA struct { |
|
}
|
|
|