Trading via image classification

Naftali Cohen, Tucker Balch, Manuela Veloso

Introduction

In systematic trading, algorithms typically process financial data as numerical time-series. However, professional human traders often rely on visual patterns in charts to develop intuition for market movements. Researchers from J.P. Morgan AI Research have explored bridging this gap by treating financial trading as a computer vision problem. By converting standard numerical data into candlestick chart images, they trained machine learning models to replicate complex trading signals with up to 95% accuracy, effectively automating the visual processing traditionally performed by humans.

Methodology

The core of the approach involves transforming discrete stock price data into a visual format suitable for image classification.

Data Processing and Encoding

The researchers utilized 1-minute interval trading data, aggregating it into Open, High, Low, and Close (OHLC) values. These values serve as the fundamental building blocks for financial charts.

Conversion of OHLC time-series data into candlestick representations.

These values were rendered into candlestick (box and whisker) charts. The study experimented with various visual designs, such as adjusting box widths to represent time or volume and overlaying previous "Close" values to provide additional context.

Labeling and Classification

To establish a ground truth for training, three classic technical analysis indicators were used to label images as "Buy" or "No-Buy":

  1. Bollinger Bands (BB): Identifying oversold conditions relative to volatility.
  2. Relative Strength Index (RSI): Measuring the speed and change of price movements.
  3. Moving Average Convergence Divergence (MACD): A trend-following momentum indicator.

The study employed a "hard voting" ensemble of 16 different classifiers, including traditional models like Random Forest and modern Convolutional Neural Networks (CNNs).

Dataset

The research utilized historical data from Yahoo Finance for all S&P 500 companies from 2010 to 2018. This resulted in a balanced dataset of 10,000 high-resolution images per indicator (5,000 "Buy" and 5,000 "No-Buy" samples).

Results and Key Insights

The experimental results demonstrate that visual representations can serve as robust proxies for underlying numerical data.

Performance Metrics

The ensemble model achieved approximately 95% accuracy and precision for the Bollinger Band and RSI rules. For the more complex MACD indicator, which involves multiple time-scales, the model achieved roughly 80% accuracy.

Model performance on 2018 AAPL data, showing identified buy signals relative to Bollinger Bands.

Visual Representation as a Feature Filter

A key finding was that high-resolution images are not necessary; model performance matured at a resolution of just 30x30 pixels. The researchers suggest that converting numbers to images acts as a form of feature engineering, helping models ignore numerical noise and focus on the spatial relationships defining market trends. Furthermore, models were capable of inferring the direction of time from the standard left-to-right layout without explicit visual cues.

Conclusion and Future Work

This research proves that financial trading strategies can be effectively automated by treating market data as a computer vision problem. While the study focused on recovering known algebraic rules, it opens the door for discovering new profitable patterns that may not be easily defined by existing formulas.

Future research directions include expanding the analysis to include "Sell" signals and moving from static images to dynamic representations, such as video-based classification or Recurrent Neural Networks (RNNs), to capture the market's "flow."

Summary updated

BibTeX
@inproceedings{cohen2019trading,
  author = {Naftali Cohen and Tucker Balch and Manuela Veloso},
  title = {{Trading via image classification}},
  booktitle = {ICAIF},
  year = {2019},
  doi = {10.1145/3383455.3422544},
}
Figure