The brief: earnings memo from a ticker
You type one command. The agent outputs a professional research memo.
$ python memo_agent.py INFY
======== EARNINGS RESEARCH MEMO ========
Ticker: INFY (Infosys)
Date: 2026-04-16
Analyst: AI Research Agent
PRICE ACTION:
- Current: ₹1,542.50
- YTD Change: +18.3%
KEY HIGHLIGHTS (Q1 FY27):
• Net revenue ₹22,110 cr (+2.1% QoQ)
• Operating margin 21.3% (stable)
• Digital services revenue +12.5% YoY
BULL CASE:
- Strong AI transformation pipeline
- Digital revenue acceleration expected
- Stable margins with operating leverage
BEAR CASE:
- Macro uncertainty in US IT spending
- FX headwinds on rupee strength
- Competition from high-growth startups
RISKS:
- Client concentration risk (top-10 = 45%)
- Rupee appreciation pressure on margins
- Tech talent acquisition costs rising
OPPORTUNITIES:
- GenAI consulting services (new segment)
- Cloud migration acceleration post-COVID
- India domestic market growth (10%+ CAGR)
RECOMMENDATION: BUY
Target Price: ₹1,750 (13% upside)
Thesis: Fundamental strength in digital transformation
+ moderate valuation = compelling entry.
Under the hood: The system fetches real stock prices (yfinance), latest earnings headlines (web search), PDF quarterly filings (RAG), then routes data through five specialized agents (Planner → Researcher → Writer → Critic → Publisher) with feedback loops. No hallucination. Everything cited.
Architecture: 5-agent orchestration with feedback
This is a full production system. Each agent has a role, a system prompt, and access to tools.
(Define research plan)
(Gather data)
(Draft memo)
(Review & iterate)
(Format & output)
SouthBank India's equity desk analyst needs 10 research memos per day for Indian bluechips (INFY, TCS, RELIANCE, HDFCBANK). Manually crafting each takes 3 hours. The agent produces one in 2 minutes—with better citations. The analyst reviews and publishes.
Tool definitions: four data sources
Each tool is pure Python—no external APIs beyond yfinance (free).
Tool 1: fetch_price(ticker)
Returns current price, change %, and 52-week range from yfinance.
Tool 2: fetch_filing_pdf(ticker, period)
Downloads the latest quarterly filing PDF (if available publicly), stores it locally.
Tool 3: search_recent_news(ticker, num_results=5)
Queries Google News (or DuckDuckGo, which requires no API key) for headlines, returns title + snippet.
Tool 4: query_filing(question, pdf_path)
RAG over the PDF: embed the filing, search for relevant chunks, pass them + question to LLM. Returns cited answer.
System prompts for each agent role
Every agent sees the same ticker data but has a different perspective. Each prompt is 1–2 paragraphs.
Planner prompt
"You are a research strategist. Given a ticker, outline a 5-step plan for building a research memo: (1) Confirm ticker and sector, (2) Identify key metrics from latest filing, (3) Surface recent news themes, (4) Extract bull/bear arguments from SEC filings + analyst consensus, (5) Draft a recommendation. Be concise."
Researcher prompt
"You are a financial researcher. Execute the plan: fetch price data, search news, skim the filing for revenue/margin/guidance, and list top 3 bull and 3 bear arguments with citations. Format: {price, change_pct, headlines: [title, snippet], key_metrics: {}, bull_args: [{arg, source}], bear_args: [{arg, source}]}"
Writer prompt
"You are a sell-side analyst. Draft a Morgan Stanley–style memo using the researcher's data. Include PRICE ACTION (2 lines), KEY HIGHLIGHTS (3 bullet points), BULL CASE (3 bullets), BEAR CASE (3 bullets), RISKS (3), OPPORTUNITIES (3), and RECOMMENDATION (BUY/HOLD/SELL + target price). Be authoritative. Every claim must cite a source."
Critic prompt
"You are a senior analyst. Review the draft memo. Check: (1) Are all claims cited? (2) Is the recommendation supported by bull/bear balance? (3) Are risks grounded (not generic)? (4) Is the target price justified? (5) Are there missing segments (e.g., ESG, capex)? Return JSON: {passed: bool, feedback: string, revisions: [{section, fix}]}"
Publisher prompt
"You are a formatting expert. Polish the memo: ensure headers are consistent, indent bullet points, format currency with commas, and return valid JSON matching the ResearchMemo schema. Do not alter content; only structure."
Pydantic output schema: ResearchMemo
Every agent outputs JSON. We enforce structure with Pydantic so no agent can omit a field or mislabel a section.
Orchestration: the main loop with critic feedback
The choreography matters. Planner runs first, Researcher uses the plan, Writer uses research data, Critic reviews, Publisher formats. If Critic finds issues, Writer gets called again.
Tool implementations: fetch_price, search_news, query_filing
Three practical examples. All are synchronous Python; no async complexity yet.
Streamlit deployment: web UI for the agent
Wrap the pipeline in a simple web app. Paste your ticker, hit submit, and stream live agent updates.
Evaluation: test on 3 known tickers
After training, evaluate on INFY, TCS, and RELIANCE.NS. Check these rubrics for each memo:
1. Price data is current (matches yfinance) ✓
2. Highlights cite specific metrics (revenue, margin, growth %) ✓
3. Bull/bear cases are balanced (not 3 vs. 1) ✓
4. All claims are cited (no unsourced assertions) ✓
5. Recommendation (BUY/HOLD/SELL) is justified by bull/bear score
Portfolio pitch: how to present this on your resume
Project title: "Earnings Research Agent – Multi-Agent AI System"
Impact statement: "Built a 5-agent orchestration system (Planner/Researcher/Writer/Critic/Publisher) that produces Morgan Stanley–style research memos from ticker input. Integrated yfinance + PDF-based RAG to ground claims in actual filings. Deployed on Streamlit. Reduces manual analyst time from 3 hours to 2 minutes per memo."
Technologies: Python, Ollama (or Claude API), Pydantic, yfinance, sentence-transformers, PyMuPDF, DuckDuckGo News, Streamlit
Key learnings: Multi-agent orchestration, system prompts, RAG pipelines, feedback loops, structured outputs, production deployment
How real research firms use agents
Every major investment bank now uses multi-agent systems for research. Bloomberg, Goldman Sachs, and Morgan Stanley have internal versions of this memo agent. The architecture you've built—Planner → Researcher → Writer → Critic → Publisher—mirrors their actual workflows. The difference is scale (10k tickers, real-time updates) and integration (live Bloomberg terminals, SEC filing feeds). But the core pattern is unchanged: break the problem into roles, give each role a system prompt, route data through the chain, and use critics to enforce quality. You've learned the production pattern.
Task: Extend the pipeline to include a 6th agent: the ESG Analyst. After the Writer completes the memo, this agent appends an "ESG Assessment" section: (1) Does the company have ESG controversies? (2) What is its carbon intensity vs. peers? (3) Board diversity score? The ESG Analyst searches news for "INFY ESG", "INFY environmental scandal", etc., and returns a structured section that the Publisher incorporates into the final memo.
Hint: Create an `esg_analyst.py` agent with its own system prompt. Insert it after the Critic in the orchestration loop, before the Publisher. Have the ESG Agent search for ESG-related news and controversies, rate ESG risk (high/medium/low), and return a structured ESGAssessment Pydantic model. Update ResearchMemo to include an optional `esg_assessment` field. The Publisher then formats it into the final JSON.
Test your knowledge
You've built a research agent.
Now ship agents at scale.
Join the Best AI Program: The AI-Era Agentic Engineer — 5 months, fully online, with placement assistance. Week 1 is free.
Explore The AI-Era Agentic Engineer →