get_price_target_info
Retrieve analyst price target details, including summaries, consensus views, or related news for a specific stock symbol. Customize results by selecting page and limit for precise data retrieval.
Instructions
获取分析师目标价相关信息,可选择汇总、共识或新闻。
参数说明: info_type: str summary、consensus、news、latest_news symbol: str 股票代码,news/summary/consensus 必填 page: int 页码,默认 0 limit: int 返回数量,默认 10
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| info_type | Yes | ||
| limit | No | ||
| page | No | ||
| symbol | No |
Implementation Reference
- server.py:1059-1098 (handler)The main handler function for the 'get_price_target_info' tool. It fetches analyst price target information (summary, consensus, news, or latest news) from the Financial Modeling Prep API based on the provided info_type and optional symbol, page, and limit parameters.async def get_price_target_info( info_type: str, symbol: str = "", 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." base = "https://financialmodelingprep.com/stable" endpoint_map = { "summary": "price-target-summary", "consensus": "price-target-consensus", "news": "price-target-news", "latest_news": "price-target-latest-news", } endpoint = endpoint_map.get(info_type.lower()) if not endpoint: return "Error: invalid info type" params = {"apikey": api_key} if info_type in ["summary", "consensus", "news"]: if not symbol: return "Error: symbol is required for this info type" params["symbol"] = symbol if info_type in ["news", "latest_news"]: params.update({"page": page, "limit": limit}) url = f"{base}/{endpoint}" try: resp = requests.get(url, params=params, timeout=10) resp.raise_for_status() data = resp.json() except Exception as e: return f"Error: getting price target info {info_type} for {symbol}: {e}" return json.dumps(data)
- server.py:1045-1058 (registration)The @fmp_server.tool decorator that registers the 'get_price_target_info' tool, specifying its name and description including parameter details.@fmp_server.tool( name="get_price_target_info", description="""获取分析师目标价相关信息,可选择汇总、共识或新闻。 参数说明: info_type: str summary、consensus、news、latest_news symbol: str 股票代码,news/summary/consensus 必填 page: int 页码,默认 0 limit: int 返回数量,默认 10""", )