Yfinance
YFinanceTools give an agent access to stock prices, fundamentals, and analyst data from Yahoo Finance.
YFinanceTools enable an Agent to access stock data, financial information and more from Yahoo Finance.
Prerequisites
The following example requires the yfinance and openai libraries.
uv pip install -U agno yfinance openaiExample
The following agent will provide information about the stock price and analyst recommendations for NVDA (Nvidia Corporation).
from agno.agent import Agent
from agno.tools.yfinance import YFinanceTools
agent = Agent(
tools=[YFinanceTools(all=True)],
description="You are an investment analyst that researches stock prices, analyst recommendations, and stock fundamentals.",
instructions=["Format your response using markdown and use tables to display data where possible."],
)
agent.print_response("Share the NVDA stock price and analyst recommendations", markdown=True)Toolkit Params
Only get_current_stock_price is enabled by default. Enable the rest individually or pass all=True.
| Parameter | Type | Default | Description |
|---|---|---|---|
enable_stock_price | bool | True | Enable the get_current_stock_price function |
enable_company_info | bool | False | Enable the get_company_info function |
enable_stock_fundamentals | bool | False | Enable the get_stock_fundamentals function |
enable_income_statements | bool | False | Enable the get_income_statements function |
enable_key_financial_ratios | bool | False | Enable the get_key_financial_ratios function |
enable_analyst_recommendations | bool | False | Enable the get_analyst_recommendations function |
enable_company_news | bool | False | Enable the get_company_news function |
enable_technical_indicators | bool | False | Enable the get_technical_indicators function |
enable_historical_prices | bool | False | Enable the get_historical_stock_prices function |
all | bool | False | Enable all functions |
session | Optional[Any] | None | Custom requests session passed to yfinance |
Toolkit Functions
| Function | Description |
|---|---|
get_current_stock_price | This function retrieves the current stock price of a company. |
get_company_info | This function retrieves detailed information about a company. |
get_historical_stock_prices | This function retrieves historical stock prices for a company. |
get_stock_fundamentals | This function retrieves fundamental data about a stock. |
get_income_statements | This function retrieves income statements of a company. |
get_key_financial_ratios | This function retrieves key financial ratios for a company. |
get_analyst_recommendations | This function retrieves analyst recommendations for a stock. |
get_company_news | This function retrieves the latest news related to a company. |
get_technical_indicators | Returns historical price and volume data from Ticker.history(period) for analysis; does not calculate RSI, MACD, or other indicators. |
You can use include_tools or exclude_tools to modify the list of tools the agent has access to. Learn more about selecting tools.