get_income_statement
Retrieve income statement data for stock symbols to analyze company financial performance over yearly or quarterly periods.
Instructions
Get income statement for a given stock symbol.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Stock symbol in Yahoo Finance format. | |
| freq | No | At what frequency to get cashflow statements. Defaults to "yearly". Valid freqencies: "yearly", "quarterly", "trainling" |
Implementation Reference
- src/mcp_yahoo_finance/server.py:260-270 (handler)MCP tool handler for 'get_income_statement', registered via @mcp_instance.tool() decorator. Delegates to the YahooFinance instance method.def get_income_statement( symbol: str, freq: Literal["yearly", "quarterly", "trainling"] = "yearly" ) -> str: """Get income statement for a given stock symbol. Args: symbol (str): Stock symbol in Yahoo Finance format. freq (str): At what frequency to get cashflow statements. Defaults to "yearly". Valid freqencies: "yearly", "quarterly", "trainling" """ return yf_instance.get_income_statement(symbol, freq)
- YahooFinance class helper method implementing the core logic: fetches income statement using yfinance Ticker.get_income_stmt(), processes DataFrame columns to dates, and returns JSON string.def get_income_statement( self, symbol: str, freq: Literal["yearly", "quarterly", "trainling"] = "yearly" ) -> str: """Get income statement for a given stock symbol. Args: symbol (str): Stock symbol in Yahoo Finance format. freq (str): At what frequency to get cashflow statements. Defaults to "yearly". Valid freqencies: "yearly", "quarterly", "trainling" """ stock = Ticker(ticker=symbol, session=self.session) income_statement = stock.get_income_stmt(freq=freq, pretty=True) if isinstance(income_statement, pd.DataFrame): income_statement.columns = [ str(col.date()) for col in income_statement.columns ] return f"{income_statement.to_json()}" return f"{income_statement}"