Skip to main content
Glama
24mlight

A-Share MCP Server

previous_trading_day

Find the previous trading day for China's A-share market to calculate accurate date-based financial metrics and analysis.

Instructions

Get the previous trading day before the given date.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes

Implementation Reference

  • MCP tool handler function for 'previous_trading_day'. Decorated with @app.tool() for registration and execution. Delegates to the use case layer's previous_trading_day function via run_tool_with_handling for error handling and logging.
    @app.tool() def previous_trading_day(date: str) -> str: """Get the previous trading day before the given date.""" return run_tool_with_handling( lambda: uc_date.previous_trading_day(active_data_source, date=date), context=f"previous_trading_day:{date}", )
  • Core implementation of previous_trading_day logic. Fetches trading days from the data source around the given date and returns the most recent trading day strictly before the input date, or the input date if none found.
    def previous_trading_day(data_source: FinancialDataSource, *, date: str) -> str: target = datetime.strptime(date, "%Y-%m-%d") start = (target - timedelta(days=31)).strftime("%Y-%m-%d") df = _fetch_trading_days(data_source, start_date=start, end_date=date) days = df[df["is_trading_day"] == "1"]["calendar_date"].tolist() prev = max([d for d in days if d < date], default=None) return prev or date
  • mcp_server.py:56-56 (registration)
    Top-level registration call in the main MCP server file that registers the date_utils tools module, including the previous_trading_day tool.
    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