get_coin_funding_history
Retrieve historical funding rate data for cryptocurrencies by specifying coin symbol and time range to analyze market trends.
Instructions
Fetch the funding rate history for a specific coin.
Parameters:
coin_name (str): The trading symbol (e.g., 'BTC', 'ETH').
start_time (str): The start time for the funding history in ISO 8601 format (e.g., '2025-01-01T00:00:00Z').
end_time (str): The end time for the funding history in ISO 8601 format (e.g., '2025-12-31T23:59:59Z').
ctx (Context): The MCP context object for accessing server state.
Returns:
str: A JSON string containing a list of funding rate records, each with details such as funding rate and timestamp.
Returns a JSON string with an error message if the query fails.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin_name | Yes | ||
| start_time | Yes | ||
| end_time | Yes |
Implementation Reference
- main.py:123-146 (handler)The handler function for the 'get_coin_funding_history' tool. It is decorated with @mcp.tool(), which registers it. Converts ISO 8601 timestamps to milliseconds and uses the Hyperliquid SDK's info.funding_history() to fetch the data, returning it as JSON or an error message.# Tool: Get coin funding history @mcp.tool() async def get_coin_funding_history(coin_name: str, start_time: str, end_time: str, ctx: Context) -> str: """ Fetch the funding rate history for a specific coin. Parameters: coin_name (str): The trading symbol (e.g., 'BTC', 'ETH'). start_time (str): The start time for the funding history in ISO 8601 format (e.g., '2025-01-01T00:00:00Z'). end_time (str): The end time for the funding history in ISO 8601 format (e.g., '2025-12-31T23:59:59Z'). ctx (Context): The MCP context object for accessing server state. Returns: str: A JSON string containing a list of funding rate records, each with details such as funding rate and timestamp. Returns a JSON string with an error message if the query fails. """ try: start_ms = int(iso8601.parse_date(start_time).timestamp() * 1000) end_ms = int(iso8601.parse_date(end_time).timestamp() * 1000) data = info.funding_history(coin_name, start_ms, end_ms) return json.dumps(data) except Exception as e: return json.dumps({"error": f"Failed to fetch coin funding history: {str(e)}"})