This example shows how to create a sophisticated financial analyst that provides comprehensive market insights using real-time news and research data. The agent combines financial news, market analysis, company information, and expert insights to deliver professional-grade financial research and market commentary. Example prompts to try:
  • “What’s the latest news and market sentiment around Apple?”
  • “Give me a detailed analysis of Tesla’s recent market developments”
  • “How is Microsoft performing in the current market? Include recent news”
  • “Analyze NVIDIA’s recent news and market position”
  • “What’s the latest financial news about Amazon’s business performance?”

Code

finance_agent.py
from textwrap import dedent

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.duckduckgo import DuckDuckGoTools

finance_agent = Agent(
    model=OpenAIChat(id="gpt-4o"),
    tools=[
        DuckDuckGoTools(
            search=True,
            news=True,
        )
    ],
    instructions=dedent("""\
        You are a seasoned financial analyst with deep expertise in market analysis and financial research! 📊

        Follow these steps for comprehensive financial analysis:
        1. Market Overview
           - Search for latest company news and developments
           - Current market sentiment and trends
        2. Financial Deep Dive
           - Key financial developments and announcements
           - Recent earnings or business updates
        3. Professional Analysis
           - Expert opinions and market commentary
           - Recent news impact assessment

        4. Financial Context
           - Industry trends and competitive positioning
           - Comparative market analysis
           - Current investor sentiment and market indicators

        Your reporting style:
        - Begin with an executive summary
        - Use tables for data presentation when available
        - Include clear section headers
        - Add emoji indicators for trends (📈 📉)
        - Highlight key insights with bullet points
        - Compare findings to industry benchmarks when possible
        - Include technical term explanations
        - End with a forward-looking market analysis

        Financial Disclosure:
        - Always highlight news sources and dates
        - Note data limitations and availability
        - Mention this is based on publicly available information
        - This analysis is for educational purposes only
    """),
    add_datetime_to_instructions=True,
    show_tool_calls=True,
    markdown=True,
)

# Example usage with detailed financial analysis request
finance_agent.print_response(
    "Provide a comprehensive financial analysis of Apple's recent market performance and news", stream=True
)

# Financial sector analysis example
finance_agent.print_response(
    dedent("""\
    Analyze the technology sector's financial performance focusing on:
    - Apple's latest earnings and market position
    - Microsoft's business developments and financial health
    - Google's revenue streams and market outlook
    - Tesla's financial performance and industry position
    Compare their market positions, financial metrics, and future outlook."""),
    stream=True,
)

# Banking sector financial analysis example
finance_agent.print_response(
    dedent("""\
    Evaluate the banking sector's current financial landscape:
    - JPMorgan Chase's recent financial performance
    - Bank of America's market position and earnings
    - Wells Fargo's business developments
    - Goldman Sachs' market activities and performance
    Include profitability trends and regulatory impact analysis."""),
    stream=True,
)

# More example prompts to explore:
"""
Advanced analysis queries:
1. "Compare Tesla's valuation metrics with traditional automakers"
2. "Analyze the impact of recent product launches on AMD's stock performance"
3. "How do Meta's financial metrics compare to its social media peers?"
4. "Evaluate Netflix's subscriber growth impact on financial metrics"
5. "Break down Amazon's revenue streams and segment performance"

Industry-specific analyses:
Semiconductor Market:
1. "How is the chip shortage affecting TSMC's market position?"
2. "Compare NVIDIA's AI chip revenue growth with competitors"
3. "Analyze Intel's foundry strategy impact on stock performance"
4. "Evaluate semiconductor equipment makers like ASML and Applied Materials"

Automotive Industry:
1. "Compare EV manufacturers' production metrics and margins"
2. "Analyze traditional automakers' EV transition progress"
3. "How are rising interest rates impacting auto sales and stock performance?"
4. "Compare Tesla's profitability metrics with traditional auto manufacturers"
"""

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2

Install libraries

pip install openai ddgs agno
3

Set environment variables

export OPENAI_API_KEY=****
4

Run the agent

python finance_agent.py