Deep reinforcement learning for time series: playing idealized trading games

Xiang Gao

Abstract

Deep Q-learning is investigated as an end-to-end solution to estimate the optimal strategies for acting on time series input. Experiments are conducted on two idealized trading games. 1) Univariate: the only input is a wave-like price time series, and 2) Bivariate: the input includes a random stepwise price time series and a noisy signal time series, which is positively correlated with future price changes. The Univariate game tests whether the agent can capture the underlying dynamics, and the Bivariate game tests whether the agent can utilize the hidden relation among the inputs. Stacked Gated Recurrent Unit (GRU), Long Short-Term Memory (LSTM) units, Convolutional Neural Network (CNN), and multi-layer perceptron (MLP) are used to model Q values. For both games, all agents successfully find a profitable strategy. The GRU-based agents show best overall performance in the Univariate game, while the MLP-based agents outperform others in the Bivariate game.

Introduction

In domains such as finance and healthcare, determining optimal actions based on time-series data is a significant challenge. Traditional supervised learning often fails to account for the long-term consequences of actions, where the value of a decision today is intrinsically linked to future states and subsequent choices. Reinforcement Learning (RL) offers a robust framework for such sequential decision-making. However, applying RL to real-world financial markets is complicated by extreme noise and non-stationarity. To isolate the impact of neural architectures from market unpredictability, this study utilizes "idealized trading games" with synthetic data to evaluate how different models capture temporal patterns and inter-input relationships.

Methodology

The core algorithm employed is Deep Q-Learning (DQN) with Experience Replay. The agent observes a sliding window of the past 40 time steps and must select one of three actions: CASH (exit or stay out), BUY (enter a position, incurring a fixed transaction cost), or HOLD (maintain an existing position). The reward signal is defined as the change in price (Profit & Loss) minus any transaction costs.

Four neural architectures were benchmarked:

  • Convolutional Neural Networks (CNN): Designed to extract local features through spatial filters.
  • Recurrent Neural Networks (GRU & LSTM): Specialized in maintaining state over long sequences to capture temporal dependencies.
  • Multi-Layer Perceptrons (MLP): Standard feed-forward networks used as a baseline for non-sequential pattern recognition.

Experimental Datasets

The study utilizes two distinct synthetic environments to test specific agent capabilities:

  1. Univariate Game: This environment features a wave-like price series generated by superimposing multiple sine waves of varying frequencies with added noise. It tests the agent's ability to recognize and exploit cyclical oscillations.
Univariate game dataset: Synthetic wave-like price series used to test pattern recognition.
  1. Bivariate Game: This environment consists of a random stepwise price series and a "leading signal." The signal is a noisy, time-shifted version of future price movements, requiring the agent to discover the hidden correlation between two separate input streams.
Bivariate game dataset: Stepwise price series paired with a noisy leading signal.

Results and Discussion

The agents were trained over 1,000 episodes and evaluated on 100 out-of-sample episodes. Nearly all configurations achieved profitability, with many maintaining a positive P&L in 95-100% of test cases.

Task-Architecture Fit

A key finding is that architecture performance is highly task-dependent. The GRU (specifically a 3-layer, 32-unit configuration) dominated the Univariate game, achieving a Mean P&L of 116.1. This suggests that recurrent units are better suited for internalizing the "physics" of wave-like dynamics. Conversely, the MLP (5 layers, 16 units) outperformed all others in the Bivariate game with a Mean P&L of 43.8, indicating that simpler feed-forward models can be more efficient at exploiting direct signal-response relationships.

The CNN and Complexity Paradox

CNN-based agents consistently underperformed. The rigid nature of fixed filter lengths and pooling layers may have hindered their ability to adapt to these specific time-series nuances. Furthermore, increasing model depth or width did not yield linear improvements in performance, suggesting that for these idealized tasks, optimal complexity is relatively low.

Conclusion

While the agents successfully learned profitable strategies in controlled environments, real-world application remains a hurdle due to market non-stationarity, liquidity constraints, and slippage. Future research should focus on more realistic simulations and the integration of advanced techniques like Attention mechanisms or Actor-Critic methods to bridge the gap between idealized games and actual market dynamics.

Summary updated

Abstract

Deep Q-learning is investigated as an end-to-end solution to estimate the optimal strategies for acting on time series input. Experiments are conducted on two idealized trading games. 1) Univariate: the only input is a wave-like price time series, and 2) Bivariate: the input includes a random stepwise price time series and a noisy signal time series, which is positively correlated with future price changes. The Univariate game tests whether the agent can capture the underlying dynamics, and the Bivariate game tests whether the agent can utilize the hidden relation among the inputs. Stacked Gated Recurrent Unit (GRU), Long Short-Term Memory (LSTM) units, Convolutional Neural Network (CNN), and multi-layer perceptron (MLP) are used to model Q values. For both games, all agents successfully find a profitable strategy. The GRU-based agents show best overall performance in the Univariate game, while the MLP-based agents outperform others in the Bivariate game.
BibTeX
@misc{gao2018deep,
  author = {Xiang Gao},
  title = {{Deep reinforcement learning for time series: playing idealized trading games}},
  year = {2018},
  eprint = {1803.03916},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1803.03916},
}
Figure