Finance

Market Brief with FinanceTools

Build a market brief with Yahoo Finance data and an OpenAI-powered agent.

market_brief.py
"""
Market Brief with FinanceTools
==============================
The simplest finance agent: one toolkit, no API key.

`FinanceTools()` defaults to the Yahoo Finance provider (via `yfinance`) and
registers the seven "market brief" tools: search_symbols, get_quote,
get_price_history, get_company_profile, get_key_metrics, get_news and
get_analyst_recommendations. Every tool returns the same JSON shape no matter
which provider is behind it, so the agent code never changes when you swap
providers (see 03_swap_provider.py).

Prompts to try:
- "Give me a market brief on NVIDIA"
- "How has AMD traded over the last 3 months?"
- "What do analysts think about Tesla right now?"

Run: pip install yfinance
"""

from agno.agent import Agent
from agno.tools.finance import FinanceTools

# ---------------------------------------------------------------------------
# Create the Agent
# ---------------------------------------------------------------------------
agent = Agent(
    name="Finance Agent",
    model="openai:gpt-5.6",
    tools=[FinanceTools()],
    instructions="Lead with the answer, then show the evidence.",
    markdown=True,
)

# ---------------------------------------------------------------------------
# Run the Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response("Give me a market brief on NVIDIA", stream=True)

The Yahoo Finance provider needs no separate data-provider key; the OpenAI model still needs OPENAI_API_KEY. With the installed yfinance package, FinanceTools() selects Yahoo Finance. Without that package, it can fall back to Financial Datasets when FINANCIAL_DATASETS_API_KEY is set.

Run the Example

Set up your virtual environment

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

Install dependencies

uv pip install -U agno openai yfinance

Export your API keys

export OPENAI_API_KEY="your_openai_api_key_here"

Run the example

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

python market_brief.py

Full source: cookbook/91_tools/finance/01_market_brief.py