Skip to content

Latest commit

 

History

History
143 lines (108 loc) · 4.72 KB

File metadata and controls

143 lines (108 loc) · 4.72 KB

Market Research Agent

An AI-powered market research agent that analyzes retail companies for sales quota planning. It retrieves historical financial metrics (revenue, market cap, physical store count), predicts next-year performance with bear/base/bull ranges, and provides long-format reasoning with source citations.

Built with Microsoft Agent Framework and deployed as a hosted agent in Azure AI Foundry.

What It Does

You: "Analyze Target Corporation for my quota planning"

Agent:
  📊 Historical Data — structured JSON with revenue, market cap, store count by year
  📈 Prediction — next-year bear/base/bull ranges with methodology and assumptions
  📝 Reasoning — 1000-2000 word narrative with source citations
  📎 Excel — downloadable .xlsx with Historical + Prediction sheets

Users can iterate conversationally — correct data, add context ("they announced 50 new stores"), and the agent re-predicts.

Architecture

Component Purpose
yfinance Deterministic revenue and market cap from Yahoo Finance
Bing Grounding Physical store counts, analyst forecasts, industry context
GPT-4o Synthesize data, generate predictions, write reasoning
openpyxl Excel artifact generation
Agent Framework Tool orchestration, multi-turn conversation
Foundry Hosted Agent Managed deployment with portal chat UI

Prerequisites

Quickstart

Local Development

git clone https://github.com/ericchansen/market-research.git
cd market-research

python -m venv .venv
source .venv/bin/activate  # Linux/Mac
# .venv\Scripts\activate   # Windows

pip install -r requirements.txt -r requirements-dev.txt
pytest

Deploy to Azure AI Foundry

# Install the Foundry extension
azd ext install microsoft.foundry

# Provision Azure resources (AI Foundry, Bing, OpenAI, ACR)
azd provision

# Deploy the agent
azd deploy

After deployment, the agent is available in the Foundry portal chat UI.

Output Schema

Historical Data

{
  "company": "Target Corporation",
  "ticker": "TGT",
  "sector": "Consumer Defensive",
  "historical": [
    {
      "fiscal_year": 2024,
      "revenue_usd_millions": 107600,
      "market_cap_usd_millions": 73200,
      "physical_store_count": 1956,
      "store_count_change_yoy": 8,
      "revenue_per_store_usd_millions": 55.0,
      "sources": {"financial": "Yahoo Finance", "store_count": "https://..."}
    }
  ]
}

Prediction

{
  "prediction": {
    "fiscal_year": 2027,
    "revenue_usd_millions": {"bear": 103000, "base": 108500, "bull": 114000},
    "market_cap_usd_millions": {"bear": 60000, "base": 72000, "bull": 85000},
    "physical_store_count": {"bear": 1925, "base": 1960, "bull": 2010},
    "confidence": "moderate",
    "methodology_summary": "3-year CAGR + analyst consensus adjustment",
    "key_assumptions": ["No major recession", "E-commerce mix stable"]
  }
}

Project Structure

├── main.py                      # Agent server entry point
├── src/
│   ├── agent.py                 # Agent definition with tools
│   ├── prompts.py               # System prompt
│   ├── schemas.py               # Pydantic output models
│   └── tools/
│       ├── financial_data.py    # yfinance wrapper
│       └── excel_generator.py   # Excel artifact builder
├── tests/                       # Unit tests
├── infra/                       # Bicep templates for Azure resources
├── Dockerfile                   # Container definition
├── agent.manifest.yaml          # Foundry agent manifest
└── azure.yaml                   # azd project config

Cost Notes

  • Bing Grounding: Each query triggers multiple Bing searches. Cost is billed separately from model inference. See Bing Grounding pricing.
  • GPT-4o: Standard token-based pricing per query. A typical analysis uses 2000-4000 input tokens and 3000-6000 output tokens.
  • yfinance: Free, no API key required.

Disclaimer

Predictions are LLM-synthesized estimates based on public data and analyst consensus. They are not financial advice. Always validate with authoritative sources before making business decisions.

Contributing

See CONTRIBUTING.md for development setup and PR guidelines.

License

MIT