]> Piment Noir Git Repositories - freqai-strategies.git/commit
fix(zigzag): default normalize to False to prevent label magnitude leak (#71)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 23 May 2026 22:23:35 +0000 (00:23 +0200)
committerGitHub <noreply@github.com>
Sat, 23 May 2026 22:23:35 +0000 (00:23 +0200)
commit900a646d1220189e1df8ebec31a07a0c65e792e3
tree4789b06f798238650ada21a0bd934d942d6d9d42
parent86d64da6259cf007c96a45defec0d90c2e8b3a42
fix(zigzag): default normalize to False to prevent label magnitude leak (#71)

When set_freqai_targets is invoked by FreqAI's backtesting loop, the dataframe
passed to _generate_extrema_label spans the full historical window
(right-truncated to the current train-window stop), not just train_period_days.
With normalize=True, zigzag applies a global minmax scaling across all detected
pivots in that wider window to amplitudes, amplitude_threshold_ratios,
volume_rates and speeds. The resulting label magnitudes therefore depend on the
global pivot distribution, including pivots outside the current training slice
— a magnitude leak from out-of-train data into training labels.

Switching the zigzag default to normalize=False emits raw log-amplitude values
(|log(P2/P1)|) and defers any scaling to LabelTransformer, which is fitted
strictly on the train slice and is therefore leak-free. The two existing call
sites — _generate_extrema_label (label generation) and label_objective (Optuna
hyperopt) — both want the unnormalized output, so the redundant
normalize=False kwargs are dropped at the call sites in favor of the default.

Strategy and regressor patch versions are bumped to 3.11.8.

Caveat: with apply_label_weighting strategy="combined", the metrics now sit on
heterogeneous scales (raw log-amplitudes ~[0.005, 0.5] mix with bounded ratios
in [0, 1] like efficiency_ratio). Users relying on "combined" aggregation
(power means, weighted_median, softmax) may need to introduce metric-specific
rescaling on the train slice before aggregation. Direction-only (strategy=
"none") and single-metric strategies (e.g. strategy="amplitude") are
unaffected.
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py
quickadapter/user_data/strategies/QuickAdapterV3.py
quickadapter/user_data/strategies/Utils.py