Skip to main content
Glama

get_user_trade_history

Retrieve trade history for a Hyperliquid account to analyze past transactions, view trade details including symbol, size, price, and timestamps.

Instructions

Fetch the trade fill history for a specific user account. Parameters: account_address (str): The Hyperliquid account address (e.g., '0xcd5051944f780a621ee62e39e493c489668acf4d'). ctx (Context): The MCP context object for accessing server state. Returns: str: A JSON string containing a list of trade fills, each with details such as symbol, size, price, timestamp, and trade ID. Returns a JSON string with an error message if the query fails.

Input Schema

NameRequiredDescriptionDefault
account_addressYes

Input Schema (JSON Schema)

{ "properties": { "account_address": { "title": "Account Address", "type": "string" } }, "required": [ "account_address" ], "type": "object" }

Implementation Reference

  • main.py:84-102 (handler)
    The handler function for the 'get_user_trade_history' tool. It is decorated with @mcp.tool() for registration in the FastMCP server. The function fetches the user's trade fills using the Hyperliquid Info SDK's user_fills method and returns the data as a JSON string, handling errors appropriately. The function signature and docstring define the input schema and output format.
    @mcp.tool() async def get_user_trade_history(account_address: str, ctx: Context) -> str: """ Fetch the trade fill history for a specific user account. Parameters: account_address (str): The Hyperliquid account address (e.g., '0xcd5051944f780a621ee62e39e493c489668acf4d'). ctx (Context): The MCP context object for accessing server state. Returns: str: A JSON string containing a list of trade fills, each with details such as symbol, size, price, timestamp, and trade ID. Returns a JSON string with an error message if the query fails. """ try: fills = info.user_fills(account_address) return json.dumps(fills) except Exception as e: return json.dumps({"error": f"Failed to fetch user fills: {str(e)}"})
  • A helper prompt function 'analyze_positions' that instructs the use of the 'get_user_trade_history' tool among others for analyzing user trading positions.
    base.UserMessage(f"Please analyze the trading positions for account {account_address}:"), base.UserMessage("Use the get_user_state, get_user_open_orders, get_user_trade_history, get_user_funding_history, and get_user_fees tools to fetch data."), base.AssistantMessage( "I'll analyze the user's trading positions, open orders, trade history, funding payments, and fees to provide insights on risk and performance." ) ]

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/kukapay/hyperliquid-info-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server