]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
chore: refine types
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 19 Nov 2025 20:29:14 +0000 (21:29 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 19 Nov 2025 20:29:14 +0000 (21:29 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/strategies/Utils.py

index 5149bd4ab4a2b190b5f9b012e82452ba410be0ae..7230382143511fde5a6c36bb8adaafb9e314a45a 100644 (file)
@@ -5,7 +5,7 @@ import math
 from enum import IntEnum
 from functools import lru_cache
 from logging import Logger
-from typing import Any, Callable, Literal, Optional, TypeVar
+from typing import Any, Callable, Literal, Optional, TypeVar, Union
 
 import numpy as np
 import optuna
@@ -17,24 +17,31 @@ from technical import qtpylib
 
 T = TypeVar("T", pd.Series, float)
 
-WEIGHT_STRATEGIES = ("none", "pivot_threshold")
+
 WeightStrategy = Literal["none", "pivot_threshold"]
+WEIGHT_STRATEGIES: tuple[WeightStrategy, ...] = ("none", "pivot_threshold")
 
-NORMALIZATION_TYPES = ("minmax", "l1", "none")
 NormalizationType = Literal["minmax", "l1", "none"]
+NORMALIZATION_TYPES: tuple[NormalizationType, ...] = ("minmax", "l1", "none")
 
-SMOOTHING_METHODS = ("gaussian", "kaiser", "triang", "smm", "sma")
 SmoothingKernel = Literal["gaussian", "kaiser", "triang"]
-SmoothingMethod = Literal["gaussian", "kaiser", "triang", "smm", "sma"]
+SmoothingMethod = Union[SmoothingKernel, Literal["smm", "sma"]]
+SMOOTHING_METHODS: tuple[SmoothingMethod, ...] = (
+    "gaussian",
+    "kaiser",
+    "triang",
+    "smm",
+    "sma",
+)
 
 
-DEFAULTS_EXTREMA_SMOOTHING = {
+DEFAULTS_EXTREMA_SMOOTHING: dict[str, Any] = {
     "method": SMOOTHING_METHODS[0],  # "gaussian"
     "window": 5,
     "beta": 8.0,
 }
 
-DEFAULTS_EXTREMA_WEIGHTING = {
+DEFAULTS_EXTREMA_WEIGHTING: dict[str, Any] = {
     "normalization": NORMALIZATION_TYPES[0],  # "minmax"
     "gamma": 1.0,
     "strategy": WEIGHT_STRATEGIES[0],  # "none"