MarketSenseAI: A Multi-Agent LLM Framework for Stock Selection
Laying the groundwork for an n8n + EODHD implementation
Introduction
Single-model “all-knowing” bots still break in the wild: they hallucinate numbers, struggle with long SEC filings, and can fail outright when a single data feed times out. The MarketSenseAI papers (2024, 2025) demonstrated a better path: splitting the workload across specialized LLM agents improved reliability and delivered 10–30% excess returns while keeping risk in line. J.P. Morgan’s 2024 note Agents Are All You Need reached the same conclusion—specialisation, fault isolation, and structured agent-level debate consistently outperform monolithic architectures.
This research convinced me to rebuild my own toolchain around a five-agent design—orchestrated in n8n and powered by the EODHD API—so the system remains self-hosted, reproducible, and extensible.
At this stage, the project is still in exploration and design. I have several existing n8n workflows that can be adapted, but nothing is fully specified or implemented yet. The purpose of this article is therefore to map the architecture, agent design, and data flows, providing a clear blueprint that can evolve into a working system.
Conceptually, MarketSenseAI is a large language model–driven stock selection framework that replicates the reasoning of a professional investment team. It leverages GPT-4 to integrate four distinct streams of financial intelligence:
Progressive news summaries that track evolving market narratives
Quarterly fundamentals reflecting company performance
Comparative price-action metrics for technical context
A macroeconomic digest capturing the broader environment
These heterogeneous inputs are synthesized into transparent buy, hold, or sell recommendations for each stock in the S&P 100.
Back-tests in the original papers, covering a 15-month out-of-sample period, showed the framework delivering excess returns of 10–30% and cumulative gains up to 72%, with Sharpe ratios that outperform both equal-weighted and cap-weighted S&P 100 benchmarks.
In short, MarketSenseAI demonstrates how multi-agent LLM workflows can transform diverse financial data into scalable, explainable, and actionable investment insights—a design I now aim to replicate and adapt in n8n with the EODHD API, starting from a specification and working toward automation.
Note: all EODHD API links in this article are affiliate links. I am not affiliated with MarketSenseAI or its parent company, Alpha Tensor.
1. System Architecture
The platform orchestrates five specialized GPT-4 agents, each delivering a structured JSON payload to a central decision layer at every rebalancing date:
Progressive News Summarizer
Fundamentals Summarizer
Stock-Price Dynamics Summarizer
Macroeconomic Environment Summarizer (MarketDigest)
Signal-Generation Agent (decision layer)
2. Agentic Framework
2.1 Progressive News Summarizer
The Progressive News Summarizer maintains a rolling narrative of company-specific developments rather than static snapshots.
Process
Daily ingestion – A news-feed EODHD News API collects all articles mentioning the target stock; click-bait and irrelevant items are filtered out.
Daily summarization (NSᵢ) – GPT-4 condenses the filtered set into an abstract labeled NSᵢ, distinguishing factual disclosures from analyst opinions. All NSᵢ are stored.
Periodic synthesis – At review end, the batch of NSᵢ is concatenated with the previous roll-up (PNSₜ₋₁). GPT-4 produces an updated progressive summary (PNSₜ), retaining material developments (e.g., litigation, mergers) and discarding obsolete or contradicted items.
Output – The PNSₜ normally spans ~60 days of news flow. A 7-day rolling buffer can be run for short-term horizons (e.g., day or swing trading).
2.2 Fundamentals Summarizer
The Fundamentals Summarizer converts raw quarterly statements into analyst-ready briefs.
Process
Data retrieval – Balance sheet, income statement, and cash flow tables are fetched from the EODHD Fundamentals API, covering the most recent four quarters.
Standardization – Values are numerically abbreviated (e.g.,
28 947 000 000 USD
→USD 28.95 bn
) and aligned side-by-side to highlight trends.Analyst-style summarization (Fₜ) – GPT-4, prompted as a sell-side accountant, identifies shifts in profitability, revenue growth, leverage, and cash generation, flags anomalies, and outputs a terse bullet-point digest.
Output & storage – The summary (Fₜ) is stored in JSON and may be queried independently or forwarded to the Signal-Generation Agent.
2.3 Stock-Price Dynamics Summarizer
The Stock-Price Dynamics Summarizer situates a firm’s market behavior in peer and index context.
Process
Peer selection – Business descriptions of S&P 500 firms are embedded with all-MPNet-base-v2. Cosine similarity determines the five closest thematic peers.
Data retrieval – For the target, peers, and the S&P 500 benchmark, OHLCV data is collected over 3-, 6-, and 12-month windows.
Statistical analysis – Standard time-series metrics are computed: cumulative return, annualized volatility, Sharpe ratio, maximum drawdown, and pairwise correlations.
Analyst-style summarization (PSₜ) – GPT-4 produces a neutral appraisal of relative performance, risk, and co-movement.
Output & storage – The digest (PSₜ) is stored with NS, Fₜ, and Mₜ for integration.
2.4 Macroeconomic Environment Summarizer (MarketDigest)
The Macroeconomic Environment Summarizer (MarketDigest) captures consensus views from global financial institutions through a two-stage pipeline.
Process
First-stage summarization – Twice monthly, full-length strategy notes and outlooks from sell-side banks and multilaterals are scraped, converted to text, and summarized by GPT-4 into short précis covering monetary policy, growth, inflation, geopolitical risks, and asset-class exposures.
Second-stage consensus synthesis – Individual précis are concatenated and summarized again by GPT-4, producing a consensus view that also flags disagreements. Sentiment is tagged by asset class (equities, credit, rates, commodities), with directional confidence added when possible.
Output & storage – The digest (Mₜ) is stored as JSON with timestamps and versioning, enabling integration with firm-level signals.
3. Signal-Generation Agent
The Signal-Generation Agent integrates all four digests at rebalancing points. Inputs include:
Progressive News Summary (PNSₜ)
Fundamentals Summary (Fₜ)
Price-Dynamics Summary (PSₜ)
Macroeconomic Digest (Mₜ)
Process sequence
News analysis – Classify PNSₜ as favorable, neutral, or adverse and flag key catalysts.
Price-dynamics analysis – Benchmark return, volatility, Sharpe ratio, and drawdown against peers and the S&P 500.
Macroeconomic analysis – Assess whether trends in Mₜ create tailwinds or headwinds for the sector.
Fundamentals analysis – Examine four quarters of Fₜ, focusing on profitability, leverage, and free cash flow.
Integration & scoring
Each stream is assigned a sign (supportive/neutral/adverse) and a weight (news and price momentum carry higher priors; fundamentals and macro are down-weighted but still material).
Contradictions must be resolved explicitly, with reasoning on which signal dominates.
A numeric score is assigned using a three-tier rubric:
≥ +1.0 → BUY
–1.0 to +0.99 → HOLD
≤ –1.0 → SELL
The agent outputs the decision label plus:
A numbered rationale citing exactly one decisive insight from each stream.
A confidence tag (high/medium/low), derived from dispersion across sub-scores.
Design choice
All reasoning occurs inside a single GPT-4 call. There is no downstream optimizer—interpretability and alpha both stem directly from the model’s structured reasoning.
Results
In out-of-sample tests on S&P 100 stocks, the agent produced:
10–30% excess returns
Up to 72% cumulative gains
Sharpe ratios exceeding both equal- and cap-weighted benchmarks
This demonstrates that a step-wise, integrated prompt can yield consistent, explainable trading value.
Next steps
This architecture now serves as the blueprint for developing my n8n workflows, which will ultimately include features such as Chat with Fundamentals and likely an integration with QuantCoderFS, with n8n acting as the backend engine. A key technical challenge will be connecting Next.js to n8n in a clean and scalable way—a non-trivial point that I plan to address in the next phase of development.
Once the workflows are stable, I will make them available behind my paywall, while selected outputs will be published to a Telegram channel for broader access. A first version of the Telegram bot is already active for private use and will gradually evolve as the system matures.
As usual, I am open to collaboration or tailor-made design for readers who want to adapt this approach to their own use cases.
Conclusion
This article has outlined a blueprint for agentic workflows that can transform heterogeneous financial data into explainable trading signals. While the system is not yet implemented—day- and swing-trading in particular will require shorter horizons, more frequent updates, and additional fault-tolerance—the design provides a solid foundation for full automation.
By combining n8n for orchestration with the EODHD API for data retrieval, developers gain a reproducible framework for scaling stock analysis and signal generation into an end-to-end pipeline. Future work will involve adapting existing n8n workflows into the five-agent specification presented here and testing the architecture under live conditions.
References
https://www.marketsense-ai.com/
https://www.alpha-tensor.ai/
Fatouros, G., Metaxas, K., Soldatos, J., & Kyriazis, D. (2024). Can Large Language Models Beat Wall Street? Unveiling the Potential of AI in Stock Selection (arXiv:2401.03737v2).
Kar, I., Ralte, Z., Shivakumara, M., Roy, R., & Kumari, A. (2024). “Agents Are All You Need: Elevating Trading Dynamics with Advanced Generative AI-Driven Conversational LLM Agents and Tools.” 2024 IEEE 9th International Conference for Convergence in Technology (I2CT), Pune, India, 1-6. https://doi.org/10.1109/I2CT61223.2024.10543356