A股关键指标
stock_indicators_aRetrieve key financial report indicators for Chinese A-share stocks from Shanghai and Shenzhen exchanges using a stock symbol.
Instructions
获取中国A股市场(上证、深证)的股票财务报告关键指标
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | 股票代码 |
Implementation Reference
- mcp_aktools/__init__.py:177-182 (handler)The handler function for the 'stock_indicators_a' tool. It calls ak_cache with ak.stock_financial_abstract_ths using the provided symbol, converts the result to CSV, and returns only the header row plus the last 15 rows of data.
def stock_indicators_a( symbol: str = field_symbol, ): dfs = ak_cache(ak.stock_financial_abstract_ths, symbol=symbol) keys = dfs.to_csv(index=False, float_format="%.3f").strip().split("\n") return "\n".join([keys[0], *keys[-15:]]) - mcp_aktools/__init__.py:173-176 (registration)The @mcp.tool decorator registering stock_indicators_a as an MCP tool with title 'A股关键指标' and description '获取中国A股市场(上证、深证)的股票财务报告关键指标'.
@mcp.tool( title="A股关键指标", description="获取中国A股市场(上证、深证)的股票财务报告关键指标", ) - mcp_aktools/__init__.py:178-179 (schema)The input parameter schema: 'symbol' is a string using the shared 'field_symbol' field descriptor (description: '股票代码').
symbol: str = field_symbol, ): - mcp_aktools/__init__.py:564-579 (helper)The ak_cache helper function used by stock_indicators_a to cache and fetch data. It wraps akshare API calls with a two-layer cache (in-memory TTLCache + diskcache).
def ak_cache(fun, *args, **kwargs) -> pd.DataFrame | None: key = kwargs.pop("key", None) if not key: key = f"{fun.__name__}-{args}-{kwargs}" ttl1 = kwargs.pop("ttl", 86400) ttl2 = kwargs.pop("ttl2", None) cache = CacheKey.init(key, ttl1, ttl2) all = cache.get() if all is None: try: _LOGGER.info("Request akshare: %s", [key, args, kwargs]) all = fun(*args, **kwargs) cache.set(all) except Exception as exc: _LOGGER.exception(str(exc)) return all