get_top_gainers
Retrieve a list of today's top-performing stocks from Yahoo Finance to identify significant market trends and opportunities.
Instructions
获取今日涨幅最大的股票列表。
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_top_gainers"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- server.py:688-702 (handler)The main handler function that fetches the list of top gaining stocks from the Financial Modeling Prep API endpoint '/stock_market/gainers' and returns the data as a JSON string.
async def get_top_gainers() -> 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/api/v3/stock_market/gainers" try: resp = requests.get(url, params={"apikey": api_key}, timeout=10) resp.raise_for_status() data = resp.json() except Exception as e: return f"Error: getting top gainers: {e}" return json.dumps(data) - server.py:684-687 (registration)Registers the 'get_top_gainers' tool with the FastMCP server instance 'fmp_server' using the @tool decorator, providing the tool name and Chinese description.
@fmp_server.tool( name="get_top_gainers", description="""获取今日涨幅最大的股票列表。""", )