CoolFace
Apppublic

ReidLCaulder/agentic-equity-researcher

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
App README

Equity Research Multi-Agent System

A LangGraph-based multi-agent system for comprehensive equity research, powered by Gemini 2.5 Pro. Features an adversarial research architecture with Bull and Bear teams, a Gradio web interface, and CLI.

Quick Start

Web Interface (Gradio)

bash
uv run python -m equity_researcher.app

Opens at http://127.0.0.1:7862 with a chat interface for research queries.

Command Line Interface

bash
uv run python -m equity_researcher.main

Interactive CLI with conversation memory.


Architecture

mermaid
graph TD
    User[๐Ÿ‘ค User] --> DH[๐ŸŽฉ Desk Head]
    DH -->|"Send API โšก"| BullTeam
    DH -->|"Send API โšก"| BearTeam
    
    subgraph BullTeam["๐Ÿ‚ Bull Team (Subgraph)"]
        BullLead[๐Ÿ“ˆ Lead Analyst] -->|"Delegates"| BullRes[๐Ÿ“ฐ Research Agent]
        BullRes --> BullSEC[๐Ÿ“Š SEC Agent]
        BullSEC -->|"Returns Findings"| BullLead
        BullLead -->|"Satisfied?"| BullDecision{Decision}
        BullDecision -->|"No: More Research"| BullLead
        BullDecision -->|"Yes"| BullThesis[๐Ÿ“„ Bull Thesis]
    end
    
    subgraph BearTeam["๐Ÿป Bear Team (Subgraph)"]
        BearLead[๐Ÿ“‰ Lead Analyst] -->|"Delegates"| BearRes[๐Ÿ“ฐ Research Agent]
        BearRes --> BearSEC[๐Ÿ“Š SEC Agent]
        BearSEC -->|"Returns Findings"| BearLead
        BearLead -->|"Satisfied?"| BearDecision{Decision}
        BearDecision -->|"No: More Research"| BearLead
        BearDecision -->|"Yes"| BearThesis[๐Ÿ“„ Bear Thesis]
    end
    
    BullThesis --> Collect[๐Ÿ“Š Collect Theses]
    BearThesis --> Collect
    Collect --> Judge[๐Ÿ‘จโ€โš–๏ธ Warren Buffett Judge]
    Judge -->|"JudgeVerdict"| Report[๐Ÿ“ Final Report]
    Report --> Memory[(sqlite: History)]

Team Internal Flow

Each team runs as a single-pass subgraph optimized for speed (4-5x faster than iteration):

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     TEAM SUBGRAPH (Single-Pass)                  โ”‚
โ”‚                                                                  โ”‚
โ”‚   START                                                          โ”‚
โ”‚     โ”‚                                                            โ”‚
โ”‚     โ–ผ                                                            โ”‚
โ”‚   Query Generator (Pro) โ”€โ”€โ†’ Generate research & SEC queries     โ”‚
โ”‚     โ”‚                                                            โ”‚
โ”‚     โ–ผ                                                            โ”‚
โ”‚   Research Agent (Flash) โ”€โ”€โ†’ Execute web searches               โ”‚
โ”‚     โ”‚                                                            โ”‚
โ”‚     โ–ผ                                                            โ”‚
โ”‚   SEC Agent (Flash) โ”€โ”€โ†’ Retrieve & analyze filings              โ”‚
โ”‚     โ”‚                                                            โ”‚
โ”‚     โ–ผ                                                            โ”‚
โ”‚   Synthesis Node (Pro) โ”€โ”€โ†’ Full FinCoT reasoning                โ”‚
โ”‚     โ”‚                      โ€ข Uses 14k/12k char analyst prompts   โ”‚
โ”‚     โ”‚                      โ€ข Quality Constitution thresholds     โ”‚
โ”‚     โ”‚                      โ€ข Named interpretation lenses         โ”‚
โ”‚     โ”‚                      โ€ข Moat/Mortality frameworks           โ”‚
โ”‚     โ–ผ                                                            โ”‚
โ”‚   END โ†’ final_thesis                                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Project Structure

