Skip to main content
Glama

get_trade_history

Retrieve recent trade data for a specific cryptocurrency pair on Binance. Specify the symbol and limit to fetch detailed trade summaries for analysis or decision-making.

Instructions

Get recent trade history for a pair.

Args: symbol: The trading pair. limit: Number of trades to fetch.

Returns: List of trade summaries.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
symbolYes

Implementation Reference

  • The handler function for the 'get_trade_history' tool. It is decorated with @mcp.tool() for registration in the MCP server and implements the logic to fetch authenticated trade history from the Binance API, returning a list of trade summaries or an error.
    @mcp.tool() def get_trade_history(symbol: str, limit: int = 10) -> Any: """ Get recent trade history for a pair. Args: symbol: The trading pair. limit: Number of trades to fetch. Returns: List of trade summaries. """ url = "https://api.binance.com/api/v3/myTrades" timestamp = int(time.time() * 1000) params = { "symbol": symbol, "limit": limit, "timestamp": timestamp } query_string = "&".join([f"{k}={v}" for k, v in params.items()]) signature = hmac.new(BINANCE_SECRET_KEY.encode(), query_string.encode(), hashlib.sha256).hexdigest() params["signature"] = signature headers = {"X-MBX-APIKEY": BINANCE_API_KEY} response = requests.get(url, headers=headers, params=params) if response.status_code == 200: return [ { "time": trade["time"], "side": "BUY" if trade["isBuyer"] else "SELL", "qty": trade["qty"], "price": trade["price"] } for trade in response.json() ] return {"error": response.text}

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/mixuechu/binance-mcp'

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