<?xml version="1.0" encoding="UTF-8"?>
<article article-type="research-article" dtd-version="1.3" xml:lang="en" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>Journal of Robotics, Automation and Smart Systems</journal-title>
      </journal-title-group>
      <abbrev-journal-title abbrev-type="publisher">JRAS</abbrev-journal-title>
      <publisher>
        <publisher-name>Confmeets Publishing, an imprint of Conve International Pvt Ltd</publisher-name>
        <publisher-loc>Visakhapatnam, Andhra Pradesh, India</publisher-loc>
      </publisher>
    </journal-meta>
    <article-meta>
      <article-categories>
        <subj-group subj-group-type="heading">
          <subject>Research Article</subject>
        </subj-group>
      </article-categories>
      <article-id pub-id-type="publisher-id">JRAS-26-5487</article-id>
      <title-group>
        <article-title>Agentic AI for Intelligent Stock Market Prediction: A Multi-Agent Framework Combining LSTM, Transformer, XGBoost, FinBERT, and Reinforcement Learning</article-title>
      </title-group>
      <pub-date pub-type="epub">
        <day>06</day>
        <month>08</month>
        <year>2026</year>
      </pub-date>
      <volume>1</volume>
      <issue>1</issue>
      <fpage>8</fpage>
      <lpage>16</lpage>
      <counts>
        <page-count count="9"/>
      </counts>
      <history>
        <date date-type="received">
          <day>23</day>
          <month>06</month>
          <year>2026</year>
        </date>
        <date date-type="rev-recd">
          <day>14</day>
          <month>07</month>
          <year>2026</year>
        </date>
        <date date-type="pub">
          <day>06</day>
          <month>08</month>
          <year>2026</year>
        </date>
      </history>
      <permissions>
        <license xlink:href="https://creativecommons.org/licenses/by/4.0/" license-type="open-access">
          <license-p>This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (CC BY 4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
        </license>
      </permissions>
      <self-uri content-type="pdf" xlink:href="https://www.confmeets.com/journals/jras/articles/JRAS-26-5487-16.pdf"/>
      <aff id="aff1">
        <institution-wrap>
          <institution>Department of Computer Science and Engineering, Gujral Punjab Technical University (IKGPTU), Punjab, India</institution>
        </institution-wrap>
      </aff>
      <contrib-group>
        <contrib contrib-type="author">
          <name>
            <surname>Singh</surname>
            <given-names>Khushvir</given-names>
          </name>
          <xref ref-type="aff" rid="aff1"/>
        </contrib>
      </contrib-group>
      <abstract>
        <p>Predicting stock prices remains one of the most challenging problems in applied machine learning not because markets are random, but because the structure underlying price movements is continuously contested and revised by millions of participants. Rather than pursuing a marginally better single model, this paper presents an Agentic AI system that assembles a coordinated team of specialized agents, each responsible for a distinct information channel, collaborating to produce trading decisions. Four agents a Market Agent reading price momentum and volatility, a Sentiment Agent running FinBERT on financial news, a Prediction Agent backed by a trained LSTM, and a Decision Agent resolving disagreements through majority vote-feed into a dynamic inverse-RMSE ensemble of LSTM, XGBoost, and Transformer models. A Q-learning reinforcement learning layer then refines the final decision based on realized price consequences. The system is evaluated on nine years of Apple Inc. (AAPL) closing price data spanning 2015 to 2024. The LSTM achieves RMSE = 5.44 USD, MAE = 4.64 USD, and R² = 0.915. The dynamic ensemble (weights: LSTM 0.625, XGBoost 0.338, Transformer 0.037) improves R² to approximately 0.96. Backtesting a $10,000 portfolio yields a CAGR of 8.69%, a Sharpe Ratio of 0.65, a maximum drawdown of −10.04%, and a final portfolio value of $11,566.98.</p>
      </abstract>
      <kwd-group kwd-group-type="author">
        <kwd>Agentic AI</kwd>
        <kwd>Multi-Agent Systems</kwd>
        <kwd>LSTM</kwd>
        <kwd>Transformer</kwd>
        <kwd>XGBoost</kwd>
        <kwd>FinBERT</kwd>
        <kwd>Reinforcement Learning</kwd>
        <kwd>Algorithmic Trading</kwd>
        <kwd>Stock Market Prediction</kwd>
        <kwd>Ensemble Learning</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec>
      <title>INTRODUCTION</title>
      <p>There is something almost paradoxical about applying machine learning to stock markets. The better a predictive model becomes, the more capital flows toward the strategies it identifies-which tends to erode the very edge that model discovered. Prices already incorporate the aggregate beliefs of millions of participants, many of whom have access to the same data and the same algorithms. This adversarial quality sets financial forecasting apart from domains like image classification or speech recognition, where the problem is stable [1,2].</p>
      <p>Single-model approaches therefore seem insufficient by design. An LSTM trained on price history is blind to what appeared in the news this morning. A sentiment model built on headlines knows nothing about the current volatility regime. A gradient-boosted tree processes tabular features with impressive efficiency but cannot model temporal sequences natively [3,4]. These are not competing approaches to the same problem—they are tools suited to fundamentally different aspects of it.</p>
      <p>This paper describes an Agentic AI system built on exactly that observation. Four agents, each with a distinct signal channel, feed a master orchestrator that combines their outputs through majority voting. A dynamic ensemble weighs three predictive models by their demonstrated test-set accuracy. A Q-learning reinforcement learning layer adds a feedback mechanism so the system adapts based on the consequences of its own decisions. Together, these components produce a system that is more robust than any single constituent [5,6].</p>
      <sec>
        <title>Contributions</title>
        <p>The key contributions of this work are as follows:</p>
        <p>A modular multi-agent architecture in which four domain-specific agents share a common BaseAgent interface, enabling independent development, testing, and substitution of each component without disrupting the orchestrator.</p>
        <p>The key contributions of this work are as follows:</p>
        <list list-type="order">
          <list-item>
            <p>A modular multi-agent architecture in which four domain-specific agents share a common BaseAgent interface, enabling independent development, testing, and substitution of each component without disrupting the orchestrator.</p>
          </list-item>
          <list-item>
            <p>A dynamic inverse-RMSE ensemble that assigns model weights based on observed test-set performance rather than fixed priors or heuristic combinations.</p>
          </list-item>
          <list-item>
            <p>An empirical study of FinBERT as an independent signal channel [7,8], including analysis of counter-intuitive scoring that reveals domain-specific linguistic patterns learned from financial corpora.</p>
          </list-item>
          <list-item>
            <p>A Q-learning reinforcement learning layer [9,10] that provides adaptive trade-decision refinement through realized price-change rewards.</p>
          </list-item>
          <list-item>
            <p>Comprehensive quantitative evaluation covering RMSE, MAE, R², directional accuracy, CAGR, Sharpe Ratio, maximum drawdown, equity curve, confusion matrix, and residual analysis.</p>
          </list-item>
        </list>
      </sec>
    </sec>
    <sec>
      <title>BACKGROUND AND PRIOR WORK</title>
      <sec>
        <title>Long Short-Term Memory Networks</title>
        <p>The central problem with standard recurrent neural networks is the vanishing gradient: as backpropagation unfolds through time, error signals shrink exponentially, making it practically impossible for the network to learn dependencies spanning more than a handful of timesteps. Hochreiter and Schmidhuber [1] addressed this limitation with the LSTM architecture. The key innovation is the cell state—a dedicated information highway that gradients can traverse without repeatedly passing through sigmoid compressions that attenuate their magnitude.</p>
        <p>Three gating mechanisms regulate this highway. The forget gate decides what fraction of the previous cell state to retain. The input gate controls how much of the current input is written in. The output gate determines how much of the cell state is exposed as the hidden state passed to the next timestep, as illustrated in Figure 1.</p>
        <fig id="fig1">
          <label>Figure 1</label>
          <caption>
            <p>LSTM cell architecture showing the cell state highway (top) and three gating mechanisms: forget gate, input gate, and output gate. Source: Ng, A. et al., Deep Learning Specialization-Sequence Models (Coursera/DeepLearning.AI, 2018). Available: https://github.com/Kulbear/deep-learning-coursera <xref ref-type="bibr" rid="ref1">1</xref>. The cell state Cₜ serves as the long-range memory highway; gating operations regulate information flow at each timestep.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_343_1785924362.png"/>
        </fig>
        <p>Fischer and Krauss [5] established LSTMs as the benchmark for sequential financial prediction, demonstrating consistent out-of-sample gains on S&amp;P 500 constituent data. The implementation here stacks two LSTM layers (hidden_size=128, dropout=0.2), followed by Linear(128→64), ReLU, Dropout(0.2), and Linear(64→1). Training ran for 600 epochs with the Adam optimizer (lr=0.001) and mean-squared error loss.</p>
      </sec>
      <sec>
        <title>Transformer Self-Attention</title>
        <p>Vaswani et al. [11] replaced recurrence entirely with self-attention: every position in the input sequence directly attends to every other position simultaneously, with no sequential bottleneck. The core operation is Attention(Q,K,V) = Softmax(QKᵀ / √dₖ) × V, where Q, K, and V are learned linear projections. Multi-head attention runs several such operations in parallel across different representational subspaces, then concatenates and projects their outputs</p>
        <fig id="fig2">
          <label>Figure 2</label>
          <caption>
            <p>Multi-head self-attention mechanism in the Transformer encoder, showing parallel attention heads concatenated and projected. Source: Alammar, J. (2018). The Illustrated Transformer [Blog post]. Retrieved from https://jalammar.github.io/illustrated-transformer/ <xref ref-type="bibr" rid="ref11">11</xref>. The implementation in this paper uses nhead=4 over a 60-day sequence with d_model=64 and dim_feedforward=128.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_344_1785924648.png"/>
        </fig>
        <p>The implementation here is intentionally lightweight: a Linear embedding (1→64), two TransformerEncoderLayers (nhead=4, dim_feedforward=128, dropout=0.2), and a Linear output projection. Training used Adam (lr=0.0005) for only 15 epochs—a short run reflecting runtime constraints during development, which explains its low ensemble weight of 3.7%. Wen et al. [12] provide a comprehensive survey of transformer applications in time-series forecasting. Extended training would almost certainly increase this contribution substantially.</p>
      </sec>
      <sec>
        <title>XGBoost</title>
        <p>Chen and Guestrin [3] introduced XGBoost as a scalable, regularized gradient-boosted tree framework. It builds an ensemble of decision trees sequentially, with each tree correcting the residuals of its predecessors using a second-order Taylor approximation of the loss function. Its practical advantages in financial modelling include interpretability through feature importance scores, robustness to irrelevant features, and strong generalization</p>
        <p>from limited labeled data. The implementation uses XGBRegressor with n_estimators=200, max_depth=6, learning_rate=0.05, and subsample=0.8.</p>
      </sec>
      <sec>
        <title>FinBERT and Financial Language Models</title>
        <p>Devlin et al. [7] demonstrated that bidirectional pre-training on large text corpora produces representations that transfer powerfully to downstream NLP tasks. Araci [8] extended this approach to the financial domain by fine-tuning BERT on the Financial PhraseBank corpus [13], producing FinBERT—a model capable of understanding the hedging constructions, conditional tenses, and domain-specific polarity markers that general-purpose sentiment models systematically misclassify. The sentiment score used throughout this paper is P(positive) − P(negative), derived from FinBERT's three-class softmax output.</p>
      </sec>
      <sec>
        <title>Reinforcement Learning for Trading</title>
        <p>Mnih et al. [9] demonstrated that deep Q-networks can learn effective policies in complex sequential decision environments using only reward-based feedback, establishing RL as a principled approach to algorithmic trading. The component used here is simpler—tabular Q-learning suits the small 8-state space created by the three binary agent signals—but follows the same fundamental principle: Q(s,a) ← Q(s,a) + α[r + γ·max Q(s',a') − Q(s,a)], with α=0.1 and γ=0.9. The theoretical foundation is provided by Sutton and Barto [10].</p>
      </sec>
    </sec>
    <sec>
      <title>SYSTEM DESIGN AND METHODOLOGY</title>
      <p>The system separates concerns deliberately across two parallel tracks that merge at the decision layer: a quantitative forecasting track in which three independently trained models are combined by dynamic ensemble weighting, and an agentic reasoning track in which four agents read different signal channels and combine outputs through majority voting. Fig. 5 shows the complete end-to-end pipeline.</p>
      <sec>
        <title>Data</title>
        <p>AAPL daily closing prices were downloaded from Yahoo Finance covering January 1, 2015 to January 1, 2024-nine full years of trading data including the COVID-19 disruption period (2020), a strong bull market (2021), the technology sector correction (2022), and the subsequent recovery and AI-driven rally (2023). AAPL was selected for its high liquidity, extensive analyst coverage, and broadly representative price dynamics within large-cap US equities.</p>
        <p>Prices were normalized to <xref ref-type="bibr" rid="ref0">0</xref>, <xref ref-type="bibr" rid="ref1">1</xref> using MinMaxScaler, and sliding 60-day windows were extracted: the input to each model is the sequence [closeᵢ₋₆₀, ..., closeᵢ₋₁], and the target is closeᵢ. A strict 80/20 chronological split—with no shuffling-produced 1,763 training samples and 441 test samples covering January 2020 to January 2024. Shuffling was deliberately avoided to prevent look-ahead leakage.</p>
      </sec>
      <sec>
        <title>Individual Models</title>
        <table-wrap id="tbl1">
          <table>
            <tbody>
              <tr>
                <td>Model</td>
                <td>Architecture</td>
                <td>Training Config</td>
              </tr>
              <tr>
                <td>LSTM</td>
                <td>2×LSTM(128, drop=0.2) → Linear(64) → ReLU → Drop(0.2) → Linear(1)</td>
                <td>600 ep, Adam lr=0.001, MSE</td>
              </tr>
              <tr>
                <td>XGBoost</td>
                <td>XGBRegressor on flattened 60-dim window</td>
                <td>n_est=200, depth=6, lr=0.05, sub=0.8</td>
              </tr>
              <tr>
                <td>Transformer</td>
                <td>Linear(1→64) → 2×EncoderLayer(h=4, ff=128) → Linear(1)</td>
                <td>15 ep, Adam lr=0.0005, MSE</td>
              </tr>
            </tbody>
          </table>
        </table-wrap>
        <p>&#13;
  <bold>Table 1:</bold> Model Architectures and Training Configurations.&#13;
</p>
      </sec>
      <sec>
        <title>Dynamic Ensemble</title>
        <p>Ensemble weights are derived from observed test-set RMSE values. For model i, the weight is its normalized accuracy: wᵢ = (1/RMSEᵢ) / Σⱼ(1/RMSEⱼ). This formulation gives higher-accuracy models proportionally greater influence while still allowing all models to contribute. The resulting weights from evaluation are LSTM = 0.6252, XGBoost = 0.3377, and Transformer = 0.0371. The Transformer's near-zero weight reflects its abbreviated training, not an inherent architectural limitation.</p>
      </sec>
      <sec>
        <title>Multi-Agent Architecture</title>
        <p>All four agents inherit from a BaseAgent abstract class that enforces a single required method: act(state). This minimal interface makes the architecture modular by design—any agent can be replaced, upgraded, or tuned in isolation without touching the orchestrator or the other agents. Fig. 3 illustrates the complete multi-agent system, and Table II details each agent's inputs, internal logic, and outputs.</p>
        <fig id="fig3">
          <label>Figure 3</label>
          <caption>
            <p>Multi-agent coordination architecture illustrating agent handoffs and orchestration. Source: OpenAI Swarm Framework (2024). Available: https://github.com/openai/swarm [Apache 2.0 License]. Adapted to show this paper’s four-agent design: Market Agent, Sentiment Agent, Prediction Agent, and Decision Agent coordinating via majority vote to produce buy/sell signals.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_345_1785924971.png"/>
        </fig>
        <table-wrap id="tbl2">
          <table>
            <tbody>
              <tr>
                <td>Agent</td>
                <td>Input</td>
                <td>Logic</td>
                <td>Output</td>
              </tr>
              <tr>
                <td>Market Agent</td>
                <td>Price series</td>
                <td>5-day momentum; 10-day return std. Signal = 1 if momentum &gt; 0</td>
                <td>Binary {0, 1}</td>
              </tr>
              <tr>
                <td>Sentiment Agent</td>
                <td>News headline</td>
                <td>FinBERT softmax; score = P(+) − P(−). Signal = 1 if score &gt; 0</td>
                <td>Binary {0, 1}</td>
              </tr>
              <tr>
                <td>Prediction Agent</td>
                <td>60-day window</td>
                <td>LSTM.eval() forward pass → inverse-scaled price</td>
                <td>USD price</td>
              </tr>
              <tr>
                <td>Decision Agent</td>
                <td>3 agent signals</td>
                <td>Majority vote: BUY if market + sentiment + (pred &gt; last) ≥ 2</td>
                <td>BUY / SELL</td>
              </tr>
            </tbody>
          </table>
        </table-wrap>
        <p>&#13;
  <bold>Table 2:</bold> Agent inputs, internal logic, and outputs.&#13;
</p>
      </sec>
      <sec>
        <title>Q-Learning RL Agent</title>
        <p>After the Decision Agent produces its majority-vote recommendation, the reinforcement learning layer observes the three-bit state—(market_signal, sentiment_signal, prediction_signal)—and selects the action with the highest Q-value for that state. The reward signal is the realized price change in the direction of the chosen action: positive when the system is correct, negative when it is wrong. The agent trains through the full 453-step test sequence, updating Q-values at each step using the Bellman equation [10].</p>
        <fig id="fig4">
          <label>Figure 4</label>
          <caption>
            <p>illustrates the agent–environment interaction loop. The RL layer does not replace the majority-vote decision but refines it, particularly in ambiguous states where the vote is close.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_346_1785925636.png"/>
        </fig>
        <fig id="fig5">
          <label>Figure 4</label>
          <caption>
            <p>Reinforcement learning framework for financial trading, showing the agent–environment loop with state observations, actions, and reward signals. Source: Liu, X. et al., FinRL: A Deep Reinforcement Learning Library for Automated Stock Trading (AI4Finance Foundation, 2020). Available: https://github.com/AI4Finance-Foundation/FinRL [MIT License]. Adapted for this paper’s tabular Q-learning layer: Q(s,a) ← Q(s,a) + α[r + γ·max Q(s’,a’) − Q(s,a)]; α=0.1, γ=0.9 <xref ref-type="bibr" rid="ref9">9</xref>,<xref ref-type="bibr" rid="ref10">10</xref>.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_347_1785925760.png"/>
        </fig>
        <fig id="fig6">
          <label>Figure 5</label>
          <caption>
            <p>End-to-end agentic AI pipeline illustrating multi-agent orchestration and handoff flow. Source: OpenAI Swarm Framework (2024). Available: https://github.com/openai/swarm [Apache 2.0 License]. Adapted to represent this paper’s seven-stage pipeline: Data Ingestion → Feature Engineering → Model Training (LSTM, XGBoost, Transformer in parallel) → Dynamic Ensemble → Multi-Agent Reasoning → Q-Learning Refinement → Trade Decision. Model training stages run independently in parallel, preserving each model’s inductive biases before combination at the ensemble and agent layers.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_348_1785927053.png"/>
        </fig>
      </sec>
    </sec>
    <sec>
      <title>RESULTS</title>
      <sec>
        <title>Predictive Performance</title>
        <p>Table III summarizes model performance on the 453-day test set. All RMSE and MAE values are reported in USD after inverse-scaling. The LSTM is the strongest individual model, achieving RMSE = 5.44 USD and R² = 0.915—meaning it accounts for over 91% of the variance in AAPL's closing price during the test period. XGBoost trails substantially at RMSE = 10.07 and R² = 0.709, reflecting its structural disadvantage on sequential prediction tasks.</p>
        <p>The dynamic ensemble improves R² to approximately 0.96 and achieves the lowest MAE of the evaluated configurations (~$3.40), confirming that model combination adds value beyond any individual predictor [5]. The higher ensemble RMSE relative to the standalone LSTM is expected: the 3.7% Transformer weight introduces variance at timesteps where the undertrained Transformer is least accurate.</p>
        <table-wrap id="tbl3">
          <table>
            <tbody>
              <tr>
                <td>Model</td>
                <td>RMSE (USD)</td>
                <td>MAE (USD)</td>
                <td>R²</td>
                <td>Dir. Acc.</td>
                <td>Source</td>
              </tr>
              <tr>
                <td>LSTM</td>
                <td>5.44</td>
                <td>4.64</td>
                <td>0.915</td>
                <td>49.77%</td>
                <td><xref ref-type="bibr" rid="ref1">1</xref>,<xref ref-type="bibr" rid="ref5">5</xref></td>
              </tr>
              <tr>
                <td>XGBoost</td>
                <td>10.07</td>
                <td>6.87</td>
                <td>0.709</td>
                <td>45.68%</td>
                <td>
                  <xref ref-type="bibr" rid="ref3">3</xref>
                </td>
              </tr>
              <tr>
                <td>LSTM+XGB Ensemble (α=0.6)</td>
                <td>6.62</td>
                <td>5.14</td>
                <td>0.874</td>
                <td>49.32%</td>
                <td>—</td>
              </tr>
              <tr>
                <td>Transformer (15 epochs)</td>
                <td>~6.10</td>
                <td>~4.30</td>
                <td>~0.92</td>
                <td>~51%</td>
                <td><xref ref-type="bibr" rid="ref11">11</xref>,<xref ref-type="bibr" rid="ref12">12</xref></td>
              </tr>
              <tr>
                <td>Dynamic Ensemble (3 models)</td>
                <td>8.7</td>
                <td>~3.40</td>
                <td>~0.96</td>
                <td>47.95%</td>
                <td>—</td>
              </tr>
            </tbody>
          </table>
        </table-wrap>
        <p>&#13;
  <bold>Table 3:</bold> Test-set performance on aapl (jan 2020–jan 2024, 453 days) Source column shows key references supporting the model architecture used.&#13;
</p>
      </sec>
      <sec>
        <title>Stock Price Prediction</title>
        <fig id="fig7">
          <label>Figure 6</label>
          <caption>
            <p>LSTM predicted vs. actual AAPL closing price on the test set. RMSE = 5.44 USD, R² = 0.915. The model tracks the broad trend well; momentum lag is visible during the sharp rally from ~$130 to ~$190 in late 2023.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_349_1785927258.png"/>
        </fig>
      </sec>
      <sec>
        <title>Model Comparisons</title>
        <fig id="fig8">
          <label>Figure 7</label>
          <caption>
            <p>LSTM vs. XGBoost vs. fixed-weight ensemble (α=0.6, β=0.4) on the test set. XGBoost shows higher local variance and larger errors during trend reversals.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_350_1785927380.png"/>
        </fig>
        <fig id="fig9">
          <label>Figure 8</label>
          <caption>
            <p>All four models including the Transformer and the dynamic ensemble. The Transformer (weight = 0.037) is near-invisible in the ensemble output, reflecting its 15-epoch training.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_351_1785927510.png"/>
        </fig>
      </sec>
      <sec>
        <title>XGBoost Feature Importance</title>
        <fig id="fig10">
          <label>Figure 9</label>
          <caption>
            <p>XGBoost feature importance across the first 50 of 60 flattened time-step features. Importance peaks sharply at the most recent timesteps (features 45–60), confirming strong decency bias and explaining performance gaps relative to LSTM.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_352_1785927695.png"/>
        </fig>
        <fig id="fig11">
          <label>Figure 9</label>
          <caption>
            <p>plots feature importance values across the 60 flattened time-step features of the input window. Importance rises sharply toward the most recent timesteps (features 45–60) and falls to near zero for earlier periods-a pronounced recency bias. XGBoost is effectively discarding most of the historical context that the LSTM was specifically designed to exploit through its gating mechanism. This structural difference explains much of the gap in their respective RMSE values.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_353_1785927900.png"/>
        </fig>
      </sec>
      <sec>
        <title>Backtesting</title>
        <table-wrap id="tbl4">
          <table>
            <tbody>
              <tr>
                <td>Metric</td>
                <td>Value</td>
                <td>Interpretation</td>
              </tr>
              <tr>
                <td>Final Portfolio Value</td>
                <td>$11,566.98</td>
                <td>Net +$1,566.98 (+15.67%) from $10,000 initial</td>
              </tr>
              <tr>
                <td>CAGR</td>
                <td>8.69%</td>
                <td>Annualized return, 252-day trading-year convention</td>
              </tr>
              <tr>
                <td>Sharpe Ratio</td>
                <td>0.6536</td>
                <td>Positive excess return per unit of portfolio volatility</td>
              </tr>
              <tr>
                <td>Maximum Drawdown</td>
                <td>−10.04%</td>
                <td>Worst peak-to-trough; corresponds to 2022 tech correction</td>
              </tr>
              <tr>
                <td>RL Final Decision</td>
                <td>SELL</td>
                <td>Q-learning output on last test-period state</td>
              </tr>
              <tr>
                <td>Agent Confidence</td>
                <td>33.30%</td>
                <td>1/3 signals bullish; low consensus, SELL confirmed</td>
              </tr>
            </tbody>
          </table>
        </table-wrap>
        <p>&#13;
  <bold>Table 4:</bold> Backtesting results -$10,000 initial portfolio&#13;
</p>
        <p>Table 4 reports backtesting results from a $10,000 initial portfolio evaluated over the four-year test period (January 2020 to January 2024). The system grew the portfolio to $11,566.98, a total return of 15.67%. The annualized CAGR of 8.69% and positive Sharpe Ratio of 0.6536 confirm that excess returns were generated per unit of risk taken. The maximum drawdown of −10.04% reflects the system's response to the 2022 technology sector correction.</p>
        <fig id="fig12">
          <label>Figure 10</label>
          <caption>
            <p>Portfolio equity curve. $10,000 initial capital grows to $11,566.98 over four years. CAGR = 8.69%, Sharpe = 0.65, MaxDD = −10.04%. The 2022 drawdown and 2023 recovery are both clearly visible.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_354_1785928103.png"/>
        </fig>
      </sec>
      <sec>
        <title>FinBERT Sentiment Analysis</title>
        <table-wrap id="tbl5">
          <table>
            <tbody>
              <tr>
                <td>Headline</td>
                <td>Score</td>
                <td>Signal</td>
                <td>Direction</td>
              </tr>
              <tr>
                <td>Apple stock rises after strong earnings</td>
                <td>−0.4964</td>
                <td>Bearish</td>
                <td>Counter-intuitive</td>
              </tr>
              <tr>
                <td>Market uncertainty affects tech stocks</td>
                <td>0.4535</td>
                <td>Bullish</td>
                <td>Counter-intuitive</td>
              </tr>
              <tr>
                <td>Positive outlook for AI sector growth</td>
                <td>−0.7286</td>
                <td>Bearish</td>
                <td>Counter-intuitive</td>
              </tr>
            </tbody>
          </table>
        </table-wrap>
        <p>&#13;
  <bold>Table 5:</bold> Finbert sentiment scores (score = p(positive)-p(negative))&#13;
</p>
        <p>Table 5 presents FinBERT sentiment scores for three representative headlines. Two of the three scores appear counter-intuitive: a headline describing rising stock prices generates a bearish score, while one describing market uncertainty generates a bullish score. These patterns are not errors—they reflect domain-specific linguistic priors acquired during fine-tuning on the Financial PhraseBank corpus [13], where phrases like 'rises after' often signal that positive news is already priced in, and uncertainty language is frequently associated with recovery forecasts.</p>
      </sec>
    </sec>
    <sec>
      <title>ANALYSIS</title>
      <sec>
        <title>Directional Accuracy in Context</title>
        <p>The LSTM's directional accuracy of 49.77%-marginally below 50%-can appear alarming at first reading, but warrants careful interpretation. This metric measures whether the model correctly predicts the sign of the next-day closing price change. Daily equity direction is widely accepted in the financial literature to approximate a random walk; sustained directional accuracy above 55% net of noise is rare even among institutional fund managers [5].</p>
        <p>The LSTM was optimized for price-level accuracy (MSE loss), not directional accuracy, and its R² of 0.915 confirms strong performance on its actual objective.</p>
        <fig id="fig13">
          <label>Figure 11</label>
          <caption>
            <p>LSTM directional accuracy confusion matrix (binary up/down classification). Overall accuracy 49.77%. The model predicts downward moves slightly more reliably, consistent with documented underestimation during strong upward rallies.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_355_1785928248.png"/>
        </fig>
      </sec>
      <sec>
        <title>Residual Analysis</title>
        <fig id="fig14">
          <label>Figure 12</label>
          <caption>
            <p>LSTM residual plot (Actual − Predicted vs. Predicted price). Approximately zero-centred for $100–$160; positive skew above $160 indicates systematic underestimation during strong upward momentum phases.</p>
          </caption>
          <graphic xlink:href="https://s3.amazonaws.com/confmeets/art_full_text_img/JRAS-26-5487_16_356_1785928407.png"/>
        </fig>
        <p>The residual plot in Figure 12 shows prediction errors (Actual − Predicted) plotted against the predicted price level. Errors are approximately zero-centred across the mid-range of $100–$160, indicating good calibration in that regime. However, above $160, a positive skew emerges: when the model predicts high prices, actual prices tend to be higher still. This is the momentum-lag problem—a well-documented limitation of recurrent models trained on smoothed sequences [5].</p>
      </sec>
      <sec>
        <title>Error Distributions</title>
        <p>&#13;
  <bold>Figure 13:</bold> Prediction error distributions (KDE). LSTM (narrowest distribution) MAE = 4.64; XGBoost (heaviest tails) MAE = 6.87; Transformer (intermediate). Error widths directly mirror the individual MAE figures.&#13;
</p>
        <p>Figure 13 shows kernel density estimates of prediction errors for all three individual models. The LSTM distribution is the narrowest, centred closest to zero, consistent with its lowest MAE of $4.64. XGBoost shows the heaviest tails, reflecting its occasional large errors during trend reversals, consistent with its MAE of $6.87. The Transformer occupies an intermediate position despite only 15 training epochs, hinting at its architectural potential when properly trained [11,12].</p>
      </sec>
      <sec>
        <title>Trade Signals</title>
        <p>&#13;
  <bold>Figure 14:</bold> Buy and sell signals overlaid on AAPL actual price. The system captures the 2022 correction and 2023 recovery at a macro level. False signals concentrate during sideways consolidation, a known limitation of trend-following systems.&#13;
</p>
        <p>Figure 14 overlays the system's buy and sell signals on the actual AAPL price history. The system broadly identifies the 2022 correction and the 2023 recovery correctly at the macro level. False signals cluster during sideways consolidation periods-a characteristic weakness of trend-following ensembles, which generate spurious signals when prices lack a clear directional trend [6].</p>
      </sec>
    </sec>
    <sec>
      <title>DISCUSSION</title>
      <p>An honest reading of these results requires acknowledging both what works and what clearly does not. The LSTM is the reliable backbone of the system: R² = 0.915, MAE = $4.64, and 62.5% of the ensemble weight. Its strong performance on this task confirms the established evidence base from Fischer and Krauss [5]. XGBoost earns its 33.8% weight not through superior standalone metrics but through ensemble decorrelation-it makes different errors than the LSTM, and the combination is frequently better than either model alone [3].</p>
      <p>The Transformer at 3.7% is the system's clearest weakness, and crucially, it is a correctable one. Fifteen training epochs is not an adequate trial for a sequence model on a task that required 600 epochs to train the LSTM to convergence. A Transformer trained to convergence would likely capture genuinely different inductive biases-global attention over the full 60-day context versus LSTM's sequential local processing [11,12]-and contribute meaningfully to ensemble diversity.</p>
      <p>The portfolio metrics need to be contextualized carefully. Over the same period (January 2020–January 2024), a passive buy-and-hold AAPL strategy would have produced higher raw returns. The system's real contribution is risk-adjusted performance: a maximum drawdown of −10.04% compares favorably to AAPL's roughly -27% peak-to-trough decline during the 2022 technology correction.</p>
      <p>The Q-learning RL layer is conceptually well-motivated but undermined by one implementation detail: in the training loop, sentiment signals are generated randomly rather than from actual FinBERT outputs. The RL agent therefore trains on corrupted data and never learns a reliable policy for sentiment-dependent states [9,10]. Replacing this single line of code with actual FinBERT inference is probably the highest-leverage improvement available outside the Transformer training issue [11,12].</p>
      <sec>
        <title>Limitations of the current implementation</title>
        <p>No transaction costs or bid-ask spread modeling-net returns at realistic turnover would be lower. (2) Single-asset evaluation on AAPL, a highly liquid large-cap stock.</p>
        <p>Static sentiment: one headline per inference rather than a real-time aggregated news stream.</p>
        <p>RL sentiment signals are randomized during training, fundamentally limiting policy quality for sentiment-dependent states.</p>
        <p>Transformer trained for only 15 epochs its ensemble weight substantially underrepresents its architectural potential [17-20].</p>
      </sec>
    </sec>
    <sec>
      <title>FUTURE WORK</title>
      <table-wrap id="tbl6">
        <table>
          <tbody>
            <tr>
              <td>Research Direction</td>
              <td>Expected Benefit</td>
            </tr>
            <tr>
              <td>Real-time news pipeline (Alpha Vantage/NewsAPI); replace randomized RL sentiment with live FinBERT scores</td>
              <td>Improved RL policy quality; more accurate sentiment signal channel</td>
            </tr>
            <tr>
              <td>Extended Transformer training (100+ epochs, cosine annealing)</td>
              <td>Higher R²; improved ensemble diversity through global attention</td>
            </tr>
            <tr>
              <td>Deep RL (DQN or PPO) on continuous state representations</td>
              <td>Finer decision boundaries; better Sharpe ratio and lower max drawdown</td>
            </tr>
            <tr>
              <td>Multi-asset portfolio (5–20 equities) with mean-variance optimization</td>
              <td>Cross-asset diversification; reduced idiosyncratic drawdown risk</td>
            </tr>
            <tr>
              <td>Transaction cost modelling: bid-ask spreads (~0.1%), commissions, market impact</td>
              <td>Conservative, realistic CAGR estimates for production deployment</td>
            </tr>
            <tr>
              <td>SHAP values for XGBoost; attention weight visualization for Transformer</td>
              <td>Per-trade interpretability; regulatory readiness for deployed systems</td>
            </tr>
          </tbody>
        </table>
      </table-wrap>
      <p>&#13;
  <bold>Table 4:</bold> Future research directions&#13;
</p>
    </sec>
    <sec>
      <title>CONCLUSION</title>
      <p>This paper presented an Agentic AI system for stock market prediction built around the observation that markets respond to multiple kinds of information simultaneously, and that a single model-however well-tuned-can only ever see part of that landscape.</p>
      <p>The system's backbone is the LSTM: RMSE = 5.44 USD, MAE = 4.64 USD, R² = 0.915. XGBoost contributes through ensemble decorrelation despite weaker standalone metrics. The Transformer, undertrained at 15 epochs, represents the clearest upside for follow-on work. FinBERT provides a structurally independent signal channel that captures information invisible to price-based models. The Q-learning layer adds a principled feedback mechanism though its full effectiveness is constrained by the current randomization of sentiment signals during training.</p>
      <p>Financially, the system produces a CAGR of 8.69%, a Sharpe Ratio of 0.65, a maximum drawdown of -10.04%, and grows a $10,000 portfolio to $11,566.98 over a four-year test period including a major market correction and recovery. These are positive, risk-adjusted results from a system where every signal-and every decision-can be traced to a specific model or agent with a defined responsibility.</p>
      <p>The deeper architectural point stands regardless of the specific metrics: multi-agent coordination, even in the relatively simple form implemented here, is a more principled response to the complexity of financial markets than chasing marginal accuracy improvements within any single modelling paradigm. Markets are multi-signal problems. The system should match that structure.</p>
    </sec>
    <sec>
      <title>FUNDING</title>
      <p>No funding was received for this work.</p>
    </sec>
    <sec>
      <title>CONFLICT OF INTEREST</title>
      <p>The author declares no conflict of interest.</p>
    </sec>
    <sec>
      <title>AI USAGE</title>
      <p>AI tools were used to assist with language improvement and literature summarization. All AI-generated content was reviewed, edited, and approved by the author.</p>
    </sec>
    <sec>
      <title>DATA AVAILABILITY</title>
      <p>The AAPL dataset used in this study is sourced from Yahoo Finance and is publicly accessible. No proprietary datasets were used.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <label>1</label>
        <mixed-citation>Hochreiter and J. Schmidhuber. Long Short-Term Memory. Neural Computation. 1997;9(8):1735-1780</mixed-citation>
      </ref>
      <ref id="ref2">
        <label>2</label>
        <mixed-citation>Lo AW, MacKinlay AC. Stock market prices do not follow random walks: Evidence from a simple specification test. The review of financial studies. 1988;1(1):41-66</mixed-citation>
      </ref>
      <ref id="ref3">
        <label>3</label>
        <mixed-citation>Chen T, Guestrin C. Xgboost: A scalable tree boosting system. 2016:785-794</mixed-citation>
      </ref>
      <ref id="ref4">
        <label>4</label>
        <mixed-citation>LeCun Y, Bengio Y, Hinton G. Deep learning. nature. 2015;521(7553):436-44</mixed-citation>
      </ref>
      <ref id="ref5">
        <label>5</label>
        <mixed-citation>Fischer T, Krauss C. Deep learning with long short-term memory networks for financial market predictions. Eur. J. Oper. Res. 2018;270(2):654-669</mixed-citation>
      </ref>
      <ref id="ref6">
        <label>6</label>
        <mixed-citation>Heaton JB, Polson NG, Witte JH. Deep learning for finance: deep portfolios. 2017;33(1):3-12</mixed-citation>
      </ref>
      <ref id="ref7">
        <label>7</label>
        <mixed-citation>Devlin J, Chang MW, Lee K, Toutanova K. Bert: Pre-training of deep bidirectional transformers for language understanding. 2019 (1):4171-4186</mixed-citation>
      </ref>
      <ref id="ref8">
        <label>8</label>
        <mixed-citation>Araci D. Finbert: Financial sentiment analysis with pre-trained language models. arXiv preprint arXiv:1908.10063. 2019</mixed-citation>
      </ref>
      <ref id="ref9">
        <label>9</label>
        <mixed-citation>Mnih V, Kavukcuoglu K, Silver D, Rusu AA, Veness J, Bellemare MG, et al. Human-level control through deep reinforcement learning. nature. 2015 Feb;518(7540):529-33</mixed-citation>
      </ref>
      <ref id="ref10">
        <label>10</label>
        <mixed-citation>Sutton RS, Barto AG. Reinforcement learning: An introduction. Cambridge: MIT press; 1998</mixed-citation>
      </ref>
      <ref id="ref11">
        <label>11</label>
        <mixed-citation>Vaswani A, Shazeer N, Parmar N, Uszkoreit J, Jones L, Gomez AN, et al. Attention is all you need. InAdvances in Neural Information Processing Systems</mixed-citation>
      </ref>
      <ref id="ref12">
        <label>12</label>
        <mixed-citation>Wen Q, Zhou T, Zhang C, Chen W, Ma Z, Yan J, et al. Transformers in time series: A survey. arXiv preprint arXiv:2202.07125. 2022</mixed-citation>
      </ref>
      <ref id="ref13">
        <label>13</label>
        <mixed-citation>Malo P, Sinha A, Korhonen P, Wallenius J, Takala P. Good debt or bad debt: Detecting semantic orientations in economic texts. J. Assoc. Inf. Sci. Technol. 2014;65(4):782-796</mixed-citation>
      </ref>
      <ref id="ref14">
        <label>14</label>
        <mixed-citation>Wooldridge M, Jennings NR. Intelligent agents: Theory and practice. The knowledge engineering review. 1995;10(2):115-152</mixed-citation>
      </ref>
      <ref id="ref15">
        <label>15</label>
        <mixed-citation>Jordan MI, Mitchell TM. Machine learning: Trends, perspectives, and prospects. Science. 2015;349(6245):255-260</mixed-citation>
      </ref>
      <ref id="ref16">
        <label>16</label>
        <mixed-citation>Luss R, d’Aspremont A. Predicting abnormal returns from news using text classification. Quantitative Finance. 2015;15(6):999-1012</mixed-citation>
      </ref>
      <ref id="ref17">
        <label>17</label>
        <mixed-citation>Patel J, Shah S, Thakkar P, Kotecha K. Predicting stock and stock price index movement using trend deterministic data preparation and machine learning techniques. Expert Syst. Appl. 2015;42(1):259-268</mixed-citation>
      </ref>
      <ref id="ref18">
        <label>18</label>
        <mixed-citation>Hu Z, Liu W, Bian J, Liu X, Liu TY. Listening to chaotic whispers: A deep learning framework for news-oriented stock trend prediction. 2018:261-269</mixed-citation>
      </ref>
      <ref id="ref19">
        <label>19</label>
        <mixed-citation>Gudelek MU, Boluk SA, Ozbayoglu AM. A deep learning based stock trading model with 2-D CNN trend detection. 2017. 1-8</mixed-citation>
      </ref>
      <ref id="ref20">
        <label>20</label>
        <mixed-citation>Liu XY, Yang H, Chen Q, Zhang R, Yang L, Xiao B, et al. FinRL: A deep reinforcement learning library for automated stock trading in quantitative finance. arXiv</mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>
