0% found this document useful (0 votes)
80 views31 pages

Stock Agent

Uploaded by

Achraf Louiza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views31 pages

Stock Agent

Uploaded by

Achraf Louiza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/379835420

When AI Meets Finance (StockAgent): Large Language Model- based Stock


Trading in Simulated Real-world Environments

Preprint · April 2024


DOI: 10.13140/RG.2.2.29976.20489

CITATIONS READS

0 1,016

9 authors, including:

Chong Zhang Mingyu Jin


Xi'an Jiaotong-Liverpool University Rutgers, The State University of New Jersey
12 PUBLICATIONS 0 CITATIONS 20 PUBLICATIONS 87 CITATIONS

SEE PROFILE SEE PROFILE

Yongfeng Zhang
Rutgers, The State University of New Jersey
256 PUBLICATIONS 10,457 CITATIONS

SEE PROFILE

All content following this page was uploaded by Chong Zhang on 16 April 2024.

The user has requested enhancement of the downloaded file.


Preprint. Under review.

When AI Meets Finance (StockAgent): Large Language Model-


based Stock Trading in Simulated Real-world Environments

Xinyi Liu∗ Chong Zhang∗ Mingyu Jin∗


Peking University University of Liverpool Rutgers University

Zhongmou Zhang∗ Zhenting Wang Dong Shu


SUFE Rutgers University Northwestern University

Suiyuan Zhu Sujian Li Mengnan Du


New York University Peking University New Jersey Institute of Technology

Yongfeng Zhang
Rutgers University

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. This study addresses this question
with the latest advancements in Artificial Intelligence and Large Language
Models (LLMs). We have developed a multi-agent AI system called StockA-
gent, 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 envi-
ronment that closely resembles real-world conditions. The experimental
results demonstrate the impact of key external factors on stock market trad-
ing, including trading behavior and stock price fluctuation rules. This study
addresses the lack of research on AI-agent free trading without prior market
data. The patterns identified through our StockAgent simulations offer valu-
able insights for LLM-based investment advice and stock recommendations.
The code is available at https://github.com/MingyuJ666/Stockagent.

1 Introduction
In the stock market, the trading behaviors of buyers and sellers reflect a complex interplay
of conflict and cooperation, characterized by uncertainties and influenced by investors’
diverse motivations, strategies, and decisions. Gaining insights into the mechanisms of
market operations is essential for formulating robust investment strategies. While historical
data analysis provides valuable insights into market understanding, its static nature and ret-
rospective bias limit its predictive capability for future trends. Simulating human behaviour
is a way to near the mechanisms of the market or society. This approach is common in social
sciences, and the precision and applicability of simulations have significantly improved due
to the application of updated technology (Smith, 1970; Hermann & Hermann, 1967).
∗ Equal Contribution.

1
Preprint. Under review.

Stock price Financial Report BBS Discussion

Gross Margin 70.8% Net Profit Margin -16.9% I recommend Stock


Return On Investment -9.6% Operating Margin 15.6% A because…
03/23 06/23 09/23 12/23
I believe Stock A
Total Revenue 1.82B 2.48B 3.4B 2.22B
has potential…
Gross Profit 1.11B 1.74B 2.62B 1.56B

Operating 7M 538M 1.5B -493M I think Stock B


Income is undervalued…
Net Income 117M 650M 4.37B -349M

Special Event

Reduction in the reserve


requirement ratio!
Buy Stock A.

Figure 1: The demonstration of stock market investment. In our simulation, agents make
investment decisions based on multiple external sources of information.

The prevalent method in stock market simulation primarily utilizes backtesting with his-
torical data to simulate trading environments and assess strategies, using tools like Zi-
pline (Jansen, 2020), Backtrader (Glucksmann et al., 2019), and PyAlgoTrade (Hilpisch,
2020). These event-driven frameworks help evaluate trader-designed strategies. Trading
Gym’s introduction has furthered the use of reinforcement learning in optimizing strategies.
Nonetheless, these approaches, reliant on historical data, are prone to overfitting and cannot
account for the real-time market’s liquidity effects nor simulate the influence of collective
sentiment, being bound by their simulation premises.
Recent approaches to enhance market simulations involve LLMs that mimic complex human
behaviors, addressing backtesting limitations (Park et al., 2023; Xu et al., 2023; Hua et al.,
2023; Chen et al., 2023; Ge et al., 2023). These simulations replicate social dynamics by
leveraging AI-Agents’ generalization capabilities. Yet, applying these technologies to fully
grasp the nuanced investor behaviors in financial markets is an area still under-explored.
This study introduces StockAgent, a novel LLM AI-Agent-based multi-agent stock trading
framework that operates on an event-driven simulation. It consists of stages such as
Pre-Trading Preparation, involving interest rates and financial events; Trading Sessions,
handling transactions and account updates; and Post-Trading, focusing on future actions
and strategy sharing. StockAgent’s unique contribution is its ability to assess the impact
of external factors, asset quantity, and strategies on trading by tuning its parameters, as
detailed in Appendix A. Unlike other LLM-based trading tools, it minimizes the influence
of the model’s prior knowledge on market predictions, offering an ideal setup for AI-Agents.
A demonstration of StockAgent is presented in Figure 1. Agents make trading decisions
based on numerous external information in our simulations.
Our research around StockAgent will focus on the following issues:

• Can we use LLMs AI agents to reasonably simulate the real stock market and enable
AI agents to trade according to their own will? The real stock market includes
corporate financial data, market indicators, benchmark interest rates, emergencies,
and after-hours BBS discussions.

• Can we trust the simulation results of the StockAgent and whether the simulations
conducted using different LLMs to drive the AI-Agent are biased in their trading
decisions?

• Will the StockAgent’s trading behavior be affected by the existing external informa-
tion to make different decisions?

2
Preprint. Under review.

• Is the large model stock recommendation and real-time trading strategy driven by
LLMs AI-Agent reliable? Will it be disturbed by the tendencies of the model itself?

2 Background and Related Work

2.1 Stock Simulation Model

Computational finance leverages platforms like Zipline (Vaucher et al., 2020) and Back-
trader (Jansen, 2020) for backtesting strategies with historical data. Cloud solutions like
QuantConnect (Maheshwari, 2020) enable global market simulations, while Trading Gym
offers a reinforcement learning setup for algorithms (Amrouni et al., 2021). PyAlgoTrade
and Alpaca cater to easy strategy development and paper trading (Taye, 2021). Despite their
utility for strategy refinement, challenges like over-fitting and neglecting market sentiment
and liquidity can hinder transitioning from backtesting to live trading (Campbell, 2005).

2.2 LLM-based Agents

LLMs are transforming AI agents by equipping them with enhanced cognitive skills for
reasoning and interaction. Techniques like Chain of Thought (CoT) (Wei et al., 2022; Wang
et al., 2022; Zelikman et al., 2022; Jin et al., 2024b) empower LLM agents to tackle tasks
typically reserved for symbolic AI, while multimodal and feedback learning approaches
bring them closer to reactive agents’ adaptability. These agents are applied to natural lan-
guage tasks in different domains, such as WarAgent project (Hua et al., 2023), CosmoAgent
(Jin et al., 2024a), ChatDev (Qian et al., 2023), MetaGPT (Hong et al., 2023). This cross-
domain application demonstrates the flexibility and diversity of LLM agents in complex
environments.

2.3 LLMs with Finance

In the nexus of LLMs and economics, financial analysis and forecasting are evolving. Tradi-
tional quantitative models are giving way to LLMs’ sophisticated processing of economic
literature, improving trend forecasts as shown by Alonso-Robisco & Carbó (2023). LLMs,
through works like Huang et al. (2023)’s work, also advance algorithmic trading by refining
sentiment analysis and financial text interpretation. In compliance and risk sectors, LLMs
detect textual risks, as evidenced by de Zarzà et al. (2023). Additionally, PIXIU’s Financial
Language Model, built upon LLaMA, offers enhanced financial statement assessments
(Zhao et al., 2024).

2.4 Behavioral Finance

Behavioral finance (Hirshleifer, 2015) integrates psychological insights into the financial
theory to examine why investors often diverge from classical principles like the efficient
market hypothesis (Hirshleifer, 2015; Baker & Nofsinger, 2010). It elucidates market anoma-
lies and informs the creation of financial products, investment strategies, and regulations to
prevent market instabilities and investment errors.

3 Stock-Agent Simulation Setting

This study investigates stock trading within a Multi-Agent System (MAS) to understand
market dynamics and agent interactions. We simulate trading to observe how AI agents’
decision-making, informed by varied information, influences market indicators like volatil-
ity and liquidity. Our simulation replicates real market conditions to assess agents’ impact
on these indicators. For an in-depth financial analysis, see Appendix A.

3
Preprint. Under review.

