MCPcopy Index your code
hub / github.com/Agentic-Analyst/stock-analyst

github.com/Agentic-Analyst/stock-analyst @v1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.0 ↗ · + Follow
583 symbols 2,266 edges 62 files 563 documented · 97%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

VYNN AI logo

Agentic Financial Analyst

Give it a ticker and a prompt. Get back a 10-tab DCF model, structured catalyst/risk data, and a full analyst report.

Multi-agent equity research system built on LangGraph. Autonomous pipeline from financial data collection through DCF modeling, news intelligence, and report generation -- end-to-end in ~6 minutes.

The system automates what a human equity analyst does manually: pull financial statements, build a valuation model in Excel, read and synthesize dozens of news articles, identify catalysts and risks, and write an investment recommendation with price targets -- all from a single natural language prompt.

Python 3.11 LangGraph Docker License: MIT

Demo

VYNN AI Agent Demo

▶️ Click to watch -- agentic chatbot and broker-style dashboard


Table of Contents


Sample Output

Running a comprehensive analysis produces three artifacts:

1. 10-tab Excel DCF Model (download AAPL sample · download META sample)

All formulas are live -- not static values. The Assumptions tab pulls from LLM-inferred projections; Projections references Assumptions; Valuation references Projections; Summary cross-references everything with QA flags. Opening the workbook and changing a single assumption (e.g., FY3 revenue growth) cascades through projections, valuation, sensitivity, and summary automatically.

Workbook structure (10 tabs)

Tab Contents
Raw Imported financials -- income statement, balance sheet, cash flow (677-738 rows depending on company)
Keys_Map Cell reference mapping for cross-tab formula wiring
Assumptions FY0 actuals + FY1-FY5 projected assumptions sourced from LLM_Inferred
LLM_Inferred Raw LLM assumptions: WACC, revenue growth rates, gross/EBITDA/operating margins, DSO/DIO/DPO
Historical Derived metrics across 4 fiscal years: revenue, margins, growth rates, working capital ratios
Projections 5-year forward projections -- revenue, COGS, gross profit, EBIT, NOPAT, D&A, CapEx, NWC, FCF, EBITDA
Valuation (DCF) Perpetual growth method: WACC build-up (Rf, ERP, beta, Ke, Kd), FCF discounting, terminal value, equity bridge
Valuation (Exit Multiple) Exit multiple method: terminal EV/EBITDA (default 20x), enterprise value, equity bridge
Sensitivity Two matrices: WACC vs. terminal growth rate + WACC vs. exit multiple
Summary Blended valuation dashboard with 6 QA sanity checks (E/V+D/V=1, WACC>g, DF<=1, shares>0, mid-year toggle)

2. Professional Analyst Report (download NVDA sample · download ORCL sample)

Multi-section PDF (typically 35-40 pages depending on company complexity and article count) covering: Executive Summary, Company Overview, Financial Performance (4-year historicals + YoY growth + profitability metrics), DCF Valuation (dual method with 5-year projections), News & Market Analysis (up to 50 articles screened, structured catalysts/risks/mitigations with confidence scores, quotes, and source URLs), Investment Thesis (bull/bear/balanced), Recommendation with multi-horizon price targets, and Appendix with full evidence references.

NVDA report excerpt -- Recommendation & Price Target

Investment Rating: HOLD
12-Month Price Target: $199.31
Expected Return: +3.8%

Price Targets:
  3-Month:  $194.40 (Range: $176.90 - $211.90)
  6-Month:  $196.89 (Range: $171.83 - $221.95)
  12-Month: $199.31 (Range: $163.44 - $235.19)

Calculation Methodology:
  Raw Valuation Gap: 12.3%
  Sector Premium Adjustment: 50%
  Adjusted Valuation Gap: 6.2%
  Catalyst Score: +25.0%
  Risk Score: -25.0%
  Momentum Score: +6.8%

  Expected Return = 40% x Valuation (6.2%)
                  + 40% x Net Catalysts/Risks (0.0%)
                  + 20% x Momentum (6.8%)
                  = 3.8%

