QNNs for Stock Price Trend Prediction background cover

QNNs for Stock Price Trend Prediction

Develop quantum neural network models using PyTorch to predict stock price trends based on limit order book data.

Quantum Signals

Hosted by

Quantum Signals

Getting Started on Aqora

If you need to understand how to interact with the Aqora platform first, please follow our tutorial.

Competition Period

Held online from November 1st, 2024, to January 31st, 2025, 11:59PM GMT.

Prizes

Paid Internship roles at Quantum Signals might be offered to the first 3 winners.

Stock Price Trend Prediction with Limit Order Book Data

Predicting stock price trends is a critical task in finance, enabling traders and investors to make informed decisions. The Limit Order Book (LOB) provides a detailed view of the market's supply and demand, offering granular information about buy and sell orders at different price levels. Leveraging LOB data can significantly enhance the accuracy of short-term stock price trend predictions.
Financial markets are characterized by high volatility and complexity, making accurate predictions challenging. Traditional deep learning models often struggle with the high dimensionality and non-linearity inherent in LOB data. In this context, quantum computing techniques, specifically Quantum Neural Networks, offer a promising avenue to handle complex data structures more efficiently.
In this competition, participants are challenged to develop quantum neural network models using PyTorch to predict stock price trends based on LOB data. The goal is to harness quantum computing techniques to handle the high dimensionality and complexity of LOB data for improved prediction performance.

Setting

Each market observation consists of LOB data over a fixed time window. Specifically, for a given time tt, we consider a market observation M(T)\mathcal{M}(T) over the time window T=[th,t]T = [t - h, t], where hh is the length of the time window (number of past events considered). The LOB data at each time tt include the prices and volumes at multiple levels LL on both the bid and ask sides.
Formally, the LOB at time tt is represented as:
L(t)={Pask(t),Vask(t),Pbid(t),Vbid(t)}\mathbb{L}(t) = \{ P^{\text{ask}}(t), V^{\text{ask}}(t), P^{\text{bid}}(t), V^{\text{bid}}(t) \}
where:
  • Pask(t)RLP^{\text{ask}}(t) \in \mathbb{R}^L: Prices on the ask side at levels 11 to LL.
  • Vask(t)RLV^{\text{ask}}(t) \in \mathbb{R}^L: Volumes on the ask side at levels 11 to LL.
  • Pbid(t)RLP^{\text{bid}}(t) \in \mathbb{R}^L: Prices on the bid side at levels 11 to LL.
  • Vbid(t)RLV^{\text{bid}}(t) \in \mathbb{R}^L: Volumes on the bid side at levels 11 to LL.
The mid-price at time tt is defined as:
m(t)=P1ask(t)+P1bid(t)2m(t) = \frac{P^{\text{ask}}_1(t) + P^{\text{bid}}_1(t)}{2}
Our goal is to predict the future trend of the mid-price based on the historical LOB data in the time window TT.

Trend Definition

We define the stock price trend at time tt by comparing the current mid-price m(t)m(t) with the average future mid-price over a horizon of kk events:
a+(k,t)=1ki=1km(t+i)a^+(k, t) = \frac{1}{k} \sum_{i=1}^k m(t + i)
We classify the trend into three categories:
  • Upward (U): If a+(k,t)>m(t)(1+θ)a^+(k, t) > m(t)(1 + \theta)
  • Downward (D): If a+(k,t)<m(t)(1θ)a^+(k, t) < m(t)(1 - \theta)
  • Stable (S): If a+(k,t)[m(t)(1θ), m(t)(1+θ)]a^+(k, t) \in [m(t)(1 - \theta),\ m(t)(1 + \theta)]
where θ\theta is a predefined threshold that determines the sensitivity of the trend classification.

Challenges

  • Volatility and Noise: Financial markets are inherently volatile, and LOB data can be noisy. Models need to be robust to noise and capable of capturing relevant patterns.
  • Computational Complexity: Traditional neural networks may struggle with the computational complexity of large LOB datasets. Quantum neural networks offer a potential advantage in handling such complexity.

Objective

The objective is to develop a quantum neural network model that can accurately predict the stock price trend y(t){U,D,S}y(t) \in \{ U, D, S \} at time tt based on the market observation M(T)\mathcal{M}(T).
Formally, the model ff aims to approximate the mapping:
y(t)=f(M(T);θ)y(t) = f(\mathcal{M}(T); \theta)
where θ\theta represents the model parameters.
Participants are to minimize the prediction error on the trend classes. This can be formulated as an optimization problem:
minθ1Ni=1NL(f(M(Ti);θ),y(ti))\min_{\theta} \frac{1}{N} \sum_{i=1}^N \mathcal{L}(f(\mathcal{M}(T_i); \theta), y(t_i))
where NN is the number of samples, and L\mathcal{L} is the cross-entropy loss function appropriate for multi-class classification.

Constraints

Participants should consider the following constraints:
  • Class Imbalance: The dataset may exhibit class imbalance among the trend classes U, D, and S. Appropriate techniques should be employed to address this issue if necessary.
  • Quantum Neural Networks: The model must incorporate quantum neural network techniques, leveraging quantum computing capabilities to enhance performance.
  • Model Implementation: Models should be implemented using PyTorch and should utilize quantum computing frameworks compatible with PyTorch.

Problem Formulation

Putting it all together, the problem can be formulated as developing a quantum neural network model f(;θ)f(\cdot; \theta) that maps high-dimensional LOB data M(T)\mathcal{M}(T) to trend predictions y(t){U,D,S}y(t) \in \{ U, D, S \}, by solving the optimization problem:
minθ1Ni=1NL(f(M(Ti);θ),y(ti))\min_{\theta} \frac{1}{N} \sum_{i=1}^N \mathcal{L}(f(\mathcal{M}(T_i); \theta), y(t_i))
Traditional methods struggle with this problem due to the high dimensionality and complexity of the data. Quantum computing techniques offer the potential to process this data more efficiently, potentially leading to better predictive performance.