equity_researcher/
โ”œโ”€โ”€ app.py              # Gradio web interface
โ”œโ”€โ”€ main.py             # CLI interface
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ agents/
โ”‚   โ”œโ”€โ”€ bull_team/      # ๐Ÿ‚ Bullish research team (placeholder)
โ”‚   โ”œโ”€โ”€ bear_team/      # ๐Ÿป Bearish research team (placeholder)
โ”‚   โ””โ”€โ”€ core/           # Orchestration & evaluation
โ”‚       โ”œโ”€โ”€ judge.py          # Warren Buffett-style arbitrator
โ”‚       โ””โ”€โ”€ desk_head.py      # Initial briefing & context extraction
โ”œโ”€โ”€ tools/
โ”‚   โ”œโ”€โ”€ serper_tools.py # Web search tools (Serper API)
โ”‚   โ”œโ”€โ”€ sec_tools.py    # SEC EDGAR API tools
โ”‚   โ”œโ”€โ”€ e2b_code.py     # E2B sandboxed Python execution
โ”‚   โ”œโ”€โ”€ forensics.py    # (Placeholder for future)
โ”‚   โ””โ”€โ”€ openbb_tools.py # (Placeholder for future)
โ”œโ”€โ”€ graph/
โ”‚   โ”œโ”€โ”€ workflow.py     # Main workflow with parallel Send API dispatch
โ”‚   โ”œโ”€โ”€ team_subgraph.py # Team subgraph factory (Bull/Bear teams)
โ”‚   โ”œโ”€โ”€ state.py        # MainState, TeamState, JudgeVerdict, & models
โ”‚   โ””โ”€โ”€ checkpoint.py   # Memory-based state persistence
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ test_desk_head.py              # Unit tests for Desk Head
โ”‚   โ””โ”€โ”€ test_database_persistence.py   # Database persistence tests
โ””โ”€โ”€ utils/
    โ””โ”€โ”€ database.py     # Supabase long-term memory utilities

Agent Descriptions

๐ŸŽฉ Desk Head

Role: Initial Briefing & Context Extraction

The Desk Head is the first agent in every research workflow. It:

  • โ€”Uses LLM to extract ticker symbols from any company name (works for all public companies)
  • โ€”Identifies focus areas when users specify particular topics
  • โ€”Queries long-term memory to load previous analyses via Supabase
  • โ€”Creates a structured briefing that configures the research teams

๐Ÿ‚ Bull Team

The Bull Team builds the ownership case using Warren Buffett-Philip Fisher methodology.

๐Ÿ“ˆ Bull Synthesis (14k-char Prompt)

Uses the full Buffett-Fisher Ownership Framework:

  • โ€”FinCoT Protocol: Structured Signal โ†’ Moat Interpretation โ†’ Durability โ†’ Integration
  • โ€”Business Quality Constitution: ROIC >15%, FCF/NI >80%, Gross Margin stability
  • โ€”Named Lenses: Owner, Moat, Fisher, Durability, Margin of Safety
  • โ€”Moat Types: Network Effects, Switching Costs, Cost Advantages, Intangibles, Efficient Scale
๐Ÿ“ฐ Bull Research Agent

Searches for quality signals: competitive moats, pricing power, market position, management reputation.

๐Ÿ“Š Bull SEC Agent

Finds financial quality: ROIC trends, margin analysis, FCF conversion, capital allocation track record.


๐Ÿป Bear Team

The Bear Team builds the risk case using Charlie Munger-Seth Klarman methodology.

๐Ÿ“‰ Bear Synthesis (12k-char Prompt)

Uses the full Capital Guardian Framework:

  • โ€”FinCoT Protocol: Signal โ†’ Skeptical Interpretation โ†’ Failure Mapping โ†’ Integration
  • โ€”Forensic Accounting Constitution: CFO/NI ratios, accrual analysis, EBITDA skepticism
  • โ€”Named Lenses: Klarman, Munger, Marks, Forensic, Too Hard
  • โ€”Mortality Mapping: Business failure, moat decay, management failure scenarios
๐Ÿ“ฐ Bear Research Agent

Searches for risk factors: competitive threats, regulatory risks, short seller reports, customer churn.

๐Ÿ“Š Bear SEC Agent

Performs forensic analysis: cash flow quality, accrual trends, related party transactions, SBC burden.


๐Ÿ‘จโ€โš–๏ธ Judge Agent

Role: Warren Buffett-style Arbitrator

After both teams present their theses, the Judge evaluates the arguments and delivers a final verdict on the investment opportunity.


Interfaces

Gradio Web UI (app.py)

A modern chat interface with:

  • โ€”Real-time progress indicators showing which step is executing during analysis
  • โ€”Parallel Bull/Bear team status with completion tracking
  • โ€”Persistent conversation sessions via thread_id
  • โ€”Formatted markdown output with headers and sections
  • โ€”Error handling with user-friendly messages

Progress Display:

## Analyzing AAPL...

**[2/5] Research Teams** (parallel execution)

| Team | Status |
|------|--------|
| Bull | [โœ“] Completed |
| Bear | [...] Running |

Configuration:

  • โ€”Server: 127.0.0.1:7860
  • โ€”Model: Gemini 3.0 Pro (temperature=0)

CLI (main.py)

