Skip to main content
Open In ColabOpen on GitHub

Yahoo Finance News

This notebook goes over how to use the yahoo_finance_news tool with an agent.

Setting up​

First, you need to install yfinance python package.

%pip install --upgrade --quiet  yfinance
Note: you may need to restart the kernel to use updated packages.

Example with Chain​

import os

os.environ["OPENAI_API_KEY"] = ".."
from langchain_community.tools.yahoo_finance_news import YahooFinanceNewsTool
from langgraph.prebuilt import create_react_agent

tools = [YahooFinanceNewsTool()]
agent = create_react_agent("openai:gpt-4.1-mini", tools)
USER_AGENT environment variable not set, consider setting it to identify your requests.
input_message = {
"role": "user",
"content": ("What happened today with Microsoft stocks?"),
}

for step in agent.stream(
{"messages": [input_message]},
stream_mode="values",
):
step["messages"][-1].pretty_print()
================================ Human Message =================================

What happened today with Microsoft stocks?
================================== Ai Message ==================================
Tool Calls:
yahoo_finance_news (call_s1Waj1rAoJ89CfxWX1RWDiWL)
Call ID: call_s1Waj1rAoJ89CfxWX1RWDiWL
Args:
query: MSFT
================================= Tool Message =================================
Name: yahoo_finance_news

Microsoft (MSFT), Meta Platforms (META) Reported “Home Run” Results: Dan Ives’ Recent Comments
Microsoft (MSFT) and Meta Platforms (META) delivered “home run” results yesterday, as the AI Revolution has not been slowed by the Trump administration’s tariffs, Dan Ives, the Managing Director and Senior Equity Research Analyst at Wedbush Securities said on CNBC recently. Ives covers tech stocks. Tech Is Poised for a Comeback, Ives Indicates “The tech […]
================================== Ai Message ==================================

Today, Microsoft (MSFT) reported strong financial results, described as "home run" results by Dan Ives, Managing Director and Senior Equity Research Analyst at Wedbush Securities. Despite the Trump administration’s tariffs, the AI Revolution driving tech stocks like Microsoft has not slowed down, indicating a positive outlook for the company and the tech sector overall.
input_message = {
"role": "user",
"content": ("How does Microsoft feels today comparing with Nvidia?"),
}

for step in agent.stream(
{"messages": [input_message]},
stream_mode="values",
):
step["messages"][-1].pretty_print()
================================ Human Message =================================

How does Microsoft feels today comparing with Nvidia?
================================== Ai Message ==================================
Tool Calls:
yahoo_finance_news (call_r9m4YxdEqWeXotkNgK8jGzeJ)
Call ID: call_r9m4YxdEqWeXotkNgK8jGzeJ
Args:
query: MSFT
yahoo_finance_news (call_fxj3AIKPB4MYuquvFFWrBD8B)
Call ID: call_fxj3AIKPB4MYuquvFFWrBD8B
Args:
query: NVDA
================================= Tool Message =================================
Name: yahoo_finance_news

NVIDIA Corporation (NVDA): Among Ken Fisher’s Technology Stock Picks with Huge Upside Potential
We recently published an article titled Billionaire Ken Fisher’s 10 Technology Stock Picks with Huge Upside Potential. In this article, we are going to take a look at where NVIDIA Corporation (NASDAQ:NVDA) stands against the other technology stocks. Technology stocks have faced heightened volatility in 2025, with market sentiment swinging sharply in response to President Donald […]

Nvidia (NVDA) Redesigns Chips to Sidestep U.S. Export Ban, Eyes June China Rollout
Nvidia plans China-specific AI chip revamp after new U.S. export limits

Is NVIDIA (NVDA) the Best NASDAQ Stock to Buy According to Billionaires?
We recently published a list of 10 Best NASDAQ Stocks to Buy According to Billionaires. In this article, we are going to take a look at where NVIDIA Corporation (NASDAQ:NVDA) stands against other best NASDAQ stocks to buy according to billionaires. The latest market data shows that the US economy contracted at an annualized rate […]
================================== Ai Message ==================================

Today, Microsoft (MSFT) is viewed positively with recent strong earnings reported, described as "home run" results, indicating confidence in its performance amid an ongoing AI revolution.

Nvidia (NVDA) is also in focus with its strategic moves, such as redesigning AI chips to bypass U.S. export bans and targeting a China rollout. It is considered one of the technology stocks with significant upside potential, attracting attention from notable investors.

In summary, both Microsoft and Nvidia have positive sentiments today, with Microsoft showing strong financial results and Nvidia making strategic advancements in AI technology and market positioning.

How YahooFinanceNewsTool works?

tool = YahooFinanceNewsTool()
tool.invoke("NVDA")
'NVIDIA Corporation (NVDA): Among Ken Fisher’s Technology Stock Picks with Huge Upside Potential\nWe recently published an article titled Billionaire Ken Fisher’s 10 Technology Stock Picks with Huge Upside Potential. In this article, we are going to take a look at where NVIDIA Corporation (NASDAQ:NVDA) stands against the other technology stocks. Technology stocks have faced heightened volatility in 2025, with market sentiment swinging sharply in response to President Donald […]\n\nNvidia (NVDA) Redesigns Chips to Sidestep U.S. Export Ban, Eyes June China Rollout\nNvidia plans China-specific AI chip revamp after new U.S. export limits\n\nIs NVIDIA (NVDA) the Best NASDAQ Stock to Buy According to Billionaires?\nWe recently published a list of 10 Best NASDAQ Stocks to Buy According to Billionaires. In this article, we are going to take a look at where NVIDIA Corporation (NASDAQ:NVDA) stands against other best NASDAQ stocks to buy according to billionaires. The latest market data shows that the US economy contracted at an annualized rate […]'
res = tool.invoke("AAPL")
print(res)
No news found for company that searched with AAPL ticker.

Was this page helpful?