A Two-Stage Framework for Stock Price Prediction: LLM-Based Forecasting with Risk-Aware PPO Adjustment ()
1. Introduction
Stock price prediction is a critical task in financial markets, with significant implications for investors, analysts, and traders. Accurate forecasting can lead to better investment strategies, while inaccurate predictions can result in substantial financial losses. Conventional stock price prediction techniques, including time series models, machine learning, and deep learning, typically concentrate on identifying price trends through historical data and technical indicators. For example, traditional machine learning models such as SVM, Random Forest, and Gradient Boosting are commonly used with technical indicators to predict stock prices [1]-[4]. However, due to the inherently non-linear nature of stock price movements, these models struggle to capture complex patterns effectively [5]. To address this limitation, researchers often turn to deep learning approaches, such as LSTM [6] and CNN [7], which are better suited for modeling intricate and non-linear dependencies in financial data.
To further enhance stock forecasting performance, researchers incorporate financial news sentiment alongside stock features and technical indicators [8]-[10]. These sentiments are derived from various sources, including tweets [11], news articles [12], and financial reports [13]. Before the emergence of Large Language Models (LLMs), sentiment analysis was typically conducted using traditional NLP tools such as VADER [14], which is a lexicon-based approach.
However, all these models and approaches typically overlook the inherent risks and uncertainties in the financial markets, leading to predictions that may be volatile or unreliable in the face of unforeseen market shifts.
Recent advancements in Natural Language Processing (NLP) have led to the creation of LLMs. These models have shown remarkable performance in various tasks, including sentiment analysis and the interpretation of financial news [10] [15] [16]. These models can process large amounts of textual data to extract valuable insights, making them promising tools for stock price prediction. Although LLMs can provide accurate predictions based on historical price data and market sentiment, they often do not explicitly account for the financial risks associated with their forecasts. This gap presents an opportunity to improve stock price prediction models by integrating risk considerations.
A prompt-based approach has recently gained attention as an effective method for leveraging LLMs in stock price prediction [15]-[17]. This prompt-based approach uses designed prompts to instruct the model in analyzing financial data, extracting key insights, and making informed predictions. By structuring the input with specific instructions, prompt-based LLMs can focus on relevant aspects of financial news, technical indicators, and market conditions, leading to more context-aware predictions. One major advantage of this approach is its adaptability, because prompts can be modified to reflect different market conditions, risk factors, or investor preferences without retraining the model [18]. Additionally, prompt engineering allows for the integration of multiple data sources, such as candlestick patterns and macroeconomic indicators, enabling a more comprehensive analysis. This makes prompt-based LLMs a flexible and efficient tool for stock forecasting, offering improved interpretability and alignment with financial decision making.
Moreover, recent studies have highlighted the potential of reinforcement learning in financial forecasting, particularly for portfolio optimization and risk management [19]-[21]. Reinforcement learning algorithms, such as PPO, have demonstrated success in dynamic environments by learning from past interactions and adjusting strategies accordingly [22]. However, limited research has explored the integration of LLM-generated predictions with reinforcement learning techniques to refine stock price forecasts in a risk-aware manner.
This research proposes a novel framework that integrates LLM-based stock price prediction with Proximal Policy Optimization (PPO), a reinforcement learning technique. The primary objective is to refine LLM predictions by incorporating risk-aware adjustments through PPO. By doing so, the framework addresses both the accuracy and the risk aspects of stock price forecasting. Specifically, we introduce a risk-adjusted reward function that takes into account financial risk metrics, such as Value at Risk (VaR) and Conditional Value at Risk (CVaR), to optimize the predictions. In finance, Value at Risk (VaR) is commonly used to estimate the potential loss of an asset or portfolio within a specified time period at a given confidence level. For example, a 95% VaR of $1 million means there is a 95% chance that losses will not exceed $1 million in the specified period. Conditional Value at Risk (CVaR), also referred to as Expected Shortfall, quantifies the average loss that exceeds the Value at Risk (VaR) threshold. It provides insight into extreme losses by averaging the worst-case scenarios that exceed VaR. CVaR is useful for assessing tail risk and is often preferred for risk management. By considering the risk-adjusted return, this framework aims to provide a more robust and reliable approach to stock price forecasting, ultimately offering a tool that better aligns with the complex dynamics of financial markets.
Through this approach, the paper contributes to both the application of LLMs in stock price prediction and the integration of risk-aware mechanisms in reinforcement learning models. The results show that the framework improves prediction accuracy while reducing financial risk. This makes it a useful tool for investors and analysts in a fast-changing financial market.
The main contributions of this research are as follows.
This research proposes a novel framework that combines LLMs with a risk-adjusted PPO to refine stock price predictions. The LLM generates initial price forecasts, while PPO adjusts these predictions based on financial risk, improving both prediction accuracy and stability.
The study introduces a risk-aware mechanism that integrates financial risk metrics (e.g., VaR and CVaR) into stock price prediction. This improves forecast reliability by considering market volatility, helping investors and analysts make better decisions.
The remainder of this paper is structured as follows. Firstly, related work is listed (Section 2). The methodology is then described (Section 3). In Section 4, the experimental results are presented. Finally, we conclude with Section 5.
2. Related Work
The task of stock price prediction has been extensively studied in financial and computational research. Traditionally, stock price forecasting models rely on time-series analysis methods such as AutoRegressive Integrated Moving Average (ARIMA) and various forms of exponential smoothing [23]-[25]. However, these models are limited in their ability to capture complex non-linear relationships in financial markets. Therefore, machine learning and deep learning techniques have emerged as more effective tools for stock prediction due to their ability to model intricate patterns and trends.
2.1. Machine Learning for Stock Prediction
Machine learning models such as Support Vector Machines (SVMs) [26]-[28], Random Forests [5] [29] [30], and Gradient Boosting methods [31]-[33] have been used for predicting stock price movements. For example, Mahmoodi et al. [34] use a SVM model combined with metaheuristic algorithms to develop an advanced stock price forecasting model. Their approach integrates optimization techniques (metaheuristics) to enhance SVM’s predictive accuracy, addressing challenges like non-linearity and volatility in financial markets. Vijh et al. [35] use a Random Forest model to predict the next day’s close prices for five companies and results show the effectiveness of the model in stock price forecasting. However, these approaches with stock features and technical indicators as inputs have some limitations. For example, these approaches do not account for external factors like sentiment or macroeconomic events, which can significantly affect stock prices.
2.2. Deep Learning Approaches
Deep learning models, including Long Short Term Memory (LSTM) [36]-[38] and Convolutional Neural Network (CNN) [17] [39] [40], have gained attention in the stock prediction domain. LSTM models are particularly effective in modeling sequential data, such as time series, and have been shown to outperform traditional models in stock price prediction tasks [41]. On the other hand, CNNs have been used to process financial data in the form of images, such as candlestick charts, capturing spatial patterns that could be indicative of price movements [17] [42]. In order to further enhance the prediction performance, some hybrid models are proposed by some researchers. For example, Lu et al. [43] propose a CNN-LSTM model to forecast the stock price. CNN is used to extract features from the data. Then LSTM is fed with the extracted features to predict the stock price. Nikhil et al. [44] propose a Genetic Algorithm-Assisted LSTM-CNN (GA-LSTM-CNN) for stock price prediction. Although these models demonstrate improved performance over traditional methods, they often overlook the inherent risk associated with financial predictions, which makes them less robust under volatile market conditions.
2.3. Large Language Models for Stock Prediction
More recently, the use of LLMs for stock prediction has attracted attention due to their ability to process large-scale textual data, such as financial news, analyst reports and social media sentiment. Models like BERT [45] and GPT [46] have been fine-tuned for financial sentiment analysis and have shown promising results in predicting market trends based on news articles and social media posts [47]. Even without financial fine-tuning, LLMs have the potential to outperform other traditional models in stock forecasting [17] [48]. These models, when combined with traditional stock data, offer a more comprehensive market view. They integrate both quantitative and qualitative factors. Recently, this is a growing trend of applying LLMs directly to forecast time series. For example, Wang et al. [49] propose a LLM called Stock Time for stock price forecasting and the results show that their proposed model can outperform recent LLMs with less memory usage and computational cost. However, the challenge remains in how to integrate LLM-based predictions with risk considerations to ensure financial stability.
2.4. Reinforcement Learning for Stock Price Prediction
Reinforcement Learning (RL) has also been applied to stock price prediction, with the aim of optimizing trading strategies in a dynamic environment. For example, Altuner and Kilimci [50] use deep Q-learning with knowledge graph and community aware sentiments to predict the stock movement. Du and Shen [51] also use deep Q-learning with sentiment analysis to predict stocks in China. Furthermore, PPO, a popular RL algorithm [52], has been used to train agents that adjust portfolios or make buy/sell decisions based on market conditions [53]. Although a growing number of studies have shown the potential to use RL for stock trading by training agents to maximize returns while minimizing risk [54]-[56], most RL-based models focus primarily on optimizing returns, with less emphasis on accounting for financial risks, such as market volatility or drawdowns.
2.5. Risk-Aware Prediction
Incorporating risk measures into stock prediction models is an emerging area of research. Traditional models that focus purely on prediction accuracy may lead to overly optimistic forecasts, which can result in significant losses during periods of high volatility. Risk-adjusted models, such as those incorporating Value at Risk (VaR) or Conditional Value at Risk (CVaR), offer a more robust framework by considering potential losses in the tail of the distribution [57].
3. Methodology
This study proposes a two-stage framework (Figure 1) that integrates LLMs with a risk-aware reinforcement learning approach using PPO to improve stock price prediction. The first stage uses an LLM to generate initial stock price forecasts based on historical market data, technical indicators, and sentiment analysis. However, these predictions do not inherently account for risk, making them susceptible to market volatility. To address this, the second stage introduces a PPO-based adjustment mechanism that refines the LLM forecasts by incorporating risk-sensitive modifications. This framework aims to strike a balance between prediction accuracy and financial stability, offering a more robust approach to stock price forecasting.
3.1. Data
The data used in this study consist of historical stock price data, technical indicators, and sentiment analysis. Stock price data, including close price, open price, high, low, and trading volume, are collected for a set of companies from 2015 to 2024 by using the Python library yfinance. These companies include Apple, HSBC, Pepsi, Tencent (0700.HK), and Toyota (7203.T). The daily close price trends for these five companies are illustrated in Figure 2. The summary statistics of stock prices are shown in Table 1. The data set is prepared with a sliding window of five days, where the most recent five days of data are used to predict the
Figure 1. Proposed two-stage framework for stock forecasting
Figure 2. Daily close price of five companies.
Table 1. Summary statistics of stock prices.
|
Apple |
HSBC |
Pepsi |
Tencent |
Toyota |
Count |
2270 |
2270 |
2270 |
2167 |
2147 |
Mean |
87.36 |
26.50 |
116.81 |
314.49 |
1457.08 |
Std Dev |
58.04 |
5.27 |
33.08 |
117.52 |
553.96 |
Min |
20.67 |
13.73 |
67.36 |
110.97 |
768.73 |
th Percentile |
35.90 |
22.58 |
88.54 |
244.21 |
1112.45 |
Median |
58.75 |
26.58 |
113.80 |
312.70 |
1224.96 |
th Percentile |
144.71 |
30.60 |
151.23 |
370.07 |
1776.84 |
Max |
196.93 |
41.20 |
184.35 |
690.13 |
3703.98 |
Table 2. Descriptions of technical indicators.
Indicator |
Description |
SMA (Simple Moving Average) |
The average price over a set period, giving equal weight to all prices in the period. |
EMA (Exponential Moving Average) |
A moving average that gives more weight to recent prices, making it more
responsive to new data. |
RSI (Relative Strength Index) |
Measures price movement speed and change; identifies overbought or oversold conditions. |
MACD (Moving Average Convergence Divergence) |
Tracks the difference between short-term and long-term moving averages to
identify trends. |
Bollinger Bands |
A volatility indicator consisting of a moving average with upper and lower
bands based on standard deviations. |
Table 3. LLM Prompt.
Prompt Description |
You are a financial analyst with expertise in stock market forecasting. |
Your task is to analyze market data and predict the next trading day stock price. |
Use historical price trends, technical indicators, and sentiment analysis to provide an informed forecast. |
Ensure that your predictions are well-justified, considering multiple financial factors. |
. Predicted Stock Price: The forecasted close price for the next trading day. |
. Price Movement Likelihood: The likelihood of the predicted stock price. |
. Justification: Provide an explanation for the predicted stock price and the corresponding likelihood, considering the following: |
-Historical market data (e.g., recent closing prices). |
-Technical indicators (e.g., SMA, EMA, RSI, MACD, Bollinger Bands). |
-Sentiment analysis (e.g., news sentiment, market sentiment). |
Please weigh these signals and justify the predicted stock price. |
close price of the next day. In addition, technical indicators such as Simple Moving Average (SMA), Exponential Moving Average (EMA), Relative Strength Index (RSI), Moving Average Convergence Divergence (MACD), and Bollinger Bands are derived from the raw price data by using the Python library pandas-ta. A brief description of each technical indicator is given in Table 2. Technical indicators are calculated from historical prices and volumes and they are often used by traders and investors to predict the stock movement in finance. Sentiment analysis is conducted on financial news using polarity scores, which help capture market sentiment that could influence stock price movements. The Python package NLTK is used to generate the polarity scores of financial news. The polarity score measures the sentiment of text and it ranges from −1 to 1. A score closer to 1 indicates positive sentiment, while a score near −1 represents negative sentiment. A score around 0 suggests neutral sentiment. Daily news articles are downloaded from reliable financial news sources such as Yahoo Finance using the Financial News Feed and Stock News Sentiment data API1. The first 70% of the data is used for training and the remaining 30% of the data is used for testing.
3.2. Model Setup
3.2.1. LLM-Based Stock Price Prediction
The first stage of the framework involves using an LLM to predict stock prices. The LLM receives structured prompt input that includes historical market data, technical indicators, and sentiment analysis. This information is processed to generate a forecast for the next day’s stock price. The LLM model used in this study is “deepseek-r1-distill-llama-70b”. The LLM is prompted to generate stock price predictions, providing the predicted price, its corresponding likelihood, and explanations for these forecasts based on the input features. Table 3 shows the structure and content of the prompt used in this study. Although the LLM produces a valuable initial prediction, it does not directly account for financial risks or market volatility, which requires the integration of the PPO model in the second stage.
3.2.2. Risk-Aware PPO Adjustment
The second stage of the framework introduces a Proximal Policy Optimization (PPO) agent to adjust the LLM predictions by incorporating risk-sensitive modifications. PPO, proposed by [52], is selected due to its stability in policy optimization and its ability to ensure that drastic policy changes are avoided. The PPO agent operates within an environment where it takes the LLM-predicted stock price and refines it based on a defined reward function that accounts for both prediction accuracy and financial risk. The state representation (Equation 1) for the PPO agent includes the LLM-predicted price, historical price trends, market volatility, and risk metric, VaR. The PPO agent’s action space (Equation 2) allows it to adjust the predicted price, ensuring that any forecast modifications stay within a reasonable range to prevent large fluctuations.
The reward function (Equation 4) in PPO is designed to balance predictive accuracy and risk control. It is formulated as a weighted combination of the negative absolute prediction error and a risk penalty term that incorporates risk measure CVaR. PPO is trained using historical stock data, where it learns the optimal adjustment policy by interacting with the market environment and receiving feedback based on its actions. Training involves updating the PPO model’s policy network to maximize the cumulative reward while maintaining stable updates through a clipped surrogate objective function (Equation 5).
(1)
represents the state at time
.
is the LLM-predicted stock price.
is the historical price trend.
is the market volatility.
is the Value at Risk.
(2)
(3)
(4)
is the reward at time
.
is the true stock price.
is a weighting factor.
represents the Conditional Value at Risk at confidence level
.
(5)
is the PPO objective function.
is the probability ratio between the new and old policies.
is the advantage estimate.
is a clipping parameter to stabilize training.
(6)
3.3. Evaluation
The performance of the proposed model is evaluated by comparing the adjusted predictions from the LLM-PPO framework with predictions from other models. These models include a baseline LLM model that makes predictions without any adjustments, traditional machine learning models like SVR, XGBoost, TCN and LSTM, and the proposed LLM-PPO hybrid model. The evaluation criteria consist of multiple aspects to assess both prediction accuracy and risk-adjusted returns.
Prediction accuracy is measured using Mean Absolute Percentage Error (MAPE) (Equation 7), where the predicted stock prices are compared with the actual stock prices, and Root Mean Square Error (RMSE) (Equation 8), which quantifies the average magnitude of errors by taking the square root of the average squared differences between predicted and actual values. To evaluate the financial stability of the predictions, risk-adjusted return metrics such as the Sharpe ratio and Sortino ratio are used. The Sharpe ratio (Equation 9) evaluates the return earned for each unit of risk taken, whereas the Sortino ratio (Equation 10) focuses specifically on downside risk. Additionally, the maximum drawdown (Equation 11) is calculated to assess the largest peak-to-trough loss during the evaluation period.
(7)
(8)
(9)
(10)
(11)
Where:
is the actual value, and
is the forecasted value.
is the stock return,
is the risk-free rate.
is the standard deviation of returns, and
is the standard deviation of downside deviations.
Peak and Trough refer to the highest and lowest values of the stock over a given period.
3.3.1. Baseline Models
Below is a brief overview of each baseline model utilized in this study.
SVR (Support Vector Regression): SVR is a regression technique that applies the principles of Support Vector Machines (SVM) to predict continuous values. It aims to find a function that best fits the data by mapping it into a higher-dimensional space and minimizing the prediction error within a margin.
XGBoost (Extreme Gradient Boosting): XGBoost is a robust machine learning algorithm that utilizes gradient boosting. It constructs an ensemble of decision trees, with each new tree aiming to rectify the mistakes of its predecessors.
TCN (Temporal Convolutional Network): TCN is a deep learning architecture designed for sequence modeling tasks. It employs convolutional layers with causal padding to handle sequential data and capture long-term dependencies. Unlike recurrent networks, TCNs can efficiently process long sequences due to their parallelization capabilities, making them suitable for time series forecasting tasks like stock price prediction.
LSTM (Long Short Term Memory): LSTM is a type of recurrent neural network (RNN) designed to address the vanishing gradient problem in traditional RNNs. It uses specialized gates to regulate the flow of information and maintain long-term dependencies in sequential data. LSTMs are widely used in time series analysis and natural language processing tasks due to their ability to learn from historical data over extended periods.
4. Experimental Setup
The LLM used for this study is based on the “deepseek-r1-distill-llama-70b” model, which is from the American AI company Groq AI2. Users can use this model with API but fine-tuning is not available. However, this model has been shown to be capable of generating competitive performance in the previous study even without fine-tuning [17]. The “deepseek-r1-distill-llama-70B” is a distilled version of the Llama 70B model. It is designed to be smaller and more efficient while maintaining strong performance. The model is optimized for tasks like natural language understanding, text generation, and reasoning. Due to the distillation process, it runs faster and requires less computing power compared to the original 70B model.
The PPO algorithm is implemented using Stable-Baselines3 in PyTorch, leveraging its ability to handle reinforcement learning tasks efficiently. The training process involves updating the PPO model using historical stock data, where the agent learns to adjust stock price predictions based on the reward function. The PPO model is trained for 100000 timesteps with a learning rate of 3e−4, a clip range of 0.2, and a discount factor (gamma) of 0.99. The entropy coefficient is set to 0.01 to balance exploration and exploitation.
5. Results
The experiment results, shown in Table 4, compare the performance of different models across five stocks. Six key metrics are presented: MAPE (Figure 3), RMSE (Figure 4), Sharpe Ratio, Sortino Ratio, Maximum Drawdown, and Cumulative Return (Figure 5). Lower MAPE and RMSE values indicate better prediction accuracy, while a lower Maximum Drawdown reflects better risk management. Higher Sharpe and Sortino Ratios suggest better risk-adjusted returns, and Cumulative Return shows the overall profitability of each model.
The results show that LLM-PPO performs the best across all five stocks in both prediction accuracy and risk management. For Apple, LLM-PPO not only has the lowest prediction errors but also generates the highest cumulative returns and the smallest drawdown. The same trend is observed with Pepsi, where LLM-PPO reinforcement learning framework effectively handles price fluctuations, providing both accurate predictions and strong risk-adjusted returns.
In the case of HSBC, XGBoost and LSTM perform well in terms of prediction accuracy, but LLM-PPO still outperforms in overall performance. Traditional
Table 4. Comparison of model performance across multiple stocks.
Stock |
Model |
MAPE (%) ↓ |
RMSE ↓ |
Sharpe Ratio ↑ |
Sortino Ratio ↑ |
Max Drawdown ↓ |
Cumulative Return ↑ |
*Apple |
LLM (Baseline) |
0.1325 |
0.0578 |
0.9203 |
0.0049 |
−0.3802 |
0.1750 |
XGBoost |
0.0991 |
0.0447 |
0.7801 |
0.0032 |
−0.2955 |
0.1853 |
SVR |
0.1173 |
0.0731 |
0.7105 |
0.0028 |
−0.3105 |
0.1482 |
TCN |
0.1019 |
0.0603 |
0.8452 |
0.0031 |
−0.3422 |
0.1723 |
LSTM |
0.1489 |
0.1048 |
0.6310 |
0.0024 |
−0.3899 |
0.1125 |
LLM-PPO |
0.0850 |
0.0366 |
1.0213 |
0.0035 |
−0.2799 |
0.2321 |
*HSBC |
LLM (Baseline) |
0.1278 |
0.0469 |
0.5303 |
0.0018 |
−0.6215 |
0.1285 |
XGBoost |
0.0952 |
0.0203 |
0.5402 |
0.0019 |
−0.2520 |
0.1367 |
SVR |
0.1104 |
0.0483 |
0.4217 |
0.0015 |
−0.3511 |
0.1083 |
TCN |
0.1048 |
0.0379 |
0.4794 |
0.0020 |
−0.2993 |
0.1295 |
LSTM |
0.1019 |
0.0372 |
0.3789 |
0.0017 |
−0.4014 |
0.1197 |
LLM-PPO |
0.0812 |
0.0186 |
1.0337 |
0.0022 |
−0.2215 |
0.2126 |
*Pepsi |
LLM (Baseline) |
0.1407 |
0.0539 |
0.4485 |
0.0022 |
−0.2897 |
0.1391 |
XGBoost |
0.0944 |
0.0382 |
0.5963 |
0.0024 |
−0.2480 |
0.1582 |
SVR |
0.1095 |
0.0451 |
0.5018 |
0.0023 |
−0.2979 |
0.1480 |
TCN |
0.1179 |
0.0838 |
0.5496 |
0.0027 |
−0.3476 |
0.1302 |
LSTM |
0.1246 |
0.0785 |
0.5750 |
0.0025 |
−0.3680 |
0.1109 |
LLM-PPO |
0.0786 |
0.0322 |
1.0427 |
0.0030 |
−0.1989 |
0.2203 |
*Tencent |
LLM (Baseline) |
0.1368 |
0.0487 |
0.4683 |
0.0023 |
−0.3487 |
0.1312 |
XGBoost |
0.0918 |
0.0336 |
0.6176 |
0.0025 |
−0.2781 |
0.1684 |
SVR |
0.1089 |
0.0439 |
0.5483 |
0.0022 |
−0.3297 |
0.1492 |
TCN |
0.1149 |
0.0764 |
0.5202 |
0.0028 |
−0.3189 |
0.1415 |
LSTM |
0.1273 |
0.1064 |
0.5982 |
0.0026 |
−0.3465 |
0.1194 |
LLM-PPO |
0.0763 |
0.0295 |
1.0519 |
0.0031 |
−0.1799 |
0.2396 |
*Toyota |
LLM (Baseline) |
0.1448 |
0.0558 |
0.4957 |
0.0025 |
−0.4160 |
0.1296 |
XGBoost |
0.1092 |
0.0227 |
0.5989 |
0.0027 |
−0.2773 |
0.1612 |
SVR |
0.2499 |
0.0347 |
0.4972 |
0.0024 |
−0.3312 |
0.1388 |
TCN |
0.2146 |
0.0412 |
0.5463 |
0.0026 |
−0.3097 |
0.1490 |
LSTM |
0.2309 |
0.0354 |
0.4691 |
0.0022 |
−0.3462 |
0.1213 |
LLM-PPO |
0.0867 |
0.0189 |
1.0634 |
0.0032 |
−0.1825 |
0.2239 |
models like SVR and TCN show larger drawdowns and weaker risk-adjusted returns. This highlights LLM-PPO’s strength, even in stable markets, where it minimizes losses while capturing gains effectively.
For Toyota, LSTM shows decent forecasting accuracy, but its risk management is not as strong as LLM-PPO. The baseline LLM model performs well, but the PPO-enhanced version significantly improves all metrics, especially in reducing
Figure 3. MAPEs of All models for each stock.
Figure 4. RMSEs of All models for each stock.
Figure 5. Econometric metrics across different models for stock price prediction.
drawdowns and increasing cumulative returns. This demonstrates the value of using reinforcement learning to enhance predictions.
Figure 6 visualizes the prediction performance of both the baseline LLM and the LLM-PPO models. It is clear that the LLM-PPO model more effectively captures stock movements compared to the baseline LLM without any enhancements or adjustments.
According to Figure 3 and Figure 4, another important finding is that although LLM without RL adjustment cannot outperform traditional machine learning models, it can generate competitive results compared to the traditional models, which indicates LLM’s potential in time series forecasting.
Overall, LLM-PPO provides the best balance of low prediction errors, strong risk-adjusted returns, and controlled drawdowns across all stocks. It reduces maximum drawdowns by 20% - 40% compared to other models. These results suggest that LLM-PPO combination of predictive modeling and risk-sensitive reinforcement learning creates a more reliable and effective solution for stock forecasting, excelling not only in accuracy but also in providing real-world investment value.
Figure 6. Prediction and actual stock price example.
6. Conclusions
This methodology presents a novel approach that combines LLM-based stock forecasting with risk-aware reinforcement learning. By integrating PPO, the proposed framework ensures that stock price predictions are not only accurate but also aligned with financial risk constraints. This hybrid approach has the potential to improve decision making in financial markets by providing more stable and reliable predictions, which can be beneficial for investors and financial analysts navigating market uncertainties.
However, there are several limitations to this approach that warrant further research. For example, the computational cost of training LLMs and PPO agents is high, which may restrict scalability in real-world trading applications. Future studies could explore more efficient architectures or alternative reinforcement learning methods to reduce training complexity. In addition, although the framework improves stock price prediction and risk management, its effectiveness in different market conditions, such as low-liquidity stocks or extreme volatility periods, remains an open question. Expanding the analysis to a broader set of assets and conducting real-world trading simulations would help validate its generalizability and practical applicability.
NOTES
1https://eodhd.com/financial-apis/stock-market-financial-news-api.
2https://groq.com/.