Trading with Image-Encoded Time Series via Deep Learning

Uncover the Power of Transfer Learning for Time Series Using Image-Encoded Trading Systems.

Hi! Here's Iván with this week's exciting newsletter, brimming with insights and discoveries on building robust trading strategies and risk models using Machine Learning.

In this edition, I am sharing two interesting research ideas. The first piece relates to using encoded time series as images for predicting the S&P500 and developing an intraday strategy, while the second offers comprehensive research on the forecasting ability of machine learning in options trading. Both are exceptional research works!

  • 🕹️ 2 Academic Articles: Dive into groundbreaking research featuring actionable ideas that are reshaping our understanding of how to apply ML/DL in creating successful investment and trading strategies.

  • 💊 Video Insight : A detailed video presentation delving into the Gramian Angular Field (GAF) method for time series forecasting.

  • 🥐 Quick Learning: Brief summary of how to enhance your current investment strategies using meta-labeling and machine learning.

Academic Insights

“Image-Encoded Time Series via Deep Learning”

The idea is simple.

-->Step 1: Take some time series and transform them into images, using methods like Gramian Angular Fields (GAF).

-->Step 2: Once converted, these time series "images" can utilize established CNN models, such as Inception, ResNet, and AlexNet.

In essence, this taps into the power of transfer learning from pre-trained models.

The goal is to reveal the predictive capabilities of these time series, now in image form.

This method is the focus of the paper I am briefly summarizing in a two-minute overview. 👇

🔔The paper main idea: 

The paper simulates a classic intraday trading strategy, which involves buying or selling a financial instrument (like the S&P500 index future) and ensuring all positions are closed before the market's same-day close.

The authors studied an investment period from 2000-02-01 to 2015-01-30, spanning 16 years with 4569 observations on actual market open days. Each observation was labeled based on the next day's close-open value: 1 for positive and 0 otherwise.

🔔Encoding the time series as images.

The original S&P500 time series, sampled at 5-minute intervals, was aggregated into four new intervals: 1 hour, 4 hours, 8 hours, and 1 day.

Starting with the original time series of the last step, data was aggregated in four different ways, with 20 samples selected from each for next-day market prediction. For instance, 20 1-hour blocks formed one GADF image for the first time series, and 20 4-hour blocks created another GADF image, and so on.

🔔Results

The performance of the trading system (blue), see image above, was compared against the Buy & Hold strategy (red), the 1D-CNN (green), and random guessing (orange). Evaluated across all walks, the paper approach uniquely surpassed the Buy & Hold baseline..

“Can Machine Learning predict Option Returns?” 

This paper represents the most comprehensive empirical effort to date in the field of options and ML. For those interested in option strategies, it is a must-read.

Let me summarize the paper in less than a 2-minute read. 👇

  Data

--> The authors analyze the cross-section of individual U.S. equity option returns using data from OptionMetrics IvyDB, covering the period from January 1996 to December 2020.

--> The dataset comprises over 12 million option-month return observations of calls and puts, all written on individual U.S. stocks.

 Empirical Setting

-> To predict future option returns, the authors utilize 273 variables, comprising 80 option-based characteristics (such as option illiquidity, time-to-maturity, and the implied shorting fee) and 193 stock-based characteristics.

-> The authors apply various linear and nonlinear machine learning models for optimal predictions based on option- and stock-based characteristics. Linear models include penalized regression (ridge, lasso, elastic-net) and dimensionality reduction regressions (principal component, partial least squares). Nonlinear models comprise gradient-boosted regression trees (with and without dropout), random forests, and fully-connected feed-forward neural networks.

 Results

-> While none of the linear models yield positive out-of-sample R2s for the entire testing sample, all nonlinear models do. The authors find that the best-performing models are gradient-boosted regression trees, both with and without dropout (GBR and Dart), achieving out-of-sample R2s of 2.26% and 1.96%.

-> The paper examines whether machine learning models can predict option returns in an economically profitable trading strategy. The findings show that long-short portfolios based on L-En's (ensemble of all linear models) and N-En's (ensemble of all nonlinear models) forecasts generate significant monthly return spreads of 1.30% and 2.04%, respectively, both statistically significant at the 1% level.

-> These results hold also for subsets of call and put options separately, do not depend on earnings announcements, and persist over time.

AI-Essentials: Step-by-Step Tutorial

🚀 Do you want to learn more about how GAFs (Gramian Angular Fields) can aid in time series prediction? Check out this video for a comprehensive presentation of the methodology.

Quick: Learning

“Meta-Labeling: How to Improve your investment strategies with ML” 

One of the most underused yet effective ML techniques to easily improve your strategies.

It is simply a technique to systematically address the issue of sizing the positions of trades, or signals, generated by another model (the "primary" one), with the help of machine learning (ML).

Let me try to summarize the steps to follow: 👇

(1) Start with a primary model for making buy-or-sell decisions. This model can be based on fundamental analysis, technical analysis, analyst expectations, sentiment, or a combination of all these elements.

(2) After determining the buy/sell decision, decide on the size of the bet, which could range from a significant bet to no bet at all.

(3) Optionally, derive a measure of confidence from the primary model. Note that the best decisions for side and size might not always come from the same model.

(4) Address the common challenge of bet sizing with a meta-labeling classification algorithm, designed to refine the use of the primary model.

(5) Label the outcomes of trades based on the primary model as, for instance, 1 (gain) or 0 (loss).

(6) Train a secondary classifier, such as a Random Forest (RF) or XGBoost (XGB), to predict these labeled outcomes.

(7) The secondary model (meta-labeling) focuses on learning the size of the bet. It doesn’t determine the side (buy/sell), but learns how to optimize the use of the primary model for bet sizing.

If you're enjoying our newsletter and want to support us, please recommend it to anyone you know who's interested in AI and Finance. Your referrals are the biggest compliment and help us grow! 🌟🤖💼