next_trading_day
Calculate the next trading day after a specified date for A-share market planning and scheduling.
Instructions
Get the next trading day after the given date.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes |
Implementation Reference
- src/tools/date_utils.py:53-59 (handler)The MCP tool handler for 'next_trading_day'. It is decorated with @app.tool() which registers it, and executes the core logic by delegating to the use case layer via run_tool_with_handling.@app.tool() def next_trading_day(date: str) -> str: """Get the next trading day after the given date.""" return run_tool_with_handling( lambda: uc_date.next_trading_day(active_data_source, date=date), context=f"next_trading_day:{date}", )
- src/use_cases/date_utils.py:73-79 (helper)Core implementation logic of next_trading_day. Fetches trading days from data source, filters future trading days after the input date, and returns the earliest one.def next_trading_day(data_source: FinancialDataSource, *, date: str) -> str: target = datetime.strptime(date, "%Y-%m-%d") end = (target + timedelta(days=31)).strftime("%Y-%m-%d") df = _fetch_trading_days(data_source, start_date=date, end_date=end) days = df[df["is_trading_day"] == "1"]["calendar_date"].tolist() next_day = min([d for d in days if d > date], default=None) return next_day or date
- mcp_server.py:56-56 (registration)Invocation of the register_date_utils_tools function, which defines and registers the next_trading_day tool (and other date utils) to the FastMCP app.register_date_utils_tools(app, active_data_source)