Skip to content

A multi-agent AI system powered by Groq and Agno that performs comprehensive financial analysis by combining real-time stock data with web-based market research.

License

Notifications You must be signed in to change notification settings

GoJo-Rika/Financial-AI-Analyst

Repository files navigation

Financial AI Analyst

A multi-agent AI system for comprehensive financial analysis and market research. This project combines web search capabilities with financial data analysis to provide intelligent insights about stocks, market trends, and investment opportunities.

Overview

The Financial AI Analyst uses a team of specialized AI agents to gather and analyze financial information:

  • Web Search Agent: Searches the web for current market news, trends, and general financial information
  • Finance Agent: Retrieves and analyzes real-time stock data, analyst recommendations, and company fundamentals
  • Multi-Agent Coordinator: Orchestrates the agents to provide comprehensive financial analysis

Features

  • Real-time stock price monitoring and analysis
  • Analyst recommendations and market sentiment analysis
  • Company fundamentals and financial metrics
  • Current market news and trends research
  • Interactive web playground for agent testing
  • Structured data presentation in tables and markdown format

πŸš€ Quick Start

New to this project? Start here:

  1. Set up your environment β†’ Installation
  2. Get your API keys β†’ Environment Configuration
  3. Run your first analysis β†’ python financial_agent.py
  4. Try the interactive playground β†’ python playground.py

Project Structure

Financial-AI-Analyst/
β”œβ”€β”€ .env.sample                         # Environment variables template
β”œβ”€β”€ .gitignore                          # Git ignore rules
β”œβ”€β”€ .python-version                     # Python version specification
β”œβ”€β”€ financial_agent.py                  # Main agent implementation
β”œβ”€β”€ playground.py                       # Interactive web playground
β”œβ”€β”€ pyproject.toml                      # Project configuration
β”œβ”€β”€ README.md                           # This file
β”œβ”€β”€ requirements.txt                    # Python dependencies
└── uv.lock                             # Dependency lock file

Prerequisites

  • Python 3.8 or higher
  • Groq API key for accessing AI models
  • Agno API key for the playground interface

Installation

1. Clone the Repository

git clone https://github.com/GoJo-Rika/Financial-AI-Analyst.git
cd Financial-AI-Analyst

2. Set Up Python Environment

Using uv (recommended):

uv venv
source .venv/bin/activate

Or using venv:

python -m venv venv
source venv/bin/activate

Or using conda:

conda create -n financial-ai python=3.9
conda activate financial-ai

3. Install Dependencies

# Using uv
uv add -r requirements.txt

# Using pip
pip install -r requirements.txt

4. Environment Configuration

Copy the sample environment file and configure your API keys:

cp .env.sample .env

Edit the .env file and add your API keys:

GROQ_API_KEY=your_groq_api_key_here
AGNO_API_KEY=your_agno_api_key_here

Getting API Keys

Usage

Running the Financial Agent

The main financial analysis can be executed directly:

ur run financial_agent.py
# or
python3 financial_agent.py

This will run a sample analysis for Apple (AAPL) stock, providing:

  • Analyst recommendations
  • Current stock price
  • Market sentiment analysis
  • Comprehensive summary with sources

Using the Interactive Playground

For a more interactive experience, launch the web playground:

uv run playground.py
# or
python3 playground.py

This starts a web server (typically at http://localhost:8000) where you can:

  • Interact with agents through a web interface
  • Test different queries and scenarios
  • View real-time responses from both agents
  • Experiment with various financial analysis requests

Custom Analysis

You can modify the queries in financial_agent.py to analyze different stocks or ask specific questions:

# Example: Analyze multiple stocks for long-term investment
multi_ai_agent.print_response(
    "Analyze companies like Tesla, NVDA, Apple and suggest which to buy for long term"
)

# Example: Get market sentiment for a specific sector
multi_ai_agent.print_response(
    "What is the current market sentiment for technology stocks?"
)

Agent Workflow

1. πŸ” Web Search Agent

  • Purpose: Gathers current market news, sentiment, and trends
  • Model: Llama 3.1 8B Instant
  • Tools: DuckDuckGo search
  • Instructions: Always includes sources for information

2. πŸ“Š Finance Agent

  • Purpose: Retrieves real-time financial data and metrics
  • Model: Gemma2 9B IT
  • Tool: Yahoo Finance integration (YFinance)
  • Capabilities:
    • Real-time stock prices
    • Analyst recommendations
    • Company fundamentals
    • Company news
  • Instructions: Presents data in structured tables

3. πŸ€– Multi-Agent Coordinator

  • Purpose: Orchestrates both agents and synthesizes results
  • Model: Gemma2 9B IT
  • Process: Delegates tasks β†’ Combines results β†’ Formats output

4. Query Processing Flow

When you ask: "Summarize analyst recommendations and share stock price for AAPL"

  1. Multi-Agent Coordinator receives the query
  2. Finance Agent is called:
    • Uses YFinanceTools to fetch AAPL stock data
    • Retrieves current price, analyst recommendations, fundamentals
    • Formats data into structured tables
  3. Web Search Agent is called:
    • Uses DuckDuckGoTools to search for recent AAPL news
    • Gathers market sentiment and current events
    • Includes source citations
  4. Coordinator combines both results:
    • Synthesizes financial data with market context
    • Creates comprehensive analysis
    • Presents in markdown format with tables

Configuration Options

Agent Customization

You can customize agent behavior by modifying their configurations:

# Finance Agent Tool Configuration
YFinanceTools(
    stock_price=True,              # Enable real-time price data
    analyst_recommendations=True,   # Include analyst ratings
    stock_fundamentals=True,       # Company financial metrics
    company_news=True,            # Latest company news
)

# Agent Behavior Settings
instructions="Use tables to display the data"  # Output formatting
show_tool_calls=True                          # Debug visibility
markdown=True                                 # Formatted output

Available Models

The project uses Groq models:

  • llama-3.1-8b-instant: Fast responses for web searches
  • gemma2-9b-it: Balanced performance for financial analysis

Example Queries

Here are some example queries you can try:

  • "Analyze the current market sentiment for NVDA and provide buy/sell recommendations"
  • "Compare the financial fundamentals of Apple, Microsoft, and Google"
  • "What are the latest news and analyst opinions on Tesla stock?"
  • "Identify promising growth stocks in the technology sector"
  • "Analyze the impact of recent Fed decisions on bank stocks"

Troubleshooting

Common Issues

API Key Errors:

  • Ensure your .env file contains valid API keys
  • Check that environment variables are properly loaded

Installation Issues:

  • Verify Python version compatibility
  • Try upgrading pip: pip install --upgrade pip
  • Consider using a virtual environment

Agent Response Issues:

  • Check your internet connection for web search functionality
  • Verify API key permissions and rate limits
  • Ensure stock symbols are valid when querying financial data

Debug Mode

Enable debug mode by setting show_tool_calls=True in agent configurations to see detailed tool usage.

Contributing

When contributing to this project:

  1. Follow the existing code structure and naming conventions
  2. Add appropriate error handling for API calls
  3. Include docstrings for new functions and classes
  4. Test your changes with different stock symbols and queries
  5. Update this README if you add new features

License

This project is open source. Please check the license file for specific terms.

Support

For questions or issues:

  • Check the troubleshooting section above
  • Review the Agno and Groq documentation
  • Create an issue in the project repository

Note: This tool is for educational and research purposes. Always consult with financial professionals before making investment decisions.

Releases

No releases published

Packages

No packages published

Languages