From cbb752a3f41dfbeaac694dc7103074ddb2cadbe8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 1 May 2026 18:02:23 +0200 Subject: [PATCH] chore: remove unused json imports and fix line length formatting --- .../freqaimodels/QuickAdapterRegressorV3.py | 1 - quickadapter/user_data/strategies/QuickAdapterV3.py | 13 +++++++------ quickadapter/user_data/strategies/Utils.py | 8 ++++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index cd4d610..73e424b 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -1,5 +1,4 @@ import copy -import json import logging import random import time diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index e8351b7..2151e87 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -1,6 +1,5 @@ import datetime import hashlib -import json import logging import math from functools import cached_property, lru_cache, reduce @@ -169,6 +168,10 @@ class QuickAdapterV3(IStrategy): super().__init__(config, *args, **kwargs) migrate_config(self.config, logger) + @cached_property + def timeframe_minutes(self) -> int: + return timeframe_to_minutes(self.config.get("timeframe")) + @staticmethod @lru_cache(maxsize=None) def _trade_directions_set() -> set[TradeDirection]: @@ -179,10 +182,6 @@ class QuickAdapterV3(IStrategy): def _order_types_set() -> set[OrderType]: return set(QuickAdapterV3._ORDER_TYPES) - @cached_property - def timeframe_minutes(self) -> int: - return timeframe_to_minutes(self.config.get("timeframe")) - @property def can_short(self) -> bool: return self.is_short_allowed() @@ -1913,7 +1912,9 @@ class QuickAdapterV3(IStrategy): try: rho1, _ = pearsonr(x_centered[:-1], x_centered[1:]) except (ValueError, TypeError) as exc: - logger.debug("[%s] pearsonr failed, using standard df: %r", "effective_df", exc) + logger.debug( + "[%s] pearsonr failed, using standard df: %r", "effective_df", exc + ) return n - 1 if not np.isfinite(rho1): diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 3d075c3..e794082 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -2569,7 +2569,9 @@ def _optuna_suggest_int_from_range( def optuna_load_best_params( base_path: Path, pair: str, namespace: str ) -> Optional[dict[str, Any]]: - best_params_path = base_path / f"optuna-{namespace}-best-params-{pair.split('/')[0]}.json" + best_params_path = ( + base_path / f"optuna-{namespace}-best-params-{pair.split('/')[0]}.json" + ) if best_params_path.is_file(): with best_params_path.open("r", encoding="utf-8") as read_file: return json.load(read_file) @@ -2583,7 +2585,9 @@ def optuna_save_best_params( params: dict[str, Any], logger: Logger, ) -> None: - best_params_path = base_path / f"optuna-{namespace}-best-params-{pair.split('/')[0]}.json" + best_params_path = ( + base_path / f"optuna-{namespace}-best-params-{pair.split('/')[0]}.json" + ) try: with best_params_path.open("w", encoding="utf-8") as write_file: json.dump(params, write_file, indent=4) -- 2.53.0