4 Stock-Agent Simulation Setting

This research focuses on simulating stock trading. Thus, we focus on examining the dynam-
ics of financial markets as they relate to the interactions between autonomous agents within
a MAS framework. By simulating stock trading, we aim to understand how AI agents make
decisions based on diverse sources of information and how their behaviors affect market
outcomes, such as price volatility, liquidity, and price discovery efficiency. In the proposed
stock trading simulation research, a detailed setting is established to mirror actual financial
markets. This setting facilitates the examination of various agents’ behaviors and their
impact on market outcomes. The detailed financial analysis can be found in Appendix A.

4.1 Initial assumptions of StockAgent


• AI-Agent Setup Assuming basic common sense of stock market trading, our AI-
Agent can make profitable trades to maximize profits. This maximizes profits and
consists of maximizing the total value of assets and cash. The AI-Agent also has
basic estimation ability.
• AI-Agent Trading Behavior We restrict the AI-Agent actions to buy, sell, hold, long
and short. Among them, buying, selling, and holding are defined as basic behaviors,
long and short selling are defined as derived behaviors, and AI-Agent can use basic
behaviors according to the basic knowledge of the stock market.
• AI-Agent Financial Behavior We assume that under the existing AI-Agent frame-
work, the AI-Agent can understand the financial attempt settings we set for loans,
interest rates, dividends and bankruptcy and use or avoid the above situations
according to the goal of maximizing profits.

4.2 Agent Initialization Settings


• Personality and Assets Allocation: Each agent is endowed with distinct personality
traits, influencing their trading styles. Initial assets are allocated randomly within a
range of 100,000 to 5,000,000 yuan, which is the sum of an agent’s available cash
and the market value of stocks. The random allocation ensures a diverse spectrum
of wealth among agents.
• Debt Configuration: Agents may incur debt, with the amount not exceeding the
value of their capital. The loan-to-value ratio is capped to ensure realistic leverage
levels.

4.3 Market Initialization Settings


• Trading Year: The simulation covers a one-year period comprising 264 trading days,
divided into four quarters of 66 trading days each.
• Interest Rates and Deposits: For companies and individuals, the deposit rate is 0%,
reflecting contemporary low-interest-rate environments.
• Personal Loan Costs: Agents are subject to varying interest rates on loans, with
different terms and corresponding costs. The actual annualized interest rate is 2.7%
for a one-month loan, 3% for a two-month loan, and 3.3% for a three-month loan.

4.4 Simulation Flow

4.4.1 Pre-Trading Preparation


• Interest Repayment: Agents pay interest on their loans with cash on the last day of
each month {days 22, 44, 66...}. We use simple interest as the interest charge.
• Loan Repayment: When a loan matures, agents need to repay the loan with cash.
• Bankrupt Check: After interest and loan repayment, agents with negative cash
undergo bankruptcy proceedings. Bankrupted agents will sell all of their holdings
and withdraw from subsequent trading.

4
Preprint. Under review.

Day Simulation Tomorrow’s Action Estimation

Market Agents Bankrupt Events / Estimate whether you


Interest Loan Loan
Initialization Initialization Check Financial will buy and sell stock A
Repayment Repayment Decision
Report and stock B tomorrow,
and whether you will
:Initialization choose loan.

:Occurs everyday Trading Tip Tomorrow’s {"buy_A":"yes",


Price Buy & Sell Sequence
Sharing on Action "buy_B":"no",
:Occurs on selected dates Update Decision Generation
BBS Estimation "sell_A":"yes", "sell_B":
:Interact with LLM agents "no", "loan": "yes"}
Session Simulation

Loan Decision Trading Tips sharing on BBS Buy & Sell Decision
Stock market information
You are a stock trader… Stock Please briefly post your trading tips on the
of this session…Decide
background…Stock price… Last day BBS… Loan forum.
whether to buy, sell or hold.
information… Decide whether to loan.
The market is likely to remain volatile in the near {"action_type":"buy","stoc
term due to global economic uncertainties and k":"A", amount: 100, price :
{"loan": "yes", "loan_type": 3, "amount": 1000}
ongoing geopolitical tensions… 30.1}

Figure 2: The workflow of Trading Simulation Flow. The whole simulation contains 264
trading days, and each day is divided into 3 trading sessions.

• Special Events: Pre-defined special events occur on specific trading days, such as a
reserve requirement ratio reduction and an interest rate increase.

• Financial Report Release: Companies A and B are scheduled to release their


quarterly financial reports on days 12, 78, 144, and 210. The financial reports are
announced to all agents.

• Loan Decision: Agents choose whether to take out a loan and decide the amount
and duration of the loan.

4.4.2 Trading Sessions


• Sequence Generation: In each session, our simulation randomly generates a se-
quence, and agents initiate transactions in this order.

• Buy&Sell Decision: Agents decide whether to buy, sell, or hold shares and deter-
mine the transaction price and quantity. Their orders are then matched in a market
order book, when the bid and ask coincide, a trade is made.

• Price Update: To simplify the actual stock trading procedure, we only update stock
prices at the end of trading sessions. Stock prices are updated to the price of the last
transaction in this session.

4.4.3 Post-Trading Procedures


• Tomorrow’s Action Estimation: Based on current information, agents are asked to
estimate whether they will loan, buy, or sell tomorrow.

• Trading Tip Sharing on BBS: Agents share their trading tips and insights anony-
mously on BBS. Messages on BBS are available to all agents on the next day.

5 StockAgent Architecture

In this section, we will introduce the architecture of StockAgent, a multi-agent framework


that models the real-world stock market and investor transactions. StockAgent is built on
three basic modules: (1) Agent module, (2) Transaction module, and (3) BBS module. By
designing appropriate mechanisms, we avoid conflicts between the actions of numerous
agents and ensure that all messages are available to agents.

5
Preprint. Under review.

5.1 Agent Module

5.1.1 Investment Agents

Each agent is randomly initialized with its capital, liabilities, and personality. We take
four types of personalities into consideration, respectively Conservative , Aggressive
, Balanced , Growth-Oriented , to investigate the influence of personalities on decision
making. Additionally, we assign initial liabilities to agents, which encourages them to make
profits through trading.

5.1.2 Agent Interaction

In our framework, agents are asked to decide whether to loan, buy or sell, estimate tomor-
row’s actions, and share trading tips on BBS. Guided by structured prompts, they need to
make decisions in the light of diverse information sources, including stock prices, financial
reports, special events, current orders, and discussions on BBS. Detailed prompts are listed
in Appendix C. Similar to (Hua et al., 2023), we set a secretary to rectify illegal responses
generated by agents, as LLMs can be affected by hallucinations when faced with long
contexts. For instance, an agent with 100 yuan in cash cannot spend 150 yuan on trading.

5.2 Transaction Module

When an agent decides to buy or sell a stock, their order is recorded in the order book.
The order book uses the dictionary data structure in Stock Agent to store Agents’ buying
orders and buying requirements. When an Agent completes its own transaction, the system
starts to judge whether the transaction was made and the quantity of the transaction, and it
updates the order book dict values in time. In our simulation of each transaction session,

13

16 5

27 24

44 31

Figure 3: The schematic of the random clock page replacement algorithm.

there is competition among Agents and the transaction process is concurrent. Since prompts
drive our simulation, there is a high possible risk of deadlock when using prompts for
concurrency. Therefore, with the help of the page replacement algorithm in the multitasking
operating system, we propose a random clock page replacement algorithm, which is shown
in Figure 3. In our trading period, the IDs of agents are formed into a sequence of random
order by random numbers, and the agents are allowed to make the decisions for the period
in random order. In this mode, instead of concurrent scrambling, deadlock is avoided.

5.3 BBS Module

Our framework includes a unique Bulletin Board System (BBS), which serves as a platform
for agents to post messages. At the end of each day, we ask agents to share their trading tips
on BBS. By making this information available to all agents, we aim to simulate a realistic
environment where others’ opinions may influence investor decisions.

6
Preprint. Under review.

6 Experimental Design

6.1 Backbone Large Language Models

For our StockAgent experiment, we selected two common and powerful LLMs as the
backbone models of the experiment:

Gemini-pro (Gemini-pro-1.0) Gemini is a family of multimodal language models


developed by Google DeepMind (Team et al., 2023). It is the successor to LaMDA and
belongs to the new generation of the PaLM2 family. Gemini includes Gemini Ultra, Gemini
Pro, and Gemini Nano.

GPT-3.5-Turbo (gpt-3.5-turbo-0125) In the GPT (Generative Pre-trained Transformer) series


(Brown et al., 2020), the latest GPT-3.5 Turbo model with higher accuracy at responding in
requested formats. Returns a maximum of 4,096 output tokens.

6.2 Research Questions and Evaluation

6.2.1 Simulation Effectiveness(RQ1)


