Stripes or Plaid? Or Both?

Considering GAF-Trained CNNs in relation to and in combination with VecViz’s Vector Model and V-Score

Our thanks to Tyler (Foster) Shelbert for his contributions to this post.

Convolutional Neural Networks (CNNs) can excel at time series forecasting1

As a form of “Deep Learning”, CNNs can automatically extract complex, non-linear features from raw data without manual feature engineering. They use filters to automatically “learn” the most discriminative shapes within a time series.

Gramian Angular Fields (GAFs) represent time series as matrices, ideal for CNN processing

The “convolution” operation of a CNN is mathematically designed to exploit the spatial or temporal structure within a matrix of numbers. The relative position of data points within the matrix matters.

GAFs transform a time series into a square matrix via standard scaling and trigonometry.2 When visualized as heatmaps, GAFs produce plaid-like patterns (see center image, above).

The cells of a GAF matrix represent either the volatility, via a GASF, or the drift, via a GADF, between every two points in a time series window3. The earliest pair typically resides at the top left corner of the matrix, and the final pair is typically at the bottom right corner.

GAFs that are labeled with forward performance can be used to train a CNN to generate forecasts. The number of GAFs a CNN can be trained upon simultaneously for any given time series window is limited only by compute and data. It is thus no surprise that GAFs are increasingly being employed by quant-oriented investors as inputs to CNNs.

VecViz represents time series as histograms, for human and machine processing

Whereas GAFs produce plaid, VecViz produces “stripes” in the form of hundreds of channels that together form the Vector Strength Histogram (“VSH”, the leftmost image above).

The VSH displays gaps and bulwarks in the forward price distribution. Its constituent channels deliver narrative on the basis of the dates of the tops and bottoms that anchor them. Human cognition of forward price is thereby served.

From a quant perspective, the VSH enables the scaling of forward price movement in terms of support and resistance4 traversed. Its constituent channels are rich with features for machine learning (ML) relating to chart shape5. Potential “ML” ensembles abound.

We implemented price and volume GAF trained CNNs, to study how they relate to VecViz

Using the pyts GramianAngularField library, we generated GASF and GADF matrices of price and volume for all 65-day rolling windows (at 5-day intervals) back to February 2015, across all 143 tickers in VecViz’s current coverage universe. Each GAF was labelled by forward 10-day return into five categories (0_StrongSell through 4_StrongBuy).

We then trained three TensorFlow CNNs: CNN1 (price GASF only), CNN2 (price GASF + GADF), and CNN4 (price + volume GASF + GADF) on the February 2015-January 31, 2022 period. All results in the section below reflect the nearly four-year out-of-sample test period from February 1, 2022 through December 31, 2025, with zero retraining — consistent with VecViz’s Vector Model and V-Score.

Several VecViz features and outputs correlate to the CNN outputs…

We calculated the correlation of VecViz chart-shape features and Vector Model outputs to each CNNs categorical output (0–4) across the test period. The features with the most statistically significant correlations are shown below, alongside associated p-values6.

Absolute correlations averaged 0.06, 0.11, and 0.07 for CNN1, CNN2, and CNN4, respectively. Directionality sometimes varied across CNNs.

… and they do so in a way that makes sense.

  • “Up” channel angle inputs correlate to volatility oriented CNN1, signifying that too high or low an upward angle could signify sentiment is ripe for or resistant to volatility,
  • Top & Bottom age inputs relate to drift direction oriented CNN2, signifying that stale positioning can drive drift directionality
  • “Down” angles take the lead in CNN4, where volume is considered, along with price. This is consistent with downside volume typically being much higher than upside volume.

Returns generated by the GAF based CNNs were somewhat competitive with the V-Score

We compare forward 10-day returns (raw, not annualized) of CNN long (Buy + StrongBuy) and short (Sell + StrongSell) recommendations to V-Score > 0 and V-Score < 0 signals in the table below.

The “Avg/Std” column is the information ratio — average long-short differential divided by its standard deviation.

CNN4 had the highest Avg_Long_Ret, but the V-Score had the highest Avg_LongShort_Diff, both outright and relative to variability. Some other notable dynamics:

  • The “Long Ret” and “LongShort Diff” return of the CNNs improved as additional info was incorporated (i.e., CNN4 > CNN2 > CNN1)
  • CNN2 had the most number of recommendations among the CNNs.
  • The V-Score generated many more recommendations than the CNNs, averaging 120 per model date versus 44–97 for the CNNs.

GAF CNN output in combination with the V-Score shows some promise

We then examined the performance of the intersection of ticker-model dates that were identified as longs and shorts by both the GAF trained CNNs and the V-Score. The results are displayed below.

All three intersections outperformed their corresponding standalone CNNs in terms of Avg_LongShort_Diff. As expected, the performance boost for CNN1 (23bps) was greater than the boost for CNN2 (9bps), which was greater than the performance boost for CNN4 (4bps)7.

That said, only VS_CNN2 exceeded the standalone V-Score in terms of Avg_LongShort_Diff (0.22 vs 0.20), though it lags on a variance adjusted basis (0.07 vs 0.10).

Given that the performance of CNN4 was superior to that of CNN2, it is interesting that the performance of VS_CNN4 is not better than VS_CNN2. Perhaps the V-Score substantially incorporates the volume related perspective that CNN4 brings relative to CNN2. That dynamic would be consistent with our recent post on VecViz’s implicit incorporation of volume through heavy reliance on Tops and Bottoms.

Perhaps complementary stripes and plaids aren’t as rare we thought.

Given the performance of VS_CNN2 we suspect there is further alpha to be had in deeper integration of Vector Model inputs and outputs with GAF-CNNs. We look forward to exploring it in the months ahead.

  1. Ismail Fawaz, H., Forestier, G., Weber, J. et al. Deep learning for time series classification: a review. Data Min Knowl Disc 33, 917–963 (2019) ↩︎
  2. Each point in the series is converted to a log return, then z-score normalized, MinMax-scaled to a [-1, 1] range, and converted to an angle via inverse trigonometry. ↩︎
  3. Applying inverse sine to the scaled values and summing the resulting angles produces a Gramian Angular Sum Field (GASF), detailing the volatility between each set of points. Applying inverse cosine and subtracting the resulting angles produces a Gramian Angular Difference Field (GADF), detailing the directional drift between each set of points. ↩︎
  4. Vector strength quantifies support and resistance ↩︎
  5. Chart shape features include channel angles, proximity to and time elapsed from channel anchoring Tops and Bottoms. See the V-Score spider chart of our Dashboards for details and definitions. ↩︎
  6. The p-value represents the probability that the correlation is zero, calculated using scipy.stats pearsonr library. ↩︎
  7. The 23bp, 9bp, and 4bp figures reflect the difference between the ” Avg_LongShort_Diff” result for the intersection of each CNN with the V-Score and the ” Avg_LongShort_Diff” result the corresponding CNN generated on a standalone basis. ↩︎

Leave a Comment

Your email address will not be published. Required fields are marked *