Skip to main content
Glama
24mlight

A-Share MCP Server

get_recent_trading_range

Calculate date ranges for recent trading periods to analyze stock market data within specified timeframes.

Instructions

Return a date range string covering the recent N trading days.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNo

Implementation Reference

  • The MCP tool handler for get_recent_trading_range. It is decorated with @app.tool() and delegates execution to the use case layer via run_tool_with_handling for error handling.
    @app.tool() def get_recent_trading_range(days: int = 5) -> str: """Return a date range string covering the recent N trading days.""" return run_tool_with_handling( lambda: uc_date.get_recent_trading_range(active_data_source, days=days), context=f"get_recent_trading_range:{days}", )
  • mcp_server.py:56-56 (registration)
    The call to register_date_utils_tools, which includes the registration of the get_recent_trading_range tool via @app.tool() decorators.
    register_date_utils_tools(app, active_data_source)
  • Core helper function implementing the logic to compute the recent trading range by fetching trading days and selecting the last N days.
    def get_recent_trading_range(data_source: FinancialDataSource, *, days: int) -> str: today = datetime.now() start = (today - timedelta(days=days * 2)).strftime("%Y-%m-%d") end = today.strftime("%Y-%m-%d") df = _fetch_trading_days(data_source, start_date=start, end_date=end) trading_days = df[df["is_trading_day"] == "1"]["calendar_date"].tolist() if not trading_days: return "" return f"{trading_days[-days]} 至 {trading_days[-1]}" if len(trading_days) >= days else f"{trading_days[0]} 至 {trading_days[-1]}"

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