feat(crypto策略): 新增 AG 趋势、异动与波段跟踪信号支持
Motivation: crypto-strategy 源新增 AG 趋势(AGTS)、异动(AMA)、波段跟踪(BTS) 三类量化策略信号,需与既有 trade.* 事件区分以避免和 AI crypto signals 精确匹配冲突,并为缺省方向提供兜底推导。 Changes: * 事件名映射按 strategyCode 使用独立前缀(AGTS./AMA./BTS.,HLSS 保持不变) * direction/side 缺失时依据 isSale 兜底推导为 LONG/SHORT * 补充三类策略的模板、规则示例文档与渲染/转换测试
This commit is contained in:
@@ -62,18 +62,23 @@ func Convert(body []byte) (string, map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
action := inferAction(p)
|
||||
event := "trade." + strings.ToLower(action)
|
||||
if strings.EqualFold(strings.TrimSpace(p.StrategyCode), "HLSS") {
|
||||
event = "HLSS." + strings.ToLower(action)
|
||||
}
|
||||
event := eventName(p.StrategyCode, action)
|
||||
text := format(env, p, action)
|
||||
side := strings.ToUpper(strings.TrimSpace(env.Direction))
|
||||
if side == "" {
|
||||
if p.IsSale {
|
||||
side = "SHORT"
|
||||
} else {
|
||||
side = "LONG"
|
||||
}
|
||||
}
|
||||
|
||||
data := map[string]interface{}{
|
||||
"eventType": env.EventType,
|
||||
"correlationId": env.CorrelationID,
|
||||
"symbol": firstNonEmpty(env.Symbol, p.Currency),
|
||||
"direction": env.Direction,
|
||||
"side": strings.ToUpper(env.Direction),
|
||||
"direction": firstNonEmpty(env.Direction, side),
|
||||
"side": side,
|
||||
"action": action,
|
||||
"eventTime": env.EventTime,
|
||||
"strategyCode": p.StrategyCode,
|
||||
@@ -171,6 +176,17 @@ func mergePayloadFields(data map[string]interface{}, payloadJSON []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
func eventName(strategyCode, action string) string {
|
||||
code := strings.ToUpper(strings.TrimSpace(strategyCode))
|
||||
suffix := strings.ToLower(action)
|
||||
switch code {
|
||||
case "HLSS", "AMA", "BTS", "AGTS":
|
||||
return code + "." + suffix
|
||||
default:
|
||||
return "trade." + suffix
|
||||
}
|
||||
}
|
||||
|
||||
func inferAction(p payload) string {
|
||||
if strings.EqualFold(strings.TrimSpace(p.StrategyCode), "HLSS") {
|
||||
switch {
|
||||
|
||||
Reference in New Issue
Block a user