Skip to main content

Overview

The Finance Agent is a powerful AI-powered finance assistant built with the Agno framework that provides real-time financial data, stock analysis, and market insights using natural language queries. It combines YFinance for financial data and DuckDuckGo for web search to deliver comprehensive market intelligence.

Key Features

  • Real-time stock prices and historical data
  • Financial analysis with analyst recommendations
  • Web search for latest financial news
  • Interactive web UI via Agno Playground
  • Structured output with tables and bullet points

Tech Stack

Framework

Agno - Modern AI agent framework

LLM Model

Meta Llama-3.3-70B-Instruct via Nebius

Financial Data

YFinance - Yahoo Finance API wrapper

Web Search

DuckDuckGo - Privacy-focused search

Prerequisites

1

Python 3.10+

Ensure you have Python 3.10 or higher installed on your system.
2

Nebius API Key

Get your API key from Nebius Token Factory
3

Internet Connection

Required for real-time financial data and market information.

Installation

1

Clone the Repository

git clone https://github.com/Arindam200/awesome-ai-apps.git
cd awesome-ai-apps/simple_ai_agents/finance_agent
2

Install Dependencies

Using pip:
pip install -r requirements.txt
Or using uv (recommended):
uv sync
3

Configure Environment

Create a .env file with your API key:
NEBIUS_API_KEY=your_nebius_api_key_here

Implementation

Agent Configuration

The finance agent is configured with specialized tools and instructions for financial analysis:
from agno.agent import Agent
from agno.models.nebius import Nebius
from agno.tools.yfinance import YFinanceTools
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.playground import Playground, serve_playground_app
import os
from dotenv import load_dotenv

load_dotenv()

# Create the AI finance agent
agent = Agent(
    name="xAI Finance Agent",
    model=Nebius(
        id="meta-llama/Llama-3.3-70B-Instruct",
        api_key=os.getenv("NEBIUS_API_KEY")
    ),
    tools=[
        DuckDuckGoTools(), 
        YFinanceTools(
            stock_price=True, 
            analyst_recommendations=True, 
            stock_fundamentals=True
        )
    ],
    instructions=[
        "Always use tables to display financial/numerical data.",
        "For text data use bullet points and small paragraphs."
    ],
    show_tool_calls=True,
    markdown=True,
)

# UI for finance agent
app = Playground(agents=[agent]).get_app()

if __name__ == "__main__":
    serve_playground_app("xai_finance_agent:app", reload=True)

Available Tools

The agent has access to these specialized tools:
Stock Price: Real-time and historical stock pricesAnalyst Recommendations: Buy/sell/hold recommendations from financial analystsStock Fundamentals: P/E ratios, market cap, revenue, earnings, and more
Web Search: Search for latest financial news and market informationPrivacy-focused: No tracking or personal data collection

Usage

1

Run the Application

python main.py
The application will start and be available at http://localhost:8000.
2

Ask Financial Questions

Interact with the finance agent using natural language queries.

Example Queries

Here are example queries you can try with the finance agent:
What's the current stock price of Apple?

Features in Detail

Real-time Stock Data

Query current stock prices, historical data, and market trends for any publicly traded company.
"What's the current price of AAPL stock?"
"Show me Tesla's stock performance over the last month"

Financial Analysis

Access analyst recommendations and comprehensive fundamental analysis:
"Show me analyst recommendations for TSLA"
"What's the P/E ratio of Amazon?"
"Get the latest earnings report for Apple"

Market Intelligence

Stay updated with the latest financial news and market information:
"Get the latest news about Bitcoin"
"What's happening in the tech stock market today?"
The agent uses DuckDuckGo for web searches, ensuring privacy-focused results without tracking.

Security & Privacy

Best Practices

  • API Keys: Store securely in environment variables, never commit to version control
  • No Data Storage: The agent doesn’t store your queries or personal data
  • Privacy: Uses DuckDuckGo for web searches (no tracking)

Troubleshooting

Ensure your NEBIUS_API_KEY is correctly set in the .env file and the key is valid.
The application will automatically find an available port if the default is busy.
Ensure you have a stable internet connection for real-time data access.
Verify all dependencies are installed correctly:
pip install -r requirements.txt

Configuration Options

The agent can be customized with different settings:
OptionDescriptionDefault
modelLLM model to useMeta Llama-3.3-70B-Instruct
show_tool_callsDisplay tool calls in UITrue
markdownEnable markdown formattingTrue
instructionsCustom instructions for the agentTables for numbers, bullets for text

Next Steps

Explore Agno

Learn more about the Agno framework

YFinance Docs

Explore YFinance capabilities

Nebius Token Factory

Get started with Nebius AI

Advanced Agents

Build more complex multi-agent systems

Build docs developers (and LLMs) love