get_stock_fhps_detail
Retrieve dividend distribution details for specific Chinese stocks, including payout information and stock splits, with flexible output formats.
Instructions
获取指定股票的分红配送情况
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | 股票代码 (例如: '000001') | |
| output_format | No | 输出数据格式: json, csv, xml, excel, markdown, html。默认: markdown | markdown |
Implementation Reference
- src/china_stock_mcp/server.py:720-722 (registration)Registration of the 'get_stock_fhps_detail' tool using the @mcp.tool decorator with name and description.@mcp.tool( name="get_stock_fhps_detail", description="获取指定股票的分红配送情况" )
- src/china_stock_mcp/server.py:723-749 (handler)Handler function implementing the tool logic: fetches stock dividend/distribution details (FHPS) using fallback data sources (em, ths, cninfo) via akshare, handles empty data, and formats output.def get_stock_fhps_detail( symbol: Annotated[str, Field(description="股票代码 (例如: '000001')")], output_format: Annotated[ Literal["json", "csv", "xml", "excel", "markdown", "html"], Field(description="输出数据格式: json, csv, xml, excel, markdown, html。默认: markdown"), ] = "markdown" ) -> str: """获取指定股票的分红配送情况,支持降级使用 stock_fhps_detail_ths 和 stock_dividend_cninfo.""" def _fhps_detail_fetcher(source: str, **kwargs: Any) -> pd.DataFrame: if source == "em": return ak.stock_fhps_detail_em(**kwargs) elif source == "ths": return ak.stock_fhps_detail_ths(**kwargs) elif source == "cninfo": return ak.stock_dividend_cninfo(symbol=kwargs["symbol"]) else: raise ValueError(f"不支持的数据源: {source}") df = _fetch_data_with_fallback( fetch_func=_fhps_detail_fetcher, primary_source="em", fallback_sources=["ths", "cninfo"], symbol=symbol, ) if df.empty: df = pd.DataFrame() return _format_dataframe_output(df, output_format)
- Inner helper function to fetch FHPS data from different sources (eastmoney 'em', ths, cninfo).def _fhps_detail_fetcher(source: str, **kwargs: Any) -> pd.DataFrame: if source == "em": return ak.stock_fhps_detail_em(**kwargs) elif source == "ths": return ak.stock_fhps_detail_ths(**kwargs) elif source == "cninfo": return ak.stock_dividend_cninfo(symbol=kwargs["symbol"]) else: raise ValueError(f"不支持的数据源: {source}")