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
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount to buy/sell | |
| apiKey | Yes | API key for authentication | |
| exchange | Yes | Exchange ID (e.g., binance, bybit) | |
| marketType | No | Market type (default: future) | future |
| params | No | Additional order parameters | |
| passphrase | No | Passphrase for authentication (required for some exchanges like KuCoin) | |
| secret | Yes | API secret for authentication | |
| side | Yes | Order side: buy or sell | |
| symbol | Yes | Trading pair symbol (e.g., BTC/USDT) |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"amount": {
"description": "Amount to buy/sell",
"exclusiveMinimum": 0,
"type": "number"
},
"apiKey": {
"description": "API key for authentication",
"type": "string"
},
"exchange": {
"description": "Exchange ID (e.g., binance, bybit)",
"type": "string"
},
"marketType": {
"default": "future",
"description": "Market type (default: future)",
"enum": [
"future",
"swap"
],
"type": "string"
},
"params": {
"additionalProperties": {},
"description": "Additional order parameters",
"type": "object"
},
"passphrase": {
"description": "Passphrase for authentication (required for some exchanges like KuCoin)",
"type": "string"
},
"secret": {
"description": "API secret for authentication",
"type": "string"
},
"side": {
"description": "Order side: buy or sell",
"enum": [
"buy",
"sell"
],
"type": "string"
},
"symbol": {
"description": "Trading pair symbol (e.g., BTC/USDT)",
"type": "string"
}
},
"required": [
"exchange",
"symbol",
"side",
"amount",
"apiKey",
"secret"
],
"type": "object"
}
Implementation Reference
- src/tools/private.ts:190-217 (handler)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 }; } });
- src/tools/private.ts:181-189 (schema)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)")
- src/tools/private.ts:180-217 (registration)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 }; } });