Do different types of large models affect AI-Agent trading behavior? Here, we use ChatGPT
and Gemini to trade stocks for 10 trading days under exactly the same premise and setup.
In this stage, the similarity of trading volume time series, mean, standard deviation and
volatility are used to judge the similarity of trading volume. Combining these attributes,
we will evaluate the simulation effect based on different LLM AI-agents and determine the
trading preference of LLMs.

6.2.2 Simulated stock trading(RQ2)


In the process of analyzing the deviation of trading behavior in simulated stock trading, it is
first necessary to identify trading patterns by analyzing trading data, including examining
trading frequency, time period, trading volume, and buying and selling decisions. Statistical
methods can reveal anomalies or significant deviations in trading activity. In addition, we
need to assess the specific impact of these behavioral biases on investment performance,
which typically involves calculating the difference between actual trading returns and
established benchmarks. In addition, quantitative tools, such as regression analysis and
ANOVA, quantify the impact of trading behavior bias on performance.

6.3 Evaluation

Evaluation will evaluate Simulation Effectiveness and Simulated stock trading, mainly
including trading behavior correlation and trading deviation analysis. Table 1 and Table 2
below will mainly elaborate on the Evaluation method of our Research Questions and the
experimental environment setting.

7 Results & Analysis

7.1 Simulation Effectiveness

In this Simulation Effectiveness experiment, we will use GPT-3.5-Turbo and Gemini-Pro


as two baseline models, respectively, to perform simulated trading for 10 days under our
standard experimental environment. The detailed settings are in Table 2 RQ1. The specific
experimental Evaluation Metrics are shown in Table 3.

7.1.1 Correlation of price movements


In this part, we will analyze the similarity of price movement on two 10-day trading data
based on Gemini(gemini-pro-1.0) and GPT(gpt-3.5-turbo-0125). We will use the correlation

7
Preprint. Under review.

Table 1: Summary of experiment setups and the corresponding research questions.

Evaluation Method RQs Analysis Description


Simulation Effectiveness RQ1 (a) How to evaluate the correlation of price move-
ments? (Section 7.1.1)
(b) How to determine the Trading behavior charac-
teristics?(Section 7.1.2)
(c) How do we determine capital flow and AI-Agent
features? (Section 7.1.4)
Simulated Stock Trading RQ2 (d) How to carry out Transaction pattern recognition
and Behavioral analysis?(Section 7.2.1)
(e) How to evaluate the performance and Quantita-
tive analysis of AI-Agent?(Section 7.2.2)

Table 2: Trading experiment environment and basic setting.

Evaluation Method RQs Experiment Environment Settings


Simulation Effectiveness RQ1 200 AI-Agents
Special Events (Appendix A)
10 trading days (Appendix B)
Company A and Company B Basic financial Infor-
mation (Appendix B)
Simulated Stock Trading RQ2 200 AI-Agents
under various external Special Events (Appendix A)
conditions 154 trading days (Appendix A)
Company A and Company B Basic financial Infor-
mation(Appendix B)

Table 3: Trading experiment environment and basic setting.

Missing External Factors Evaluation Metrics


BBS Information Sharing (e),(f)
Financial Information Sharing (e),(f)
Change in external interest rate (e),(f)
Financial statements (e),(f)
Loan (non-initial) (e),(f)
Full-External Factors (e),(f)

coefficient to measure and visualize the linear relationship between the stock price time
series of two stocks, Stock A and B. The visualization results of correlation analysis are
as follows Figure 4. Based on the experimental results, it is evident that GPT and Gemini
exhibit different trading tendencies. Gemini tends to be more pessimistic about the market,
while GPT shows a more optimistic outlook. Consequently, within the first ten days, there
are distinct and opposing trading patterns. GPT favours long positions when trading Stock
A and Stock B and is more bullish on Stock A based on the initial financial data. On the
other hand, Gemini prefers short positions. The similarities in stock price changes under
the same model suggest that LLM itself has its own stock trading preferences.

7.1.2 Trading volume similarity


In this part, we will analyze the similarity of trading volume, which mainly includes
using a correlation coefficient to measure the similarity of trading volume time series.
Furthermore, we will analyze and summarize the correlation of trading volume through
statistical characteristics such as average value, standard deviation and volatility. From
the results shown in Table 4 and Table 5, We observe the trading preferences of the two

8
Preprint. Under review.

Price
Trading Rounds

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.

Table 4: The trading Volume results for GPT and Gemini (part 1).
AI-Agent A Trade Shares B Trade Shares A Volume B Volume
GPT 3118792 329590 176758380.8 14109526.0
Gemini 128981 112134 3588331.52 4325246.50

Table 5: The trading Volume results for GPT and Gemini (part 2).
AI-Agent Stock A price Stock B price A Trading Times B Trading Times
Gemini 23.46 36.03 800 688
GPT 55.70 43.43 384 263

LLMs from the perspective of trading volume. The trading volume of the GPT group is
significantly higher than that of the Gemini group, but the trading frequency of the GPT
group is lower than that of the Gemini group. This feature appears not only in Stock A
but also in Stock B. There is no obvious connection between the financial fundamentals of
Company A and Company B.

7.1.3 Trading behavior characteristics


In this part, we will focus on analyzing trading behavior characteristics, mainly including
trading frequency comparison. Among them, we will count and visualize the frequency of
trading within the specified trading day interval, and second, we will use the corresponding
data to analyze the similarity of style of trading. According to the statistical results, the
transaction frequency based on a Gemini Agent is significantly greater than that based on
a GPT Agent, and the transaction frequency of Gemini on Stock A and Stock B is similar.
However, GPT agents are more cautious about their trading decisions in Stock B than in
Stock A. Regarding trading frequency, Gemini trades more days, while GPT follows the
trend.

7.1.4 AI-Agent features


In this section, we will focus on the AI-Agent features. We will compare the agents between
traders and give a reasonable qualitative analysis. Further, we will use clustering analysis to
cluster according to the trading behavior of each AI agent to see whether the trading crowd
based on the two models conforms to behavioral finance.

9
Preprint. Under review.

Compare the GPT and Gemini Transaction Frequency Comparison.


800 GPT
Gemini
700
600
500

Trading Times
400
300
200
100
0
Buy Stock A Sell Stock A Buy Stock B Sell Stock B

Figure 5: The Compare between GPT and Gemini Transaction Frequency Comparison

Figure 6: 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.

We collected each Agent’s asset changes, earnings, stock holdings, and the number of
A-shares bought and sold, clustered the situation of each Agent, and performed T-SNE
visualization. According to the results in Figure 6, the investors of Gemini Agent have
similar characteristics and only a very few investors show performance different from that
of the general public in the visualization results. However, in the T-SNE visualization of GPT
agents, samples are relatively more dispersed, which means that GPT-driven agents have
more subjective decision-making ability and thus conduct fewer herd and trend transactions
than Gemini.

7.2 Simulated Stock Trading

In this Simulated Stock Trading experiment, we will use Gemini-Pro as two baseline models,
respectively, to conduct simulated trading for 100 days under our standard experimental
environment. The detailed settings are in Table 2 RQ2.

7.2.1 Transaction pattern recognition and behavioral analysis


This part will complete the transaction pattern and transaction behavior through the analysis
of the log results. First, here is a comparison of stock price movements in the Basic Settings
Table 2 of the trading environment in Figure 7. In Figure 7 you can see the comparison of

10
Preprint. Under review.

the number of transactions in different cases. The trading frequency of Stock A and Stock
B in each case is shown in Figure 8. According to our experimental results, the lack of

Figure 7: The comparison of stock trend with external condition ablation.

non-first-round loans, company financial reports, BBS discussions, and macro-financial data
has little impact on Stock A’s trading, but when the benchmark interest rate information
is cancelled, it plays a significant role in promoting Stock A’s trading. The AI-Agent is
relatively sensitive to the interest rate brought by the loan in the transaction style. The
cancellation of the interest rate promotes the interest-free loan to a certain extent, which
makes the Agent optimistic about the transaction.
According to the results of Stock B, the lack of BBS information communication directly
caused the AI-Agent to drive down the Stock price of Stock B, and the psychological price
of Stock B was lower than the ideal valuation. The lack of loan interest rate also caused
the Agent to start to pull up Stock B after the 23rd trading day. Therefore, different from
those who are firmly bullish on Stock B in other situations, the agents who lack financial
conditions have a flash crash on the 21st trading day when trading Stock B, which may be
due to the lack of financial conditions of the company and the lack of confidence in the
profitability of the company behind Stock B. However, in the trading of Stock B, the lack of
first-round trading loans and the lack of macro-financial information have the same trend,
which has little impact on the trading.
From the perspective of the overall transaction frequency Figure 8, removing the BBS
communication of investors has A reduced impact on the transaction frequency of Stock
A and B, while removing the change of interest rate has a significant promotion effect on
the transaction frequency of Stock A, and has a reduced effect on Stock B. The other three
conditions have no obvious impact on the transaction frequency.
Summarizing the commonality of the two stocks, the absence of an interest rate will make the
Agent more optimistic about the market and the performance of the company, while the lack
of BBS discussion will make the psychological valuation of the stock become conservative
and bear the stock price to a certain extent.

