get_directory_list
Retrieve structured directory lists for financial data, including stocks, ETFs, exchanges, sectors, industries, and more. Specify list_type to access targeted market or company information directly from Yahoo Finance.
Instructions
获取市场或公司目录列表。
参数说明: list_type: str 可选值:stock、financial_statement_symbol、cik、symbol_change、etf、 actively_trading、earnings_transcript、available_exchanges、 available_sectors、available_industries、available_countries
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_type | Yes |
Implementation Reference
- server.py:927-958 (handler)The handler function that implements the get_directory_list tool logic. It retrieves the API key, maps the list_type to an FMP endpoint, fetches data via HTTP GET, handles errors, and returns JSON string.async def get_directory_list(list_type: str) -> 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 = { "stock": "stock-list", "financial_statement_symbol": "financial-statement-symbol-list", "cik": "cik-list", "symbol_change": "symbol-change", "etf": "etf-list", "actively_trading": "actively-trading-list", "earnings_transcript": "earnings-transcript-list", "available_exchanges": "available-exchanges", "available_sectors": "available-sectors", "available_industries": "available-industries", "available_countries": "available-countries", } endpoint = endpoint_map.get(list_type.lower()) if not endpoint: return "Error: invalid list type" url = f"{base}/{endpoint}" 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 directory list for {list_type}: {e}" return json.dumps(data)
- server.py:917-926 (registration)The decorator that registers the get_directory_list tool with its name and description including parameter details, serving as schema.@fmp_server.tool( name="get_directory_list", description="""获取市场或公司目录列表。 参数说明: list_type: str 可选值:stock、financial_statement_symbol、cik、symbol_change、etf、 actively_trading、earnings_transcript、available_exchanges、 available_sectors、available_industries、available_countries""", )
- server.py:919-926 (schema)The description string in the decorator provides input schema details for the list_type parameter.description="""获取市场或公司目录列表。 参数说明: list_type: str 可选值:stock、financial_statement_symbol、cik、symbol_change、etf、 actively_trading、earnings_transcript、available_exchanges、 available_sectors、available_industries、available_countries""", )