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);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Create a new order', implying a write/mutation operation, but doesn't disclose critical traits like authentication needs, rate limits, error handling, or what happens on success (e.g., order ID returned). For a financial trading tool with potential real-world consequences, this lack of transparency is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core action ('Create a new order') and includes only essential context ('using a configured account'). Every part earns its place, making it highly concise and well-structured for quick comprehension.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a financial trading tool with 7 parameters, no annotations, and no output schema, the description is incomplete. It lacks crucial context such as authentication requirements, error scenarios, return values (e.g., order ID), and behavioral details like rate limits or idempotency. The schema handles parameter documentation, but the description fails to compensate for missing annotations and output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 7 parameters thoroughly with descriptions and enums. The description adds no additional meaning beyond the schema, as it doesn't explain parameter relationships (e.g., 'price' required for 'limit' orders) or provide usage examples. The baseline score of 3 reflects adequate parameter documentation solely from the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create a new order') and resource ('using a configured account'), making the purpose unambiguous. It distinguishes from sibling tools like 'cancelOrder' or 'fetchOpenOrders' by focusing on creation rather than modification or retrieval. However, it doesn't specify what kind of order (e.g., trading order) or differentiate from other potential order creation tools that might exist in other contexts.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing a configured account), exclusions (e.g., not for modifying existing orders), or comparisons to siblings like 'cancelOrder' or 'fetchOrder'. The phrase 'using a configured account' hints at a prerequisite but doesn't explicitly state it as a requirement or explain how to configure accounts.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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