]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
perf(qav3): fine tune prediction min/max thresholds
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 21 Apr 2025 14:41:24 +0000 (16:41 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 21 Apr 2025 14:41:24 +0000 (16:41 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py
quickadapter/user_data/strategies/QuickAdapterV3.py

index 740ee9ddedd5d5eeee6e662bcad0af34998642e5..38135f9263ba46317b15a7b4649be38856db7f1c 100644 (file)
@@ -44,7 +44,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
     https://github.com/sponsors/robcaulk
     """
 
-    version = "3.7.16"
+    version = "3.7.17"
 
     @cached_property
     def _optuna_config(self) -> dict:
@@ -229,6 +229,7 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
                     X_test,
                     y_test,
                     test_weights,
+                    self.data_split_parameters.get("test_size", TEST_SIZE),
                     self.freqai_info.get("fit_live_predictions_candles", 100),
                     self._optuna_config.get("candles_step"),
                     model_training_parameters,
@@ -384,9 +385,10 @@ class QuickAdapterRegressorV3(BaseRegressionModel):
             self.freqai_info.get("prediction_thresholds_temperature", 125.0)
         )
         extrema = pred_df[EXTREMA_COLUMN].iloc[
-            -(
-                (fit_live_predictions_candles // label_period_candles)
-                * label_period_candles
+            -max(
+                label_period_candles,
+                int((fit_live_predictions_candles / 2) / label_period_candles)
+                * label_period_candles,
             ) :
         ]
         min_pred = smoothed_min(extrema, temperature=temperature)
@@ -732,11 +734,12 @@ def train_objective(
     X_test: pd.DataFrame,
     y_test: pd.DataFrame,
     test_weights: np.ndarray,
+    test_size: float,
     fit_live_predictions_candles: int,
     candles_step: int,
     model_training_parameters: dict,
 ) -> float:
-    min_train_window: int = fit_live_predictions_candles * 2
+    min_train_window: int = fit_live_predictions_candles * int(1 / test_size)
     max_train_window: int = len(X)
     if max_train_window < min_train_window:
         min_train_window = max_train_window
@@ -970,7 +973,7 @@ def label_objective(
 
     df = df.iloc[
         -(
-            (fit_live_predictions_candles // label_period_candles)
+            int(fit_live_predictions_candles / label_period_candles)
             * label_period_candles
         ) :
     ]
index 67a9f3801ecbaa2fa3b1c17a8683ff6b5ccfeb06..edff17a60355c4523d8558d6c4f42ac01fec9a80 100644 (file)
@@ -519,11 +519,12 @@ class QuickAdapterV3(IStrategy):
         current_natr = df["natr_label_period_candles"].iloc[-1]
         if isna(current_natr):
             return None
+        take_profit_natr_ratio = self.get_take_profit_natr_ratio(trade.pair)
         trade_take_profit_distance = (
-            trade.open_rate * entry_natr * self.get_take_profit_natr_ratio(trade.pair)
+            trade.open_rate * entry_natr * take_profit_natr_ratio
         )
         current_take_profit_distance = (
-            current_rate * current_natr * self.get_take_profit_natr_ratio(trade.pair)
+            current_rate * current_natr * take_profit_natr_ratio
         )
         return (
             max(