An interactive terminal interface with:

  • โ€”Conversation memory across queries
  • โ€”Real-time processing status
  • โ€”Type quit, exit, or q to exit

Example Prompts

Research Tesla and give me a comprehensive report including recent news, 
SEC filings, and financial analysis.
What are Apple's latest 10-K and 10-Q filings? Summarize their financial position.
Analyze Palantir and tell me the bull and bear cases.
Analyze NVDA and calculate its current valuation multiples.

Environment Variables

Create a .env file in the project root:

env
# Required
GOOGLE_API_KEY=your-gemini-api-key
SERPER_API_KEY=your-serper-api-key

# Optional
SEC_USER_AGENT=YourAppName your-email@example.com
E2B_API_KEY=your-e2b-api-key  # For code execution (get from https://e2b.dev)

# Long-Term Memory (Supabase)
SUPABASE_URL=your-supabase-project-url
SUPABASE_KEY=your-supabase-anon-key

Dependencies

Core dependencies from pyproject.toml:

PackageVersionPurpose
langgraphโ‰ฅ0.2.0Multi-agent orchestration
langchain-google-genaiโ‰ฅ3.2.0Gemini 2.5 Pro integration
langchain-communityโ‰ฅ0.3.0Serper search integration
gradioโ‰ฅ5.0.0Web interface
e2b-code-interpreterโ‰ฅ2.0.0Secure Python code execution
supabaseโ‰ฅ2.25.0Long-term memory database
python-dotenvโ‰ฅ1.0.0Environment variable loading

External APIs:

  • โ€”SEC EDGAR API (free, no key required)
  • โ€”Serper API (requires key)
  • โ€”E2B API (requires key for code execution)
  • โ€”Supabase (requires URL and key for long-term memory)

Technical Details

State Management

The system uses multiple state types:

AgentState (main graph):

python
class AgentState(TypedDict):
    messages: Annotated[list[BaseMessage], add_messages]
    session_id: str
    briefing: Optional[DeskHeadBriefing]
    bull_thesis: Optional[str]
    bear_thesis: Optional[str]
    verdict: Optional[str]
    next_agent: str

TeamState (team subgraphs):

python
class TeamState(TypedDict):
    briefing: DeskHeadBriefing
    team_bias: Literal["bull", "bear"]
    research_findings: list[str]
    sec_findings: list[str]
    pending_requests: list[dict]
    iteration_count: int
    max_iterations: int
    is_satisfied: bool
    final_thesis: Optional[str]

Memory Architecture

Short-Term Memory:

  • โ€”MemorySaver for in-memory state persistence within a session
  • โ€”Conversations persist via thread_id

Long-Term Memory (Supabase):

  • โ€”Stores completed analyses with key facts, verdicts, and theses
  • โ€”Desk Head retrieves previous analyses for context

Workflow Routing

  1. 1.Desk Head processes user input โ†’ extracts ticker via LLM โ†’ creates briefing
  2. 2.Bull Team subgraph executes (Lead Analyst iterates with Research/SEC agents)
  3. 3.Bear Team subgraph executes (same pattern)
  4. 4.Judge compares theses โ†’ renders verdict
  5. 5.Results saved to long-term memory

Current Status

Completed:

  • โ€”Real-Time Progress Indicator (January 2026) - Streaming progress updates during analysis
  • โ€”Uses graph.stream(stream_mode="updates") with Gradio generator pattern
  • โ€”Shows step-by-step progress (Desk Head โ†’ Research Teams โ†’ Judge โ†’ Report)
  • โ€”Parallel Bull/Bear team status with completion tracking
  • โ€”Analyst Architecture Fixed (January 2026) - Full FinCoT prompts now integrated
  • โ€”Bull Team: 14k-char Buffett-Fisher prompt with moat frameworks, Quality Constitution
  • โ€”Bear Team: 12k-char Munger-Klarman prompt with inversion methodology, Forensic Accounting Constitution
  • โ€”Named interpretation lenses (Owner, Moat, Fisher, Klarman, Marks, etc.)
  • โ€”Quality scorecards and mortality mapping now generated
  • โ€”Database persistence (Supabase) - Analyses now persist to long-term memory
  • โ€”Desk Head briefing extraction with LLM-based ticker identification
  • โ€”Parallel Bull/Bear team execution via LangGraph Send API
  • โ€”Judge verdict with structured output

Future Roadmap

Planned enhancements:

  • โ€”Enhanced Judge Logic: Full debate-style evaluation with rebuttals
  • โ€”Forensics Tool: Deep-dive financial forensics and accounting analysis
  • โ€”OpenBB Tools: Integration with OpenBB terminal for market data
  • โ€”RAG Knowledge Base: ChromaDB with Buffett letters for judge decisions