get_month_end_trading_dates
Retrieve month-end trading dates for China's A-share market by specifying a year. This tool helps identify the last trading day of each month for scheduling and analysis purposes.
Instructions
Return month-end trading dates for a given year.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year | Yes |
Implementation Reference
- src/use_cases/date_utils.py:102-113 (handler)The core handler function that implements the logic to retrieve the last trading day of each month for a given year by querying the financial data source for trading days in the week leading up to the month's end.def get_month_end_trading_dates(data_source: FinancialDataSource, *, year: int) -> str: results = [] for month in range(1, 13): last_day = calendar.monthrange(year, month)[1] start_date = datetime(year, month, last_day - 7).strftime("%Y-%m-%d") end_date = datetime(year, month, last_day).strftime("%Y-%m-%d") df = _fetch_trading_days(data_source, start_date=start_date, end_date=end_date) trading_days = df[df["is_trading_day"] == "1"]["calendar_date"].tolist() if trading_days: results.append(trading_days[-1]) return ", ".join(results)
- src/tools/date_utils.py:77-83 (registration)The tool registration decorator (@app.tool()) and wrapper function that handles the tool invocation, logging context, and delegates execution to the use_cases layer handler.@app.tool() def get_month_end_trading_dates(year: int) -> str: """Return month-end trading dates for a given year.""" return run_tool_with_handling( lambda: uc_date.get_month_end_trading_dates(active_data_source, year=year), context=f"get_month_end_trading_dates:{year}", )