get_coin_funding_history
Retrieve historical funding rate data for cryptocurrencies on Hyperliquid by specifying coin symbol and date range to analyze funding 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
| Name | Required | Description | Default |
|---|---|---|---|
| coin_name | Yes | ||
| start_time | Yes | ||
| end_time | Yes |
Input Schema (JSON Schema)
{
"properties": {
"coin_name": {
"title": "Coin Name",
"type": "string"
},
"end_time": {
"title": "End Time",
"type": "string"
},
"start_time": {
"title": "Start Time",
"type": "string"
}
},
"required": [
"coin_name",
"start_time",
"end_time"
],
"type": "object"
}
Implementation Reference
- main.py:124-145 (handler)Handler function for the 'get_coin_funding_history' tool. Decorated with @mcp.tool() for registration. Fetches funding rate history using hyperliquid SDK's info.funding_history, converts ISO times to ms, returns JSON.@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)}"})