Skip to main content
Glama
mixuechu

Binance MCP Server

by mixuechu

get_open_orders

Retrieve active trading orders for a specific cryptocurrency pair on Binance to monitor positions and manage trades.

Instructions

Get open orders for a symbol.

Args: symbol: The trading pair.

Returns: List of open orders.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes

Implementation Reference

  • The handler function for the 'get_open_orders' MCP tool. It is decorated with @mcp.tool() which registers it with the FastMCP server. The function retrieves open orders for a specified trading pair (symbol) from the Binance API by signing the request and parsing the response into a list of order details (side, quantity, price).
    @mcp.tool()
    def get_open_orders(symbol: str) -> Any:
        """
        Get open orders for a symbol.
    
        Args:
            symbol: The trading pair.
    
        Returns:
            List of open orders.
        """
        url = "https://api.binance.com/api/v3/openOrders"
        timestamp = int(time.time() * 1000)
        params = {
            "symbol": symbol,
            "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 [
                {
                    "side": order["side"],
                    "quantity": order["origQty"],
                    "price": order["price"]
                } for order 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