美股关键指标
stock_indicators_usFetch key financial report indicators for US stocks by providing a stock symbol. Access essential metrics from financial statements.
Instructions
获取美股市场的股票财务报告关键指标
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | 股票代码 |
Implementation Reference
- mcp_aktools/__init__.py:197-206 (registration)The @mcp.tool decorator registers 'stock_indicators_us' as an MCP tool with title '美股关键指标' and description '获取美股市场的股票财务报告关键指标'.
@mcp.tool( title="美股关键指标", description="获取美股市场的股票财务报告关键指标", ) def stock_indicators_us( symbol: str = field_symbol, ): dfs = ak_cache(ak.stock_financial_us_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:201-206 (handler)The handler function 'stock_indicators_us' accepts a 'symbol' parameter, calls ak_cache() with ak.stock_financial_us_analysis_indicator_em to fetch US stock financial indicators (single quarter), converts the result to CSV format, and returns the first 15 rows.
def stock_indicators_us( symbol: str = field_symbol, ): dfs = ak_cache(ak.stock_financial_us_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:201-203 (schema)The input schema for the tool: a single 'symbol' parameter (str) using field_symbol which has description '股票代码'.
def stock_indicators_us( symbol: str = field_symbol, ): - mcp_aktools/__init__.py:564-579 (helper)The 'ak_cache' helper function provides a caching layer around akshare API calls, using both in-memory TTL cache and disk-based 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