Skip to main content
Glama

place-futures-market-order

Execute a futures market order on supported cryptocurrency exchanges. Specify exchange, trading pair, side, amount, and authentication details to place buy or sell orders directly through the CCXT MCP Server.

Instructions

Place a futures market order

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
amountYesAmount to buy/sell
apiKeyYesAPI key for authentication
exchangeYesExchange ID (e.g., binance, bybit)
marketTypeNoMarket type (default: future)future
paramsNoAdditional order parameters
passphraseNoPassphrase for authentication (required for some exchanges like KuCoin)
secretYesAPI secret for authentication
sideYesOrder side: buy or sell
symbolYesTrading pair symbol (e.g., BTC/USDT)

Implementation Reference

  • The main handler function for the 'place-futures-market-order' tool. It retrieves the exchange instance with credentials, logs the action, places a market order using ex.createOrder, and returns the order details or error.
    }, async ({ exchange, symbol, side, amount, params, apiKey, secret, passphrase, marketType }) => {
      try {
        return await rateLimiter.execute(exchange, async () => {
          // Get futures exchange
          const ex = getExchangeWithCredentials(exchange, apiKey, secret, marketType, passphrase);
          
          // Place futures market order
          log(LogLevel.INFO, `Placing futures ${side} market order for ${symbol} on ${exchange} (${marketType}), amount: ${amount}`);
          const order = await ex.createOrder(symbol, 'market', side, amount, undefined, params || {});
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify(order, null, 2)
            }]
          };
        });
      } catch (error) {
        log(LogLevel.ERROR, `Error placing futures market order: ${error instanceof Error ? error.message : String(error)}`);
        return {
          content: [{
            type: "text",
            text: `Error: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    });
  • Zod schema defining the input parameters for the tool, including exchange, symbol, side, amount, optional params and passphrase, API credentials, and marketType.
    exchange: z.string().describe("Exchange ID (e.g., binance, bybit)"),
    symbol: z.string().describe("Trading pair symbol (e.g., BTC/USDT)"),
    side: z.enum(['buy', 'sell']).describe("Order side: buy or sell"),
    amount: z.number().positive().describe("Amount to buy/sell"),
    params: z.record(z.any()).optional().describe("Additional order parameters"),
    apiKey: z.string().describe("API key for authentication"),
    secret: z.string().describe("API secret for authentication"),
    passphrase: z.string().optional().describe("Passphrase for authentication (required for some exchanges like KuCoin)"),
    marketType: z.enum(["future", "swap"]).default("future").describe("Market type (default: future)")
  • The server.tool call that registers the 'place-futures-market-order' tool with its name, description, input schema, and handler function.
    server.tool("place-futures-market-order", "Place a futures market order", {
      exchange: z.string().describe("Exchange ID (e.g., binance, bybit)"),
      symbol: z.string().describe("Trading pair symbol (e.g., BTC/USDT)"),
      side: z.enum(['buy', 'sell']).describe("Order side: buy or sell"),
      amount: z.number().positive().describe("Amount to buy/sell"),
      params: z.record(z.any()).optional().describe("Additional order parameters"),
      apiKey: z.string().describe("API key for authentication"),
      secret: z.string().describe("API secret for authentication"),
      passphrase: z.string().optional().describe("Passphrase for authentication (required for some exchanges like KuCoin)"),
      marketType: z.enum(["future", "swap"]).default("future").describe("Market type (default: future)")
    }, async ({ exchange, symbol, side, amount, params, apiKey, secret, passphrase, marketType }) => {
      try {
        return await rateLimiter.execute(exchange, async () => {
          // Get futures exchange
          const ex = getExchangeWithCredentials(exchange, apiKey, secret, marketType, passphrase);
          
          // Place futures market order
          log(LogLevel.INFO, `Placing futures ${side} market order for ${symbol} on ${exchange} (${marketType}), amount: ${amount}`);
          const order = await ex.createOrder(symbol, 'market', side, amount, undefined, params || {});
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify(order, null, 2)
            }]
          };
        });
      } catch (error) {
        log(LogLevel.ERROR, `Error placing futures market order: ${error instanceof Error ? error.message : String(error)}`);
        return {
          content: [{
            type: "text",
            text: `Error: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    });

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/doggybee/mcp-server-ccxt'

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