Discussing the article: "Neural Networks in Trading: Adaptive Periodic Segmentation (Creating Tokens)"

 

Check out the new article: Neural Networks in Trading: Adaptive Periodic Segmentation (Creating Tokens).

We invite you to embark on an exciting journey through the world of adaptive analysis of financial time series and learn how to turn complex spectral analysis and flexible convolution into real trading signals. You will see how LightGTS listens to the market rhythm, adapting to its changes through a variable-window stride, and how OpenCL acceleration can turn computation into a fast track to profitable decisions.

In the practical section of the previous article, we began developing an algorithm for adaptive periodic patching — one of the key elements of the LightGTS architecture. The limitations associated with the inability to use dynamic memory allocation in the runtime environments typical of MQL5 and OpenCL were examined in detail. These limitations forced us to abandon the idea of an arbitrary number of output tokens.

Instead, we made a strategically sound decision: to fix the number of patches and use patch overlap as a tool to compensate for variations in the length of individual segments. Thus, we managed to strike a balance between adaptability (the model remains sensitive to the actual periodicity of the time series) and computational stability, which is necessary for the efficient use of hardware resources. This approach made it possible to preserve both the fidelity of representation of the cyclic structures in the analyzed data and predictability in memory management, which is critical for high-frequency trading models and for implementation in a constrained execution context.

We have already implemented the algorithm for selecting the dominant frequency: it effectively extracts the main periodicity for each univariate sequence in the input time series. This will allow us to specify a base scale for subsequent data segmentation. Today, we will continue the work we started and take the next step: implement the token generation algorithm within the OpenCL context.

Our goal is to divide each time series into a fixed number of segments, with the segment size determined according to the identified dominant frequency, while the overlap controls adaptation to the window length. All of this must be performed in a strictly parallel manner, using GPU-compatible code, where each thread (work-item) is responsible for generating a single token in one of the univariate components of the sequence being analyzed.


Author: Dmitriy Gizlyk