11
Preprint. Under review.

Figure 8: The comparison of stock trend with external con-


dition ablation.

200

150
Agent

100

50
Non-finance
Non-BBS
Non-Loan
Non-statement
0 Non-Interest-Change
8 6 4 2 0 2 4 6
Value 1e6

Figure 9: The 3D profit and loss diagram of the Agent group.

7.2.2 Evaluation of performance and Quantitative analysis

We will analyze the profitability effect of the AI-Agent group and individual in the long
trading cycle so as to evaluate its asset profitability in the long cycle. This will include two
aspects: the first one is the profitability of the individual Agent, and the other one looks at
the AI-Agent population. From this perspective, the trading propensity and profitability of
different large models in the same trading environment can be verified.

12
Preprint. Under review.

As shown in the experimental results above, we conducted an ablation study on the five
cases in Table 3 so as to obtain the profitability comparison between the single Agent in the
following various cases and the profitability of the Agent group in the large model.
The visualization results in the Figure 9, We can see the profitability of the single Agent
and the profitability of the group Agent. It can be intuitively seen from the figure that
when we cancel the non-first round loan, our Agent’s trading concept starts to be more
conservative and bearish, and if we cancel the BBS-sharing function, The Agent will behave
more conservatively than otherwise and will not buy or sell shares at large prices. When we
cancel the earnings report and the interest rate changes, it is surprising that many agents
turn from loss to profit. From the visual results, the profitability of the Agent group is
enhanced. However, when we cancel any support of Finance Information, the profit and
loss gap between Agents begins to widen, and the overall market game becomes stronger.

8 Conclusions, Discussions, and Future Vision

8.1 Conclusions

This paper proposes a simulated trading framework based on AI-Agent-driven StockAgent;


StockAgent has the process and external environment of simulation and real exchange,
which provides a profound observation for studying AI-Agent-based stock trading. The
design of StockAgent fully eliminates the influence of the real stock historical trend in the
large model prior knowledge and fully liberates the trading freedom of AI-Agent. This
study mainly shows the different trading patterns and preferences of different LLMs in
StockAgent’s trading environments. It provides a basis for further exploring AI-Agent-
driven trading strategies and market analysis.

8.2 Highlights & Discussions

8.2.1 Highlights 1: Significant differences in trading behavior for different AI-Agents

When comparing GPT-based and Gemini-based AI agents, we observe significant differ-


ences in trading behavior. Although the GPT agent trades less frequently, the volume
is significantly higher than that of the Gemini agent. In addition, the GPT agent makes
more cautious trading decisions on stock A, while the Gemini agent trades with a similar
frequency on stocks A and B, showing a higher trading activity. This suggests that different
AI agents may have different understandings of the market and strategic preferences.

8.2.2 Highlights 2: The Difference of Agent group behavior

Through cluster analysis and T-SNE visualization, we find that Gemini-based investors
have similar characteristics and group behavior is more consistent, while GPT agent-driven
investors show more individual differences and subjective decision-making ability. The
sample of GPT agents is more spread out in the visualizations, meaning that they engage in
less herding and trend trading and instead exhibit more independence and diversity. This
may indicate that GPT agents are more able to embody personalized investment strategies
and styles when facing the market.

8.2.3 Highlights 3: Different external factors have different effects on stock market
trading.

Through our simulated trading experiments, we observe that cancelling the functions of
non-first round loans and BBS sharing will make individual agents more conservative while
cancelling the profit report and interest rate change will make some agents turn from loss to
profit. At the same time, cancelling the support of any financial information will lead to the
widening of the profit and loss gap between agents, and the overall market competition will
become more intense.

13
Preprint. Under review.

8.2.4 Highlights 4: Reliability of stock recommendation and trading strategy


development based on LLMs Agent
We believe that under the same external information and trading market environment,
different LLM agents have different performances in trading style and decision-making,
which may affect the stock recommendation and quantitative trading methods based on
these mainstream big models by the prior knowledge of the model itself. Moreover, the
trading style cannot change the inherent attitude of the big model to the market through
context learning.

8.3 Future Vision

As a further extension of this study, we will build a stock market simulation experiment
platform in the future. Further, customizable AI-agent-based trading experiments will be
carried out in different quantities and stock markets. The customized content can be set and
deduced according to the trading rules of a certain exchange or even a certain country.
We will conduct more technical analysis strategies for the stock market based on the current
platform, including in-depth research on indicators, for example, we will conduct in-depth
research on commonly used technical indicators such as moving average (MA), Relative
Strength Index (RSI), Bollinger Bands, etc., to explore their effectiveness in different market
conditions. Other aspects such as algorithm optimization, high-frequency trading strategies,
risk management tools, market sentiment analysis, cross-market strategies, visualization
tools and other directions drive in-depth research.
Furthermore, we will use this experimental platform to conduct listing simulations for the
stocks to be IPOs, to better serve issuers, and to help them evaluate the listing performance
under different pricing strategies and market environments. Specific work may include mar-
ket acceptance prediction, liquidity analysis, lock-up strategy simulation, investor behaviour
analysis, risk assessment, after-market performance prediction and legal compliance review.

14
Preprint. Under review.

Limitations

Financial and Trading Limitations

Our StockAgent simulation scenario is to reduce the size of the exchange in equal proportion,
so there may be insufficient consideration of the trading volume energy issue. On the other
hand, the frequency of emergencies in the stock market may lack a reasonable setting, and
there may be correlation links between different emergencies.

Limitations of LLMs and simulation methods

The definition of the trading personality of AI-Agent traders is passed through hints; we
set two trading styles, conservative and aggressive; it is uncertain whether LLMs can
understand the trading style and whether it can embody the trading style in the trading.
Secondly, we only use prompts to teach the ffAI-Agent that it can carry out short selling
through in-context Learning, and we are not sure whether the AI-Agent is an ordinary
transaction or a deliberate short-selling operation In the trading process.

References
Andres Alonso-Robisco and José Manuel Carbó. Analysis of cbdc narrative by central banks
using large language models. Finance Research Letters, 58:104643, 2023.
Selim Amrouni, Aymeric Moulin, Jared Vann, Svitlana Vyetrenko, Tucker Balch, and
Manuela Veloso. Abides-gym: gym environments for multi-agent discrete event simula-
tion and application to financial markets. In Proceedings of the Second ACM International
Conference on AI in Finance, pp. 1–9, 2021.
H Kent Baker and John R Nofsinger. Behavioral finance: an overview. Behavioral finance:
Investors, corporations, and markets, pp. 1–21, 2010.
Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla
Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al.
Language models are few-shot learners. Advances in neural information processing systems,
33:1877–1901, 2020.
Sean D Campbell. A review of backtesting and backtesting procedures. ., 2005.
Jiangjie Chen, Siyu Yuan, Rong Ye, Bodhisattwa Prasad Majumder, and Kyle Richardson.
Put your money where your mouth is: Evaluating strategic planning and execution of llm
agents in an auction arena. arXiv preprint arXiv:2310.05746, 2023.
I de Zarzà, J de Curtò, Gemma Roig, and Carlos T Calafate. Optimized financial planning:
Integrating individual and cooperative budgeting models with llm recommendations. AI,
5(1):91–114, 2023.
Yingqiang Ge, Wenyue Hua, Jianchao Ji, Juntao Tan, Shuyuan Xu, and Yongfeng Zhang.
Openagi: When llm meets domain experts. arXiv preprint arXiv:2304.04370, 2023.
Alain Glucksmann, Didier Sornette, and Ke Wu. Backtesting of trading strategies for bitcoin.
ETH Zürich, 2019.
Charles F Hermann and Margaret G Hermann. An attempt to simulate the outbreak of
world war i. American Political Science Review, 61(2):400–416, 1967.
Yves Hilpisch. Python for Algorithmic Trading. O’Reilly Media, 2020.
David Hirshleifer. Behavioral finance. Annual Review of Financial Economics, 7:133–159, 2015.
Sirui Hong, Xiawu Zheng, Jonathan Chen, Yuheng Cheng, Jinlin Wang, Ceyao Zhang, Zili
Wang, Steven Ka Shing Yau, Zijuan Lin, Liyang Zhou, et al. Metagpt: Meta programming
for multi-agent collaborative framework. arXiv preprint arXiv:2308.00352, 2023.

15
Preprint. Under review.

