Skip to main content
Glama

place_market_order

Execute instant buy or sell orders on Binance by specifying the trading pair, side (BUY/SELL), and quantity. Simplifies cryptocurrency trading through automated market order placement.

Instructions

Place a market order to buy or sell.

Args: symbol: The trading pair, e.g., BTCUSDT. side: BUY or SELL. quantity: Amount to trade.

Returns: Order placement result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
quantityYes
sideYes
symbolYes

Implementation Reference

  • The primary handler function for the 'place_market_order' MCP tool. Decorated with @mcp.tool() to register it automatically with FastMCP. Handles placing market orders on Binance spot market via signed API request.
    @mcp.tool() def place_market_order(symbol: str, side: str, quantity: str) -> Any: """ Place a market order to buy or sell. Args: symbol: The trading pair, e.g., BTCUSDT. side: BUY or SELL. quantity: Amount to trade. Returns: Order placement result. """ url = "https://api.binance.com/api/v3/order" timestamp = int(time.time() * 1000) params = { "symbol": symbol, "side": side, "type": "MARKET", "quantity": quantity, "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.post(url, headers=headers, params=params) if response.status_code == 200: return {"message": f"{side} {quantity} {symbol} order placed"} 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