get_fundamentals
Retrieve core financial data and fundamentals for analysis by providing a ticker symbol to access key metrics for investment decisions.
Instructions
Retrieves core financial and fundamental data.
Args:
symbol: The ticker symbol.
Returns:
Dictionary containing fundamental data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes |
Implementation Reference
- tools/market_data.py:87-108 (handler)The main handler function for the 'get_fundamentals' tool. Fetches key financial metrics (market cap, PE ratios, margins, etc.) for a given stock symbol using yfinance.Ticker.info.def get_fundamentals(symbol: str) -> Dict[str, Any]: """ Retrieves core financial and fundamental data. Args: symbol: The ticker symbol. Returns: Dictionary containing fundamental data. """ try: ticker = yf.Ticker(symbol) info = ticker.info # Filter for key metrics to avoid overwhelming context key_metrics = [ "marketCap", "forwardPE", "trailingPE", "pegRatio", "priceToBook", "profitMargins", "revenueGrowth", "returnOnEquity", "totalDebt", "totalCash", "sector", "industry" ] return {k: info.get(k) for k in key_metrics if k in info} except Exception as e: return {"error": f"Error fetching fundamentals for {symbol}: {str(e)}"}
- server.py:370-373 (registration)MCP tool registration in the FastMCP server. The get_fundamentals function is registered as part of the 'Market Data' tools category via the register_tools helper.register_tools( [get_price, get_fundamentals, get_orderbook], "Market Data" )
- app.py:286-286 (registration)Tool listing/registration in the Gradio app's tools_map dictionary, used for UI toolbox and potentially MCP integration when launching with mcp_server=True."Market Data": [get_price, get_fundamentals, get_orderbook],
- server.py:12-12 (registration)Import statement in the MCP server.py that brings in the get_fundamentals handler.from tools.market_data import get_price, get_fundamentals, get_orderbook
- app.py:47-47 (registration)Import statement in app.py for Gradio UI + MCP.from tools.market_data import get_price, get_fundamentals, get_orderbook