StockformerBands<T>

Models & Types · AiDotNet.Finance.Trading.Factors

The dual-frequency band split behind Stockformer: a single-level discrete wavelet transform that separates a return series into a LOW-frequency band (trend) and a HIGH-frequency band (short-term fluctuation and abrupt events).

For Beginners

A stock’s return series mixes a slow drift with fast jitter. This separates the two so each can be studied with machinery suited to it — the paper’s finding is that treating them identically wastes information.

How It Works

Ma, Xue, Lu and Chen, “Stockformer: A price-volume factor stock selection model based on wavelet transform and multi-task self-attention networks” (arXiv:2401.06139; Expert Systems with Applications 273:126803, 2025).

This is a preprocessing stage, not a layer, and that is deliberate. In the reference implementation (github.com/Eric991005/Multitask-Stockformer) the transform lives in the TRAINING SCRIPT — it imports pytorch_wavelets.DWT1DForward and hands the model two already-split inputs, xl and xh. The network never sees the undecomposed series. Implementing the DWT as a layer inside the model would look reasonable and would not match the paper.

One level, sym2. From the reference config: wave = sym2, level = 1. Exactly one split into two bands, which is why the encoder downstream has exactly two branches. “Wavelet decomposition” invites building a deep multi-resolution pyramid; the paper does not.

sym2 and db2 (Daubechies-2) are the same wavelet — identical four filter taps — so this reuses the library’s SymletWavelet at order 2 rather than restating the coefficients.

Constructors

Constructor Summary
StockformerBands(int waveletOrder, int levels) Creates a band splitter.

Properties

Property Summary
int Levels { get; } Gets the number of decomposition levels (1 per the paper).
int WaveletOrder { get; } Gets the Symlet order in use (2 per the paper).

Methods

Method Summary
ValueTuple<Matrix<T>, Matrix<T>> SplitAll(Matrix<T> perStockSeries) Splits every stock’s series in a [stocks, time] matrix, returning one matrix per band.
ValueTuple<Vector<T>, Vector<T>> Split(Vector<T> series) Splits series into (low, high) bands.
int BandLength(int inputLength) The band length produced from an input window of inputLength samples.