Wenyue Hua, Lizhou Fan, Lingyao Li, Kai Mei, Jianchao Ji, Yingqiang Ge, Libby Hemphill,
and Yongfeng Zhang. War and peace (waragent): Large language model-based multi-
agent simulation of world wars. arXiv preprint arXiv:2311.17227, 2023.
Allen H Huang, Hui Wang, and Yi Yang. Finbert: A large language model for extracting
information from financial text. Contemporary Accounting Research, 40(2):806–841, 2023.
Stefan Jansen. Machine Learning for Algorithmic Trading: Predictive models to extract signals
from market and alternative data for systematic trading strategies with Python. Packt Publishing
Ltd, 2020.
Mingyu Jin, Beichen Wang, Zhaoqian Xue, Suiyuan Zhu, Wenyue Hua, Hua Tang, Kai Mei,
Mengnan Du, and Yongfeng Zhang. What if llms have different world views: Simulating
alien civilizations with llm-based agents. arXiv preprint arXiv:2402.13184, 2024a.
Mingyu Jin, Qinkai Yu, Haiyan Zhao, Wenyue Hua, Yanda Meng, Yongfeng Zhang, Meng-
nan Du, et al. The impact of reasoning step length on large language models. arXiv
preprint arXiv:2401.04925, 2024b.
Nicholas Leo Maheshwari. Stock trading quantified: An exploration of algorithmic trading
principles using quantconnect. ., 2020.
Joon Sung Park, Joseph O’Brien, Carrie Jun Cai, Meredith Ringel Morris, Percy Liang, and
Michael S Bernstein. Generative agents: Interactive simulacra of human behavior. In
Proceedings of the 36th Annual ACM Symposium on User Interface Software and Technology, pp.
1–22, 2023.
Chen Qian, Xin Cong, Cheng Yang, Weize Chen, Yusheng Su, Juyuan Xu, Zhiyuan Liu,
and Maosong Sun. Communicative agents for software development. arXiv preprint
arXiv:2307.07924, 2023.
Robert B Smith. Presidential decision-making during the cuban missile crisis: a computer
simulation. Simulation & Games, 1(2):173–201, 1970.
Yared Taye. Trading and Investing Systems Analysis. PhD thesis, PhD thesis, Worcester
Polytechnic Institute, 2021.
Gemini Team, Rohan Anil, Sebastian Borgeaud, Yonghui Wu, Jean-Baptiste Alayrac, Jiahui
Yu, Radu Soricut, Johan Schalkwyk, Andrew M Dai, Anja Hauth, et al. Gemini: a family
of highly capable multimodal models. arXiv preprint arXiv:2312.11805, 2023.
Sébastien Vaucher, Niloofar Yazdani, Pascal Felber, Daniel E Lucani, and Valerio Schiavoni.
Zipline: in-network compression at line speed. In Proceedings of the 16th International
Conference on emerging Networking EXperiments and Technologies, pp. 399–405, 2020.
Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, Sharan Narang, Aakanksha
Chowdhery, and Denny Zhou. Self-consistency improves chain of thought reasoning in
language models. arXiv preprint arXiv:2203.11171, 2022.
Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Fei Xia, Ed Chi, Quoc V
Le, Denny Zhou, et al. Chain-of-thought prompting elicits reasoning in large language
models. Advances in neural information processing systems, 35:24824–24837, 2022.
Yuzhuang Xu, Shuo Wang, Peng Li, Fuwen Luo, Xiaolong Wang, Weidong Liu, and Yang
Liu. Exploring large language models for communication games: An empirical study on
werewolf. arXiv preprint arXiv:2309.04658, 2023.
Eric Zelikman, Jesse Mu, Noah D Goodman, and Yuhuai Tony Wu. Star: Self-taught reasoner
bootstrapping reasoning with reasoning. Advances in Neural Information Processing Systems
(NeurIPS), 2022.
Huaqin Zhao, Zhengliang Liu, Zihao Wu, Yiwei Li, Tianze Yang, Peng Shu, Shaochen Xu,
Haixing Dai, Lin Zhao, Gengchen Mai, et al. Revolutionizing finance with llms: An
overview of applications and insights. arXiv preprint arXiv:2401.11641, 2024.

16
Preprint. Under review.

Appendix

A Financial Analysis for Market and Agent Initialization Settings


In this section, we selected two stocks from the United States as a reference and used the
balance sheet, income statement, and cash flow statement in their financial reports as the
basis to calculate the initial setting of our simulation. In our simulated stock market, we
have two stocks: Stock A and Stock B. Stock A is a stock that is already circulating in the
stock market, while Stock B is a newly issued stock that is currently in the IPO stage.

A.1 Simulate external event Settings

We used external economic and financial events from 2014 to 2019 to align our valuation
and volume energy calculations with reality. The specific conditions are listed below:
• Suppose that Company A and Company B, which issue Stock A and Stock B, both
announce the financial situation of the previous quarter at the end of each quarter;
for example, the third quarter of the first year announces the financial data of the
second quarter of the first year, and so on.
• Suppose that on the first trading day of the first quarter of the second year, both
Company A and Company B announce their financial results for the fourth quarter
of the previous year. On the same day, the government announces a reduction in
the reserve ratio, causing a boost in markets M1 and M2. This results in a decrease
in the loan cost for both companies from 6% to 4.5%.
• Suppose that on the first trading day of Q1 in year three, the economy overheats
which leads to the government announcing an interest rate hike and balance sheet
contraction. This results in a decrease in market liquidity and a rise in loan costs
from 4.5% to 5%.
• Also assume that on the first trading day of the first quarter of the third year,
Company A announces that it expects revenue in the fourth quarter of the second
year to be 3% below expectations because of special events in the quarter, and
Company B announces that it expects revenue in the fourth quarter of the second
year to be 2% above expectations because of special events in the quarter.
All assumptions are based on real events, and the ratios fall within a reasonable range. The
detailed events are shown in Table 6.

Table 6: Special Events Timeline for Trading Periods


Trading Period 1Q3 1Q4(78) 2Q1(144) 2Q2
Special Events - Monetary Easing - Interest Rate Hike

B Financial analysis of Company A and Company B


The following tables are Statement of Valuation, financial indicators, and ideal stock price
tables of stocks A and B. First, the enterprise’s financial data are collected, including the
income statement, balance sheet, and cash flow statement. Determine the income statement’s
non-cash expenses such as Net Income and Depreciation & Amortization. Determine long-
term debt and shareholders’ equity in the balance sheet.
The valuation method we use is FCFF (discounted free cash flow) valuation, as can be seen
from the equation:
n
FCFt FV
Total market value = ∑ (1 + WACC)t + (1 + WACC)n (1)
t =1
which FCFt represents the cash flow in the growth period, FV represents the present value
of the cash flow discounted to the end of the growth period,

17
Preprint. Under review.

Value of equity = Total market value − Present value of debt (2)


 
Number of listed shares
IPO listing price = × Value of equity + IPO fees /Number of listed shares
Number of total shares
(3)

Ke × E Kd × D
WACC = + (4)
D+E D+E
Weighted average cost of capital (WACC) represents a company’s average after-tax cost of
capital from all sources, including common stock, preferred stock, bonds, and other forms
of debt. Where Ke is the cost of equity, Kd is the cost of debt, E is equity capital, and D is
debt capital. According to the Capital Asset Pricing Model (CAPM) :

Ke = Rf + β × (Rf − Rm ) (5)

Where R f is the risk-free rate of return, Rm is the expected market rate of return, and β is
the beta coefficient. Where Kd can be calculated as follows,

(SD × SR + LD × LR)
Kd = × AF × (1 − TR) (6)
D
Where SD is short-term debt, LD is long-term debt, SR is short-term interest rate, LR is
long-term interest rate, AF is bond adjustment factor, and TR is income tax rate and D is
debt capital.

Table 7: The Valuation Table of Company A for Trading Days


Trading Day D1 D12 D78 D144 D210
1 1930.38 3197.27 2429.94 3306.45 3203.58
2 2177.57 3415.69 2525.99 3420.97 3271.76
3 2166.84 3583.25 2629.69 3728.14 3647.98
4 2435.53 4101.14 2952.86 4157.99 3998.96
5 2631.68 4491.81 3176.54 4524.21 4342.30
FV 2802.14 4961.16 3457.12 5005.83 4812.35
Valuation 1 56379.29 98789.18 70745.68 101847.84 97966.06
1 1937.84 3214.78 2442.73 3328.10 3227.63
2 2193.92 3448.79 2547.91 3457.03 3308.96
3 2191.11 3634.12 2662.47 3783.43 3704.62
4 2471.97 4178.62 3001.14 4237.97 4078.29
5 2680.87 4598.64 3241.54 4632.24 4448.11
FV 2865.03 5104.56 3542.89 5149.74 4952.47
Upper Bound 57545.93 101435.23 72370.51 104570.65 99952.27
1 1922.93 3179.79 2417.19 3284.86 3179.63
2 2161.29 3382.79 2504.19 3385.15 3234.84
3 2142.75 3532.89 2597.22 3673.45 3591.99
4 2399.49 4024.78 2905.21 4079.22 3920.88
5 2583.22 4387.02 3112.63 4418.28 4238.60
FV 2740.40 4821.19 3373.13 4865.38 4675.63
Lower Bound 55233.23 96204.11 69153.24 98522.87 94729.68

