Skip to main content
Glama
24mlight

A Share MCP

get_month_end_trading_dates

Retrieve month-end trading dates for A-share markets in a specified year to support financial analysis and reporting.

Instructions

Return month-end trading dates for a given year.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYes

Implementation Reference

  • MCP tool handler function for 'get_month_end_trading_dates'. It wraps the use case execution with error handling via run_tool_with_handling.
    @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}",
        )
  • Core helper function implementing the logic to fetch the last trading day of each month for a given year using the financial data source.
    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)
  • mcp_server.py:56-56 (registration)
    Invocation of register_date_utils_tools which registers the date utility tools, including 'get_month_end_trading_dates', to the FastMCP app.
    register_date_utils_tools(app, active_data_source)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/24mlight/a_share_mcp_is_just_I_need'

If you have feedback or need assistance with the MCP directory API, please join our Discord server