YFinanceTools enable an Agent to access stock data, financial information and more from Yahoo Finance.

Prerequisites

The following example requires the yfinance library.

pip install -U yfinance

Example

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

cookbook/tools/yfinance_tools.py
from phi.agent import Agent
from phi.tools.yfinance import YFinanceTools

agent = Agent(
    tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, stock_fundamentals=True)],
    show_tool_calls=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

ParameterTypeDefaultDescription
stock_priceboolTrueEnables the functionality to retrieve current stock price information.
company_infoboolFalseEnables the functionality to retrieve detailed company information.
stock_fundamentalsboolFalseEnables the functionality to retrieve fundamental data about a stock.
income_statementsboolFalseEnables the functionality to retrieve income statements of a company.
key_financial_ratiosboolFalseEnables the functionality to retrieve key financial ratios for a company.
analyst_recommendationsboolFalseEnables the functionality to retrieve analyst recommendations for a stock.
company_newsboolFalseEnables the functionality to retrieve the latest news related to a company.
technical_indicatorsboolFalseEnables the functionality to retrieve technical indicators for stock analysis.
historical_pricesboolFalseEnables the functionality to retrieve historical price data for a stock.

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_indicatorsThis function retrieves technical indicators for stock analysis.