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
- General internet research
- News and articles
- Market sentiment
Finance Agent
Role: Get financial dataTools:
- Current stock prices
- Analyst recommendations
- Company information
- Company news
Team Agent
Role: Coordinate between agentsResponsibilities:
- Route queries to appropriate agents
- Combine insights from both agents
- Present unified analysis
Implementation
- Complete System (20 Lines)
- Individual Agents
- Team Configuration
Key Features
Real-Time Financial Data
Real-Time Financial Data
YFinance Integration:
- Current stock prices
- Analyst recommendations
- Company information and fundamentals
- Latest company news
- Historical data analysis
- Always formatted in tables
- Clear, readable format
- Supports multiple tickers
Web Search Capabilities
Web Search Capabilities
DuckDuckGo Search:
- General market research
- News and sentiment analysis
- Industry trends
- Competitive intelligence
- Economic indicators
- No tracking
- Anonymous searches
- Reliable results
Persistent Storage
Persistent Storage
SQLite Database:
- Stores agent interactions
- Maintains conversation history
- Context awareness across queries
- Historical analysis
- Faster follow-up queries
- Consistent analysis
- Learning from past interactions
Team Coordination
Team Coordination
Intelligent Routing:
- Automatically selects appropriate agent
- Combines insights from multiple agents
- Unified response format
- 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
- get_current_stock_price
- get_analyst_recommendations
- get_company_info
- get_company_news
Installation
Set OpenAI API Key
Usage Examples
Stock Analysis
Stock Analysis
Industry Research
Industry Research
Comparative Analysis
Comparative Analysis
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
Related Examples
Investment Agent
Advanced investment analysis
Deep Research Agent
Comprehensive research capabilities
Legal Agent Team
Document analysis with teams
