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 openai

Example

The following agent will provide information about the stock price and analyst recommendations for NVDA (Nvidia Corporation).

cookbook/91_tools/yfinance_tools.py
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.

ParameterTypeDefaultDescription
enable_stock_priceboolTrueEnable the get_current_stock_price function
enable_company_infoboolFalseEnable the get_company_info function
enable_stock_fundamentalsboolFalseEnable the get_stock_fundamentals function
enable_income_statementsboolFalseEnable the get_income_statements function
enable_key_financial_ratiosboolFalseEnable the get_key_financial_ratios function
enable_analyst_recommendationsboolFalseEnable the get_analyst_recommendations function
enable_company_newsboolFalseEnable the get_company_news function
enable_technical_indicatorsboolFalseEnable the get_technical_indicators function
enable_historical_pricesboolFalseEnable the get_historical_stock_prices function
allboolFalseEnable all functions
sessionOptional[Any]NoneCustom requests session passed to yfinance

Toolkit Functions

FunctionDescription
get_current_stock_priceThis function retrieves the current stock price of a company.
get_company_infoThis function retrieves detailed information about a company.
get_historical_stock_pricesThis function retrieves historical stock prices for a company.
get_stock_fundamentalsThis function retrieves fundamental data about a stock.
get_income_statementsThis function retrieves income statements of a company.
get_key_financial_ratiosThis function retrieves key financial ratios for a company.
get_analyst_recommendationsThis function retrieves analyst recommendations for a stock.
get_company_newsThis function retrieves the latest news related to a company.
get_technical_indicatorsReturns 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.

Developer Resources