Relation-Aware Transformer for Portfolio Policy Learning

Ke Xu, Yifan Zhang, Deheng Ye, Peilin Zhao, Mingkui Tan

Abstract

Portfolio selection (PS) involves the dynamic reallocation of wealth across a set of assets to maximize returns while managing risk. Traditional and early deep learning approaches often struggle with the inherent noise and complex correlations in financial data. This paper presents the Relation-Aware Transformer (RAT), a reinforcement learning framework that integrates context-aware sequential attention and relation-aware asset attention. By explicitly modeling local price contexts and inter-asset dependencies, RAT effectively filters market noise and captures macro-market trends. Additionally, a leverage-enabled decision-making layer allows the model to engage in short-selling, providing a significant competitive edge. Experimental results on cryptocurrency and S&P500 datasets show that RAT substantially outperforms state-of-the-art baselines in terms of accumulated portfolio value and risk-adjusted returns.

Introduction

Dynamic portfolio selection is a fundamental challenge in quantitative finance. The primary difficulties stem from the "noisy" and non-stationary nature of financial time series. Existing AI models often face two major hurdles:

  1. Sequential Complexity: Asset prices are prone to sudden oscillations and follow complex laws like mean reversion. Standard models looking at isolated data points often fail to distinguish between meaningful trends and random noise.
  2. Asset Correlations: Financial assets do not move independently. Market-wide factors often cause assets to move in tandem or in opposition. Most current models treat assets as independent threads, failing to leverage the predictive power of asset relationships.

The Relation-Aware Transformer (RAT) addresses these gaps by combining a robust temporal encoder with a relational layer that views the portfolio as a cohesive system.

Methodology

The RAT framework adapts the classic Transformer architecture for the specific demands of financial forecasting and decision-making.

The RAT architecture featuring Sequential Attention, Relation Attention, and a Leverage-Enabled Decoder.

Sequential Attention Layer

To combat price "jitters," the encoder utilizes Context Attention. Unlike standard self-attention that performs point-wise matching, this layer considers a small window of previous prices (local context) to generate queries and keys. This smoothing effect makes the model more resilient to high-frequency noise.

Relation Attention Layer

Following the temporal analysis, the Relation Attention layer performs self-attention across the assets themselves. This allows the model to learn dynamic correlations between different stocks or cryptocurrencies, helping it balance risk across the entire portfolio based on current market conditions.

Leverage-Enabled Decoder

Standard reinforcement learning models for PS typically use a softmax output, restricting strategies to "long-only" positions. RAT introduces a novel leverage operation. The decoder outputs an initial portfolio, a short-sale vector, and a reinvestment vector. This allows the model to take "short" positions (betting against an asset), with weights ranging from -1 to 2, significantly expanding the strategy space.

Experimental Setup

The model was evaluated on three real-world datasets:

  • Crypto-A: 12 cryptocurrencies from the Poloniex exchange (2016–2018).
  • Crypto-B: A larger set of 37 cryptocurrencies (2017–2019).
  • S&P500: 506 stocks from the US equity market (2013–2018).

Training utilized a direct policy gradient algorithm aimed at maximizing logarithmic cumulative returns while accounting for a 0.25% transaction cost.

Results and Analysis

RAT demonstrated significant superiority over traditional online learning baselines (e.g., OLMAR, RMR) and deep learning models (e.g., EIIE, MTL).

Performance comparison of RAT against various baselines across three datasets.

As shown in the results table, RAT achieved an Accumulated Portfolio Value (APV) of 156.53 on the Crypto-A dataset, nearly eight times higher than the best non-RAT baseline. On the S&P500 dataset, the inclusion of leverage allowed RAT to achieve exceptional theoretical returns, outperforming standard models by several orders of magnitude.

Ablation studies confirmed that both the Context Attention and Relation Attention components are critical. Removing either led to a significant performance degradation, proving that both "local timing" and "asset relationships" are vital for success.

Conclusion

The Relation-Aware Transformer represents a significant step forward in AI-driven portfolio management. By moving beyond point-wise analysis to context-aware and relation-aware modeling, RAT handles market noise and asset dependencies more effectively than previous architectures. The addition of a leverage-enabled decoder further empowers the model to capitalize on market downturns. Future work will focus on improving the stability of reinforcement learning in these environments and incorporating alternative data sources like news sentiment.

Summary updated

BibTeX
@inproceedings{xu2020relation,
  author = {Ke Xu and Yifan Zhang and Deheng Ye and Peilin Zhao and Mingkui Tan},
  title = {{Relation-Aware Transformer for Portfolio Policy Learning}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2020},
  doi = {10.24963/ijcai.2020/641},
}
Figure