get_stock_grade_news
Retrieve stock rating news for a specific ticker using customizable pagination. Access detailed financial insights directly from Yahoo Finance. Ideal for tracking market analyst updates efficiently.
Instructions
获取指定股票的评级新闻。
参数说明: ticker: str 股票代码,例如 "AAPL" page: int 页码,默认 0 limit: int 每页数量,最大 100,默认 1
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| page | No | ||
| ticker | Yes |
Implementation Reference
- server.py:819-843 (handler)The main handler function that executes the tool logic: fetches analyst grade news for a given stock ticker from the FMP API endpoint /stable/grades-news, handles API key, pagination, and returns JSON data.async def get_stock_grade_news(ticker: str, page: int = 0, limit: int = 1) -> 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/grades-news" try: resp = requests.get( url, params={ "symbol": ticker, "page": page, "limit": limit, "apikey": api_key, }, timeout=10, ) resp.raise_for_status() data = resp.json() except Exception as e: return f"Error: getting grade news for {ticker}: {e}" return json.dumps(data)
- server.py:807-818 (registration)Tool registration using the FastMCP decorator, specifying the tool name and description with input parameters (serving as schema).@fmp_server.tool( name="get_stock_grade_news", description="""获取指定股票的评级新闻。 参数说明: ticker: str 股票代码,例如 "AAPL" page: int 页码,默认 0 limit: int 每页数量,最大 100,默认 1""", )
- server.py:809-818 (schema)Description string defining the input schema: ticker (str), page (int, default 0), limit (int, default 1).description="""获取指定股票的评级新闻。 参数说明: ticker: str 股票代码,例如 "AAPL" page: int 页码,默认 0 limit: int 每页数量,最大 100,默认 1""", )
- server.py:48-48 (helper)Tool mentioned in the server instructions list.- get_stock_grade_news:获取指定股票的评级新闻。