placeOrder
Execute buy or sell orders on Bitget for spot and futures trading. Automatically detects market type, supports limit and market orders, and manages parameters like quantity, price, and time in force for efficient trading.
Instructions
Place a new buy or sell order (automatically detects spot vs futures)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clientOrderId | No | Client order ID | |
| marginCoin | No | Margin coin for futures (default: USDT) | |
| marginMode | No | Margin mode for futures (default: crossed) | |
| price | No | Order price (required for limit orders) | |
| quantity | Yes | Order quantity (in base currency for spot, in contracts for futures) | |
| reduceOnly | No | Reduce only flag for futures | |
| side | Yes | Order side | |
| symbol | Yes | Trading pair symbol (e.g., BTCUSDT for spot, BTCUSDT_UMCBL for futures) | |
| timeInForce | No | Time in force | |
| type | Yes | Order type |
Input Schema (JSON Schema)
{
"properties": {
"clientOrderId": {
"description": "Client order ID",
"type": "string"
},
"marginCoin": {
"description": "Margin coin for futures (default: USDT)",
"type": "string"
},
"marginMode": {
"description": "Margin mode for futures (default: crossed)",
"enum": [
"crossed",
"isolated"
],
"type": "string"
},
"price": {
"description": "Order price (required for limit orders)",
"type": "string"
},
"quantity": {
"description": "Order quantity (in base currency for spot, in contracts for futures)",
"type": "string"
},
"reduceOnly": {
"description": "Reduce only flag for futures",
"type": "boolean"
},
"side": {
"description": "Order side",
"enum": [
"buy",
"sell"
],
"type": "string"
},
"symbol": {
"description": "Trading pair symbol (e.g., BTCUSDT for spot, BTCUSDT_UMCBL for futures)",
"type": "string"
},
"timeInForce": {
"description": "Time in force",
"enum": [
"GTC",
"IOC",
"FOK"
],
"type": "string"
},
"type": {
"description": "Order type",
"enum": [
"market",
"limit"
],
"type": "string"
}
},
"required": [
"symbol",
"side",
"type",
"quantity"
],
"type": "object"
}
Implementation Reference
- src/server.ts:381-398 (handler)MCP tool handler for placeOrder: parses input with PlaceOrderSchema, detects spot/futures, delegates to BitgetRestClient.placeOrder, returns resultcase 'placeOrder': { const orderParams = PlaceOrderSchema.parse(args); console.error('Received placeOrder request:', JSON.stringify(orderParams, null, 2)); // Determine if this is a futures order const isFutures = orderParams.symbol.includes('_UMCBL') || orderParams.symbol.includes('_'); console.error(`Order type detected: ${isFutures ? 'futures' : 'spot'}`); const order = await this.bitgetClient.placeOrder(orderParams); return { content: [ { type: 'text', text: `Order placed successfully (${isFutures ? 'futures' : 'spot'}):\\n${JSON.stringify(order, null, 2)}`, }, ], } as CallToolResult; }
- src/types/mcp.ts:38-49 (schema)Zod schema for validating placeOrder tool input parametersexport const PlaceOrderSchema = z.object({ symbol: z.string().describe('Trading pair symbol'), side: z.enum(['buy', 'sell']).describe('Order side'), type: z.enum(['market', 'limit']).describe('Order type'), quantity: z.string().describe('Order quantity'), price: z.string().optional().describe('Order price (required for limit orders)'), timeInForce: z.enum(['GTC', 'IOC', 'FOK']).optional().describe('Time in force'), clientOrderId: z.string().optional().describe('Client order ID'), reduceOnly: z.boolean().optional().describe('Reduce only flag for futures'), marginMode: z.enum(['crossed', 'isolated']).optional().describe('Margin mode for futures (default: crossed)'), marginCoin: z.string().optional().describe('Margin coin for futures (default: USDT)') });
- src/server.ts:161-180 (registration)Tool registration in ListTools response, including name, description, and input schema matching PlaceOrderSchema{ name: 'placeOrder', description: 'Place a new buy or sell order (automatically detects spot vs futures)', inputSchema: { type: 'object', properties: { symbol: { type: 'string', description: 'Trading pair symbol (e.g., BTCUSDT for spot, BTCUSDT_UMCBL for futures)' }, side: { type: 'string', enum: ['buy', 'sell'], description: 'Order side' }, type: { type: 'string', enum: ['market', 'limit'], description: 'Order type' }, quantity: { type: 'string', description: 'Order quantity (in base currency for spot, in contracts for futures)' }, price: { type: 'string', description: 'Order price (required for limit orders)' }, timeInForce: { type: 'string', enum: ['GTC', 'IOC', 'FOK'], description: 'Time in force' }, clientOrderId: { type: 'string', description: 'Client order ID' }, reduceOnly: { type: 'boolean', description: 'Reduce only flag for futures' }, marginMode: { type: 'string', enum: ['crossed', 'isolated'], description: 'Margin mode for futures (default: crossed)' }, marginCoin: { type: 'string', description: 'Margin coin for futures (default: USDT)' } }, required: ['symbol', 'side', 'type', 'quantity'] }, },
- src/api/rest-client.ts:539-545 (helper)Core placeOrder implementation in BitgetRestClient: dispatches to spot or futures order placement based on symbolasync placeOrder(params: OrderParams): Promise<Order> { if (this.isFuturesSymbol(params.symbol)) { return this.placeFuturesOrder(params); } else { return this.placeSpotOrder(params); } }