18
Preprint. Under review.

Table 8: The financial indicators of Company A


Common financial
D1 D78 D144
indicators
Cost of Depts (Kd) 6% 5% 5%
Cost of Equity (Ke) 9% 9% 9%
Cost of debt ratio 5% 5% 5%
Cost of equity ratio 95% 95% 95%
WACC 8.85% 8.78% 8.80%
Sustainable growth rate 5% 5% 5%
Number of shares 200000 Shares

Table 9: The Valuation Table of Company B for Trading Days


Trading Day D1 D12 D78 D144 D210
1 874.70 910.86 915.98 988.02 1024.25
2 1138.94 1178.67 1175.10 1259.19 1244.98
3 1405.41 1372.95 1328.84 1339.54 1371.82
4 1589.73 1580.71 1554.98 1604.62 1636.20
5 1938.51 1888.52 1844.53 1877.51 1905.27
FV 2315.54 2198.77 2132.51 2131.85 2179.07
Valuation 45357.95 43338.41 43363.09 43554.37 44486.81
1 881.94 920.36 927.17 1001.97 1039.84
2 1157.58 1200.08 1198.32 1285.95 1273.13
3 1439.86 1408.31 1365.07 1377.93 1412.88
4 1641.82 1633.77 1609.35 1662.08 1697.04
5 2018.13 1966.28 1922.81 1958.08 1989.85
FV 2430.10 2305.95 2238.89 2238.44 2291.31
Upper Bound 47480.03 45337.32 45415.46 45175.15 46207.95
1 867.45 901.40 904.85 974.18 1008.77
2 1120.45 1157.50 1152.19 1232.81 1217.25
3 1371.51 1338.24 1293.32 1301.97 1331.67
4 1538.90 1529.01 1502.09 1548.77 1577.12
5 1861.41 1813.31 1768.93 1799.74 1823.71
FV 2205.53 2095.85 2030.49 2029.66 2071.59
Lower Bound 43317.66 41416.61 41392.46 41165.26 41985.16

Table 10: Financial Constants of Company B


Common financial
D1 D78 D144
indicators
Cost of Depts (Kd) 6% 5% 5%
Cost of Equity (Ke) 9% 9% 9%
Debt Cost Ratio 7% 7% 7%
Equity Cost Ratio 93% 93% 93%
WACC 8.79% 8.69% 8.72%
Sustainable Growth Rate 5% 5% 5%
Number of Shares 100,000 Shares

B.1 The ideal stock price conclusion

According to the financial analysis in the previous sections, the table below shows the
ideal stock prices of stocks A and B for each year and quarter 11 12. The financial analysis
provided the following valuations which can be used as initial data for our simulations.

19
Preprint. Under review.

Table 11: The Ideal Stock Price of Company A


Ideal Stock Price D1 D12 D78 D144 D210
Upper Bound 27.33 48.18 34.38 49.34 47.48
Lower Bound 26.24 45.70 32.85 46.80 45.00

Table 12: The Ideal Stock Price Table of Company B


Ideal Stock Price D1 D12 D78 D144 D210
Upper Bound 44.16 42.16 42.24 42.01 42.97
Lower Bound 40.29 38.52 38.49 38.28 39.05

Table 13: Initial Stock Prices of Companies A and B


Initial Stock Price of Company A 30
Initial Stock Price of Company B 40

C Event-driven Prompts in Market and Agent Roles


C.1 Stock Trading Drives Prompts

BACKGROUND PROMPT

You are a stock trader, and next, you will simulate interactions with other
traders in the market. There are two stocks in the market, A and B, where B is
the newly listed stock. Next, please complete your trading actions according
to the order.

LASTDAY FORUM AND STOCK PROMPT

After the close of trading yesterday, the stock prices of Company A and
Company B were {stock\_a\_price} dollars per share and {stock\_b\_price}
dollars per share, respectively. Posts by other traders on the forum are as
follows: {lastday\_forum\_message}.

LOAN TYPE PROMPT

[0]. 1 year, the benchmark interest rate {loan\_rate1}.


[1]. 2 years, the benchmark interest rate {loan\_rate2}.
[2]. 3 years, the benchmark interest rate {loan\_rate3}.

DECIDE IF LOAN PROMPT

It is the {time} trading session on the {date} day, and after the previous
session, the stock price of Company A is {stock_a_price} and the stock price
of Company B is {stock_b_price}.
In the current session, the buy and sell order of stock A is {stock_a_deals},
and the buy and sell order of stock B is {stock_b_deals}, You currently hold
{stock_a} shares of Company A, {stock_b} shares of Company B, and {cash} yuan
in cash.
You need to decide whether to buy/sell shares of Company A or Company B, and
how much to buy/sell and at what price.
You can refer to the current share price and the market to determine the price
yourself, not the current share price. The quantity must be an integer.
Encourage buying and selling as much as you can.

20
Preprint. Under review.

Return the result as JSON, for example:


{{"action_type": "buy"|"sell", "stock": "A"|"B", amount: 100, price: 30}}
If neither buy nor sell, return:
{{"action_type" : "no"}}

LOAN RETRY PROMPT

The following questions appeared in the action format you last answered:
{fail_response}. You should return the result as JSON, for example:
{{"action_type": "buy"|"sell", "stock": "A"|"B", amount: 100, price: 30}}
If neither buy nor sell, return:
{{"action_type" : "no"}}
Please answer again.

DECIDE BUY STOCK PROMPT

It is the {time} trading session on the {date} day, and after the previous
session, the stock price of Company A is {stock_a_price} and the stock price
of Company B is {stock_b_price}.
In the current session, the buy and sell order of stock A is {stock_a_deals},
and the buy and sell order of stock B is {stock_b_deals}.
You currently hold {stock_a} shares of Company A, {stock_b} shares of Company
B, and {cash} yuan in cash.
You need to decide whether to buy/sell shares of Company A or Company B, and
how much to buy/sell and at what price.
You can refer to the current share price and the market to determine the price
yourself, not the current share price.
The quantity must be an integer.
Encourage buying and selling as much as you can.
Return the result as JSON, for example:
{{"action\_type":"buy"|"sell", "stock": "A"|"B", amount: 100, price: 30}}
If neither buy nor sell, return:
{{"action_type" : "no"}}

BUY STOCK RETRY PROMPT

The following questions appeared in the action format you last answered:
{fail_response}.
You should return the result as JSON, for example:
{{"action_type": "buy"|"sell", "stock": "A"|"B", amount: 100, price: 30}}
If neither buy nor sell, return:
{{"action_type" : "no"}}
Please answer again.

21
Preprint. Under review.

C.2 Post-Trading prompts

FIRST DAY FINANCIAL REPORT

Company A has been listed for 10 years, deeply rooted in the chemical industry.
However, the company's operations have encountered bottlenecks, with revenues
declining over the past three years. In the short term, the stock price is
expected to further decrease.
Although Company A's performance has declined over the past five years, the
overall trend is stable. With the recent CEO change and the exploration of new
business avenues, the new CEO appears more proactive compared to the previous
one. The future operational outlook is expected to improve. Currently, Company
A is at a low valuation, and I choose to buy into Company A.

Company B, as a technology company, has just been listed for three years and
is in a period of business growth. Last year, its revenue declined due to the
overall tech environment, but the company's operations remain robust.
According to the latest corporate news, it is expected that the future revenue
growth rate will return to over 20%. In the short term, the stock price is
expected to continue rising.
While Company B's operations are good, there is a history of concealing
critical data before its IPO, casting doubt on the reliability of its revenue.
I believe it is prudent to continue monitoring its performance in the next
quarter before making investment decisions.
Company B recently received government inquiries regarding recent operational
and stock price fluctuations, and it provided explanations while committing to
allocate more resources to social services. I believe it will be challenging
for it to expand into new businesses in the short term, and its stock price is
likely to peak in the near term.

The government recently held talks with both Company A and Company B, actively
encouraging their contributions to society. Subsequently, agreements on
government subsidies were signed with both companies. I believe the stock
prices of these two companies should rise in the near term. Company A's
performance has been declining over the past five years, and I believe it
should be given a lower valuation. In the short term, I am bearish on Company
A. On the other hand, Company B is at a relatively low valuation point, so I
choose to buy into Company B and sell Company A.

