Skip to main content
Glama

get_cni_index_hist

Retrieve daily historical market data for Chinese stock indices by specifying index code and date range, with output in multiple formats including JSON, CSV, and Excel.

Instructions

获取指定指数的日频率历史行情数据

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes指数代码 (例如: '399005')
start_dateYes开始日期,格式为 YYYYMMDD (例如: '20230114')
end_dateYes结束日期,格式为 YYYYMMDD (例如: '20240114')
output_formatNo输出数据格式: json, csv, xml, excel, markdown, html。默认: markdownmarkdown

Implementation Reference

  • Registers the 'get_cni_index_hist' tool with MCP, providing the tool name and description.
    @mcp.tool( name="get_cni_index_hist", description="获取指定指数的日频率历史行情数据" )
  • Defines the input schema with Pydantic Field descriptions for parameters: symbol (index code), start_date, end_date (YYYYMMDD), output_format (default markdown).
    symbol: Annotated[str, Field(description="指数代码 (例如: '399005')")], start_date: Annotated[str, Field(description="开始日期,格式为 YYYYMMDD (例如: '20230114')")], end_date: Annotated[str, Field(description="结束日期,格式为 YYYYMMDD (例如: '20240114')")], output_format: Annotated[ Literal["json", "csv", "xml", "excel", "markdown", "html"], Field(description="输出数据格式: json, csv, xml, excel, markdown, html。默认: markdown"), ] = "markdown"
  • The main handler function that executes the tool: fetches daily historical quote data for the given CNI index using akshare's index_hist_cni, handles empty DataFrame, and returns formatted output via _format_dataframe_output.
    def get_cni_index_hist( symbol: Annotated[str, Field(description="指数代码 (例如: '399005')")], start_date: Annotated[str, Field(description="开始日期,格式为 YYYYMMDD (例如: '20230114')")], end_date: Annotated[str, Field(description="结束日期,格式为 YYYYMMDD (例如: '20240114')")], output_format: Annotated[ Literal["json", "csv", "xml", "excel", "markdown", "html"], Field(description="输出数据格式: json, csv, xml, excel, markdown, html。默认: markdown"), ] = "markdown" ) -> str: """获取指定指数的日频率历史行情数据.""" df = ak.index_hist_cni(symbol=symbol, start_date=start_date, end_date=end_date) if df.empty: df = pd.DataFrame() return _format_dataframe_output(df, output_format)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xinkuang/china-stock-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server