Every number in this output is computed deterministically by RecommendationCalculator. The LLM writes only the surrounding narrative. RecommendationValidator verifies every figure matches.

ORCL report excerpt -- a SELL recommendation (the system issues non-BUY ratings)

Investment Rating: SELL
12-Month Price Target: $187.72
Expected Return: -15.8%

DCF Perpetual Growth: -$19.27/share (negative equity value)
DCF Exit Multiple:    $117.34/share
Average Intrinsic:    $49.04
Current Price:        $222.85
Implied Downside:     -78.0%

Oracle's negative perpetual-growth valuation (driven by negative FCF and $100B+ long-term debt) combined with the exit-multiple method's more favorable $117 figure demonstrates how the dual-DCF approach surfaces valuation disagreement rather than hiding it behind a single number.

3. Structured Screening Data (JSON)

Sample catalyst from NVDA screening

{
  "type": "Financial",
  "description": "Nvidia reported a significant revenue increase of 69% year-over-year",
  "confidence": 0.90,
  "timeline": "Immediate",
  "impact_assessment": "Strong demand for AI products driving investor confidence",
  "evidence": [
    "Revenue increased to $44.1 billion",
    "Year-over-year growth of 69%"
  ],
  "direct_quotes": [
    {
      "text": "NVIDIA reported revenue for the first quarter ended April 27, 2025, of $44.1 billion, up 12% from the previous quarter and up 69% from a year ago.",
      "source": "NVIDIA Announces Financial Results for First Quarter Fiscal 2026",
      "url": "https://..."
    }
  ]
}

Architecture

Supervisor-worker architecture on LangGraph's cyclical state graph. An LLM-powered supervisor classifies user intent, extracts tickers from natural language, and routes to specialized agents with enforced dependency ordering. If LLM routing fails, a deterministic rule-based fallback takes over.

                            User Query (Natural Language)
                "Analyze NVDA comprehensively with focus on AI chips"
                                        |
                                        v
               +------------------------------------------------+
               |              SUPERVISOR AGENT                   |
               |                                                |
               |  - Ticker extraction from NL prompt (LLM)     |
               |  - Intent classification (COMPREHENSIVE /      |
               |    MODEL_ONLY / QUICK_NEWS / CUSTOM)           |
               |  - Dynamic routing with dependency resolution  |
               |  - Deterministic fallback when LLM fails       |
               +-----+------------------------------------------+
                     |
                     v
               +-----------+       +---------------+
               | Financial |------>|    Model      |
               |   Data    |       |  Generation   |
               |   Agent   |       |    Agent      |
               +-----------+       +-------+-------+
                                           |
                                           v
                                   +---------------+
                                   |     News      |
                                   | Intelligence  |
                                   |    Agent      |
                                   +-------+-------+
                                           |
                                           v
                                   +---------------+
                                   |    Report     |
                                   |   Generator   |
                                   |    Agent      |
                                   +-------+-------+
                                           |
                                           v
                                    Output Artifacts
                        Excel DCF  -  Screening Data  -  Analyst Report

Dependency chain: financial_data -> model_generation -> news_analysis -> report_generator

The supervisor enforces this sequential ordering regardless of what the LLM proposes. Agents share state through a FinancialState blackboard dataclass -- a single mutable state object passed through every node in the graph.

Intent-Based Routing

Intent Agents Triggered Use Case
COMPREHENSIVE All 4 (sequential) Full equity research pipeline
MODEL_ONLY Financial Data -> Model -> Summary DCF modeling without news
QUICK_NEWS News -> Summary Recent developments only
CUSTOM Varies Simple questions, single-agent routing

Objective-driven early termination means MODEL_ONLY workflows stop after model + summary and QUICK_NEWS stops after news + summary -- avoiding unnecessary LLM calls.


Core Design Patterns

