Skip to main content
Glama
leoncuhk

MCP Yahoo Finance

by leoncuhk

get_stock_price_by_date

Retrieve historical stock prices for specific symbols and dates to analyze market trends and track investment performance.

Instructions

Get the stock price for a given stock symbol on a specific date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesStock symbol in Yahoo Finance format.
dateYesThe date in YYYY-MM-DD format.

Implementation Reference

  • MCP tool handler for 'get_stock_price_by_date'. Decorated with @mcp_instance.tool(), defines input schema via annotations and docstring, and delegates execution to the YahooFinance instance method.
    @mcp_instance.tool() def get_stock_price_by_date(symbol: str, date: str) -> str: """Get the stock price for a given stock symbol on a specific date. Args: symbol (str): Stock symbol in Yahoo Finance format. date (str): The date in YYYY-MM-DD format. """ return yf_instance.get_stock_price_by_date(symbol, date)
  • YahooFinance class helper method that implements the core logic: fetches historical stock data for a specific date using yfinance Ticker.history() and returns the closing price.
    def get_stock_price_by_date(self, symbol: str, date: str) -> str: """Get the stock price for a given stock symbol on a specific date. Args: symbol (str): Stock symbol in Yahoo Finance format. date (str): The date in YYYY-MM-DD format. """ stock = Ticker(ticker=symbol, session=self.session) price = stock.history(start=date, period="1d") return f"{price.iloc[0]['Close']:.4f}"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/leoncuhk/mcp-yahoo-finance'

If you have feedback or need assistance with the MCP directory API, please join our Discord server