港股关键指标
stock_indicators_hkRetrieve key financial report indicators for Hong Kong stocks by providing a stock symbol.
Instructions
获取港股市场的股票财务报告关键指标
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | 股票代码 |
Implementation Reference
- mcp_aktools/__init__.py:185-194 (handler)Handler function for stock_indicators_hk tool. Fetches Hong Kong stock financial indicators using akshare's stock_financial_hk_analysis_indicator_em, returns first 15 rows as CSV.
@mcp.tool( title="港股关键指标", description="获取港股市场的股票财务报告关键指标", ) def stock_indicators_hk( symbol: str = field_symbol, ): dfs = ak_cache(ak.stock_financial_hk_analysis_indicator_em, symbol=symbol, indicator="报告期") keys = dfs.to_csv(index=False, float_format="%.3f").strip().split("\n") return "\n".join(keys[0:15]) - mcp_aktools/__init__.py:185-194 (registration)Registration via @mcp.tool decorator with title and description for the stock_indicators_hk tool.
@mcp.tool( title="港股关键指标", description="获取港股市场的股票财务报告关键指标", ) def stock_indicators_hk( symbol: str = field_symbol, ): dfs = ak_cache(ak.stock_financial_hk_analysis_indicator_em, symbol=symbol, indicator="报告期") keys = dfs.to_csv(index=False, float_format="%.3f").strip().split("\n") return "\n".join(keys[0:15]) - mcp_aktools/__init__.py:564-579 (helper)Helper function ak_cache that caches results from akshare API calls. Used by stock_indicators_hk to call ak.stock_financial_hk_analysis_indicator_em with caching.
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