get_latest_trading_date
Retrieve the most recent stock market trading date for A-share market data analysis and financial reporting.
Instructions
Get the latest trading date up to today.
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_latest_trading_date"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/date_utils.py:19-26 (handler)MCP tool handler for 'get_latest_trading_date'. Decorated with @app.tool(), logs the invocation, and delegates execution to the use-case layer using run_tool_with_handling.
@app.tool() def get_latest_trading_date() -> str: """Get the latest trading date up to today.""" logger.info("Tool 'get_latest_trading_date' called") return run_tool_with_handling( lambda: uc_date.get_latest_trading_date(active_data_source), context="get_latest_trading_date", ) - src/use_cases/date_utils.py:15-25 (helper)Core implementation that fetches recent trading days from the data source and determines the latest trading date up to today.
def get_latest_trading_date(data_source: FinancialDataSource) -> str: today = datetime.now().strftime("%Y-%m-%d") start_date = datetime.now().replace(day=1).strftime("%Y-%m-%d") end_date = datetime.now().replace(day=28).strftime("%Y-%m-%d") df = _fetch_trading_days(data_source, start_date=start_date, end_date=end_date) valid_trading_days = df[df["is_trading_day"] == "1"]["calendar_date"].tolist() latest_trading_date = None for dstr in valid_trading_days: if dstr <= today and (latest_trading_date is None or dstr > latest_trading_date): latest_trading_date = dstr return latest_trading_date or today - mcp_server.py:56-56 (registration)Calls the registration function that defines and registers the 'get_latest_trading_date' tool with the FastMCP app.
register_date_utils_tools(app, active_data_source)