]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(qav3): ensure optuna storage path is sanitized
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 16 Feb 2025 08:39:13 +0000 (09:39 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 16 Feb 2025 08:39:13 +0000 (09:39 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
ReforceXY/user_data/config-template.json
ReforceXY/user_data/freqaimodels/ReforceXY.py
quickadapter/user_data/freqaimodels/LightGBMRegressorQuickAdapterV35.py
quickadapter/user_data/freqaimodels/XGBoostRegressorQuickAdapterV35.py

index 1ea31f6571bf852cb4e14706121dce9d7a4fe3e3..8e498f163e015ecf9269d960619fc2e78c0a9838 100644 (file)
       "max_trade_duration_candles": 96, // Timeout exit value used with force_actions
       "force_actions": false, // Utilize minimal_roi, stoploss, and max_trade_duration_candles as TP/SL/Timeout in the environment
       "n_envs": 1, // Number of DummyVecEnv environments
-      "frame_staking": 0, // Number of VecFrameStack stacks (set to 1 to use)
+      "frame_staking": 0, // Number of VecFrameStack stacks (set > 1 to use)
       "lr_schedule": false, // Enable learning rate linear schedule
       "cr_schedule": false, // Enable clip range linear schedule
       "max_no_improvement_evals": 0, // Maximum consecutive evaluations without a new best model
index 4eb33624f86a2c5286cc1701be5afc1bd4bc4a91..4c1cc2f7c9316dc49bdf8afdac44ea4c50efba33 100644 (file)
@@ -73,7 +73,7 @@ class ReforceXY(BaseReinforcementLearningModel):
                 "max_trade_duration_candles": 96,   // Timeout exit value used with force_actions
                 "force_actions": false,             // Utilize minimal_roi, stoploss, and max_trade_duration_candles as TP/SL/Timeout in the environment
                 "n_envs": 1,                        // Number of DummyVecEnv environments
-                "frame_staking": 0,                 // Number of VecFrameStack stacks (set to 1 to use)
+                "frame_staking": 0,                 // Number of VecFrameStack stacks (set > 1 to use)
                 "lr_schedule": false,               // Enable learning rate linear schedule
                 "cr_schedule": false,               // Enable clip range linear schedule
                 "max_no_improvement_evals": 0,      // Maximum consecutive evaluations without a new best model
@@ -489,6 +489,7 @@ class ReforceXY(BaseReinforcementLearningModel):
         except KeyboardInterrupt:
             pass
 
+        # FIXME: ensure that best trial params are handled on a per pair basis
         logger.info("------------ Hyperopt results ------------")
         logger.info(
             "Best trial: %s. Score: %s", study.best_trial.number, study.best_trial.value
index 11bdb94bcb16d6072afa99c130fdbedc3749a3ea..602c8703d29dfced1263504ae6acd4caeb783c91 100644 (file)
@@ -230,11 +230,14 @@ class LightGBMRegressorQuickAdapterV35(BaseRegressionModel):
         storage_dir = str(dk.full_path)
         storage_backend = self.__optuna_config.get("storage", "file")
         if storage_backend == "sqlite":
-            storage = f"sqlite:///{storage_dir}/optuna-{sanitize_path(dk.pair.split('/')[0])}.sqlite"
+            sqlite_path = sanitize_path(
+                f"{storage_dir}/optuna-{dk.pair.split('/')[0]}.sqlite"
+            )
+            storage = f"sqlite:///{sqlite_path}"
         elif storage_backend == "file":
             storage = optuna.storages.JournalStorage(
                 optuna.storages.journal.JournalFileBackend(
-                    f"{storage_dir}/optuna-{sanitize_path(dk.pair.split('/')[0])}.log"
+                    sanitize_path(f"{storage_dir}/optuna-{dk.pair.split('/')[0]}.log")
                 )
             )
         return storage
index fe44dd9acb262ba3c87757d5bd9cad2abdc743ea..a43d9156dd1e93773f12d789e1944c405a2dbaf3 100644 (file)
@@ -231,11 +231,14 @@ class XGBoostRegressorQuickAdapterV35(BaseRegressionModel):
         storage_dir = str(dk.full_path)
         storage_backend = self.__optuna_config.get("storage", "file")
         if storage_backend == "sqlite":
-            storage = f"sqlite:///{storage_dir}/optuna-{sanitize_path(dk.pair.split('/')[0])}.sqlite"
+            sqlite_path = sanitize_path(
+                f"{storage_dir}/optuna-{dk.pair.split('/')[0]}.sqlite"
+            )
+            storage = f"sqlite:///{sqlite_path}"
         elif storage_backend == "file":
             storage = optuna.storages.JournalStorage(
                 optuna.storages.journal.JournalFileBackend(
-                    f"{storage_dir}/optuna-{sanitize_path(dk.pair.split('/')[0])}.log"
+                    sanitize_path(f"{storage_dir}/optuna-{dk.pair.split('/')[0]}.log")
                 )
             )
         return storage