Skip to main content
Glama

cancel_order

Cancel a specific cryptocurrency order on Binance by providing the trading pair and order ID. Ideal for managing trading strategies and adjusting market positions effectively.

Instructions

Cancel a specific order.

Args: symbol: The trading pair. order_id: Order ID to cancel.

Returns: Cancellation result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
order_idYes
symbolYes

Implementation Reference

  • The main handler function for the 'cancel_order' tool. It uses the Binance API to cancel a specific order by symbol and order ID. Registered via @mcp.tool() decorator.
    @mcp.tool() def cancel_order(symbol: str, order_id: str) -> Any: """ Cancel a specific order. Args: symbol: The trading pair. order_id: Order ID to cancel. Returns: Cancellation result. """ url = "https://api.binance.com/api/v3/order" timestamp = int(time.time() * 1000) params = { "symbol": symbol, "orderId": order_id, "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.delete(url, headers=headers, params=params) if response.status_code == 200: return {"message": f"Order {order_id} canceled"} return {"error": response.text}

Other Tools

Related Tools

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