From 4dbadf96b16353579bf53dfc47b21511d3d493d8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 23 Jul 2026 21:25:54 +0200 Subject: [PATCH] refactor(quickadapter): extract is_finite_number to Utils and reuse it (#122) * refactor(quickadapter): extract is_finite_number to Utils and reuse it - move the numeric/finite/non-bool scalar guard from a QuickAdapterV3 static method to a shared Utils.is_finite_number helper - reuse it across the strategy label getters/setters and the shared label_natr_multiplier validation guard - leave the strict positive-int label_period_candles/label_horizon_candles paths unchanged (distinct predicate) * refactor(quickadapter): harden label-param fallbacks and per-row NATR guard Address the #112 re-review findings (landed in this PR): - coerce the per-row label_period_candles series with pandas to_numeric before np.isfinite, matching the guarded scalar path (object/str dtype no longer raises) - re-validate the persisted _label_params fallback in the label getters via is_finite_number before use, otherwise fall back to config - generalize the is_trade_runmode comment (it gates both persisted-param reuse and per-candle param setting) - README: drop the inaccurate 'simulated' wording and the runmode-specific framing on the label_period_candles/label_natr_multiplier rows * docs(quickadapter): drop per-candle label-param behavior notes from tunables The label_period_candles/label_natr_multiplier rows describe labeling tunables; the per-candle strategy-NATR/exit consumption is an internal behavior detail (already documented inline in the code), not needed to configure the tunable. Revert both rows to their base description. * style(quickadapter): wrap set_label_natr_multiplier guard per ruff format The committed one-liner exceeded the 88-char line length; apply ruff format wrapping (behavior unchanged). * docs(quickadapter): align warm_start tunable row padding Trim one over-pad space so the warm_start row matches the surrounding table column width (whitespace only). --- README.md | 6 +-- .../user_data/strategies/QuickAdapterV3.py | 49 ++++++++----------- quickadapter/user_data/strategies/Utils.py | 17 ++++--- 3 files changed, 34 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index b2bcc1d..5ac33d9 100644 --- a/README.md +++ b/README.md @@ -100,12 +100,12 @@ docker compose up -d --build | freqai.label_pipeline.sigmoid_scale | 1.0 | float > 0 | Scale parameter for `sigmoid` normalization, controls steepness. | | freqai.label_pipeline.gamma | 1.0 | float (0,10] | Contrast exponent applied to labels after normalization: >1 emphasizes extrema, values between 0 and 1 soften. | | _Feature parameters_ | | | | -| freqai.feature_parameters.label_period_candles | min/max midpoint | int >= 1 | Zigzag labeling NATR period. When label HPO is enabled, backtest and hyperopt retain the period produced for each simulated candle when calculating strategy NATR. | +| freqai.feature_parameters.label_period_candles | min/max midpoint | int >= 1 | Zigzag labeling NATR period. | | freqai.feature_parameters.label_horizon_candles | `label_period_candles` | int >= 1 | Number of candles after a label row before the label is considered known by causal split guards. Recommended: cover the zigzag pivot confirmation lag (the smoothing kernel half-width is added automatically by `set_freqai_targets`). Used by causal split guards and `