SEASONAL FINANCIAL REPORT

Stock A: {stock_a_report}
Stock B: {stock_b_report}

POST MESSAGE PROMPT

The current trading day is over, please briefly post your trading tips on the
forum and post them on the forum. What you post will be publicly visible to
all traders. The responses contain only what needs to be posted.

NEXT DAY ESTIMATE PROMPT

Based on the market information and forum information of the current trading
day, please estimate whether you will buy and sell stock A and stock B
tomorrow and whether you will choose a loan.
Actions that are expected to take place are marked yes, and actions that will
not take place are marked no.

22
Preprint. Under review.

Return the result in JSON format, for example:


{{"buy_A": "yes", "buy_B": "no", "sell_A": "yes", "sell_B": "no", "loan":
"yes"}}

23
Preprint. Under review.

D AI-Agent Investors Trading and Behavior Data

D.1 Price statistics of the StockAgent’s pending orders on StockA and Stock B

47.5 Stock A
Stock B
45.0
42.5
40.0
Price

37.5
35.0
32.5
30.0
0 100 200 300 400
Days

Figure 10: The Gemini-based agent order price.

110 Stock A
100 Stock B
90
80
70
Price

60
50
40
30
0 250 500 750 1000 1250 1500 1750
Days

Figure 11: The GPT-based agent order Price

24
Preprint. Under review.

E Experiments Figures

Table 14: The profit and loss of The StockAgent in different external environments.(Part I)
Agent Non-finance Non-BBS Non-Loan Non-statement
0 -156779.47 -15745.19 529310.72 -21934.03
1 -689016.46 -4887.07 265022.24 13311.27
2 -223032.53 32037.27 302167.25 79.18
3 96490.38 -59496.88 612046.82 -48529.67
4 -1745400.27 -17709.74 537866.50 3881.38
5 -156246.98 11111.27 828530.87 -42928.78
6 41642.21 -2767.66 1212495.30 -2823.07
7 -1012926.31 12649.82 11560.30 14249.82
8 -496997.31 45591.91 529839.08 13353.14
9 1614942.67 -3375.10 32736.43 40877.82
10 364317.30 44323.95 341684.56 20990.38
11 -858128.36 -46191.30 580223.50 67595.85
12 838929.98 -56073.47 382722.50 -13335.78
13 797626.81 -24126.24 771147.59 -53765.72
14 225132.36 -18013.94 253366.11 35900.08
15 272069.46 32821.59 323245.63 4679.30
16 -1411078.16 4113.27 442866.07 9863.41
17 -1578977.91 43809.94 80994.05 65456.97
18 1801568.53 9090.56 474417.70 -1770.68
19 -409366.23 24176.59 110635.39 -14292.14
20 905509.34 3929.84 10864.42 -22021.30
21 1577414.73 -4757.95 698848.84 15979.12
22 -1640417.94 -64931.81 135945.59 -35297.88
23 73159.00 -54690.57 299238.95 -37855.64
24 748900.51 -7049.34 386527.46 70325.96
25 -62019.05 -25237.13 8280.01 -24916.43
26 -300850.29 38222.78 171963.15 14488.07
27 -1958752.57 -131992.39 1218441.76 -106001.35
28 1211683.67 4210.60 290570.31 -22150.17
29 45614.85 -6475.64 848355.59 27480.70
30 132912.09 35589.47 791398.93 40837.73
31 236293.07 10999.13 159097.39 -17798.89
32 2848581.05 14230.15 78757.44 67849.57
33 212978.91 9066.21 -14833.09 -1837.53
34 778185.26 8579.54 740683.39 -36053.55
35 917514.35 16595.45 310930.50 -16053.04
36 848886.30 -18358.99 709731.51 140262.95
37 -2513474.12 -1030.03 113785.80 -25919.84
38 81247.80 -7063.13 591216.43 -81138.50
39 -3111160.94 -32038.81 305957.45 140712.93
40 -1895940.05 4145.11 300702.02 176815.29
41 -1501258.97 33561.65 50588.31 -117634.55
42 -589746.53 4824.77 249717.14 -8286.80
43 -4077757.38 5916.18 40132.84 -111623.81
44 1761357.10 -100695.62 572314.27 -32365.55
45 1807590.44 -18840.46 157156.45 60180.71
46 12662.42 3772.76 383685.25 -76783.70
47 -3063049.11 8833.90 392021.90 81286.26
48 616907.76 58387.09 536951.70 72720.27
49 353078.32 -62948.08 318243.33 -45226.56
50 228931.33 20622.87 424742.21 33897.88

25
Preprint. Under review.

Table 15: The profit and loss of The StockAgent in different external environments.(Part II)
Agent Non-finance Non-BBS Non-Loan Non-statement
51 719313.71 -2728.61 491370.66 22523.10
52 -501576.75 22801.29 300612.63 -87321.17
53 342224.89 -6181.24 255547.80 52706.61
54 898350.85 27587.46 383961.94 -75002.23
55 -5327194.97 -21339.18 544499.77 10113.13
56 488576.57 -12792.26 722882.11 -25783.49
57 -808982.90 -19946.85 588549.75 -1252.88
58 -1190697.04 10465.77 531740.66 -101322.06
59 -500034.46 -23961.59 413390.92 1211.81
60 532080.40 5775.15 843165.02 42056.80
61 -2434682.31 -115398.53 35161.81 -149619.19
62 1083612.64 -1016.63 19242.98 228542.74
63 -461643.22 14305.04 163364.28 -120267.07
64 -1424189.14 -18740.44 92341.81 -122033.91
65 -1739735.53 -70111.68 294754.96 -44432.65
66 461148.72 -70370.91 310600.75 201036.24
67 -2658874.18 7446.28 676927.29 -198879.32
68 1588560.26 -14168.10 126915.69 -9431.21
69 282220.80 4018.11 336276.81 29871.23
70 -5981425.75 19946.07 272755.98 -21129.84
71 1160778.74 -9981.79 361579.45 87998.81
72 531484.39 -25570.15 465131.78 13347.49
73 -3063651.24 12500.33 1214836.99 -68289.60
74 129353.09 -33127.70 198820.09 111997.12
75 -5296080.05 -9157.76 2606.87 48262.70
76 451592.90 -25893.98 140416.41 -81306.28
77 1207812.49 8187.97 735354.78 21750.48
78 -2720809.54 10195.86 244849.79 -10004.15
79 799885.57 2519.12 687269.08 1030.39
80 -3747958.85 -61408.59 294798.79 19909.15
81 137400.56 9212.03 162287.98 -80712.20
82 2959120.98 -97978.93 44305.35 2847.82
83 -6252315.09 25597.62 303311.38 68417.17
84 -53447.31 34925.66 377790.09 -29041.65
85 912800.85 -73578.94 688732.78 29587.13
86 -553463.36 11322.14 12502.56 -94327.24
87 -1804927.38 21922.03 -17648.21 148314.47
88 1723276.30 12614.85 427244.26 114754.16
89 1289542.65 -25794.60 154190.44 -190224.50
90 177644.46 5402.24 282702.38 -4732.47
91 934827.13 -67237.83 849675.94 16116.05
92 2861690.50 -16324.46 746076.10 -79070.65
93 658919.86 48445.66 167233.71 -26917.54
94 2278357.75 -2656.92 296735.39 -16190.51
95 313115.13 -29362.15 397431.35 237527.72
96 -179647.13 -24747.97 554465.32 112077.38
97 -411707.32 -4148.34 9222.96 -91673.99
98 -738854.23 -47277.98 164133.79 3252.62
99 -823917.03 17103.78 524486.66 71102.30
100 1584195.68 16727.10 320633.61 -2694.53

26
Preprint. Under review.

