Discussing the article: "Implementing and Benchmarking Bag-of-SFA-Symbols (BOSS) Against Dynamic Time Warping (DTW)"

 

Check out the new article: Implementing and Benchmarking Bag-of-SFA-Symbols (BOSS) Against Dynamic Time Warping (DTW).

This article implements BOSS from scratch in MQL5 and applies it to regime classification: SFA turns windows into words, bags record word frequencies, and an ensemble over window lengths votes on labels. We cover the encoding steps, the BOSS distance, training with auto-generated regime labels, and practical parameters. A BTCUSD benchmark versus DTW shows higher macro accuracy on clean data and markedly faster inference.

Elastic methods such as Dynamic Time Warping fix the alignment problem by stretching and compressing the time axis to find the best match, but they pay for it: they are computationally heavy, still sensitive to noise, and the warping path they produce is hard to interpret. Symbolic methods take a different route. Instead of comparing the raw numbers at all, they compress each window into a short string of letters and then compare the strings. The compression is where all the robustness comes from.

The pipeline we will build reduces a window to a word in three moves. Each move discards exactly the kind of variation we want to ignore:

  • Z-normalization removes the price level. After subtracting the mean and dividing by the standard deviation, a window is described purely by its shape. The same arc at $30,000 and $60,000 becomes the same normalized curve.
  • A low-pass Fourier filter removes the noise. By keeping only the first few Fourier coefficients of the window, we retain its coarse structure and throw away the high-frequency jitter. This is the single most important idea in the whole method, and it is what lets BOSS tolerate noisy price data where a raw matcher cannot.
  • Quantization into letters removes fine numerical detail. Each retained coefficient is mapped to one of a small alphabet of symbols, so tiny differences that do not change the shape category do not change the word.

The output is a word such as "cbad", four letters standing in for a window of prices. A whole stretch of market, run through a sliding window, becomes a bag of such words, and the frequency of each word is the market's vocabulary over that stretch. Two markets in the same regime speak the same dialect; two markets in different regimes do not. The rest of this article is the machinery that makes this precise, and the empirical test of whether it actually works on real data.

A price window compressed into a four-letter SFA word

Author: Muhammad Minhas Qamar