get_operation_data
Retrieve quarterly operation capability data for A-share stocks to analyze company performance and financial health.
Instructions
Quarterly operation capability data.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| year | Yes | ||
| quarter | Yes | ||
| limit | No | ||
| format | No | markdown |
Implementation Reference
- src/tools/financial_reports.py:39-45 (handler)MCP tool handler for get_operation_data. The @app.tool() decorator registers the tool with FastMCP. Includes input schema via type hints and docstring description. Delegates to use case with error handling.@app.tool() def get_operation_data(code: str, year: str, quarter: int, limit: int = 250, format: str = "markdown") -> str: """Quarterly operation capability data.""" return run_tool_with_handling( lambda: fetch_operation_data(active_data_source, code=code, year=year, quarter=quarter, limit=limit, format=format), context=f"get_operation_data:{code}:{year}Q{quarter}", )
- mcp_server.py:52-52 (registration)Top-level registration of financial report tools, including get_operation_data, by calling the register function.register_financial_report_tools(app, active_data_source)
- Use case helper that performs input validation, fetches data from data source, and formats the output table.def fetch_operation_data(data_source: FinancialDataSource, *, code: str, year: str, quarter: int, limit: int, format: str) -> str: validate_year(year) validate_quarter(quarter) validate_output_format(format) df = data_source.get_operation_data(code=code, year=year, quarter=quarter) return _format_financial_df(df, code=code, year=year, quarter=quarter, dataset="Operation Capability", format=format, limit=limit)
- src/baostock_data_source.py:417-419 (helper)Baostock data source implementation that queries the Baostock API for operation data using a shared fetch helper.def get_operation_data(self, code: str, year: str, quarter: int) -> pd.DataFrame: """Fetches quarterly operation capability data using Baostock.""" return _fetch_financial_data(bs.query_operation_data, "Operation Capability", code, year, quarter)
- src/data_source_interface.py:138-140 (schema)Abstract method definition in the FinancialDataSource interface, defining the expected schema for data source implementations.@abstractmethod def get_operation_data(self, code: str, year: str, quarter: int) -> pd.DataFrame: pass