Table 16: The profit and loss of The StockAgent in different external environments.(Part III)
Agent Non-finance Non-BBS Non-Loan Non-statement
101 -105625.81 13432.98 722484.19 -214672.18
102 1078835.44 -42106.21 469175.82 142142.95
103 -416374.10 10042.74 1275400.81 -38013.76
104 -100876.47 23999.53 526792.22 -174117.30
105 238619.32 -33700.20 2935.75 57943.79
106 1156134.16 -36785.39 302372.82 115059.98
107 -1545273.59 -30590.46 568349.53 -48197.05
108 -158676.57 -34301.66 385220.15 -137224.76
109 -4832144.24 -41565.12 754737.03 -37944.45
110 804477.14 19198.91 293116.45 154913.03
111 -2108163.37 19426.81 313628.42 98447.90
112 1473247.28 -18096.46 416890.50 -5267.70
113 17930.39 -23490.68 97752.37 -154982.44
114 253412.35 9261.00 466398.35 2061.02
115 760493.36 -62972.02 108400.26 -49677.36
116 -372384.36 -16064.49 24059.16 10756.79
117 436496.33 6573.43 698605.98 56100.39
118 978512.74 129353.09 -33127.70 198820.09
119 97149.71 3096.97 317523.64 -135140.62
120 1131378.01 -126979.89 409291.35 -12781.11
121 127356.38 -55320.35 38528.35 -58847.23
122 319530.35 29578.85 165810.06 20526.14
123 192615.38 15723.22 1221602.85 -68048.40
124 278460.73 -36504.17 297191.56 -3874.56
125 1579135.23 9181.32 828106.74 93454.23
126 -220686.57 -5590.81 796519.32 13694.02
127 975456.71 -2640.19 143708.72 -4448.05
128 837290.58 11494.98 83564.50 -71064.33
129 254980.31 -3690.23 -2033.85 31021.64
130 168258.52 4997.85 728259.87 -5645.30
131 -222640.20 -112072.95 323166.74 18843.17
132 -404757.64 4146.77 667962.89 -127583.66
133 876309.64 -47486.67 116975.48 -51768.81
134 260489.45 7213.84 604805.50 39809.62
135 114797.03 4495.36 307748.76 -27156.26
136 158071.54 -29013.38 339010.88 55349.71
137 -1634393.68 30977.69 8567.59 -30253.51
138 -818855.66 30280.59 252178.08 87074.52
139 -1982207.87 -47205.84 19447.99 39624.16
140 716200.30 10153.13 520477.17 -56959.28
141 -1316159.14 -25600.88 201578.75 -75984.20
142 -2122498.47 -32407.44 362434.52 68708.69
143 -81005.19 -27980.01 408372.65 -46057.02
144 1528723.84 8680.60 583657.01 -38296.30
145 48922.99 -19171.60 264185.31 8348.06
146 -3500332.09 48582.49 417507.69 79731.14
147 -566369.24 22291.64 480302.25 18142.74
148 937040.60 2338.45 302603.11 117842.83
149 -1203052.08 10293.69 305862.03 -11244.60
150 -833876.79 -19278.37 404933.97 -117929.06

27
Preprint. Under review.

Table 17: The profit and loss of The StockAgent in different external environments.(Part IV)
Agent Non-finance Non-BBS Non-Loan Non-statement
151 -1201365.32 -102420.58 544365.82 -122178.47
152 -162150.90 -70851.31 730527.64 -78328.22
153 406189.11 24523.49 594586.15 37465.05
154 -7362732.30 38329.20 536580.18 77726.95
155 -636852.37 10226.80 423032.52 76374.19
156 202177.52 29632.82 826126.95 57099.00
157 566202.41 2891.15 -22716.95 -18899.30
158 266419.81 1969.49 10882.61 73107.16
159 -2012979.15 -68800.46 180350.24 -139283.37
160 241126.68 22405.01 94751.05 42665.07
161 -561857.69 -90375.20 340652.11 67409.74
162 1306954.30 -26049.80 308934.18 -28489.11
163 -383936.14 29688.27 668817.71 -76571.81
164 458060.67 -14624.57 122174.90 -25700.32
165 1164634.00 7482.82 309735.64 21877.42
166 341680.69 9165.37 274799.07 -44899.44
167 305821.63 4002.65 370692.10 155314.38
168 -975037.64 -31341.71 482347.41 -63424.57
169 -86638.87 33707.39 1243389.98 31420.52
170 -1910620.53 12348.98 165727.12 -79898.49
171 839119.86 16899.22 3224.07 116446.44
172 1199968.82 -103766.17 134233.48 9164.44
173 -940358.54 -42810.10 728935.27 -36908.81
174 -712389.21 -48197.88 289285.14 -20553.23
175 456228.62 -345.93 665963.86 -46564.95
176 1036506.06 -39655.87 301304.01 -19053.75
177 -218618.93 -51277.02 125480.92 87788.29
178 606788.54 -17325.39 3394.30 23747.28
179 -2198442.90 -40189.44 302812.03 -807.85
180 1640630.27 29392.07 362514.94 -106331.21
181 2317537.84 5808.46 721660.34 148478.58
182 -403863.94 -13871.31 41009.84 13326.86
183 394682.37 -10578.68 -2178.92 50915.96
184 75517.66 -2780.68 409020.55 -101668.46
185 -1331009.66 -22814.79 175132.65 53716.30
186 -1906789.51 -10820.08 273817.38 -15703.72
187 172075.45 21415.58 843905.59 48538.56
188 1157491.52 2684.72 758201.99 -52973.95
189 -1088761.91 323.17 132951.63 39117.55
190 928545.17 5150.54 318504.07 29203.14
191 -1512313.11 -28458.68 387082.08 -5321.91
192 959083.41 16700.97 572748.00 -54938.08
193 -1471037.95 35837.79 41611.86 -66058.87
194 -302136.97 15665.27 162051.55 24968.25
195 2210228.93 7161.37 538696.16 148478.58
196 -672293.47 389.16 301130.48 13326.86
197 400612.61 -85830.30 720185.25 50915.96
198 659949.64 -34345.24 465646.57 -101668.46
199 -3347763.52 31579.47 1258219.66 48538.56

28
Preprint. Under review.

Table 18: StockAgent’s stock price movement in the case of ablating the external environ-
ment(Part I)
Round No Info A No Info B NoBBS A NoBBS B No State A No State B
1 29.0 39.0 28.0 39.1 30.2 44.4
2 29.0 39.1 28.9 38.0 29.7 44.3
3 28.5 39.1 28.5 38.0 29.7 44.2
4 29.0 39.1 27.8 37.7 29.7 44.2
5 29.0 37.4 27.5 37.8 29.2 44.2
6 28.5 37.4 27.7 38.0 29.4 44.2
7 28.3 37.2 27.8 37.8 29.1 44.0
8 27.9 37.2 27.1 38.2 29.2 43.8
9 28.1 37.2 28.0 38.0 29.1 43.0
10 27.8 36.5 28.2 39.3 29.1 43.0
11 28.0 36.4 28.1 39.2 29.0 43.0
12 27.0 36.2 28.0 39.2 29.0 43.0
13 27.0 35.9 28.6 39.0 29.0 42.1
14 26.3 35.1 28.1 39.2 29.5 42.2
15 26.4 35.1 28.3 39.4 28.9 42.1
16 26.3 34.9 28.4 39.1 28.9 42.4
17 26.4 34.8 28.2 39.1 28.5 42.3
18 26.1 34.8 28.5 39.1 28.5 41.9
19 26.3 34.5 28.9 39.0 28.5 41.3
20 26.3 34.5 28.3 39.0 28.5 42.0
21 26.3 34.2 28.7 39.0 28.8 42.0
22 26.1 34.2 28.5 38.9 28.5 42.0
23 26.1 34.0 28.5 38.3 28.5 33.0
24 26.0 34.2 27.6 38.7 28.2 33.0
25 25.9 34.1 27.9 38.5 28.0 33.0
26 25.9 34.0 27.4 38.6 28.0 33.3
27 25.8 33.9 27.1 38.4 28.1 33.1
28 25.3 33.5 26.0 38.0 28.1 33.1
29 25.3 33.4 26.2 37.7 28.1 33.1
30 25.3 33.4 26.4 37.8 28.0 33.1

29
Preprint. Under review.

Table 19: StockAgent’s stock price movement in the case of ablating the external environment
(Part II)
Round No Loan A No Loan B No Interest Change A No Interest Change B
1 29.0 39.1 30.0 40.0
2 29.9 38.0 30.0 40.7
3 29.5 38.0 30.0 40.7
4 28.8 37.7 30.0 40.7
5 28.5 37.8 30.0 40.7
6 28.7 38.0 33.0 40.7
7 28.8 37.8 33.0 40.7
8 28.1 38.2 33.0 40.7
9 28.0 38.0 35.5 40.7
10 28.2 39.3 35.5 40.7
11 28.1 39.2 35.5 40.7
12 28.0 39.2 35.5 40.7
13 28.6 39.0 35.5 40.7
14 28.1 39.2 36.7 41.5
15 28.3 39.4 36.7 41.6
16 28.4 39.1 41.8 41.6
17 28.2 39.1 42.7 41.8
18 28.1 39.1 43.0 41.8
19 27.9 39.0 43.0 41.8
20 28.1 39.0 43.0 41.8
21 28.1 39.0 43.0 43.0
22 26.5 38.9 46.8 43.0
23 26.6 38.3 47.5 43.0
24 27.6 38.7 47.5 45.5
25 27.9 38.5 50.5 45.5
26 27.4 38.6 51.8 45.5
27 27.1 38.4 52.0 45.5
28 26.0 38.0 56.9 45.5
29 26.2 37.7 56.9 45.5
30 26.4 37.8 62.5 46.0

30

View publication stats

You might also like