Pattern Implementation Rationale
Supervisor + Worker LangGraph cyclical graph with conditional edges LLM proposes routing; dependency resolver enforces valid sequencing
Blackboard State Shared FinancialState dataclass across all agents Avoids message-passing overhead; single source of truth
Builder Pattern Each Excel tab has a dedicated builder class (11 modules) Tabs can be tested and modified independently
Deterministic Math + LLM Narrative RecommendationCalculator -> EvidenceExtractor -> LLM -> RecommendationValidator Numbers are computed in code; LLM writes explanations; validator ensures integrity
Prompt Externalization 33 markdown templates in prompts/ Version-controlled, editable without code changes
Strategy Pattern Pluggable DCF strategies (SaaS, REIT, Bank, Utility, Energy) Sector-aware modeling without code changes

System Components

Supervisor Agent

LangGraph orchestrator managing the full workflow lifecycle: session management, ticker extraction, intent classification, and conditional routing with dependency resolution.

Location: src/agents/supervisor/

Module Responsibility
supervisor_agent.py Entry point -- SupervisorWorkflowRunner handles session management, ticker extraction, and workflow execution
supervisor.py Routing logic -- route_workflow_with_llm() with _resolve_dependencies() guardrails
graph.py LangGraph graph construction (4 agent nodes + conditional edges)
state.py FinancialState blackboard, AgentStage / AnalysisObjective enums

Routing flow:

User Prompt -> Ticker Extraction (LLM) -> Intent Classification -> Objective Detection
                                                                        |
                                              +-------------------------+------------------+
                                              v                         v                  v
                                        COMPREHENSIVE            MODEL_ONLY          QUICK_NEWS
                                        (all 4 agents)      (fin data + model     (news + summary)
                                                               + summary)

The supervisor ensures no agent runs before its prerequisites are complete, even if the LLM suggests otherwise.

Financial Data Agent

Collects comprehensive financial data from Yahoo Finance via yfinance.

Location: src/financial_scraper.py

  • Scrapes income statements, balance sheets, and cash flow statements (annual + quarterly)
  • Extracts company metadata (sector, industry, employees, market cap)
  • Handles data normalization -- converts pandas DataFrames to clean JSON with proper type handling (NaN, numpy types, dates)
  • Outputs structured JSON ready for the model generator

Financial Model Agent -- DCF Builder

Generates a 10-tab Excel DCF workbook from scraped financial data with LLM-inferred assumptions.

Location: src/agents/fm/

The workbook is fully formula-driven. Every projected value traces back to an assumption cell, and every assumption traces back to either historical data or the LLM_Inferred tab. The Projections tab computes 20+ line items per year: revenue, COGS, gross profit, R&D, SG&A, EBIT, tax, NOPAT, D&A, CapEx, AR, inventory, AP, NWC, delta-NWC, FCF, and EBITDA with margin diagnostics.

**Formula

Core symbols most depended-on inside this repo

info
called by 374
src/logger.py
_log
called by 80
src/recommendation_engine.py
log_action
called by 59
src/agents/supervisor/state.py
error
called by 57
src/logger.py
_log
called by 56
src/agents/news/daily/sector_daily_report.py
_log
called by 51
src/article_filter.py
_log
called by 50
src/agents/news/daily/company_daily_report.py
_log
called by 45
src/article_scraper.py

Shape

Method 387
Function 133
Class 63

Languages

Python100%

Modules by API surface

src/agents/fm/formula_evaluator.py41 symbols
src/agents/news/daily/company_daily_report.py31 symbols
src/agents/supervisor/state.py28 symbols
src/financial_scraper.py27 symbols
src/article_screener.py27 symbols
src/report_agent.py24 symbols
src/logger.py24 symbols
src/agents/news/daily/sector_daily_report.py24 symbols
src/article_scraper.py21 symbols
src/article_filter.py16 symbols
src/agents/fm/tabs/tab_assumptions.py15 symbols
main.py15 symbols

Datastores touched

(mongodb)Database · 1 repos

For agents

$ claude mcp add stock-analyst \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page