]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
feat(reforcexy): add custom_protections property with validation
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 17 Aug 2026 15:25:33 +0000 (17:25 +0200)
committerGitHub <noreply@github.com>
Mon, 17 Aug 2026 15:25:33 +0000 (17:25 +0200)
ReforceXY/user_data/config-template.json
ReforceXY/user_data/strategies/RLAgentStrategy.py

index c96b0a75ef4ad69d2e1ca292fd9c185fff28ae73..a5b9c7e4efd84e052ed7c39dc4f49554e90343c5 100644 (file)
@@ -89,6 +89,7 @@
       "method": "StaticPairList"
     }
   ],
+  "custom_protections": [],
   "telegram": {
     "enabled": false,
     "token": "",
index e3eb1c77f6d64a0595dd7d13edb9f57e459ae457..9cbe106bfe5c144437dc9bd75b96ac9c458d450e 100644 (file)
@@ -63,6 +63,19 @@ class RLAgentStrategy(IStrategy):
     def can_short(self) -> bool:
         return self.is_short_allowed()
 
+    @property
+    def protections(self) -> list[dict[str, Any]]:
+        custom_protections = self.config.get("custom_protections", [])
+        if not isinstance(custom_protections, list) or not all(
+            isinstance(protection, dict) and isinstance(protection.get("method"), str)
+            for protection in custom_protections
+        ):
+            raise ValueError(
+                "Config: 'custom_protections' must be a list of protection objects, "
+                "each with a 'method' string."
+            )
+        return custom_protections
+
     # def feature_engineering_expand_all(
     #     self, dataframe: DataFrame, period: int, metadata: dict[str, Any], **kwargs
     # ) -> DataFrame: