]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(qav3): cleanup extrema weighting hybrid strategy logic
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 16 Dec 2025 12:04:39 +0000 (13:04 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 16 Dec 2025 12:04:39 +0000 (13:04 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/strategies/Utils.py

index 44885a7808db6e89b464eb2fe239efd29b555fcd..2be4aab11441479bd9cdb353e15ca734c76063d7 100644 (file)
@@ -729,20 +729,20 @@ def calculate_hybrid_extrema_weights(
 
     normalized_source_weights_array: list[NDArray[np.floating]] = []
     for source in enabled_sources:
-        normalized_source_weights_array.append(
-            normalize_weights(
-                weights_array_by_source[source],
-                standardization=standardization,
-                robust_quantiles=robust_quantiles,
-                mmad_scaling_factor=mmad_scaling_factor,
-                normalization=normalization,
-                minmax_range=minmax_range,
-                sigmoid_scale=sigmoid_scale,
-                softmax_temperature=softmax_temperature,
-                rank_method=rank_method,
-                gamma=gamma,
-            )
+        source_weights_arr = weights_array_by_source[source]
+        normalized_source_weights = normalize_weights(
+            source_weights_arr,
+            standardization=standardization,
+            robust_quantiles=robust_quantiles,
+            mmad_scaling_factor=mmad_scaling_factor,
+            normalization=normalization,
+            minmax_range=minmax_range,
+            sigmoid_scale=sigmoid_scale,
+            softmax_temperature=softmax_temperature,
+            rank_method=rank_method,
+            gamma=gamma,
         )
+        normalized_source_weights_array.append(normalized_source_weights)
 
     if aggregation == HYBRID_AGGREGATIONS[0]:  # "weighted_sum"
         combined_source_weights_array: NDArray[np.floating] = np.average(
@@ -939,7 +939,10 @@ def _apply_weights(
     if weights.size == 0:
         return extrema
 
-    if not np.isfinite(weights).all() or np.allclose(weights, weights[0]):
+    if not np.isfinite(weights).all():
+        return extrema
+
+    if np.allclose(weights, weights[0]):
         return extrema
 
     if np.allclose(weights, DEFAULT_EXTREMA_WEIGHT):