get_zz500_stocks
Retrieve current or historical CSI 500 index constituents from China's A-share market. Specify date and format to access stock data for analysis.
Instructions
CSI 500 constituents.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | ||
| limit | No | ||
| format | No | markdown |
Implementation Reference
- src/tools/indices.py:49-55 (handler)The primary MCP tool handler for 'get_zz500_stocks', decorated with @app.tool() for automatic registration and schema inference. Executes by calling the indices use case with index='zz500'.@app.tool() def get_zz500_stocks(date: Optional[str] = None, limit: int = 250, format: str = "markdown") -> str: """CSI 500 constituents.""" return run_tool_with_handling( lambda: fetch_index_constituents(active_data_source, index="zz500", date=date, limit=limit, format=format), context="get_zz500_stocks", )
- mcp_server.py:53-53 (registration)Top-level call to register_index_tools, which defines and registers the get_zz500_stocks tool along with other index tools.register_index_tools(app, active_data_source)
- src/use_cases/indices.py:25-35 (helper)Helper use case function that dispatches to data_source.get_zz500_stocks() for 'zz500' index, validates input, and formats the DataFrame output as markdown or other.def fetch_index_constituents(data_source: FinancialDataSource, *, index: str, date: Optional[str], limit: int, format: str) -> str: validate_output_format(format) key = validate_index_key(index, INDEX_MAP) if key == "hs300": df = data_source.get_hs300_stocks(date=date) elif key == "sz50": df = data_source.get_sz50_stocks(date=date) else: df = data_source.get_zz500_stocks(date=date) meta = {"index": key, "as_of": date or "latest"} return format_table_output(df, format=format, max_rows=limit, meta=meta)
- src/baostock_data_source.py:578-580 (helper)Concrete data source implementation that calls Baostock's query_zz500_stocks API via a shared helper to fetch CSI 500 constituents.def get_zz500_stocks(self, date: Optional[str] = None) -> pd.DataFrame: """Fetches CSI 500 index constituents using Baostock.""" return _fetch_index_constituent_data(bs.query_zz500_stocks, "CSI 500", date)
- src/data_source_interface.py:199-201 (schema)Interface definition specifying the get_zz500_stocks method signature for data sources.@abstractmethod def get_zz500_stocks(self, date: Optional[str] = None) -> pd.DataFrame: pass