Skip to main content
Glama

createOrder

Place cryptocurrency buy or sell orders on exchanges by specifying account, symbol, type, side, and amount.

Instructions

Create a new order using a configured account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountNameYesAccount name defined in the configuration file (e.g., 'bybit_main')
symbolYesTrading symbol (e.g., 'BTC/USDT')
typeYesOrder type: 'market' or 'limit'
sideYesOrder side: 'buy' or 'sell'
amountYesAmount of base currency to trade
priceNoPrice per unit (required for limit orders)
paramsNoAdditional exchange-specific parameters

Implementation Reference

  • Handler function that gets the exchange instance and calls ccxt's createOrder method, handles validation and errors.
    async ({ accountName, symbol, type, side, amount, price, params, }) => { try { const exchange = ccxtServer.getExchangeInstance(accountName); // getExchangeInstance가 성공하면 인증은 보장됨 // 주문 유형이 limit인데 가격이 없는 경우 if (type === "limit" && price === undefined) { return { content: [ { type: "text", text: "Price is required for limit orders", }, ], isError: true, }; } const order = await exchange.createOrder( symbol, type, side, amount, price, params, ); return { content: [ { type: "text", text: JSON.stringify(order, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error creating order for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } },
  • Zod schema defining the input parameters for the createOrder tool.
    { accountName: z .string() .describe( "Account name defined in the configuration file (e.g., 'bybit_main')" ), symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), type: z .enum(["market", "limit"]) .describe("Order type: 'market' or 'limit'"), side: z.enum(["buy", "sell"]).describe("Order side: 'buy' or 'sell'"), amount: z.number().describe("Amount of base currency to trade"), price: z .number() .optional() .describe("Price per unit (required for limit orders)"), params: z .record(z.any()) .optional() .describe("Additional exchange-specific parameters"), },
  • Registration of the createOrder tool on the MCP server using server.tool().
    "createOrder", "Create a new order using a configured account", { accountName: z .string() .describe( "Account name defined in the configuration file (e.g., 'bybit_main')" ), symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), type: z .enum(["market", "limit"]) .describe("Order type: 'market' or 'limit'"), side: z.enum(["buy", "sell"]).describe("Order side: 'buy' or 'sell'"), amount: z.number().describe("Amount of base currency to trade"), price: z .number() .optional() .describe("Price per unit (required for limit orders)"), params: z .record(z.any()) .optional() .describe("Additional exchange-specific parameters"), }, async ({ accountName, symbol, type, side, amount, price, params, }) => { try { const exchange = ccxtServer.getExchangeInstance(accountName); // getExchangeInstance가 성공하면 인증은 보장됨 // 주문 유형이 limit인데 가격이 없는 경우 if (type === "limit" && price === undefined) { return { content: [ { type: "text", text: "Price is required for limit orders", }, ], isError: true, }; } const order = await exchange.createOrder( symbol, type, side, amount, price, params, ); return { content: [ { type: "text", text: JSON.stringify(order, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error creating order for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } }, );
  • src/server.ts:373-373 (registration)
    Call to registerOrderTools which registers the createOrder tool among others.
    registerOrderTools(this.server, this);

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/lazy-dinosaur/ccxt-mcp'

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