From: Jérôme Benoit Date: Mon, 17 Aug 2026 15:25:33 +0000 (+0200) Subject: feat(reforcexy): add custom_protections property with validation X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=2a7310497ed64c0db4f0c37006924a2172baaf85;p=freqai-strategies.git feat(reforcexy): add custom_protections property with validation --- diff --git a/ReforceXY/user_data/config-template.json b/ReforceXY/user_data/config-template.json index c96b0a7..a5b9c7e 100644 --- a/ReforceXY/user_data/config-template.json +++ b/ReforceXY/user_data/config-template.json @@ -89,6 +89,7 @@ "method": "StaticPairList" } ], + "custom_protections": [], "telegram": { "enabled": false, "token": "", diff --git a/ReforceXY/user_data/strategies/RLAgentStrategy.py b/ReforceXY/user_data/strategies/RLAgentStrategy.py index e3eb1c7..9cbe106 100644 --- a/ReforceXY/user_data/strategies/RLAgentStrategy.py +++ b/ReforceXY/user_data/strategies/RLAgentStrategy.py @@ -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: