get_time_info
Retrieve current time in ISO format, timestamp, and the last trading day for accurate time-based data analysis and synchronization.
Instructions
Get current time with ISO format, timestamp, and the last trading day.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/akshare_one_mcp/server.py:252-273 (handler)The handler function for the 'get_time_info' tool, decorated with @mcp.tool for registration. It returns current time info including the last trading day using akshare data.@mcp.tool def get_time_info() -> dict: """Get current time with ISO format, timestamp, and the last trading day.""" local_time = datetime.now().astimezone() current_date = local_time.date() # Get trading calendar trade_date_df = ak.tool_trade_date_hist_sina() trade_dates = [d for d in trade_date_df["trade_date"]] # Filter dates <= current date and sort descending past_dates = sorted([d for d in trade_dates if d <= current_date], reverse=True) # Find the most recent trading day last_trading_day = past_dates[0].strftime("%Y-%m-%d") if past_dates else None return { "iso_format": local_time.isoformat(), "timestamp": local_time.timestamp(), "last_trading_day": last_trading_day, }