Refine agent strategy routing and config handling

This commit is contained in:
lky-spec
2026-04-28 19:37:44 +08:00
parent fc6c42ac11
commit 2d45e7ab15
22 changed files with 1321 additions and 968 deletions

View File

@@ -142,6 +142,7 @@ func MergeStrategyConfig(base StrategyConfig, patch map[string]any) (StrategyCon
return StrategyConfig{}, err
}
normalizeStrategyConfigPatch(patch)
mergeJSONMaps(mergedMap, patch)
mergedJSON, err := json.Marshal(mergedMap)
@@ -156,6 +157,18 @@ func MergeStrategyConfig(base StrategyConfig, patch map[string]any) (StrategyCon
return merged, nil
}
func normalizeStrategyConfigPatch(patch map[string]any) {
if patch == nil {
return
}
if _, hasType := patch["strategy_type"]; hasType {
return
}
if gridConfig, hasGrid := patch["grid_config"]; hasGrid && gridConfig != nil {
patch["strategy_type"] = "grid_trading"
}
}
func mergeJSONMaps(dst, src map[string]any) {
for key, srcVal := range src {
srcMap, srcIsMap := srcVal.(map[string]any)