Deep Stock Trading: A Hierarchical Reinforcement Learning Framework for Portfolio Optimization and Order Execution

Rundong Wang, Hongxin Wei, Bo An, Zhouyan Feng, Jun Yao · DOI

Abstract

Portfolio management via reinforcement learning is at the forefront of fintech research, exploring how to optimally reallocate funds across financial assets over the long term. However, existing methods often assume instantaneous trades, ignoring the significant impact of price slippage and trading costs. We propose the Hierarchical Reinforced Stock Trading System (HRPM), which decomposes the trading process into a hierarchy of high-level portfolio management and low-level order execution. The high-level policy determines portfolio weights at a lower frequency to maximize long-term profit, while the low-level policy executes trades at a higher frequency to minimize costs. Extensive experiments in U.S. and Chinese markets demonstrate that HRPM significantly outperforms state-of-the-art approaches.

Introduction: The Gap Between Strategy and Execution

Most automated trading research focuses on Portfolio Management (PM)—the strategic decision of which stocks to hold and in what proportions. While these models can identify theoretically profitable strategies, they often operate under the idealistic assumption that trades occur instantly at the last observed market price.

In practice, large orders take time to fill and can move market prices against the trader, a phenomenon known as price slippage. Furthermore, a single "flat" Reinforcement Learning (RL) agent struggles to manage the disparate timescales involved: the days or weeks required for portfolio strategy versus the seconds or minutes required for efficient execution. HRPM addresses this disconnect by mimicking the real-world division of labor between a portfolio manager and a floor trader.

The HRPM Framework

The core of our approach is the Hierarchical Reinforced Stock Trading System (HRPM). It splits the trading task into two distinct Markov Decision Processes (MDPs) operating at different frequencies.

The HRPM model architecture showing the interaction between high-level ($\pi^h$) and low-level ($\pi^l$) policies across holding and trading periods.

High-Level Policy: The Portfolio Manager

The high-level policy ($\pi^h$) operates at a lower frequency (e.g., every 5 days). It observes historical price data and current portfolio weights to output a new target distribution. To ensure robustness and risk management, we utilize the REINFORCE algorithm with an entropy bonus. This bonus naturally encourages diversification, preventing the agent from over-concentrating in a few assets and thereby reducing Maximum Drawdown (MDD).

Low-Level Policy: The Execution Trader

The low-level policy ($\pi^l$) operates at a high frequency (e.g., every 30 seconds). It receives a specific subtask from the manager—such as "buy $N$ shares of stock $X$"—and interacts with the Limit Order Book (LOB) to execute the trade at the best possible price. We employ a Branching Dueling Q-Network to handle the multi-dimensional action space of price levels and quantities without exponential complexity.

Training for Data Efficiency

To overcome data scarcity, we implement a pre-training scheme where the low-level policy is first trained on individual stocks. This is followed by an iterative training process that augments the agent's experience with various "remaining quantity" and "remaining time" scenarios, ensuring the trader can handle diverse market conditions.

Experimental Evaluation

We evaluated HRPM on two major global indices:

  • U.S. Market: 23 stocks from the Dow Jones Industrial Average (DJIA).
  • China Market: 23 stocks from the SSE 50 Index.

The model was tested using historical price data (OHLCV) for high-level strategy and detailed Limit Order Book (LOB) data for low-level execution, spanning from 2000 to 2018.

Key Results and Insights

HRPM consistently outperformed both market indices and previous state-of-the-art RL methods like Deep Portfolio Management (DPM).

Cumulative wealth comparison in the U.S. market (DJIA), showing HRPM ("Ours") outperforming indices and baseline RL models.

In the U.S. market, HRPM achieved an Annual Rate of Return (ARR) of 27.089%, compared to 20.823% for the DJIA and 19.864% for the DPM baseline. In the China market, the performance was even more striking, with HRPM reaching an ARR of 48.742%, vastly outperforming the SSE50 index (6.081%).

Beyond raw returns, HRPM demonstrated superior risk-adjusted performance. It consistently maintained the highest Sharpe Ratios and the lowest Maximum Drawdowns. This suggests that the hierarchical structure acts as a regularizer: the high-level policy avoids getting bogged down in micro-fluctuations, while the low-level policy focuses purely on execution efficiency.

Conclusion and Future Work

HRPM successfully bridges the gap between high-level portfolio strategy and low-level market execution. By explicitly modeling trading costs and slippage, it provides a more realistic and profitable framework for automated trading.

Future research will focus on scaling the system to handle even larger funds where market impact becomes more significant. Additionally, we aim to incorporate alternative data sources, such as news sentiment and macroeconomic indicators, to further enhance the "Manager's" strategic foresight across a wider variety of asset classes.

Summary updated

Abstract

Portfolio management via reinforcement learning is at the forefront of fintech research, which explores how to optimally reallocate a fund into different financial assets over the long term by trial-and-error. Existing methods are impractical since they usually assume each reallocation can be finished immediately and thus ignoring the price slippage as part of the trading cost. To address these issues, we propose a hierarchical reinforced stock trading system for portfolio management (HRPM). Concretely, we decompose the trading process into a hierarchy of portfolio management over trade execution and train the corresponding policies. The high-level policy gives portfolio weights at a lower frequency to maximize the long term profit and invokes the low-level policy to sell or buy the corresponding shares within a short time window at a higher frequency to minimize the trading cost. We train two levels of policies via pre-training scheme and iterative training scheme for data efficiency. Extensive experimental results in the U.S. market and the China market demonstrate that HRPM achieves significant improvement against many state-of-the-art approaches.
BibTeX
@inproceedings{wang2021deep,
  author = {Rundong Wang and Hongxin Wei and Bo An and Zhouyan Feng and Jun Yao},
  title = {{Deep Stock Trading: A Hierarchical Reinforcement Learning Framework for Portfolio Optimization and Order Execution}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i1.16142},
}
Figure