yfinance package); financialdatasets.ai is built in, and custom providers can be registered. Agent code does not change when the data source does.
Agno ships three finance toolkits, coexisting by design. FinanceTools fixes the tool names while the provider is swappable; YFinanceTools and FinancialDatasetsTools each expose one data source directly, with their own tool names. The older two are not deprecated.
Prerequisites
The default provider needs theyfinance package; the example also uses openai:
httpx, an Agno core dependency — but requires an API key:
Example
cookbook/91_tools/finance/01_market_brief.py
Provider Selection
provider accepts a FinanceProvider instance, a registered provider id ("yfinance", "financial_datasets", or one you added with register_provider), or None. With None (the default), FinanceTools uses Yahoo Finance if the yfinance package is importable, otherwise financialdatasets.ai if FINANCIAL_DATASETS_API_KEY is set, and otherwise raises an ImportError at construction telling you to install yfinance or set the key. An unknown id raises a ValueError listing the registered providers.
Each provider declares the tools it serves, and FinanceTools registers only those:
- Yahoo Finance (
"yfinance") serves all eleven tools. No API key is needed. - Financial Datasets (
"financial_datasets") serves nine — it has nosearch_symbolsorget_analyst_recommendations, and the agent never sees them. Requests carry theFINANCIAL_DATASETS_API_KEYas anX-API-KEYheader; see financialdatasets.ai for plans and rate limits.
FinanceProvider, declare its capabilities, and call register_provider — the custom provider cookbook shows the shape.
At call time, provider failures are returned to the agent as JSON {"error": ...} envelopes, never raised.
Toolkit Params
Toolkit Functions
Every tool returns JSON carrying a
provider field, and each has an async variant registered under the same name, used automatically with arun and aprint_response. Invalid arguments are returned as JSON errors before any provider call.