Groq Finance Agent

Write a stock report with GPT-OSS 120B on Groq and explicitly enabled YFinance tools.

Groq retired deepseek-r1-distill-llama-70b-specdec on March 24, 2025. Replace it with openai/gpt-oss-120b. See Groq deprecations.

finance_agent.py
"""
Groq Finance Agent
==================

Cookbook example for `groq/reasoning/finance_agent.py`.
"""

from agno.agent import Agent
from agno.models.groq import Groq
from agno.tools.yfinance import YFinanceTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

# Create an Agent with Groq and YFinanceTools
finance_agent = Agent(
    model=Groq(id="deepseek-r1-distill-llama-70b-specdec"),
    tools=[YFinanceTools()],
    description="You are an investment analyst with deep expertise in market analysis",
    instructions=[
        "Use tables to display data where possible.",
        "Always call the tool before you answer.",
    ],
    add_datetime_to_context=True,
    markdown=True,
)

# Example usage
finance_agent.print_response(
    "Write a report on NVDA with stock price, analyst recommendations, and stock fundamentals.",
    stream=True,
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass

The source's default YFinanceTools() registers only stock prices. Enable fundamentals and analyst recommendations to answer the full report request.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno groq yfinance

Export your Groq API key

export GROQ_API_KEY="your_groq_api_key_here"

Replace DeepSeek R1 SpecDec

Replace deepseek-r1-distill-llama-70b-specdec with openai/gpt-oss-120b in the saved file.

Enable all data requested by the prompt

Replace YFinanceTools() with YFinanceTools(enable_stock_fundamentals=True, enable_analyst_recommendations=True) in the saved file. Stock prices remain enabled by default.

Run the example

Save the code above as finance_agent.py, then run:

python finance_agent.py

Full source: cookbook/90_models/groq/reasoning/finance_agent.py