Skip to content

ericchansen/market-research

Repository files navigation

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

About

AI-powered market research agent for retail financial analysis. Built with Microsoft Agent Framework, deployed in Azure AI Foundry.

Resources

License

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors