get_cashflow
Retrieve cashflow statements for a specific stock symbol at custom frequencies (yearly, quarterly, trailing) using Yahoo Finance data to analyze financial performance.
Instructions
Get cashflow for a given stock symbol.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| freq | No | At what frequency to get cashflow statements. Defaults to "yearly". Valid freqencies: "yearly", "quarterly", "trainling" | |
| symbol | Yes | Stock symbol in Yahoo Finance format. |
Implementation Reference
- src/mcp_yahoo_finance/server.py:272-285 (handler)The main MCP tool handler for get_cashflow. It is registered via @mcp_instance.tool() decorator and executes the tool logic by calling the YahooFinance helper method, returning the cashflow data as string.@mcp_instance.tool() def get_cashflow( symbol: str, freq: Literal["yearly", "quarterly", "trainling"] = "yearly" ) -> str: """Get cashflow 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" """ # Note: Original function didn't specify return type, assuming str return str(yf_instance.get_cashflow(symbol, freq))
- Supporting helper method in the YahooFinance class that fetches cashflow data from yfinance Ticker, formats it as JSON string if DataFrame.def get_cashflow( self, symbol: str, freq: Literal["yearly", "quarterly", "trainling"] = "yearly" ): """Get cashflow 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) cashflow = stock.get_cashflow(freq=freq, pretty=True) if isinstance(cashflow, pd.DataFrame): cashflow.columns = [str(col.date()) for col in cashflow.columns] return f"{cashflow.to_json(indent=2)}" return f"{cashflow}"