get_finance_ratios
Retrieve financial ratios for Vietnamese companies to analyze performance and make investment decisions. Specify stock symbol, period (quarter/year), and output format.
Instructions
Get finance ratios of a company from stock market
Args:
symbol: str (symbol of the company to get finance ratios)
period: Literal['quarter', 'year'] = 'year' (period to get finance ratios)
output_format: Literal['json', 'dataframe'] = 'json'
Returns:
pd.DataFrame
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | ||
| period | No | year | |
| output_format | No | json |
Implementation Reference
- src/vnstock_mcp/server.py:450-470 (handler)The handler function for the 'get_finance_ratios' tool, decorated with @server.tool() for registration in FastMCP. It uses VCIFinance to fetch financial ratios for a given symbol and period, returning data as JSON or DataFrame based on output_format.@server.tool() def get_finance_ratios( symbol: str, period: Literal["quarter", "year"] = "year", output_format: Literal["json", "dataframe"] = "json", ): # pyright: ignore[reportUndefinedVariable] """ Get finance ratios of a company from stock market Args: symbol: str (symbol of the company to get finance ratios) period: Literal['quarter', 'year'] = 'year' (period to get finance ratios) output_format: Literal['json', 'dataframe'] = 'json' Returns: pd.DataFrame """ finance = VCIFinance(symbol=symbol, period=period) df = finance.ratio() if output_format == "json": return df.to_json(orient="records", force_ascii=False) else: return df
- src/vnstock_mcp/server.py:451-470 (schema)The function signature defines the input schema with type hints and defaults, used by FastMCP to generate the tool schema.def get_finance_ratios( symbol: str, period: Literal["quarter", "year"] = "year", output_format: Literal["json", "dataframe"] = "json", ): # pyright: ignore[reportUndefinedVariable] """ Get finance ratios of a company from stock market Args: symbol: str (symbol of the company to get finance ratios) period: Literal['quarter', 'year'] = 'year' (period to get finance ratios) output_format: Literal['json', 'dataframe'] = 'json' Returns: pd.DataFrame """ finance = VCIFinance(symbol=symbol, period=period) df = finance.ratio() if output_format == "json": return df.to_json(orient="records", force_ascii=False) else: return df
- src/vnstock_mcp/server.py:450-450 (registration)The @server.tool() decorator registers the get_finance_ratios function as an MCP tool in the FastMCP server.@server.tool()