get_analyst_estimates
Retrieve analyst financial estimates for stocks by providing the symbol, period, page, and limit parameters. Access detailed forecasts for informed investment decisions.
Instructions
获取分析师的财务预估数据。
参数说明: symbol: str 股票代码,例如 "AAPL" period: str annual 或 quarter,默认 annual page: int 页码,默认 0 limit: int 返回数量,默认 10
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| page | No | ||
| period | No | annual | |
| symbol | Yes |
Implementation Reference
- server.py:975-1001 (handler)The main handler function that implements the get_analyst_estimates tool. It fetches analyst estimates data from the Financial Modeling Prep API using requests, handles errors, and returns JSON string.async def get_analyst_estimates( symbol: str, period: str = "annual", page: int = 0, limit: int = 10 ) -> str: """获取分析师预估指标""" api_key = os.environ.get("FMP_API_KEY") if not api_key: return "Error: FMP_API_KEY environment variable not set." url = "https://financialmodelingprep.com/stable/analyst-estimates" try: resp = requests.get( url, params={ "symbol": symbol, "period": period, "page": page, "limit": limit, "apikey": api_key, }, timeout=10, ) resp.raise_for_status() data = resp.json() except Exception as e: return f"Error: getting analyst estimates for {symbol}: {e}" return json.dumps(data)
- server.py:961-974 (registration)The @fmp_server.tool decorator that registers the get_analyst_estimates tool, specifying its name and description with parameter details serving as schema information.@fmp_server.tool( name="get_analyst_estimates", description="""获取分析师的财务预估数据。 参数说明: symbol: str 股票代码,例如 "AAPL" period: str annual 或 quarter,默认 annual page: int 页码,默认 0 limit: int 返回数量,默认 10""", )
- server.py:975-977 (schema)The function signature with type annotations defining the input schema (parameters) and output type.async def get_analyst_estimates( symbol: str, period: str = "annual", page: int = 0, limit: int = 10 ) -> str: