From: Jérôme Benoit Date: Sun, 21 Jun 2026 19:38:52 +0000 (+0200) Subject: style(quickadapter): wrap long expression lines X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=538ac5836c305810813b1e608bd7a74527da60d0;p=freqai-strategies.git style(quickadapter): wrap long expression lines --- diff --git a/quickadapter/user_data/strategies/LabelTransformer.py b/quickadapter/user_data/strategies/LabelTransformer.py index 2a34253..d028358 100644 --- a/quickadapter/user_data/strategies/LabelTransformer.py +++ b/quickadapter/user_data/strategies/LabelTransformer.py @@ -33,6 +33,7 @@ def _clip_sigmoid_domain(values: NDArray[np.floating]) -> NDArray[np.floating]: eps = np.finfo(float).eps return np.clip(values, -1.0 + eps, 1.0 - eps) + CombinedMetric = Literal[ "amplitude", "amplitude_threshold_ratio", @@ -355,9 +356,7 @@ class LabelTransformer(BaseTransform): if inverse: clipped = _clip_sigmoid_domain(values[mask]) clipped_count = int( - np.count_nonzero( - (clipped != values[mask]) & ~np.isnan(values[mask]) - ) + np.count_nonzero((clipped != values[mask]) & ~np.isnan(values[mask])) ) if clipped_count: logger.warning( diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index 2beefe6..b1b44b6 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -700,7 +700,11 @@ class QuickAdapterV3(IStrategy): ) with np.errstate(divide="ignore", invalid="ignore"): dataframe["%-close_pct_change"] = Series( - np.where(np.isfinite(close_values) & (close_values > 0.0), np.log(close_values), np.nan), + np.where( + np.isfinite(close_values) & (close_values > 0.0), + np.log(close_values), + np.nan, + ), index=dataframe.index, ).diff() dataframe["%-raw_volume"] = volumes @@ -733,13 +737,11 @@ class QuickAdapterV3(IStrategy): dataframe["kc_lowerband"] = kc["KCLe_14_2.0"] dataframe["kc_middleband"] = kc["KCBe_14_2.0"] dataframe["kc_upperband"] = kc["KCUe_14_2.0"] - dataframe["%-kc_width"] = ( - safe_divide( - dataframe["kc_upperband"] - dataframe["kc_lowerband"], - dataframe["kc_middleband"], - context="feature_engineering_expand_basic:kc_width", - logger=logger, - ) + dataframe["%-kc_width"] = safe_divide( + dataframe["kc_upperband"] - dataframe["kc_lowerband"], + dataframe["kc_middleband"], + context="feature_engineering_expand_basic:kc_width", + logger=logger, ) ( dataframe["bb_upperband"], @@ -751,13 +753,11 @@ class QuickAdapterV3(IStrategy): nbdevup=2.2, nbdevdn=2.2, ) - dataframe["%-bb_width"] = ( - safe_divide( - dataframe["bb_upperband"] - dataframe["bb_lowerband"], - dataframe["bb_middleband"], - context="feature_engineering_expand_basic:bb_width", - logger=logger, - ) + dataframe["%-bb_width"] = safe_divide( + dataframe["bb_upperband"] - dataframe["bb_lowerband"], + dataframe["bb_middleband"], + context="feature_engineering_expand_basic:bb_width", + logger=logger, ) dataframe["%-ibs"] = (closes - lows) / non_zero_diff(highs, lows) dataframe["jaw"], dataframe["teeth"], dataframe["lips"] = alligator( @@ -788,13 +788,11 @@ class QuickAdapterV3(IStrategy): dataframe["vwap_middleband"], dataframe["vwap_upperband"], ) = vwapb(dataframe, 20, 1.0) - dataframe["%-vwap_width"] = ( - safe_divide( - dataframe["vwap_upperband"] - dataframe["vwap_lowerband"], - dataframe["vwap_middleband"], - context="feature_engineering_expand_basic:vwap_width", - logger=logger, - ) + dataframe["%-vwap_width"] = safe_divide( + dataframe["vwap_upperband"] - dataframe["vwap_lowerband"], + dataframe["vwap_middleband"], + context="feature_engineering_expand_basic:vwap_width", + logger=logger, ) dataframe["%-dist_to_vwap_upperband"] = get_distance( closes, dataframe["vwap_upperband"] diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 82e2130..40d95eb 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -2425,12 +2425,15 @@ def ewo( ma2 = ma_fn(prices, timeperiod=ma2_length) madiff = ma1 - ma2 if normalize: - madiff = safe_divide( - madiff, - prices, - context="ewo:normalize", - logger=logger, - ) * 100.0 + madiff = ( + safe_divide( + madiff, + prices, + context="ewo:normalize", + logger=logger, + ) + * 100.0 + ) return madiff @@ -2561,7 +2564,9 @@ def zigzag( invalid_price_count, ) with np.errstate(divide="ignore", invalid="ignore"): - closes_log = np.where(np.isfinite(closes) & (closes > 0.0), np.log(closes), np.nan) + closes_log = np.where( + np.isfinite(closes) & (closes > 0.0), np.log(closes), np.nan + ) highs_log = np.where(np.isfinite(highs) & (highs > 0.0), np.log(highs), np.nan) lows_log = np.where(np.isfinite(lows) & (lows > 0.0), np.log(lows), np.nan) volumes = df.get("volume").to_numpy()