Table of Contents
Fetching ...

When AI Meets Finance (StockAgent): Large Language Model-based Stock Trading in Simulated Real-world Environments

Chong Zhang, Xinyi Liu, Zhongmou Zhang, Mingyu Jin, Lingyao Li, Zhenting Wang, Wenyue Hua, Dong Shu, Suiyuan Zhu, Xiaobo Jin, Sujian Li, Mengnan Du, Yongfeng Zhang

TL;DR

StockAgent introduces a large-language-model–driven multi-agent stock trading framework that simulates real-world, event-driven market environments to study how external factors shape trading behavior and profitability. By contrasting GPT-3.5-Turbo and Gemini-Pro, the paper evaluates simulation effectiveness, LLM reliability, and performance under varying external conditions, while mitigating test-data leakage through controlled setups. The architecture (Investment Agents, Transaction Module, and BBS) supports randomized decision sequencing and FCFF-based valuation with $Total\ market\ value=\sum_{t=1}^n\frac{FCF_t}{(1+WACC)^t}+\frac{FV}{(1+WACC)^n}$ and $K_e=R_f+\beta(R_f-R_m)$, providing ideal price references for analysis. Key findings show distinct trading tendencies and group behaviors across LLMs, significant responsiveness to external events, and important implications for the reliability of LLM-based investment advice, offering a versatile platform for future finance-focused AI research. The work also supplies a publicly available codebase to enable reproducibility and extended experimentation in AI-driven market simulations.

Abstract

Can AI Agents simulate real-world trading environments to investigate the impact of external factors on stock trading activities (e.g., macroeconomics, policy changes, company fundamentals, and global events)? These factors, which frequently influence trading behaviors, are critical elements in the quest for maximizing investors' profits. Our work attempts to solve this problem through large language model based agents. We have developed a multi-agent AI system called StockAgent, driven by LLMs, designed to simulate investors' trading behaviors in response to the real stock market. The StockAgent allows users to evaluate the impact of different external factors on investor trading and to analyze trading behavior and profitability effects. Additionally, StockAgent avoids the test set leakage issue present in existing trading simulation systems based on AI Agents. Specifically, it prevents the model from leveraging prior knowledge it may have acquired related to the test data. We evaluate different LLMs under the framework of StockAgent in a stock trading environment that closely resembles real-world conditions. The experimental results demonstrate the impact of key external factors on stock market trading, including trading behavior and stock price fluctuation rules. This research explores the study of agents' free trading gaps in the context of no prior knowledge related to market data. The patterns identified through StockAgent simulations provide valuable insights for LLM-based investment advice and stock recommendation. The code is available at https://github.com/MingyuJ666/Stockagent.

When AI Meets Finance (StockAgent): Large Language Model-based Stock Trading in Simulated Real-world Environments

TL;DR

StockAgent introduces a large-language-model–driven multi-agent stock trading framework that simulates real-world, event-driven market environments to study how external factors shape trading behavior and profitability. By contrasting GPT-3.5-Turbo and Gemini-Pro, the paper evaluates simulation effectiveness, LLM reliability, and performance under varying external conditions, while mitigating test-data leakage through controlled setups. The architecture (Investment Agents, Transaction Module, and BBS) supports randomized decision sequencing and FCFF-based valuation with and , providing ideal price references for analysis. Key findings show distinct trading tendencies and group behaviors across LLMs, significant responsiveness to external events, and important implications for the reliability of LLM-based investment advice, offering a versatile platform for future finance-focused AI research. The work also supplies a publicly available codebase to enable reproducibility and extended experimentation in AI-driven market simulations.

Abstract

Can AI Agents simulate real-world trading environments to investigate the impact of external factors on stock trading activities (e.g., macroeconomics, policy changes, company fundamentals, and global events)? These factors, which frequently influence trading behaviors, are critical elements in the quest for maximizing investors' profits. Our work attempts to solve this problem through large language model based agents. We have developed a multi-agent AI system called StockAgent, driven by LLMs, designed to simulate investors' trading behaviors in response to the real stock market. The StockAgent allows users to evaluate the impact of different external factors on investor trading and to analyze trading behavior and profitability effects. Additionally, StockAgent avoids the test set leakage issue present in existing trading simulation systems based on AI Agents. Specifically, it prevents the model from leveraging prior knowledge it may have acquired related to the test data. We evaluate different LLMs under the framework of StockAgent in a stock trading environment that closely resembles real-world conditions. The experimental results demonstrate the impact of key external factors on stock market trading, including trading behavior and stock price fluctuation rules. This research explores the study of agents' free trading gaps in the context of no prior knowledge related to market data. The patterns identified through StockAgent simulations provide valuable insights for LLM-based investment advice and stock recommendation. The code is available at https://github.com/MingyuJ666/Stockagent.
Paper Structure (52 sections, 5 equations, 10 figures, 17 tables)

This paper contains 52 sections, 5 equations, 10 figures, 17 tables.

Figures (10)

  • Figure 1: The schematic diagram of random clock page replacement algorithm. During our trading period, agents are assigned IDs in a random sequence using random numbers, allowing them to make decisions in a random order.
  • Figure 2: The workflow of trading simulation.
  • Figure 3: The demonstration of stock market investment. In our simulation, agents make investment decisions based on multiple external sources of information.
  • Figure 4: The correlation of price movements of Stock A and B Trading. The LLMs include Gemini and GPT in 10 days round. The top right shows the stock price movement of the GPT-based simulation, and the bottom right shows the simulated stock price movement based on Gemini.
  • Figure 5: The T-SNE visualization of the GPT and Gemini agents. (The left one is GPT Agent and the right one is Gemini Agent). K-means attempted the clustering process to perform 3-class clustering.
  • ...and 5 more figures