A股龙虎榜统计
stock_lhb_ggtj_sinaFetch individual stock statistics on the A-share dragon and tiger list for recent 5, 10, 30, or 60 days, with configurable result count (30-100).
Instructions
获取中国A股市场(上证、深证)的龙虎榜个股上榜统计数据
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | 统计最近天数,仅支持: [5/10/30/60] | 5 |
| limit | No | 返回数量(int,30-100) |
Implementation Reference
- mcp_aktools/__init__.py:283-293 (handler)Handler function for the 'stock_lhb_ggtj_sina' tool. It uses the @mcp.tool decorator (which also acts as registration), retrieves data via ak_cache wrapping akshare's stock_lhb_ggtj_sina function, limits results, and returns CSV.
@mcp.tool( title="A股龙虎榜统计", description="获取中国A股市场(上证、深证)的龙虎榜个股上榜统计数据", ) def stock_lhb_ggtj_sina( days: str = Field("5", description="统计最近天数,仅支持: [5/10/30/60]"), limit: int = Field(50, description="返回数量(int,30-100)", strict=False), ): dfs = ak_cache(ak.stock_lhb_ggtj_sina, symbol=days, ttl=3600) dfs = dfs.head(int(limit)) return dfs.to_csv(index=False, float_format="%.2f").strip() - mcp_aktools/__init__.py:283-286 (registration)Registration via @mcp.tool decorator on the stock_lhb_ggtj_sina function.
@mcp.tool( title="A股龙虎榜统计", description="获取中国A股市场(上证、深证)的龙虎榜个股上榜统计数据", ) - mcp_aktools/__init__.py:287-289 (schema)Input schema: 'days' (str, default '5', options: 5/10/30/60) and 'limit' (int, default 50, range 30-100).
def stock_lhb_ggtj_sina( days: str = Field("5", description="统计最近天数,仅支持: [5/10/30/60]"), limit: int = Field(50, description="返回数量(int,30-100)", strict=False), - mcp_aktools/__init__.py:564-579 (helper)Helper function 'ak_cache' that wraps akshare function calls with a two-layer caching mechanism (in-memory TTL cache + disk cache).
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