mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-15 00:36:56 +08:00
Refine agent strategy routing and config handling
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user