Skip to main content

Overview

The AI Finance Agent Team demonstrates how to build a collaborative team of AI agents that work together as financial analysts. This system combines web search capabilities with real-time financial data analysis tools to provide comprehensive financial insights in just 20 lines of Python code.

Architecture

Multi-Agent Team Structure

The Finance Agent Team uses a team coordination pattern where specialized agents collaborate under a team lead:

Agent Roles

Web Agent

Role: Search the web for informationTools:
  • DuckDuckGo search
Capabilities:
  • General internet research
  • News and articles
  • Market sentiment

Finance Agent

Role: Get financial dataTools:
  • Current stock prices
  • Analyst recommendations
  • Company information
  • Company news
Display: Always uses tables for data

Team Agent

Role: Coordinate between agentsResponsibilities:
  • Route queries to appropriate agents
  • Combine insights from both agents
  • Present unified analysis

Implementation

Key Features

YFinance Integration:
  • Current stock prices
  • Analyst recommendations
  • Company information and fundamentals
  • Latest company news
  • Historical data analysis
Data Presentation:
  • Always formatted in tables
  • Clear, readable format
  • Supports multiple tickers
DuckDuckGo Search:
  • General market research
  • News and sentiment analysis
  • Industry trends
  • Competitive intelligence
  • Economic indicators
Privacy-Focused:
  • No tracking
  • Anonymous searches
  • Reliable results
SQLite Database:
  • Stores agent interactions
  • Maintains conversation history
  • Context awareness across queries
  • Historical analysis
Benefits:
  • Faster follow-up queries
  • Consistent analysis
  • Learning from past interactions
Intelligent Routing:
  • Automatically selects appropriate agent
  • Combines insights from multiple agents
  • Unified response format
Collaboration:
  • Agents share context
  • Complementary analysis
  • Comprehensive insights

Agent Coordination Patterns

Query Routing

The Team Agent intelligently routes queries based on the type of information needed:

Agent Handoff

YFinance Tools

Available Functions

Example:

Installation

1

Clone Repository

2

Install Dependencies

Required packages:
  • agno>=2.2.10
  • openai
  • yfinance
  • duckduckgo-search
  • sqlalchemy
3

Set OpenAI API Key

Get your API key from platform.openai.com
4

Run Application

Open your browser to the URL shown in the console to access the playground interface.

Usage Examples

Technical Architecture

Database Storage

Context Management

Markdown Output

Best Practices

Query Formulation

  • Be specific about what you need
  • Mention ticker symbols explicitly
  • Combine requests for comprehensive analysis
  • Ask for comparisons when relevant

Data Interpretation

  • Review both quantitative and qualitative data
  • Consider market context
  • Look at historical trends
  • Verify with multiple sources

Cost Management

  • Use specific queries to reduce API calls
  • Leverage conversation history
  • Cache frequently accessed data
  • Monitor OpenAI usage

Error Handling

  • Verify ticker symbols
  • Check for market hours
  • Handle data unavailability
  • Validate financial data
Important Notes:
  • Financial data is for informational purposes only
  • Not investment advice
  • Always verify critical information
  • Market data may have slight delays
  • Past performance doesn’t guarantee future results

Investment Agent

Advanced investment analysis

Deep Research Agent

Comprehensive research capabilities

Legal Agent Team

Document analysis with teams