list_industries
Retrieve distinct industry classifications for China's A-share market on a specific date to analyze sector composition and market structure.
Instructions
List distinct industries for a given date.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | ||
| format | No | markdown |
Implementation Reference
- src/tools/indices.py:65-72 (handler)The MCP tool handler for 'list_industries'. Decorated with @app.tool() for automatic registration and schema inference. Logs the invocation and delegates to the core use case logic via run_tool_with_handling.@app.tool() def list_industries(date: Optional[str] = None, format: str = "markdown") -> str: """List distinct industries for a given date.""" logger.info("Tool 'list_industries' called date=%s", date or "latest") return run_tool_with_handling( lambda: fetch_list_industries(active_data_source, date=date, format=format), context="list_industries", )
- src/use_cases/indices.py:38-47 (helper)Core implementation logic for listing industries: fetches all stock industry data, extracts unique sorted industries, and formats as markdown table.def fetch_list_industries(data_source: FinancialDataSource, *, date: Optional[str], format: str) -> str: validate_output_format(format) df = data_source.get_stock_industry(code=None, date=date) if df is None or df.empty: return "(No data available to display)" col = "industry" if "industry" in df.columns else df.columns[-1] out = df[[col]].drop_duplicates().sort_values(by=col) out = out.rename(columns={col: "industry"}) meta = {"as_of": date or "latest", "count": int(out.shape[0])} return format_table_output(out, format=format, max_rows=out.shape[0], meta=meta)
- mcp_server.py:53-53 (registration)Top-level call to register_index_tools, which includes the registration of the 'list_industries' handler via its @app.tool() decorator.register_index_tools(app, active_data_source)