get_calendar_data
Retrieve calendar data for financial events like dividends, earnings, IPOs, and stock splits using event types, stock symbols, and pagination parameters.
Instructions
获取分红、收益、IPO、拆股等日历信息。
参数说明: event_type: str 可选值:dividends、dividends_calendar、earnings、earnings_calendar、 ipos_calendar、ipos_disclosure、ipos_prospectus、splits、splits_calendar symbol: str 部分类型需要股票代码 page: int 页码,默认 0 limit: int 返回数量,默认 100
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event_type | Yes | ||
| limit | No | ||
| page | No | ||
| symbol | No |
Implementation Reference
- server.py:296-339 (handler)The async handler function that implements the get_calendar_data tool logic. It fetches various calendar events (dividends, earnings, IPOs, splits) from the Financial Modeling Prep API based on the event_type, optional symbol, page, and limit parameters.async def get_calendar_data( event_type: str, symbol: str = "", page: int = 0, limit: int = 100, ) -> 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 = { "dividends": "dividends", "dividends_calendar": "dividends-calendar", "earnings": "earnings", "earnings_calendar": "earnings-calendar", "ipos_calendar": "ipos-calendar", "ipos_disclosure": "ipos-disclosure", "ipos_prospectus": "ipos-prospectus", "splits": "splits", "splits_calendar": "splits-calendar", } endpoint = endpoint_map.get(event_type.lower()) if not endpoint: return "Error: invalid event type" params = {"apikey": api_key} if event_type in ["dividends", "earnings", "splits"] and not symbol: return "Error: symbol is required for this event type" if symbol: params["symbol"] = symbol if event_type in ["ipos_calendar", "ipos_disclosure", "ipos_prospectus"]: 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 calendar data {event_type}: {e}" return json.dumps(data)
- server.py:281-295 (registration)The @fmp_server.tool decorator that registers the get_calendar_data tool, specifying its name, description, and input parameters schema.@fmp_server.tool( name="get_calendar_data", description="""获取分红、收益、IPO、拆股等日历信息。 参数说明: event_type: str 可选值:dividends、dividends_calendar、earnings、earnings_calendar、 ipos_calendar、ipos_disclosure、ipos_prospectus、splits、splits_calendar symbol: str 部分类型需要股票代码 page: int 页码,默认 0 limit: int 返回数量,默认 100""", )